mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 02:11:06 +03:30
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7db25937f | ||
|
|
7fd27c4693 | ||
|
|
7a6c81600f | ||
|
|
eeb90fe49e | ||
|
|
6f12cd4e69 | ||
|
|
b8b6e46cf2 | ||
|
|
122c7cdbda | ||
|
|
0977346b6e | ||
|
|
8f0b87c333 | ||
|
|
a467b06ea7 | ||
|
|
316c5507ba | ||
|
|
fa7df1e500 | ||
|
|
9040310170 | ||
|
|
156c3fbeb6 | ||
|
|
a7a46a1fd3 | ||
|
|
4a3b8fe5c0 | ||
|
|
2e59726bce | ||
|
|
4c48b13646 | ||
|
|
7ce5e0262b | ||
|
|
b7694a92a4 | ||
|
|
0bd017360c | ||
|
|
bcba3b7a8d | ||
|
|
dd85f7f5e2 | ||
|
|
263ef246fd | ||
|
|
38ca9b3b84 | ||
|
|
bea98bdd02 | ||
|
|
7a7ad062c6 | ||
|
|
27cd2292fe | ||
|
|
fee688c183 | ||
|
|
4eb2fa5107 | ||
|
|
edb9e9fc8a | ||
|
|
8b30242419 | ||
|
|
97f63d1435 | ||
|
|
44be70f3ff | ||
|
|
baeaed7c70 | ||
|
|
b573d1bbed | ||
|
|
6d108e43c9 | ||
|
|
2b8ad33cb2 | ||
|
|
354992fe48 | ||
|
|
b3f733cdd0 | ||
|
|
c03c1196ec | ||
|
|
be86f52ae7 | ||
|
|
200888482f | ||
|
|
838ad7ca12 | ||
|
|
3ec315bc09 | ||
|
|
d84a9a18c0 | ||
|
|
6b18d07b73 | ||
|
|
66812c5ed4 | ||
|
|
ea46db84a0 | ||
|
|
1916fac447 | ||
|
|
fd70c015f3 | ||
|
|
056160bca5 | ||
|
|
a5136a341f | ||
|
|
47aab06e49 | ||
|
|
f9023086c9 | ||
|
|
6311e2af70 | ||
|
|
4492db15cf | ||
|
|
62a353ef80 | ||
|
|
bae730e402 | ||
|
|
6c8054edac | ||
|
|
ac19e51d28 | ||
|
|
9832fbe81a | ||
|
|
24aa9fb7f2 | ||
|
|
4f25abbf36 | ||
|
|
6de8d2dbae | ||
|
|
1bd5970a58 | ||
|
|
accf16c184 | ||
|
|
540f9a1d65 | ||
|
|
4a9010d2c7 | ||
|
|
76c9ec4c8f | ||
|
|
f5e1ff198e | ||
|
|
abd611cdcf | ||
|
|
8a90d3bce4 | ||
|
|
af876a5e07 | ||
|
|
06850ca736 | ||
|
|
62fc5dc977 | ||
|
|
8ee7bb56b7 | ||
|
|
b4d3134230 | ||
|
|
322c080028 | ||
|
|
0d1b0360ac | ||
|
|
1ee3585674 | ||
|
|
1d98af0113 | ||
|
|
034000bcef | ||
|
|
5fe7474227 | ||
|
|
71e493ec10 | ||
|
|
b0b6d700ba | ||
|
|
2d1df25b0e | ||
|
|
0170cb1258 | ||
|
|
8046611c01 | ||
|
|
32a477548e | ||
|
|
505c176dad |
+11
-18
@@ -8,12 +8,12 @@ clone:
|
|||||||
# npm config set _auth token add command
|
# npm config set _auth token add command
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: docker.willaspace.com/repository/docker-hosted/alpine/git
|
image: docker.meshkee.com/repository/docker-hosted/alpine/git
|
||||||
commands:
|
commands:
|
||||||
- git clone $DRONE_GIT_HTTP_URL .
|
- git clone $DRONE_GIT_HTTP_URL .
|
||||||
- git checkout $DRONE_COMMIT
|
- git checkout $DRONE_COMMIT
|
||||||
- name: Build docker image
|
- name: Build docker image
|
||||||
image: docker.willaspace.com/repository/docker-hosted/plugins/docker
|
image: docker.meshkee.com/repository/docker-hosted/plugins/docker
|
||||||
environment:
|
environment:
|
||||||
REGISTRY_USER_NAME:
|
REGISTRY_USER_NAME:
|
||||||
from_secret: registry_username
|
from_secret: registry_username
|
||||||
@@ -24,8 +24,8 @@ steps:
|
|||||||
- latest
|
- latest
|
||||||
- ${DRONE_BUILD_NUMBER}
|
- ${DRONE_BUILD_NUMBER}
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
registry: docker.willaspace.com
|
registry: docker.meshkee.com
|
||||||
repo: docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back
|
repo: docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back
|
||||||
build_args_from_env:
|
build_args_from_env:
|
||||||
- REGISTRY_USER_NAME
|
- REGISTRY_USER_NAME
|
||||||
- REGISTRY_PASSWORD
|
- REGISTRY_PASSWORD
|
||||||
@@ -36,18 +36,16 @@ steps:
|
|||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
event:
|
|
||||||
- push
|
|
||||||
|
|
||||||
- name: Build docker nginx image
|
- name: Build docker nginx image
|
||||||
image: docker.willaspace.com/repository/docker-hosted/plugins/docker
|
image: docker.meshkee.com/repository/docker-hosted/plugins/docker
|
||||||
settings:
|
settings:
|
||||||
tags:
|
tags:
|
||||||
- nginx-latest
|
- nginx-latest
|
||||||
- nginx-${DRONE_BUILD_NUMBER}
|
- nginx-${DRONE_BUILD_NUMBER}
|
||||||
dockerfile: Dockerfile.nginx
|
dockerfile: Dockerfile.nginx
|
||||||
registry: docker.willaspace.com
|
registry: docker.meshkee.com
|
||||||
repo: docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back
|
repo: docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back
|
||||||
username:
|
username:
|
||||||
from_secret: registry_username
|
from_secret: registry_username
|
||||||
password:
|
password:
|
||||||
@@ -55,11 +53,9 @@ steps:
|
|||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
event:
|
|
||||||
- push
|
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
image: docker.willaspace.com/repository/docker-hosted/pelotech/drone-helm3:latest
|
image: pelotech/drone-helm3:latest
|
||||||
environment:
|
environment:
|
||||||
USERNAME:
|
USERNAME:
|
||||||
from_secret: registry_username
|
from_secret: registry_username
|
||||||
@@ -77,20 +73,17 @@ steps:
|
|||||||
release: cssd-production-back
|
release: cssd-production-back
|
||||||
namespace: cssd
|
namespace: cssd
|
||||||
add_repos:
|
add_repos:
|
||||||
- willaspace=https://$USERNAME:$PASSWORD@repo.willaspace.com/repository/willaspace-charts/
|
- willaspace=https://$USERNAME:$PASSWORD@repo.meshkee.com/repository/willaspace-charts/
|
||||||
values_files:
|
values_files:
|
||||||
- .values.yaml
|
- .values.yaml
|
||||||
values:
|
values:
|
||||||
- deployment.image.tag=nginx-$DRONE_BUILD_NUMBER
|
- deployment.image.tag=nginx-$DRONE_BUILD_NUMBER
|
||||||
- deployment.additionalContainers[0].image=docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back:$DRONE_BUILD_NUMBER
|
- deployment.additionalContainers[0].image=docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back:$DRONE_BUILD_NUMBER
|
||||||
- deployment.initContainers.init-artisan.image=docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back:$DRONE_BUILD_NUMBER
|
- deployment.initContainers.init-artisan.image=docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back:$DRONE_BUILD_NUMBER
|
||||||
timeout: 3000
|
timeout: 3000
|
||||||
when:
|
when:
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
- push
|
|
||||||
|
|
||||||
|
|
||||||
image_pull_secrets:
|
image_pull_secrets:
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
name: CSSD-backend-publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*' # run on any tag push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Run Publish Job
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
actions: read
|
||||||
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: https://git.meshkee.com/actions/checkout@main
|
||||||
|
|
||||||
|
- name: Setup Docker buildx
|
||||||
|
uses: https://git.meshkee.com/actions/setup-buildx-action@master
|
||||||
|
|
||||||
|
- name: Log into registry git.meshkee.com
|
||||||
|
uses: https://git.meshkee.com/actions/login-action@master
|
||||||
|
with:
|
||||||
|
registry: git.meshkee.com
|
||||||
|
username: ${{ vars.DOCKER_USERNAME }}
|
||||||
|
password: ${{ vars.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: build-and-push
|
||||||
|
uses: https://git.meshkee.com/actions/build-push-action@master
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
git.meshkee.com/${{ gitea.repository }}:${{ gitea.ref_name }}
|
||||||
|
git.meshkee.com/${{ gitea.repository }}:latest
|
||||||
|
cache-from: type=registry,ref=git.meshkee.com/${{ gitea.repository }}:buildcache
|
||||||
|
cache-to: type=registry,ref=git.meshkee.com/${{ gitea.repository }}:buildcache,mode=max
|
||||||
|
# cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
# cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
secrets: |
|
||||||
|
gitea_token=${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# deploy:
|
||||||
|
# name: Deploy Job
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# permissions:
|
||||||
|
# contents: read
|
||||||
|
# security-events: write
|
||||||
|
# actions: read
|
||||||
|
# id-token: write
|
||||||
|
|
||||||
|
# steps:
|
||||||
|
# - name: Deploy to server
|
||||||
|
# uses: appleboy/ssh-action@v1.0.0
|
||||||
|
# with:
|
||||||
|
# host: ${{ secrets.SSH_HOST }}
|
||||||
|
# username: ${{ secrets.SSH_USER }}
|
||||||
|
# key: ${{ secrets.SSH_KEY }}
|
||||||
|
# port: 22
|
||||||
|
# script: |
|
||||||
|
# cd /apps/balout-backend
|
||||||
|
# docker pull git.meshkee.com/${{ gitea.repository }}:${{ gitea.ref_name }}
|
||||||
|
# IMAGE=git.meshkee.com/${{ gitea.repository }}:${{ gitea.ref_name }} docker compose run --rm balout-backend php artisan migrate --pretend --force
|
||||||
|
# # docker run --rm git.meshkee.com/${{ gitea.repository }}:${{ gitea.ref_name }} php artisan migrate --pretend --force
|
||||||
|
# if [ $? -eq 0 ]; then
|
||||||
|
# echo "Migration check passed. Deploying..."
|
||||||
|
# IMAGE=git.meshkee.com/${{ gitea.repository }}:${{ gitea.ref_name }} docker compose up -d
|
||||||
|
|
||||||
|
# # اجرای واقعی migration داخل کانتینر در حال اجرا
|
||||||
|
# docker exec balout-backend php artisan migrate --force
|
||||||
|
# else
|
||||||
|
# echo "Migration test failed, aborting deploy"
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
+4
-4
@@ -84,7 +84,7 @@ deployment:
|
|||||||
name: cssd-production-back-configmap
|
name: cssd-production-back-configmap
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: cssd-production-back-secret
|
name: cssd-production-back-secret
|
||||||
image: docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back:latest
|
image: docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
|
|
||||||
# Additional labels for Deployment
|
# Additional labels for Deployment
|
||||||
@@ -193,7 +193,7 @@ deployment:
|
|||||||
|
|
||||||
# Image of the app container
|
# Image of the app container
|
||||||
image:
|
image:
|
||||||
repository: docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back
|
repository: docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back
|
||||||
tag: nginx-latest
|
tag: nginx-latest
|
||||||
digest: '' # if set to a non empty value, digest takes precedence on the tag
|
digest: '' # if set to a non empty value, digest takes precedence on the tag
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
@@ -258,7 +258,7 @@ deployment:
|
|||||||
# Add additional containers besides init and app containers
|
# Add additional containers besides init and app containers
|
||||||
additionalContainers:
|
additionalContainers:
|
||||||
- name: php-fpm
|
- name: php-fpm
|
||||||
image: docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back:latest
|
image: docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
envFrom:
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
@@ -315,7 +315,7 @@ deployment:
|
|||||||
podLabels:
|
podLabels:
|
||||||
# env: prod
|
# env: prod
|
||||||
|
|
||||||
image: docker.willaspace.com/repository/docker-hosted/external-projects/cssd-back:latest
|
image: docker.meshkee.com/repository/docker-hosted/external-projects/cssd-back:latest
|
||||||
command:
|
command:
|
||||||
- /usr/bin/supervisord
|
- /usr/bin/supervisord
|
||||||
- -n
|
- -n
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM docker.willaspace.com/repository/docker-hosted/standard-laravel:8.2-fpm
|
FROM docker.meshkee.com/repository/docker-hosted/standard-laravel:8.2-fpm
|
||||||
|
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ COPY database /var/www/html/database
|
|||||||
|
|
||||||
COPY composer.* /var/www/html/
|
COPY composer.* /var/www/html/
|
||||||
|
|
||||||
RUN composer config --global http-basic.repo.willaspace.com $REGISTRY_USER_NAME $REGISTRY_PASSWORD
|
RUN composer config --global http-basic.repo.meshkee.com $REGISTRY_USER_NAME $REGISTRY_PASSWORD
|
||||||
|
|
||||||
RUN composer install --no-scripts
|
RUN composer install --no-scripts
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Use the official PHP image as the base image
|
||||||
|
FROM 'docker-proxy.meshkee.com/php:8.2-fpm'
|
||||||
|
|
||||||
|
# Set working directory inside the container
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libpng-dev \
|
||||||
|
libonig-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
libzip-dev \
|
||||||
|
libpq-dev \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libjpeg62-turbo-dev \
|
||||||
|
libmcrypt-dev \
|
||||||
|
libssl-dev \
|
||||||
|
libicu-dev \
|
||||||
|
g++ \
|
||||||
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||||
|
&& docker-php-ext-install -j$(nproc) gd \
|
||||||
|
&& docker-php-ext-install pdo_mysql pdo_pgsql mbstring exif pcntl bcmath opcache intl zip
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=docker-proxy.meshkee.com/composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Copy application code into the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Install PHP dependencies
|
||||||
|
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
|
# Set permissions for the Laravel project
|
||||||
|
RUN chown -R 1000:1000 /var/www/html \
|
||||||
|
&& chmod -R 777 /var/www/html/storage /var/www/html/bootstrap/cache
|
||||||
|
|
||||||
|
# Expose port 9000 for PHP-FPM
|
||||||
|
EXPOSE 9000
|
||||||
+12
-2
@@ -1,3 +1,13 @@
|
|||||||
FROM docker.willaspace.com/repository/docker-hosted/nginx:alpine
|
FROM docker.meshkee.com/repository/docker-hosted/node:14-alpine AS builder
|
||||||
|
|
||||||
COPY public /var/www/html/public
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
COPY . /var/www/html/
|
||||||
|
|
||||||
|
RUN npm i
|
||||||
|
|
||||||
|
RUN npm run production
|
||||||
|
|
||||||
|
FROM docker.meshkee.com/repository/docker-hosted/nginx:alpine
|
||||||
|
|
||||||
|
COPY --from=builder /var/www/html/public /var/www/html/public
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ class StatusTypeEnum
|
|||||||
{
|
{
|
||||||
const APPROVED = "approved";
|
const APPROVED = "approved";
|
||||||
const REJECTED = "rejected";
|
const REJECTED = "rejected";
|
||||||
const SUSPENDED = "suspended";
|
const PENDING = "pending";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Cycle;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class CycleSaved
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Cycle $cycle;
|
||||||
|
|
||||||
|
public function __construct(Cycle $cycle)
|
||||||
|
{
|
||||||
|
$this->cycle = $cycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||||
|
*/
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// new PrivateChannel('channel-name'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class FieldNotExistsException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
if (!function_exists('pluckValues')) {
|
||||||
|
/**
|
||||||
|
* Extracts the values of a given key from an array of associative arrays.
|
||||||
|
*
|
||||||
|
* @param array $array The input array of associative arrays.
|
||||||
|
* @param string $key The key whose values need to be extracted.
|
||||||
|
* @return array An array containing the values of the specified key.
|
||||||
|
*/
|
||||||
|
function pluckValues(array $array, string $key): array
|
||||||
|
{
|
||||||
|
return array_map(function ($item) use ($key) {
|
||||||
|
return $item[$key] ?? null;
|
||||||
|
}, $array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('getNamespaceMap')) {
|
||||||
|
|
||||||
|
function getNamespaceMap(Model $model): string
|
||||||
|
{
|
||||||
|
return $model->getMorphClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Packages\Messaging\src\Facades\MessageResponse;
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Events\CycleSaved;
|
||||||
use App\Http\Requests\StoreCycleRequest;
|
use App\Http\Requests\StoreCycleRequest;
|
||||||
use App\Http\Resources\CycleResource;
|
use App\Http\Resources\CycleResource;
|
||||||
use App\Interfaces\CycleRepositoryInterface;
|
use App\Interfaces\CycleRepositoryInterface;
|
||||||
@@ -72,6 +73,8 @@ class CycleController extends Controller
|
|||||||
foreach ( $Labels as $Label => $Count ) {
|
foreach ( $Labels as $Label => $Count ) {
|
||||||
$CycleObj->labels()->attach( array( $Label ) , [ 'count' => $Count ] );
|
$CycleObj->labels()->attach( array( $Label ) , [ 'count' => $Count ] );
|
||||||
}
|
}
|
||||||
|
event(new CycleSaved($CycleObj));
|
||||||
|
|
||||||
return MessageResponse::success( trans( 'messages.success' ) );
|
return MessageResponse::success( trans( 'messages.success' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +112,7 @@ class CycleController extends Controller
|
|||||||
foreach ( $Labels as $Label => $Count ) {
|
foreach ( $Labels as $Label => $Count ) {
|
||||||
$Cycle->labels()->attach( array( $Label ) , [ 'count' => $Count ] );
|
$Cycle->labels()->attach( array( $Label ) , [ 'count' => $Count ] );
|
||||||
}
|
}
|
||||||
|
event(new CycleSaved($Cycle));
|
||||||
return MessageResponse::success( trans( 'messages.success' ) );
|
return MessageResponse::success( trans( 'messages.success' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +131,7 @@ class CycleController extends Controller
|
|||||||
public function verifyCycle( Cycle $Cycle )
|
public function verifyCycle( Cycle $Cycle )
|
||||||
{
|
{
|
||||||
if ( auth( 'api' )->user()->cant( 'verifyCycle' , $Cycle ) ) {
|
if ( auth( 'api' )->user()->cant( 'verifyCycle' , $Cycle ) ) {
|
||||||
return MessageResponse::error( trans( 'You dont have permission' ) );
|
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
||||||
}
|
}
|
||||||
if ( $Cycle->verified == 'Verified' ) {
|
if ( $Cycle->verified == 'Verified' ) {
|
||||||
$Cycle->verified = 'NotVerified';
|
$Cycle->verified = 'NotVerified';
|
||||||
|
|||||||
@@ -3,13 +3,36 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Cycle;
|
use App\Models\Cycle;
|
||||||
|
use App\Models\FakeModel;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Package;
|
use App\Models\Package;
|
||||||
use App\Services\ExportCollection;
|
use App\Services\ExportCollection;
|
||||||
|
use App\Services\Responser;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ExportController extends Controller
|
class ExportController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private function sendToS3($export){
|
||||||
|
$fakeModel = FakeModel::firstOrCreate(['batch_id' => Str::random(6)]);
|
||||||
|
|
||||||
|
$tempFileName = 'excel_' . Str::random(10) . '.xlsx';
|
||||||
|
$tempDir = 'temp';
|
||||||
|
Storage::makeDirectory($tempDir);
|
||||||
|
$tempFilePath = $tempDir . '/' . $tempFileName;
|
||||||
|
|
||||||
|
Excel::store($export, $tempFilePath, 'local', \Maatwebsite\Excel\Excel::XLSX);
|
||||||
|
|
||||||
|
$media = $fakeModel->addMedia(storage_path('app/' . $tempFilePath))->toMediaCollection('temp_medias');
|
||||||
|
|
||||||
|
// اگه مشکلی پیش نمیاد بعد از این مرحله بالایی فیک مدل رو هم حذف کن که دیتابیس شلوغ نشه
|
||||||
|
|
||||||
|
Storage::delete($tempFilePath);
|
||||||
|
return $media;
|
||||||
|
}
|
||||||
|
|
||||||
public function items()
|
public function items()
|
||||||
{
|
{
|
||||||
$Items = Item::with( [ 'user' => function ( $query ) {
|
$Items = Item::with( [ 'user' => function ( $query ) {
|
||||||
@@ -67,8 +90,17 @@ class ExportController extends Controller
|
|||||||
'نام بیمارستان',
|
'نام بیمارستان',
|
||||||
'اخرین انتقال'
|
'اخرین انتقال'
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$export = new ExportCollection( $Items );
|
$export = new ExportCollection( $Items );
|
||||||
return Excel::download( $export , 'items.xlsx' , null , [ \Maatwebsite\Excel\Excel::XLSX ] );
|
$media = $this->sendToS3($export);
|
||||||
|
|
||||||
|
return response()->json(
|
||||||
|
Responser::success(
|
||||||
|
'خروجی اکسل',
|
||||||
|
null,
|
||||||
|
['id' => $media->id, 'url' => $media->getUrl()]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function packages()
|
public function packages()
|
||||||
@@ -122,7 +154,14 @@ class ExportController extends Controller
|
|||||||
'اخرین انتقال'
|
'اخرین انتقال'
|
||||||
] );
|
] );
|
||||||
$export = new ExportCollection( $Packages );
|
$export = new ExportCollection( $Packages );
|
||||||
return Excel::download( $export , 'packages.xlsx' , null , [ \Maatwebsite\Excel\Excel::XLSX ] );
|
$media = $this->sendToS3($export);
|
||||||
|
return response()->json(
|
||||||
|
Responser::success(
|
||||||
|
'خروجی اکسل',
|
||||||
|
null,
|
||||||
|
['id' => $media->id, 'url' => $media->getUrl()]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cycles()
|
public function cycles()
|
||||||
@@ -170,6 +209,16 @@ class ExportController extends Controller
|
|||||||
'نام بیمارستان',
|
'نام بیمارستان',
|
||||||
]);
|
]);
|
||||||
$export = new ExportCollection($cycles);
|
$export = new ExportCollection($cycles);
|
||||||
return Excel::download($export, 'cycles.xlsx', null, [\Maatwebsite\Excel\Excel::XLSX]);
|
|
||||||
|
$media = $this->sendToS3($export);
|
||||||
|
|
||||||
|
return response()->json(
|
||||||
|
Responser::success(
|
||||||
|
'خروجی اکسل',
|
||||||
|
null,
|
||||||
|
['id' => $media->id, 'url' => $media->getUrl()]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,20 @@ class ItemController extends Controller
|
|||||||
{
|
{
|
||||||
public function index( Request $request )
|
public function index( Request $request )
|
||||||
{
|
{
|
||||||
$Items = Item::when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) {
|
$Items = Item::with( [
|
||||||
|
'user' ,
|
||||||
|
'package' ,
|
||||||
|
'user.medical_center' => function ( $query ) {
|
||||||
|
$query->select( 'id' , 'name' , 'address' , 'phone_number' );
|
||||||
|
} ,
|
||||||
|
] )->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) {
|
||||||
$query->where( 'name' , 'LIKE' , '%' . $request->name . '%' );
|
$query->where( 'name' , 'LIKE' , '%' . $request->name . '%' );
|
||||||
} )
|
} )
|
||||||
|
->when($request->filled('user_name'), function ($query) use ($request) {
|
||||||
|
$query->whereHas('user', function ($q) use ($request) {
|
||||||
|
$q->where('users.name', 'LIKE', '%' . $request->user_name . '%');
|
||||||
|
});
|
||||||
|
})
|
||||||
->when( $request->has( 'udi' ) && $request->udi != '' , function ( $query ) use ( $request ) {
|
->when( $request->has( 'udi' ) && $request->udi != '' , function ( $query ) use ( $request ) {
|
||||||
$query->where( 'udi' , 'LIKE' , '%' . $request->udi . '%' );
|
$query->where( 'udi' , 'LIKE' , '%' . $request->udi . '%' );
|
||||||
} )
|
} )
|
||||||
@@ -35,21 +46,10 @@ class ItemController extends Controller
|
|||||||
$query->whereHas( 'user' , function ( $query ) use ( $request ) {
|
$query->whereHas( 'user' , function ( $query ) use ( $request ) {
|
||||||
$query->where( 'medical_center_id' , $request->medical_center_id );
|
$query->where( 'medical_center_id' , $request->medical_center_id );
|
||||||
} );
|
} );
|
||||||
} )
|
} );
|
||||||
->with( [
|
|
||||||
'user' ,
|
|
||||||
'package' ,
|
|
||||||
'user.medical_center' => function ( $query ) {
|
|
||||||
$query->select( 'id' , 'name' , 'address' , 'phone_number' );
|
|
||||||
} ,
|
|
||||||
] );
|
|
||||||
|
|
||||||
$user = auth( 'api' )->user();
|
$user = auth( 'api' )->user();
|
||||||
if ( $user->hasRole( 'User' ) ) {
|
if ( $user->hasRole( 'User' ) or $user->hasRole( 'Supervisor' ) ) {
|
||||||
$Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) {
|
|
||||||
$query->where( 'medical_center_id' , $user->medical_center_id );
|
|
||||||
} )->where( "status" , StatusTypeEnum::APPROVED );
|
|
||||||
} elseif ( $user->hasRole( 'Supervisor' ) ) {
|
|
||||||
$Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) {
|
$Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) {
|
||||||
$query->where( 'medical_center_id' , $user->medical_center_id );
|
$query->where( 'medical_center_id' , $user->medical_center_id );
|
||||||
} );
|
} );
|
||||||
@@ -96,12 +96,8 @@ class ItemController extends Controller
|
|||||||
] );
|
] );
|
||||||
|
|
||||||
$user = auth( 'api' )->user();
|
$user = auth( 'api' )->user();
|
||||||
if ( $user->hasRole( 'User' ) ) {
|
if ( $user->hasRole( 'User' ) or $user->hasRole('Supervisor') ) {
|
||||||
$Items = $Items->where( "user_id" , $user->id );
|
$Items = $Items->where( "user_id" , $user->id );
|
||||||
} elseif ( $user->hasRole( 'Supervisor' ) ) {
|
|
||||||
$Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) {
|
|
||||||
$query->where( 'medical_center_id' , $user->medical_center_id );
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$Items = $Items->orderByDesc( 'id' )->paginate( 10 );
|
$Items = $Items->orderByDesc( 'id' )->paginate( 10 );
|
||||||
@@ -152,6 +148,35 @@ class ItemController extends Controller
|
|||||||
return ItemResource::make( $Item );
|
return ItemResource::make( $Item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showUdi( $udi )
|
||||||
|
{
|
||||||
|
$Item = Item::where('udi',$udi)->first();
|
||||||
|
$Item->load( [
|
||||||
|
'user' ,
|
||||||
|
'creator' ,
|
||||||
|
'package' ,
|
||||||
|
'user.medical_center' => function ( $query ) {
|
||||||
|
$query->select( 'id' , 'name' , 'address' , 'phone_number' );
|
||||||
|
} ,
|
||||||
|
"transfers" => function ( $query ) {
|
||||||
|
$query->with( [
|
||||||
|
'user' => function ( $query ) {
|
||||||
|
$query->select( 'id' , 'name' , 'cell_number' );
|
||||||
|
} ,
|
||||||
|
'user.medical_center' => function ( $query ) {
|
||||||
|
$query->select( 'id' , 'name' , 'address' , 'phone_number' );
|
||||||
|
},
|
||||||
|
'userTransfer' => function ($query) {
|
||||||
|
$query->select('id','name','cell_number');
|
||||||
|
}
|
||||||
|
] );
|
||||||
|
},
|
||||||
|
'media'
|
||||||
|
] );
|
||||||
|
|
||||||
|
return ItemResource::make( $Item );
|
||||||
|
}
|
||||||
|
|
||||||
public function store( StoreItemRequest $request )
|
public function store( StoreItemRequest $request )
|
||||||
{
|
{
|
||||||
$Item = Item::create( [
|
$Item = Item::create( [
|
||||||
@@ -161,7 +186,7 @@ class ItemController extends Controller
|
|||||||
'specific' => $request->specific ,
|
'specific' => $request->specific ,
|
||||||
'note' => $request->note ,
|
'note' => $request->note ,
|
||||||
'udi' => $request->udi ,
|
'udi' => $request->udi ,
|
||||||
'status' => StatusTypeEnum::SUSPENDED ,
|
'status' => StatusTypeEnum::PENDING ,
|
||||||
'user_id' => auth( 'api' )->user()->id ,
|
'user_id' => auth( 'api' )->user()->id ,
|
||||||
'creator_id' => auth( 'api' )->user()->id
|
'creator_id' => auth( 'api' )->user()->id
|
||||||
] );
|
] );
|
||||||
@@ -171,7 +196,7 @@ class ItemController extends Controller
|
|||||||
|
|
||||||
public function edit( Item $Item )
|
public function edit( Item $Item )
|
||||||
{
|
{
|
||||||
return ItemResource::make( $Item );
|
return ItemResource::make( $Item->load(['media']) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update( StoreItemRequest $request , Item $Item )
|
public function update( StoreItemRequest $request , Item $Item )
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class LabelController extends Controller
|
|||||||
$query->where('medical_center_id', $user->medical_center_id);
|
$query->where('medical_center_id', $user->medical_center_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})->get();
|
})->where('enabled',true)->get();
|
||||||
|
|
||||||
return MessageResponse::data($Labels);
|
return MessageResponse::data($Labels);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,50 +13,45 @@ class MessageController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$User = auth('api')->user();
|
$User = auth('api')->user();
|
||||||
$role = null;
|
|
||||||
$medical_center_id = null;
|
$medical_center_id = null;
|
||||||
|
|
||||||
$User = auth('api')->user();
|
|
||||||
if ($User->hasRole('Supervisor') || $User->hasRole('User')) {
|
if ($User->hasRole('Supervisor') || $User->hasRole('User')) {
|
||||||
$medical_center_id = $User->medical_center_id;
|
$medical_center_id = $User->medical_center_id;
|
||||||
$role = 'Admin';
|
|
||||||
}
|
}
|
||||||
$remove = $User->id;
|
|
||||||
$Users = User::whereHas('messagesSent', function ($q) use ($User) {
|
$Users = User::where(function ($query) use ($User) {
|
||||||
$q->where('recipient_user_id', $User->id);
|
$query->whereHas('messagesSent', function ($q) use ($User) {
|
||||||
})
|
$q->where('recipient_user_id', $User->id);
|
||||||
|
})
|
||||||
->orWhereHas('messagesReceived', function ($q) use ($User) {
|
->orWhereHas('messagesReceived', function ($q) use ($User) {
|
||||||
$q->where('sender_user_id', $User->id);
|
$q->where('sender_user_id', $User->id);
|
||||||
})
|
});
|
||||||
->when($medical_center_id, function ($query) use ($medical_center_id) {
|
})
|
||||||
$query->where('medical_center_id', $medical_center_id);
|
->when($medical_center_id, function ($query) use ($medical_center_id) {
|
||||||
})
|
$query->where('medical_center_id', $medical_center_id);
|
||||||
->when($role, function ($query) use ($role) {
|
})
|
||||||
$query->role($role);
|
->paginate(10);
|
||||||
})
|
|
||||||
->paginate(10);
|
|
||||||
|
|
||||||
foreach ($Users as $user) {
|
foreach ($Users as $user) {
|
||||||
$UnReadReceivedMessages = Message::where('sender_user_id', $user->id)->where('recipient_user_id', $User->id)->where('status', 'UnRead')->get()->count();
|
$user->unread_messages_count = Message::where('sender_user_id', $user->id)
|
||||||
$user->unread_messages_count = $UnReadReceivedMessages;
|
->where('recipient_user_id', $User->id)
|
||||||
|
->where('status', 'UnRead')
|
||||||
|
->count();
|
||||||
|
|
||||||
$MessagesCount = Message::where(function ($query) use ($user, $User) {
|
$user->messages_count = Message::where(function ($query) use ($user, $User) {
|
||||||
$query->where('sender_user_id', $user->id)->where('recipient_user_id', $User->id);
|
$query->where('sender_user_id', $user->id)
|
||||||
|
->where('recipient_user_id', $User->id);
|
||||||
})->orWhere(function ($query) use ($user, $User) {
|
})->orWhere(function ($query) use ($user, $User) {
|
||||||
$query->where('sender_user_id', $User->id)->where('recipient_user_id', $user->id);
|
$query->where('sender_user_id', $User->id)
|
||||||
})->get()->count();
|
->where('recipient_user_id', $user->id);
|
||||||
|
})->count();
|
||||||
$user->messages_count = $MessagesCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// $Users = $Users->filter(function ($value, $key) use($remove){
|
|
||||||
// return $value['id'] != $remove;
|
|
||||||
// });
|
|
||||||
|
|
||||||
return MessageResponse::data($Users);
|
return MessageResponse::data($Users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class PackageController extends Controller
|
|||||||
})
|
})
|
||||||
->with([
|
->with([
|
||||||
'user',
|
'user',
|
||||||
|
'items',
|
||||||
'user.medical_center' => function ($query) {
|
'user.medical_center' => function ($query) {
|
||||||
$query->select('id', 'name', 'address', 'phone_number');
|
$query->select('id', 'name', 'address', 'phone_number');
|
||||||
},
|
},
|
||||||
@@ -61,15 +62,11 @@ class PackageController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$user = auth('api')->user();
|
$user = auth('api')->user();
|
||||||
if ($user->hasRole('User')) {
|
if ($user->hasRole('User') or $user->hasRole('Supervisor')) {
|
||||||
$Packages = $Packages->where("user_id", $user->id);
|
$Packages = $Packages->where("user_id", $user->id);
|
||||||
} elseif ($user->hasRole('Supervisor')) {
|
|
||||||
$Packages = $Packages->whereHas('user', function ($query) use ($user) {
|
|
||||||
$query->where('medical_center_id', $user->medical_center_id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$Packages = $Packages->orderByDesc('id')->get();
|
$Packages = $Packages->orderByDesc('id')->paginate(10);
|
||||||
|
|
||||||
return PackageResource::collection($Packages);
|
return PackageResource::collection($Packages);
|
||||||
}
|
}
|
||||||
@@ -115,16 +112,16 @@ class PackageController extends Controller
|
|||||||
$PackageData = [
|
$PackageData = [
|
||||||
'name' => $request->name,
|
'name' => $request->name,
|
||||||
'note' => $request->note,
|
'note' => $request->note,
|
||||||
'status' => StatusTypeEnum::SUSPENDED,
|
'status' => StatusTypeEnum::PENDING,
|
||||||
'user_id' => auth('api')->user()->id,
|
'user_id' => auth('api')->user()->id,
|
||||||
'creator_id' => auth('api')->user()->id
|
'creator_id' => auth('api')->user()->id
|
||||||
];
|
];
|
||||||
$Package = Package::create($PackageData);
|
$Package = Package::create($PackageData);
|
||||||
foreach ($request->items as $itemId) {
|
foreach ($request->items as $itemNameAndId) {
|
||||||
$item = Item::where("id", $itemId)->first();
|
$item = Item::where("id", $itemNameAndId['id'])->first();
|
||||||
if ($item) {
|
if ($item) {
|
||||||
$item->update([
|
$item->update([
|
||||||
"package_id" => $Package->id
|
'package_id' => $Package->id
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,8 +138,8 @@ class PackageController extends Controller
|
|||||||
{
|
{
|
||||||
$Package->update($request->except(['items']));
|
$Package->update($request->except(['items']));
|
||||||
|
|
||||||
foreach ($request->items as $itemId) {
|
foreach ($request->items as $itemNameAndId) {
|
||||||
$item = Item::where("id", $itemId)->first();
|
$item = Item::where("id", $itemNameAndId['id'])->first();
|
||||||
if ($item) {
|
if ($item) {
|
||||||
$item->update([
|
$item->update([
|
||||||
"package_id" => $Package->id
|
"package_id" => $Package->id
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ class TestResultController extends Controller
|
|||||||
->when($request->has('testType_id') && $request->testType_id, function ($query) use ($request) {
|
->when($request->has('testType_id') && $request->testType_id, function ($query) use ($request) {
|
||||||
$query->where('test_type_id', $request->testType_id);
|
$query->where('test_type_id', $request->testType_id);
|
||||||
})
|
})
|
||||||
|
->when($request->has('test_type_name') && $request->test_type_name, function ($q) use ($request) {
|
||||||
|
$q->whereHas('test_type', function ($query) use ($request) {
|
||||||
|
$query->where('name', 'like', "%{$request->test_type_name}%");
|
||||||
|
});
|
||||||
|
})
|
||||||
->when(($request->has('device_id') && $request->device_id) && ($request->has('device_label') && $request->device_label && $request->device_label != "undefined"), function ($query) use ($request) {
|
->when(($request->has('device_id') && $request->device_id) && ($request->has('device_label') && $request->device_label && $request->device_label != "undefined"), function ($query) use ($request) {
|
||||||
if ($request->device_label != 'undefined') {
|
if ($request->device_label != 'undefined') {
|
||||||
$query->whereHas('input_values', function ($query) use ($request) {
|
$query->whereHas('input_values', function ($query) use ($request) {
|
||||||
@@ -218,6 +223,7 @@ class TestResultController extends Controller
|
|||||||
|
|
||||||
public function edit(TestResult $TestResult)
|
public function edit(TestResult $TestResult)
|
||||||
{
|
{
|
||||||
|
$TestResult->load('media');
|
||||||
foreach ($TestResult->input_values as $key => $value) {
|
foreach ($TestResult->input_values as $key => $value) {
|
||||||
$input = $value->input;
|
$input = $value->input;
|
||||||
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
||||||
@@ -320,7 +326,7 @@ class TestResultController extends Controller
|
|||||||
public function verifyTestResult(TestResult $TestResult, $Value)
|
public function verifyTestResult(TestResult $TestResult, $Value)
|
||||||
{
|
{
|
||||||
if (auth('api')->user()->cant('verifyTestResult', $TestResult)) {
|
if (auth('api')->user()->cant('verifyTestResult', $TestResult)) {
|
||||||
return MessageResponse::error(trans('You dont have permission or this test result belongs to another medical center'));
|
return MessageResponse::error('messages.access_denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
$TestResult->verified = $Value;
|
$TestResult->verified = $Value;
|
||||||
@@ -391,7 +397,7 @@ class TestResultController extends Controller
|
|||||||
|
|
||||||
public function showTestResult($id)
|
public function showTestResult($id)
|
||||||
{
|
{
|
||||||
$TestResult = TestResult::with('input_values', 'user.medical_center', 'test_type')->select('result', 'verified', 'device_id', 'user_id', 'id', 'test_type_id', 'created_at')->findOrFail($id);
|
$TestResult = TestResult::with('input_values', 'user.medical_center', 'test_type','media')->select('result', 'verified', 'device_id', 'user_id', 'id', 'test_type_id', 'created_at')->findOrFail($id);
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ($TestResult->input_values as $value) {
|
foreach ($TestResult->input_values as $value) {
|
||||||
$input = $value->input;
|
$input = $value->input;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Models\Input;
|
|||||||
use App\Models\Option;
|
use App\Models\Option;
|
||||||
use App\Models\TestResult;
|
use App\Models\TestResult;
|
||||||
use App\Models\TestType;
|
use App\Models\TestType;
|
||||||
|
use Exception;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Milon\Barcode\Facades\DNS1DFacade;
|
use Milon\Barcode\Facades\DNS1DFacade;
|
||||||
@@ -380,21 +381,20 @@ class TestTypeController extends Controller
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public function getInputs(Request $request)
|
public function getInputs($idOrCode)
|
||||||
{
|
{
|
||||||
if (auth('api')->user()->can('getInputs')) {
|
if (auth('api')->user()->can('getInputs')) {
|
||||||
return MessageResponse::error(trans('messages.failed'));
|
return MessageResponse::error(trans('messages.failed'));
|
||||||
}
|
}
|
||||||
if ($request->test_result_id !== '') {
|
try {
|
||||||
$testTypeId = TestResult::find($request->test_result_id);
|
$by = request()->query('by', 'id');
|
||||||
}
|
|
||||||
if (isset($testTypeId) && $testTypeId) {
|
|
||||||
$testType = TestType::select('id', 'name', 'unique_code', 'device_label')->find($testTypeId->test_type_id);
|
|
||||||
} else {
|
|
||||||
$testType = TestType::where('name', $request->name)->orWhere('unique_code', $request->unique_code)->select('id', 'name', 'unique_code', 'device_label')->first();
|
|
||||||
}
|
|
||||||
if (isset($testType) && $testType) {
|
|
||||||
|
|
||||||
|
$testType = TestType::select('id', 'name', 'unique_code', 'device_label');
|
||||||
|
if ($by === 'code') {
|
||||||
|
$testType = $testType->where('unique_code', $idOrCode)->firstOrFail();
|
||||||
|
} else {
|
||||||
|
$testType = $testType->findOrFail($idOrCode);
|
||||||
|
}
|
||||||
$inputs = Input::select('id', 'name', 'type', 'size', 'parent_id', 'require_scanner')->with(
|
$inputs = Input::select('id', 'name', 'type', 'size', 'parent_id', 'require_scanner')->with(
|
||||||
['options' => function ($query) {
|
['options' => function ($query) {
|
||||||
$query->select('id', 'title', 'input_id');
|
$query->select('id', 'title', 'input_id');
|
||||||
@@ -408,13 +408,14 @@ class TestTypeController extends Controller
|
|||||||
)->whereNull('parent_id')->where('test_type_id', $testType->id)->get();
|
)->whereNull('parent_id')->where('test_type_id', $testType->id)->get();
|
||||||
|
|
||||||
return MessageResponse::data(['testType' => $testType, 'inputs' => $inputs]);
|
return MessageResponse::data(['testType' => $testType, 'inputs' => $inputs]);
|
||||||
|
} catch(Exception $e) {
|
||||||
|
return MessageResponse::error();
|
||||||
}
|
}
|
||||||
return MessageResponse::error();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listNames()
|
public function list()
|
||||||
{
|
{
|
||||||
$testType = TestType::pluck('name');
|
$testType = TestType::select('id','name')->get();
|
||||||
return MessageResponse::data($testType);
|
return MessageResponse::data($testType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,25 @@ use App\Http\Requests\StoreTransferRequest;
|
|||||||
use App\Http\Resources\TransferResource;
|
use App\Http\Resources\TransferResource;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Transfer;
|
use App\Models\Transfer;
|
||||||
|
use App\Policies\TransferPolicy;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Packages\Messaging\src\Facades\MessageResponse;
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
class TransferItemController extends Controller
|
class TransferItemController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private $policy;
|
||||||
|
|
||||||
|
public function __construct(TransferPolicy $policy)
|
||||||
|
{
|
||||||
|
$this->policy = $policy;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSuspendedTransfer()
|
public function getSuspendedTransfer()
|
||||||
{
|
{
|
||||||
$data = Transfer::query()
|
$data = Transfer::query()
|
||||||
->whereHasMorph( 'transferable' , [ Item::class ] )
|
->whereHasMorph( 'transferable' , [ Item::class ] )
|
||||||
->where( "status" , StatusTypeEnum::SUSPENDED )
|
->where( "status" , StatusTypeEnum::PENDING )
|
||||||
->with( [ "user" , "transferable" , "transferable.user" ] );
|
->with( [ "user" , "transferable" , "transferable.user" ] );
|
||||||
|
|
||||||
$user = auth( 'api' )->user();
|
$user = auth( 'api' )->user();
|
||||||
@@ -41,7 +50,7 @@ class TransferItemController extends Controller
|
|||||||
if ( auth( 'api' )->user()->cant( 'changeStatus' , [ Transfer::class , $Transfer ] ) ) {
|
if ( auth( 'api' )->user()->cant( 'changeStatus' , [ Transfer::class , $Transfer ] ) ) {
|
||||||
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
||||||
}
|
}
|
||||||
if ( $Transfer->status == StatusTypeEnum::SUSPENDED ) {
|
if ( $Transfer->status == StatusTypeEnum::PENDING ) {
|
||||||
if ( $request->status == StatusTypeEnum::APPROVED ) {
|
if ( $request->status == StatusTypeEnum::APPROVED ) {
|
||||||
$item = $Transfer->transferable;
|
$item = $Transfer->transferable;
|
||||||
if ( $item->transferActive ) $item->transferActive()->update( [ "to_date" => Carbon::now() ] );
|
if ( $item->transferActive ) $item->transferActive()->update( [ "to_date" => Carbon::now() ] );
|
||||||
@@ -58,9 +67,10 @@ class TransferItemController extends Controller
|
|||||||
|
|
||||||
public function transfer( StoreTransferRequest $request , Item $Item )
|
public function transfer( StoreTransferRequest $request , Item $Item )
|
||||||
{
|
{
|
||||||
if ( auth( 'api' )->user()->cant( 'transferItem' , [ Transfer::class , $Item ] ) ) {
|
if (!$this->policy->transferItem(auth('api')->user(), $Item)) {
|
||||||
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $Item->user_id != $request->user_id ) {
|
if ( $Item->user_id != $request->user_id ) {
|
||||||
$Item->transfers()->create( [
|
$Item->transfers()->create( [
|
||||||
"user_transfer_id" => auth()->user()->id,
|
"user_transfer_id" => auth()->user()->id,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class TransferPackageController extends Controller
|
|||||||
{
|
{
|
||||||
$data = Transfer::query()
|
$data = Transfer::query()
|
||||||
->whereHasMorph( 'transferable' , [ Package::class ] )
|
->whereHasMorph( 'transferable' , [ Package::class ] )
|
||||||
->where( "status" , StatusTypeEnum::SUSPENDED )
|
->where( "status" , StatusTypeEnum::PENDING )
|
||||||
->with( [ "user" , "transferable" , "transferable.user" ] );
|
->with( [ "user" , "transferable" , "transferable.user" ] );
|
||||||
|
|
||||||
$user = auth( 'api' )->user();
|
$user = auth( 'api' )->user();
|
||||||
@@ -41,7 +41,7 @@ class TransferPackageController extends Controller
|
|||||||
if ( auth( 'api' )->user()->cant( 'changeStatus' , [ Transfer::class , $Transfer ] ) ) {
|
if ( auth( 'api' )->user()->cant( 'changeStatus' , [ Transfer::class , $Transfer ] ) ) {
|
||||||
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
||||||
}
|
}
|
||||||
if ( $Transfer->status == StatusTypeEnum::SUSPENDED ) {
|
if ( $Transfer->status == StatusTypeEnum::PENDING ) {
|
||||||
if ( $request->status == StatusTypeEnum::APPROVED ) {
|
if ( $request->status == StatusTypeEnum::APPROVED ) {
|
||||||
$package = $Transfer->transferable;
|
$package = $Transfer->transferable;
|
||||||
if ( $package->transferActive ) $package->transferActive()->update( [ "to_date" => Carbon::now() ] );
|
if ( $package->transferActive ) $package->transferActive()->update( [ "to_date" => Carbon::now() ] );
|
||||||
|
|||||||
@@ -179,14 +179,14 @@ class UserController extends Controller
|
|||||||
if ( auth( 'api' )->user()->cant( 'getByMedicalCenter' , $MedicalCenter ) ) {
|
if ( auth( 'api' )->user()->cant( 'getByMedicalCenter' , $MedicalCenter ) ) {
|
||||||
return MessageResponse::error( trans( 'messages.failed' ) );
|
return MessageResponse::error( trans( 'messages.failed' ) );
|
||||||
}
|
}
|
||||||
if ($user->hasRole('Admin')){
|
// if ($user->hasRole('Admin')){
|
||||||
$MedicalCenter = MedicalCenter::with(['users' => function ($query) {
|
// $MedicalCenter = MedicalCenter::with(['users' => function ($query) {
|
||||||
$query->select('id', 'medical_center_id', 'name', 'cell_number', 'status')
|
// $query->select('id', 'medical_center_id', 'name', 'cell_number', 'status')
|
||||||
->whereDoesntHave('roles', function ($roleQuery) {
|
// ->whereDoesntHave('roles', function ($roleQuery) {
|
||||||
$roleQuery->where('name', 'Admin');
|
// $roleQuery->where('name', 'Admin');
|
||||||
});
|
// });
|
||||||
}, 'users.roles'])->get();
|
// }, 'users.roles'])->get();
|
||||||
}else{
|
// }else{
|
||||||
$MedicalCenter = $MedicalCenter->load( [ 'users' => function ( $query ) use ( $user ) {
|
$MedicalCenter = $MedicalCenter->load( [ 'users' => function ( $query ) use ( $user ) {
|
||||||
if ( $user->hasRole( 'User' ) ) {
|
if ( $user->hasRole( 'User' ) ) {
|
||||||
return $query->select( [ 'id' , 'medical_center_id' , 'name' , 'cell_number' , 'status' ] )->where( 'id' , $user->id );
|
return $query->select( [ 'id' , 'medical_center_id' , 'name' , 'cell_number' , 'status' ] )->where( 'id' , $user->id );
|
||||||
@@ -197,7 +197,7 @@ class UserController extends Controller
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} , 'users.roles' ] );
|
} , 'users.roles' ] );
|
||||||
}
|
// }
|
||||||
|
|
||||||
return MessageResponse::data( $MedicalCenter );
|
return MessageResponse::data( $MedicalCenter );
|
||||||
}
|
}
|
||||||
@@ -227,6 +227,7 @@ class UserController extends Controller
|
|||||||
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
||||||
}
|
}
|
||||||
$User->syncRoles( $request->roles );
|
$User->syncRoles( $request->roles );
|
||||||
|
$User->load('roles');
|
||||||
return MessageResponse::data( $User );
|
return MessageResponse::data( $User );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,27 +252,28 @@ class UserController extends Controller
|
|||||||
return MessageResponse::data( [ 'ReceivedMessages' => $ReceivedMessages , 'SentMessages' => $SentMessages ] );
|
return MessageResponse::data( [ 'ReceivedMessages' => $ReceivedMessages , 'SentMessages' => $SentMessages ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchUser( Request $request )
|
public function searchUser(Request $request)
|
||||||
{
|
{
|
||||||
$role = null;
|
$User = auth('api')->user();
|
||||||
$medical_center_id = null;
|
|
||||||
|
|
||||||
$User = auth( 'api' )->user();
|
$query = User::query()
|
||||||
if ( $User->hasRole( 'Supervisor' ) || $User->hasRole( 'User' ) ) {
|
->with('roles')
|
||||||
$medical_center_id = $User->medical_center_id;
|
->where('id', '<>', $User->id)
|
||||||
if ( $User->hasRole( 'Supervisor' ) ) {
|
->select('id', 'name')
|
||||||
$role = 'Admin';
|
->where('name', 'LIKE', '%' . $request->name . '%');
|
||||||
}
|
|
||||||
|
if ($User->hasRole('Supervisor') || $User->hasRole('User')) {
|
||||||
|
$query->where(function ($q) use ($User) {
|
||||||
|
$q->where('medical_center_id', $User->medical_center_id)
|
||||||
|
->orWhereHas('roles', function ($roleQuery) {
|
||||||
|
$roleQuery->where('name', 'Admin');
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = User::where( 'id' , '<>' , $User->id )->select( 'id' , 'name' )->where( 'name' , 'LIKE' , '%' . $request->name . '%' )
|
$users = $query->get();
|
||||||
->when( $medical_center_id , function ( $query ) use ( $medical_center_id ) {
|
|
||||||
$query->where( 'medical_center_id' , $medical_center_id );
|
return MessageResponse::data($users);
|
||||||
} )
|
|
||||||
->when( $role , function ( $query ) use ( $role ) {
|
|
||||||
$query->role( $role );
|
|
||||||
} )
|
|
||||||
->get();
|
|
||||||
return MessageResponse::data( $users );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Models\Cycle;
|
use App\Models\Cycle;
|
||||||
|
use App\Rules\ValidEnabledLabels;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
|
||||||
@@ -27,8 +28,8 @@ class StoreCycleRequest extends FormRequest
|
|||||||
'sterilizer_id' => 'required',
|
'sterilizer_id' => 'required',
|
||||||
'cycle_number' => 'required|unique:cycles,cycle_number',
|
'cycle_number' => 'required|unique:cycles,cycle_number',
|
||||||
'note' => 'nullable',
|
'note' => 'nullable',
|
||||||
'labels' => 'required|array|distinct',
|
|
||||||
'labels.*.id' => 'required|numeric|exists:labels,id',
|
'labels.*.id' => 'required|numeric|exists:labels,id',
|
||||||
|
'labels' => ['required','array','distinct',new ValidEnabledLabels()],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -40,8 +41,8 @@ class StoreCycleRequest extends FormRequest
|
|||||||
'sterilizer_id' => 'required',
|
'sterilizer_id' => 'required',
|
||||||
'cycle_number' => 'required|unique:cycles,cycle_number',
|
'cycle_number' => 'required|unique:cycles,cycle_number',
|
||||||
'note' => 'nullable',
|
'note' => 'nullable',
|
||||||
'labels' => 'required|array|distinct',
|
|
||||||
'labels.*.id' => 'required|numeric|exists:labels,id',
|
'labels.*.id' => 'required|numeric|exists:labels,id',
|
||||||
|
'labels' => ['required','array','distinct',new ValidEnabledLabels()],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class StoreLabelRequest extends FormRequest
|
|||||||
'sterile_date' => 'required|date',
|
'sterile_date' => 'required|date',
|
||||||
'expire_date' => 'required|date',
|
'expire_date' => 'required|date',
|
||||||
'sterilizer_id' => 'required',
|
'sterilizer_id' => 'required',
|
||||||
'cycle_number' => 'required|exists:cycles,cycle_number',
|
'cycle_number' => 'required',
|
||||||
'lot_number' => 'required',
|
'lot_number' => 'required',
|
||||||
'package_id' => 'required|exists:packages,id',
|
'package_id' => 'required|exists:packages,id',
|
||||||
];
|
];
|
||||||
@@ -39,7 +39,7 @@ class StoreLabelRequest extends FormRequest
|
|||||||
'sterile_date' => 'required',
|
'sterile_date' => 'required',
|
||||||
'expire_date' => 'required',
|
'expire_date' => 'required',
|
||||||
'sterilizer_id' => 'required',
|
'sterilizer_id' => 'required',
|
||||||
'cycle_number' => 'required|exists:cycles,cycle_number',
|
'cycle_number' => 'required',
|
||||||
'lot_number' => 'required',
|
'lot_number' => 'required',
|
||||||
'package_id' => 'required|exists:packages,id',
|
'package_id' => 'required|exists:packages,id',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class StorePackageRequest extends FormRequest
|
|||||||
'name' => 'required|max:250',
|
'name' => 'required|max:250',
|
||||||
'note' => 'nullable',
|
'note' => 'nullable',
|
||||||
'items' => 'required|array|min:1',
|
'items' => 'required|array|min:1',
|
||||||
'items.*' => ['exists:items,id','integer',new ValidateItemOwnership()],
|
'items.*.id' => ['exists:items,id','integer',new ValidateItemOwnership()],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class StorePackageRequest extends FormRequest
|
|||||||
'name' => 'required|max:250',
|
'name' => 'required|max:250',
|
||||||
'note' => 'nullable',
|
'note' => 'nullable',
|
||||||
'items' => 'required|array|min:1',
|
'items' => 'required|array|min:1',
|
||||||
'items.*' => ['exists:items,id','integer',new ValidateItemOwnership()],
|
'items.*.id' => ['exists:items,id','integer',new ValidateItemOwnership()],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\CycleSaved;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class UpdateLabelsCycleNumber
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*/
|
||||||
|
public function handle(CycleSaved $event): void
|
||||||
|
{
|
||||||
|
$cycle = $event->cycle;
|
||||||
|
$cycleNumber = $cycle->cycle_number;
|
||||||
|
|
||||||
|
$cycle->labels()->update(['cycle_number' => $cycleNumber, 'enabled' => false]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Exceptions\FieldNotExistsException;
|
||||||
|
// use App\Scopes\OrderByIdScope;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
trait BasicModel
|
||||||
|
{
|
||||||
|
private int $pageSizeLimit = 48;
|
||||||
|
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
// if (! app()->runningInConsole()) {
|
||||||
|
// static::addGlobalScope( new OrderByIdScope );
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerPage()
|
||||||
|
{
|
||||||
|
$pageSize = (int) request( 'per_page' , $this->perPage );
|
||||||
|
return min( $pageSize , $this->pageSizeLimit );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributeExists( $attr ): bool
|
||||||
|
{
|
||||||
|
|
||||||
|
return array_key_exists( $attr , $this->attributes );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getField( $name )
|
||||||
|
{
|
||||||
|
$columnName = static::getColumn( $name );
|
||||||
|
return $this->$columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setField( $name , $value ): void
|
||||||
|
{
|
||||||
|
$columnName = static::getColumn( $name );
|
||||||
|
$this->$columnName = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getColumnTable( $name ): string
|
||||||
|
{
|
||||||
|
return static::getTableName() . '.' . static::getColumn( $name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getColumn( $name )
|
||||||
|
{
|
||||||
|
$fieldName = Arr::get( static::$maps , $name );
|
||||||
|
|
||||||
|
if ( is_null( $fieldName ) ) {
|
||||||
|
throw new FieldNotExistsException( "field $name not exists" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTable()
|
||||||
|
{
|
||||||
|
return static::getTableName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fieldValue( $name )
|
||||||
|
{
|
||||||
|
return $this->$name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributes()
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isLoaded( $relationName ): bool
|
||||||
|
{
|
||||||
|
return isset( $this->relations[ $relationName ] ) and $this->$relationName != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public static function getTableName();
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Events\CycleSaved;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
@@ -14,6 +15,7 @@ class Cycle extends Model
|
|||||||
'date', 'user_id', 'cycle_number', 'sterilizer_id', 'note', 'verified', 'unique_id'
|
'date', 'user_id', 'cycle_number', 'sterilizer_id', 'note', 'verified', 'unique_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
|
class Sms extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use BasicModel;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'client_id' , 'status_code' , 'status' , 'message' , 'rel_id' , 'rel_type' , 'cell_number' , 'segment_count' ,
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $hidden = [];
|
||||||
|
|
||||||
|
public static function getTableName(): string
|
||||||
|
{
|
||||||
|
return "sms";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function receiver(): MorphTo
|
||||||
|
{
|
||||||
|
return $this->morphTo( null , 'rel_type' , 'rel_id' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function smsBatch(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo( SmsBatch::class );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class SmsBatch extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use SoftDeletes , BasicModel;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'category' , 'operator' , 'code' , 'fee' , 'type' , 'business_id' , 'is_admin' , 'is_systematic' , 'pattern' , 'from'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $hidden = [];
|
||||||
|
|
||||||
|
public static function getTableName(): string
|
||||||
|
{
|
||||||
|
return "sms_batch";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function smsList(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany( Sms::class );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeSingle( $query )
|
||||||
|
{
|
||||||
|
return $query->whereCategory( 'single' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeBatch( $query )
|
||||||
|
{
|
||||||
|
return $query->whereCategory( 'batch' );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,11 +27,22 @@ class User extends Authenticatable
|
|||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $messageFields = [
|
||||||
|
'name', 'cell_number'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function getDefaultGuardName(): string { return 'api'; }
|
||||||
|
|
||||||
public function medical_center(): BelongsTo
|
public function medical_center(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(MedicalCenter::class);
|
return $this->belongsTo(MedicalCenter::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPhone()
|
||||||
|
{
|
||||||
|
return $this->cell_number;
|
||||||
|
}
|
||||||
|
|
||||||
public function test_results(): HasMany
|
public function test_results(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(TestResult::class);
|
return $this->hasMany(TestResult::class);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Constants\StatusTypeEnum;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -17,11 +18,12 @@ class ItemPolicy
|
|||||||
{
|
{
|
||||||
if ($user->hasRole('Admin')) {
|
if ($user->hasRole('Admin')) {
|
||||||
return true;
|
return true;
|
||||||
} elseif ($user->hasRole('Supervisor')) {
|
} elseif ($user->hasRole('Supervisor') && $Item->user->medical_center_id == $user->medical_center_id) {
|
||||||
if ($Item->status == 0) {
|
return true;
|
||||||
return true;
|
} elseif ($user->hasRole('User') && $Item->user_id == $user->id && $Item->status != StatusTypeEnum::APPROVED) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(User $user, Item $Item)
|
public function update(User $user, Item $Item)
|
||||||
|
|||||||
@@ -17,18 +17,22 @@ class TransferPolicy
|
|||||||
|
|
||||||
public function transferItem(User $user, Item $Item)
|
public function transferItem(User $user, Item $Item)
|
||||||
{
|
{
|
||||||
if ($user->hasRole('Admin')) {
|
if(is_null($Item->package_id)){
|
||||||
return true;
|
if ($user->hasRole('Admin')) {
|
||||||
} else {
|
return true;
|
||||||
if ($user->hasRole('Supervisor')) {
|
|
||||||
if ($Item->user->medical_center_id == $user->medical_center_id) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ($Item->user_id == $user->id) {
|
if ($user->hasRole('Supervisor')) {
|
||||||
return true;
|
if ($Item->user->medical_center_id == $user->medical_center_id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($Item->user_id == $user->id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
Registered::class => [
|
Registered::class => [
|
||||||
SendEmailVerificationNotification::class,
|
SendEmailVerificationNotification::class,
|
||||||
],
|
],
|
||||||
|
\App\Events\CycleSaved::class => [
|
||||||
|
\App\Listeners\UpdateLabelsCycleNumber::class,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class LabelRepository implements LabelRepositoryInterface
|
|||||||
return Label::when($request->has('sterilizer_id') && $request->sterilizer_id != '', function ($query) use ($request) {
|
return Label::when($request->has('sterilizer_id') && $request->sterilizer_id != '', function ($query) use ($request) {
|
||||||
$query->where('sterilizer_id', $request->sterilizer_id);
|
$query->where('sterilizer_id', $request->sterilizer_id);
|
||||||
})
|
})
|
||||||
|
->when($request->has('package_name') && $request->package_name != '', function ($query) use ($request) {
|
||||||
|
$this->applyPackageNameFilter($query,$request);
|
||||||
|
})
|
||||||
->when($request->has('cycle_number') && $request->cycle_number != '', function ($query) use ($request) {
|
->when($request->has('cycle_number') && $request->cycle_number != '', function ($query) use ($request) {
|
||||||
$query->where('cycle_number', $request->cycle_number);
|
$query->where('cycle_number', $request->cycle_number);
|
||||||
})
|
})
|
||||||
@@ -49,6 +52,9 @@ class LabelRepository implements LabelRepositoryInterface
|
|||||||
return Label::when($request->has('sterilizer_id') && $request->sterilizer_id != '', function ($query) use ($request) {
|
return Label::when($request->has('sterilizer_id') && $request->sterilizer_id != '', function ($query) use ($request) {
|
||||||
$query->where('sterilizer_id', $request->sterilizer_id);
|
$query->where('sterilizer_id', $request->sterilizer_id);
|
||||||
})
|
})
|
||||||
|
->when($request->has('package_name') && $request->package_name != '', function ($query) use ($request) {
|
||||||
|
$this->applyPackageNameFilter($query,$request);
|
||||||
|
})
|
||||||
->when($request->has('cycle_number') && $request->cycle_number != '', function ($query) use ($request) {
|
->when($request->has('cycle_number') && $request->cycle_number != '', function ($query) use ($request) {
|
||||||
$query->where('cycle_number', $request->cycle_number);
|
$query->where('cycle_number', $request->cycle_number);
|
||||||
})
|
})
|
||||||
@@ -86,6 +92,9 @@ class LabelRepository implements LabelRepositoryInterface
|
|||||||
return Label::when($request->has('sterilizer_id') && $request->sterilizer_id != '', function ($query) use ($request) {
|
return Label::when($request->has('sterilizer_id') && $request->sterilizer_id != '', function ($query) use ($request) {
|
||||||
$query->where('sterilizer_id', $request->sterilizer_id);
|
$query->where('sterilizer_id', $request->sterilizer_id);
|
||||||
})
|
})
|
||||||
|
->when($request->has('package_name') && $request->package_name != '', function ($query) use ($request) {
|
||||||
|
$this->applyPackageNameFilter($query,$request);
|
||||||
|
})
|
||||||
->when($request->has('cycle_number') && $request->cycle_number != '', function ($query) use ($request) {
|
->when($request->has('cycle_number') && $request->cycle_number != '', function ($query) use ($request) {
|
||||||
$query->where('cycle_number', $request->cycle_number);
|
$query->where('cycle_number', $request->cycle_number);
|
||||||
})
|
})
|
||||||
@@ -114,4 +123,11 @@ class LabelRepository implements LabelRepositoryInterface
|
|||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function applyPackageNameFilter($q,$request)
|
||||||
|
{
|
||||||
|
return $q->whereHas('package', function ($query) use ($request) {
|
||||||
|
$query->where('packages.name', 'like', "%{$request->package_name}%");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,19 @@ class PackageRepository implements PackageRepositoryInterface
|
|||||||
{
|
{
|
||||||
public function indexForUser($request, $user)
|
public function indexForUser($request, $user)
|
||||||
{
|
{
|
||||||
return Package::when($request->has('name') && $request->name != '', function ($query) use ($request) {
|
return Package::with([
|
||||||
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
'user',
|
||||||
})
|
'user.medical_center' => function ($query) {
|
||||||
|
$query->select('id', 'name', 'address', 'phone_number');
|
||||||
|
},
|
||||||
|
'items'
|
||||||
|
])
|
||||||
|
->tap(function ($query) use ($request) {
|
||||||
|
$this->applyUserNameFilter($query, $request);
|
||||||
|
})
|
||||||
|
->when($request->has('name') && $request->name != '', function ($query) use ($request) {
|
||||||
|
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
||||||
|
})
|
||||||
->when($request->has('package_id') && $request->package_id != '', function ($query) use ($request) {
|
->when($request->has('package_id') && $request->package_id != '', function ($query) use ($request) {
|
||||||
$query->where('id', $request->package_id);
|
$query->where('id', $request->package_id);
|
||||||
})
|
})
|
||||||
@@ -21,25 +31,29 @@ class PackageRepository implements PackageRepositoryInterface
|
|||||||
$query->where('medical_center_id', $request->medical_center_id);
|
$query->where('medical_center_id', $request->medical_center_id);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
->with([
|
|
||||||
'user',
|
|
||||||
'user.medical_center' => function ($query) {
|
|
||||||
$query->select('id', 'name', 'address', 'phone_number');
|
|
||||||
},
|
|
||||||
])
|
|
||||||
->whereHas('user', function ($query) use ($user) {
|
->whereHas('user', function ($query) use ($user) {
|
||||||
$query->where('medical_center_id', $user->medical_center_id);
|
$query->where('users.medical_center_id', $user->medical_center_id);
|
||||||
})
|
})
|
||||||
->orWhere("status", StatusTypeEnum::APPROVED)
|
// ->where("status", StatusTypeEnum::APPROVED)
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function indexForSupervisor($request, $user)
|
public function indexForSupervisor($request, $user)
|
||||||
{
|
{
|
||||||
return Package::when($request->has('name') && $request->name != '', function ($query) use ($request) {
|
return Package::with([
|
||||||
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
'user',
|
||||||
})
|
'user.medical_center' => function ($query) {
|
||||||
|
$query->select('id', 'name', 'address', 'phone_number');
|
||||||
|
},
|
||||||
|
'items'
|
||||||
|
])
|
||||||
|
->tap(function ($query) use ($request) {
|
||||||
|
$this->applyUserNameFilter($query, $request);
|
||||||
|
})
|
||||||
|
->when($request->has('name') && $request->name != '', function ($query) use ($request) {
|
||||||
|
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
||||||
|
})
|
||||||
->when($request->has('package_id') && $request->package_id != '', function ($query) use ($request) {
|
->when($request->has('package_id') && $request->package_id != '', function ($query) use ($request) {
|
||||||
$query->where('id', $request->package_id);
|
$query->where('id', $request->package_id);
|
||||||
})
|
})
|
||||||
@@ -48,13 +62,8 @@ class PackageRepository implements PackageRepositoryInterface
|
|||||||
$query->where('medical_center_id', $request->medical_center_id);
|
$query->where('medical_center_id', $request->medical_center_id);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
->with([
|
->whereHas('user', function ($query) use ($user) {
|
||||||
'user',
|
$query->where('users.medical_center_id', $user->medical_center_id);
|
||||||
'user.medical_center' => function ($query) {
|
|
||||||
$query->select('id', 'name', 'address', 'phone_number');
|
|
||||||
},
|
|
||||||
])->whereHas('user', function ($query) use ($user) {
|
|
||||||
$query->where('medical_center_id', $user->medical_center_id);
|
|
||||||
})
|
})
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
@@ -62,9 +71,19 @@ class PackageRepository implements PackageRepositoryInterface
|
|||||||
|
|
||||||
public function indexForAdmin($request, $user)
|
public function indexForAdmin($request, $user)
|
||||||
{
|
{
|
||||||
return Package::when($request->has('name') && $request->name != '', function ($query) use ($request) {
|
return Package::with([
|
||||||
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
'user',
|
||||||
})
|
'user.medical_center' => function ($query) {
|
||||||
|
$query->select('id', 'name', 'address', 'phone_number');
|
||||||
|
},
|
||||||
|
'items'
|
||||||
|
])
|
||||||
|
->tap(function ($query) use ($request) {
|
||||||
|
$this->applyUserNameFilter($query, $request);
|
||||||
|
})
|
||||||
|
->when($request->has('name') && $request->name != '', function ($query) use ($request) {
|
||||||
|
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
||||||
|
})
|
||||||
->when($request->has('package_id') && $request->package_id != '', function ($query) use ($request) {
|
->when($request->has('package_id') && $request->package_id != '', function ($query) use ($request) {
|
||||||
$query->where('id', $request->package_id);
|
$query->where('id', $request->package_id);
|
||||||
})
|
})
|
||||||
@@ -73,13 +92,15 @@ class PackageRepository implements PackageRepositoryInterface
|
|||||||
$query->where('medical_center_id', $request->medical_center_id);
|
$query->where('medical_center_id', $request->medical_center_id);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
->with([
|
|
||||||
'user',
|
|
||||||
'user.medical_center' => function ($query) {
|
|
||||||
$query->select('id', 'name', 'address', 'phone_number');
|
|
||||||
},
|
|
||||||
])
|
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function applyUserNameFilter($queryBuilder,$request){
|
||||||
|
return $queryBuilder->when($request->filled('user_name'), function ($query) use ($request) {
|
||||||
|
$query->whereHas('user', function ($q) use ($request) {
|
||||||
|
$q->where('users.name', 'LIKE', '%' . $request->user_name . '%');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Rules;
|
||||||
|
|
||||||
|
use App\Models\Label;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
|
||||||
|
class ValidEnabledLabels implements ValidationRule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the validation rule.
|
||||||
|
*
|
||||||
|
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||||
|
*/
|
||||||
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||||
|
{
|
||||||
|
$formattedVal = pluckValues($value,'id');
|
||||||
|
$validIds = Label::whereIn('id', $formattedVal)
|
||||||
|
->where('enabled', true)
|
||||||
|
->pluck('id')
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if(count(array_diff($formattedVal, $validIds)) !== 0)
|
||||||
|
{
|
||||||
|
$fail('the :attribute must be enabled.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Scopes;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Scope;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class OrderByIdScope implements Scope
|
||||||
|
{
|
||||||
|
public function apply(Builder $builder, Model $model)
|
||||||
|
{
|
||||||
|
$builder->orderBy($model->getTable().'.id', 'desc');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\Batch;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class BatchTransmitter
|
||||||
|
{
|
||||||
|
|
||||||
|
protected Collection $collection;
|
||||||
|
protected mixed $config;
|
||||||
|
protected $message;
|
||||||
|
|
||||||
|
public function __construct( Collection $collection )
|
||||||
|
{
|
||||||
|
$this->collection = $collection;
|
||||||
|
$this->config = config( 'notification.drivers.rahyab_advertise' );
|
||||||
|
$this->client = new \SoapClient( $this->config[ 'url' ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send( string $message )
|
||||||
|
{
|
||||||
|
$this->message = $message;
|
||||||
|
if ( $this->collection->count() <= config( 'notification.max_phone_size.do_send_sms' ) ) {
|
||||||
|
return $result = $this->client->doSendSMS( $this->payload() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPhones()
|
||||||
|
{
|
||||||
|
$phones = [];
|
||||||
|
foreach ( $this->collection as $key => $item ) {
|
||||||
|
$phones[] = $item->getPhone();
|
||||||
|
}
|
||||||
|
return array_unique( $phones );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function payload()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'uUsername' => $this->config[ 'username' ] ,
|
||||||
|
'uPassword' => $this->config[ 'password' ] ,
|
||||||
|
'uNumber' => $this->config[ 'from' ] ,
|
||||||
|
'uCellphones' => implode( ';' , $this->getPhones() ) ,
|
||||||
|
'uMessage' => $this->message ,
|
||||||
|
'uFarsi' => true ,
|
||||||
|
'uTopic' => false ,
|
||||||
|
'uFlash' => false ,
|
||||||
|
'uUDH' => ''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\Batch;
|
||||||
|
|
||||||
|
use App\Models\SmsBatch;
|
||||||
|
use App\Services\Notification\Events\SmsSent;
|
||||||
|
use App\Services\Notification\Events\SmsSentAgain;
|
||||||
|
use App\Services\Notification\MessagePattern\Pattern;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use SoapClient;
|
||||||
|
|
||||||
|
class PeerToPeer
|
||||||
|
{
|
||||||
|
protected Collection $collection;
|
||||||
|
protected array $config;
|
||||||
|
protected Pattern $messagePatternClass;
|
||||||
|
protected string $messagePattern;
|
||||||
|
protected string $operator;
|
||||||
|
protected bool $isAdmin = false;
|
||||||
|
protected bool $isSystematic = false;
|
||||||
|
protected int $price = -80;
|
||||||
|
|
||||||
|
public function __construct(string $message, Collection $collection, string $category, $uniqueCode, $operator = 'advertise')
|
||||||
|
{
|
||||||
|
if ($this->isValidCost() || $operator == 'service') {
|
||||||
|
$this->operator = ($operator == 'advertise') ? 'rahyab_advertise' : 'rahyab_service';
|
||||||
|
$this->collection = $collection;
|
||||||
|
$this->messagePatternClass = new Pattern($message);
|
||||||
|
$this->messagePattern = $this->messagePatternClass->getPattern();
|
||||||
|
$this->config = array_merge($this->createExtra($category, $uniqueCode), config('notification.drivers.' . $this->operator));
|
||||||
|
|
||||||
|
if (isset($this->config['operator'])) {
|
||||||
|
if (str_contains($this->config['operator'], 'advertise')) {
|
||||||
|
$this->config['type'] = 'advertise';
|
||||||
|
} else {
|
||||||
|
$this->config['type'] = 'service';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->client = new SoapClient( $this->config[ 'url' ] );
|
||||||
|
} catch ( \SoapFault $e ) {
|
||||||
|
dd($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isValidCost(): bool
|
||||||
|
{
|
||||||
|
if ( $this->price > -50000.00) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSystematic($isSystematic = 0): static
|
||||||
|
{
|
||||||
|
$this->isSystematic = $isSystematic;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAdmin($isAdmin = 0): static
|
||||||
|
{
|
||||||
|
$this->isAdmin = $isAdmin;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send($userData): void
|
||||||
|
{
|
||||||
|
if ($this->collection->count() <= config('notification.max_phone_size.do_send_sms_array_c')) {
|
||||||
|
$this->setIsAdminAndIsSystematicInConfig();
|
||||||
|
$payload = $this->payload($userData);
|
||||||
|
$response = $this->client->doSendSMSArrayC($payload)->doSendSMSArrayCResult->DataSendOut;
|
||||||
|
$this->serializeToDatabase($payload['uDataSendIn'], $response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendAgain($userData, SmsBatch $smsBatch): void
|
||||||
|
{
|
||||||
|
if ($this->collection->count() <= config('notification.max_phone_size.do_send_sms_array_c')) {
|
||||||
|
$payload = $this->payload($userData);
|
||||||
|
$response = $this->client->doSendSMSArrayC($payload)->doSendSMSArrayCResult->DataSendOut;
|
||||||
|
$this->updateToDatabase($payload['uDataSendIn'], $response, $smsBatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function payload($userData): array
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
foreach ($this->collection as $key => $item) {
|
||||||
|
$data[$key] = $this->prepareData($item, $userData);
|
||||||
|
}
|
||||||
|
return array(
|
||||||
|
'uUsername' => $this->config['username'],
|
||||||
|
'uPassword' => $this->config['password'],
|
||||||
|
'uDataSendIn' => $data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareData(Model $model, $userData): array
|
||||||
|
{
|
||||||
|
$fillable = is_null($userData) ? $model : $userData;
|
||||||
|
return [
|
||||||
|
'ClientID' => rand(1, 1000000000000000),
|
||||||
|
'ShortCode' => $this->findFrom(),
|
||||||
|
'Cellphone' => $model->getPhone(),
|
||||||
|
'Message' => $this->messagePatternClass->fill($fillable),
|
||||||
|
'Farsi' => true,
|
||||||
|
'Flash' => false,
|
||||||
|
'UDH' => '',
|
||||||
|
'ServiceID' => ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function findFrom()
|
||||||
|
{
|
||||||
|
$smsOperatorConfig = collect(config('notification.config_system'));
|
||||||
|
|
||||||
|
if (is_null($smsOperatorConfig) or $smsOperatorConfig->isEmpty()) {
|
||||||
|
return $this->config['from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$customConfig = $smsOperatorConfig->getConfig($this->operator);
|
||||||
|
|
||||||
|
if (is_null($customConfig)) {
|
||||||
|
return $this->config['from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $customConfig['from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function serializeToDatabase($payload, $response): void
|
||||||
|
{
|
||||||
|
$this->collection->count() > 1 ?: $response = [$response];
|
||||||
|
event(new SmsSent($this->collection, json_decode(json_encode($response), true), $payload, $this->config));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function updateToDatabase($payload, $response, $smsBatch): void
|
||||||
|
{
|
||||||
|
$this->collection->count() > 1 ?: $response = [$response];
|
||||||
|
event(new SmsSentAgain($this->collection, json_decode(json_encode($response), true), $payload, $this->config, $smsBatch));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createExtra($category, $uniqueCode): array
|
||||||
|
{
|
||||||
|
$extra ['is_admin'] = $this->isAdmin;
|
||||||
|
$extra ['is_systematic'] = $this->isSystematic;
|
||||||
|
$extra ['category'] = $category;
|
||||||
|
$extra ['operator'] = 'rahyab_advertise';
|
||||||
|
$extra ['code'] = $uniqueCode;
|
||||||
|
$extra ['messagePattern'] = $this->messagePattern;
|
||||||
|
$extra['className'] = $this->collection->isEmpty() ? null : getNamespaceMap($this->collection->first());
|
||||||
|
return $extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setIsAdminAndIsSystematicInConfig(): void
|
||||||
|
{
|
||||||
|
$this->config['is_admin'] = $this->isAdmin;
|
||||||
|
$this->config['is_systematic'] = $this->isSystematic;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\Batch;
|
||||||
|
|
||||||
|
use App\Models\SmsBatch;
|
||||||
|
use App\Services\Notification\Events\SmsSent;
|
||||||
|
use App\Services\Notification\Events\SmsSentAgain;
|
||||||
|
use App\Services\Notification\MessagePattern\Pattern;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class SimCard
|
||||||
|
{
|
||||||
|
|
||||||
|
protected Collection $collection;
|
||||||
|
protected array $config;
|
||||||
|
protected Pattern $messagePatternClass;
|
||||||
|
protected string $messagePattern;
|
||||||
|
protected array $payload;
|
||||||
|
protected bool $isAdmin = false;
|
||||||
|
protected bool $isSystematic = false;
|
||||||
|
|
||||||
|
public function __construct( $message , Collection $collection , string $category , $uniqueCode )
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->collection = $collection;
|
||||||
|
$this->messagePatternClass = new Pattern( $message );
|
||||||
|
$this->messagePattern = $this->messagePatternClass->getPattern();
|
||||||
|
$this->config = array_merge( $this->createExtra( $category , $uniqueCode ) , config( 'notification.drivers.simcard' ) );
|
||||||
|
|
||||||
|
if ( isset( $this->config[ 'operator' ] ) ) {
|
||||||
|
$this->config[ 'type' ] = 'simcard';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->client = new \SoapClient( $this->config[ 'url' ] , array( 'trace' => 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSystematic( $isSystematic = 0 ): static
|
||||||
|
{
|
||||||
|
$this->isSystematic = $isSystematic;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAdmin( $isAdmin = 0 ): static
|
||||||
|
{
|
||||||
|
$this->isAdmin = $isAdmin;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send( $userData ): void
|
||||||
|
{
|
||||||
|
if ( $this->collection->count() <= config( 'notification.max_phone_size.do_send_sms_array_c' ) ) {
|
||||||
|
$this->setIsAdminAndIsSystematicInConfig();
|
||||||
|
$payload = $this->payload( $userData );
|
||||||
|
$response = $this->client->SendSMS( $payload[ 'from' ] , $payload[ 'numbers' ] , $payload[ 'messages' ] , $payload[ 'username' ] , $payload[ 'password' ] , $payload[ 'time' ] , $payload[ 'op' ] );
|
||||||
|
$response = json_decode( $response );
|
||||||
|
$this->serializeToDatabase( json_decode( $response[ count( $response ) - 1 ] )[ 1 ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendAgain( $userData , SmsBatch $smsBatch ): void
|
||||||
|
{
|
||||||
|
if ( $this->collection->count() <= config( 'notification.max_phone_size.do_send_sms_array_c' ) ) {
|
||||||
|
$payload = $this->payload( $userData );
|
||||||
|
$response = $this->client->SendSMS( $payload[ 'from' ] , $payload[ 'numbers' ] , $payload[ 'messages' ] , $payload[ 'username' ] , $payload[ 'password' ] , $payload[ 'time' ] , $payload[ 'op' ] );
|
||||||
|
$response = json_decode( $response );
|
||||||
|
$this->updateToDatabase( $response , $smsBatch );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function payload( $userData ): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'username' => $this->config[ 'username' ] ,
|
||||||
|
'password' => $this->config[ 'password' ] ,
|
||||||
|
'from' => $this->config[ 'from' ] ,
|
||||||
|
'op' => "pointtopoint" ,
|
||||||
|
'time' => '' ,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ( $this->collection as $key => $item ) {
|
||||||
|
$modelData = $this->prepareData( $item , $userData );
|
||||||
|
$this->payload[] = $modelData;
|
||||||
|
$data[ 'numbers' ][] = $modelData[ 'Cellphone' ];
|
||||||
|
$data[ 'messages' ][] = $modelData[ 'Message' ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareData( Model $model , $userData ): array
|
||||||
|
{
|
||||||
|
$fillable = is_null( $userData ) ? $model : $userData;
|
||||||
|
return [
|
||||||
|
'Cellphone' => $model->getPhone() ,
|
||||||
|
'Message' => $this->messagePatternClass->fill( $fillable ) ,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function serializeToDatabase( $response ): void
|
||||||
|
{
|
||||||
|
$response = $this->prepareResponse( $response );
|
||||||
|
event( new SmsSent( $this->collection , json_decode( json_encode( $response ) , true ) , $this->payload , $this->config ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function updateToDatabase( $response , $smsBatch ): void
|
||||||
|
{
|
||||||
|
$response = $this->prepareResponse( $response );
|
||||||
|
event( new SmsSentAgain( $this->collection , json_decode( json_encode( $response ) , true ) , $this->payload , $this->config , $smsBatch ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareResponse( $response ): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ( $response as $value ) {
|
||||||
|
$result[] = [
|
||||||
|
'ClientID' => null ,
|
||||||
|
'ServerID' => is_numeric( $value ) ? $value : -1 ,
|
||||||
|
'Status' => is_numeric( $value ) ? 'Send OK.' : $value ,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createExtra( $category , $uniqueCode ): array
|
||||||
|
{
|
||||||
|
$extra [ 'is_admin' ] = $this->isAdmin;
|
||||||
|
$extra [ 'is_systematic' ] = $this->isSystematic;
|
||||||
|
$extra [ 'category' ] = $category;
|
||||||
|
$extra [ 'operator' ] = 'simcard';
|
||||||
|
$extra [ 'code' ] = $uniqueCode;
|
||||||
|
$extra [ 'messagePattern' ] = $this->messagePattern;
|
||||||
|
$extra [ 'className' ] = $this->collection->isEmpty() ? null : getNamespaceMap( $this->collection->first() );
|
||||||
|
return $extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setIsAdminAndIsSystematicInConfig(): void
|
||||||
|
{
|
||||||
|
$this->config[ 'is_admin' ] = $this->isAdmin;
|
||||||
|
$this->config[ 'is_systematic' ] = $this->isSystematic;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\Events;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SmsSent
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public Collection $collection;
|
||||||
|
public array $response;
|
||||||
|
public array $payload;
|
||||||
|
public array $extra;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Collection $collection
|
||||||
|
* @param array $response
|
||||||
|
* @param array $payload
|
||||||
|
* @param array $extra
|
||||||
|
*/
|
||||||
|
public function __construct( Collection $collection , array $response , array $payload , array $extra )
|
||||||
|
{
|
||||||
|
$this->collection = $collection;
|
||||||
|
$this->response = $response;
|
||||||
|
$this->payload = $payload;
|
||||||
|
$this->extra = $extra;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\Events;
|
||||||
|
|
||||||
|
use App\Models\SmsBatch;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SmsSentAgain
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public Collection $collection;
|
||||||
|
public array $response;
|
||||||
|
public array $payload;
|
||||||
|
public array $extra;
|
||||||
|
public SmsBatch $smsBatch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Collection $collection
|
||||||
|
* @param array $response
|
||||||
|
* @param array $payload
|
||||||
|
* @param array $extra
|
||||||
|
* @param SmsBatch $smsBatch
|
||||||
|
*/
|
||||||
|
public function __construct( Collection $collection , array $response , array $payload , array $extra , SmsBatch $smsBatch )
|
||||||
|
{
|
||||||
|
$this->collection = $collection;
|
||||||
|
$this->response = $response;
|
||||||
|
$this->payload = $payload;
|
||||||
|
$this->extra = $extra;
|
||||||
|
$this->smsBatch = $smsBatch;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\Listeners;
|
||||||
|
|
||||||
|
use App\Models\Sms;
|
||||||
|
use App\Models\SmsBatch;
|
||||||
|
use App\Services\Notification\Events\SmsSent;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class StoreSmsInDatabase
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{}
|
||||||
|
|
||||||
|
public function handle( SmsSent $event ): void
|
||||||
|
{
|
||||||
|
$chars_in_every_sms_part = config( "sms.sms_length_calculator.chars_in_every_sms_part" ) > 0 ? : 60;
|
||||||
|
$smsList = [];
|
||||||
|
|
||||||
|
foreach ( $event->collection as $key => $value ) {
|
||||||
|
$smsList[ $key ] = new Sms( [
|
||||||
|
'client_id' => $event->response[ $key ][ 'ClientID' ] ,
|
||||||
|
'status' => $event->response[ $key ][ 'Status' ] ,
|
||||||
|
'message' => $event->payload[ $key ][ 'Message' ] ,
|
||||||
|
'rel_id' => $value->id ,
|
||||||
|
'segment_count' => ceil( strlen( $event->extra[ 'messagePattern' ] ) / $chars_in_every_sms_part ) ,
|
||||||
|
'cell_number' => $event->payload[ $key ][ 'Cellphone' ] ,
|
||||||
|
'rel_type' => $event->extra[ 'className' ] ,
|
||||||
|
'fee' => $event->extra[ 'fee' ] ,
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::alert( 'store SmsBatch' , [ 'hasSms' => SmsBatch::where( 'code' , $event->extra[ 'code' ] )->first() ] );
|
||||||
|
|
||||||
|
$smsBatch = SmsBatch::firstOrCreate(
|
||||||
|
[
|
||||||
|
'code' => $event->extra[ 'code' ]
|
||||||
|
] ,
|
||||||
|
[
|
||||||
|
'category' => $event->extra[ 'category' ] ,
|
||||||
|
'operator' => $event->extra[ 'operator' ] ,
|
||||||
|
'type' => $event->extra[ 'type' ] ,
|
||||||
|
'pattern' => $event->extra[ 'messagePattern' ] ,
|
||||||
|
'is_admin' => $event->extra[ 'is_admin' ] ,
|
||||||
|
'is_systematic' => $event->extra[ 'is_systematic' ] ,
|
||||||
|
'from' => $event->extra[ 'from' ] ,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$smsBatch->smsList()->saveMany( $smsList );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification\MessagePattern;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Pattern
|
||||||
|
{
|
||||||
|
|
||||||
|
protected string $pattern;
|
||||||
|
|
||||||
|
public function __construct( $pattern )
|
||||||
|
{
|
||||||
|
$this->pattern = $pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fill( $model ): string
|
||||||
|
{
|
||||||
|
$replacements = $this->findReplacements( $model );
|
||||||
|
return strtr( $this->pattern , $replacements );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function findReplacements( $model , $prefix = '{' , $postfix = '}' ): array
|
||||||
|
{
|
||||||
|
$replacements = [];
|
||||||
|
foreach ( $model->messageFields as $field ) {
|
||||||
|
list( $nickName , $value ) = $this->getFieldValue( $model , $field );
|
||||||
|
$replacements[ $prefix . $nickName . $postfix ] = $value;
|
||||||
|
}
|
||||||
|
if ( config( 'notification.fields' ) ) {
|
||||||
|
foreach ( config( 'notification.fields' ) as $name => $field ) {
|
||||||
|
$replacements[ $prefix . $name . $postfix ] = $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $replacements;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFieldValue( Model $model , string $messageField ): array
|
||||||
|
{
|
||||||
|
$parts = explode( ' as ' , $messageField );
|
||||||
|
if ( count( $parts ) == 2 and $this->isRelation( $parts[ 0 ] ) ) {
|
||||||
|
list( $relation , $field ) = $this->splitRelationField( $parts[ 0 ] );
|
||||||
|
$model->loadMissing( $relation );
|
||||||
|
$key = $parts[ 1 ];
|
||||||
|
$value = $model->$relation ? $model->$relation->$field : '';
|
||||||
|
} else {
|
||||||
|
$key = $messageField;
|
||||||
|
$value = $model->$messageField;
|
||||||
|
}
|
||||||
|
return [ $key , $value ];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isRelation( $field ): bool
|
||||||
|
{
|
||||||
|
return str_contains( $field , ':' );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function splitRelationField( $field ): array
|
||||||
|
{
|
||||||
|
$parts = explode( ':' , $field );
|
||||||
|
$partsCount = count( $parts );
|
||||||
|
return [ implode( '.' , array_slice( $parts , 0 , $partsCount - 1 ) ) , $parts[ $partsCount - 1 ] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPattern(): string
|
||||||
|
{
|
||||||
|
return $this->pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class SendSmsToAdmins
|
||||||
|
{
|
||||||
|
protected array $mobiles;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->mobiles = [
|
||||||
|
"09101526570",
|
||||||
|
"09128529050"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendRequestNotification($device_title, $smsUser)
|
||||||
|
{
|
||||||
|
$adminCollection = User::query()
|
||||||
|
->orWhere('role', 'admin');
|
||||||
|
|
||||||
|
$adminText = "کاربر %s
|
||||||
|
با شماره ی همراه %s
|
||||||
|
درخواستی زیر را ثبت کرد\n
|
||||||
|
%s\n";
|
||||||
|
$adminText = sprintf($adminText, $smsUser->full_name, $smsUser->cell_number, $device_title);
|
||||||
|
SmsNotification::to($adminCollection)->isSystematic()->send(
|
||||||
|
$adminText,
|
||||||
|
'service'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$userText = "%s عزیز\n
|
||||||
|
درخواست شما را دریافت کردیم\n
|
||||||
|
به زودی همکاران ما با شما تماس خواهند گرفت\n
|
||||||
|
از اعتماد شما سپاسگزاریم\n";
|
||||||
|
$userText = sprintf($userText, $smsUser->full_name);
|
||||||
|
$userCollection = User::query()->where('id', $smsUser->id);
|
||||||
|
$res = SmsNotification::to($userCollection)->isSystematic()->send(
|
||||||
|
$userText,
|
||||||
|
'service'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Notification;
|
||||||
|
|
||||||
|
use App\Models\SmsBatch;
|
||||||
|
use App\Services\Notification\Batch\PeerToPeer;
|
||||||
|
use App\Services\Notification\Batch\SimCard;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class SmsNotification
|
||||||
|
{
|
||||||
|
protected $builder;
|
||||||
|
protected string $category;
|
||||||
|
protected $userData;
|
||||||
|
protected bool $isSystematic = false;
|
||||||
|
protected bool $isAdmin = false;
|
||||||
|
|
||||||
|
protected static $self = null;
|
||||||
|
|
||||||
|
private function __construct($builder, $userData)
|
||||||
|
{
|
||||||
|
$this->builder = $builder;
|
||||||
|
$this->userData = $userData;
|
||||||
|
$this->category = $this->builder->limit(2)->count() > 1 ? 'batch' : 'single';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBuilder($builder): static
|
||||||
|
{
|
||||||
|
$this->builder = $builder;
|
||||||
|
$this->category = $this->builder->limit(2)->count() > 1 ? 'batch' : 'single';
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserData($userData): static
|
||||||
|
{
|
||||||
|
$this->userData = $userData;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function to($builder, $userData = null)
|
||||||
|
{
|
||||||
|
if (static::$self === null) {
|
||||||
|
static::$self = new static($builder, $userData);
|
||||||
|
}
|
||||||
|
return static::$self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSystematic(): static
|
||||||
|
{
|
||||||
|
$this->isSystematic = true;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAdmin(): static
|
||||||
|
{
|
||||||
|
$this->isAdmin = true;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendAgain(SmsBatch $smsBatch): void
|
||||||
|
{
|
||||||
|
$uniqueCode = Str::random(40);
|
||||||
|
foreach ($this->chuncks() as $notification) {
|
||||||
|
switch ($smsBatch->type) {
|
||||||
|
case 'advertise':
|
||||||
|
(new PeerToPeer($smsBatch->pattern, $notification, $this->category, $uniqueCode))->isAdmin($this->isAdmin)->isSystematic($this->isSystematic)->sendAgain($this->userData,
|
||||||
|
$smsBatch);
|
||||||
|
break;
|
||||||
|
case 'simcard' :
|
||||||
|
(new SimCard($smsBatch->pattern, $notification, $this->category, $uniqueCode))->isAdmin($this->isAdmin)->isSystematic($this->isSystematic)->sendAgain($this->userData, $smsBatch);
|
||||||
|
break;
|
||||||
|
case 'service':
|
||||||
|
(new PeerToPeer($smsBatch->pattern, $notification, $this->category, $uniqueCode, 'service'))->isAdmin($this->isAdmin)->isSystematic($this->isSystematic)->sendAgain($this->userData,
|
||||||
|
$smsBatch);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send($message, $method = 'advertise'): void
|
||||||
|
{
|
||||||
|
$uniqueCode = Str::random(40);
|
||||||
|
foreach ($this->chuncks() as $notification) {
|
||||||
|
switch ($method) {
|
||||||
|
case 'advertise':
|
||||||
|
(new PeerToPeer($message, $notification, $this->category, $uniqueCode))->isAdmin($this->isAdmin)->isSystematic($this->isSystematic)->send($this->userData);
|
||||||
|
break;
|
||||||
|
case 'simcard' :
|
||||||
|
(new SimCard($message, $notification, $this->category, $uniqueCode))->isAdmin($this->isAdmin)->isSystematic($this->isSystematic)->send($this->userData);
|
||||||
|
break;
|
||||||
|
case 'service':
|
||||||
|
(new PeerToPeer($message, $notification, $this->category, $uniqueCode, 'service'))->isAdmin($this->isAdmin)->isSystematic($this->isSystematic)->send($this->userData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendWithTemplate($template): void
|
||||||
|
{
|
||||||
|
if ( ! is_null($template)) {
|
||||||
|
$this->send($template->template, $template->operator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function chuncks(): \Generator
|
||||||
|
{
|
||||||
|
$limit = config('notification.max_phone_size.do_send_sms_array_c');
|
||||||
|
$iteration = 0;
|
||||||
|
while (true) {
|
||||||
|
$offset = $iteration * $limit;
|
||||||
|
$chunk = $this->builder->offset($offset)->limit($limit)->get();
|
||||||
|
if ($chunk->isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$iteration++;
|
||||||
|
yield $chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-1
@@ -50,7 +50,10 @@
|
|||||||
"Packages\\": "packages/",
|
"Packages\\": "packages/",
|
||||||
"Database\\Factories\\": "database/factories/",
|
"Database\\Factories\\": "database/factories/",
|
||||||
"Database\\Seeders\\": "database/seeders/"
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"app/Helpers/helpers.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Sms;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'db_name' => 'willaengine',
|
||||||
|
|
||||||
|
'morph_models' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines which of drivers should be used.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'default' => 'advertise',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Notification Configs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These are the list of configs to use for sending sms.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'drivers' => [
|
||||||
|
'advertise' => [
|
||||||
|
'url' => 'http://188.0.240.110/class/sms/wsdlservice/server.php?wsdl',
|
||||||
|
'username' => env('SMS_USERNAME'),
|
||||||
|
'password' => env('SMS_PASSWORD'),
|
||||||
|
'from' => env('SMS_NUMBER_ADVERTISE'),
|
||||||
|
],
|
||||||
|
'service' => [
|
||||||
|
'url' => 'http://188.0.240.110/class/sms/wsdlservice/server.php?wsdl',
|
||||||
|
'username' => env('SMS_USERNAME'),
|
||||||
|
'password' => env('SMS_PASSWORD'),
|
||||||
|
'from' => env('SMS_NUMBER_SERVICE'),
|
||||||
|
],
|
||||||
|
'simcard' => [
|
||||||
|
'url' => 'http://188.0.240.110/class/sms/wsdlservice/server.php?wsdl',
|
||||||
|
'username' => env('SMS_USERNAME'),
|
||||||
|
'password' => env('SMS_PASSWORD'),
|
||||||
|
'from' => env('SMS_NUMBER_SIM_CARD'),
|
||||||
|
'fee' => 150
|
||||||
|
],
|
||||||
|
'pattern' => [
|
||||||
|
'url' => 'http://188.0.240.110/class/sms/wsdlservice/server.php?wsdl',
|
||||||
|
'username' => env('SMS_USERNAME'),
|
||||||
|
'password' => env('SMS_PASSWORD'),
|
||||||
|
'from' => env('SMS_NUMBER_SERVICE'),
|
||||||
|
],
|
||||||
|
'rahyab_advertise' => [
|
||||||
|
'url' => 'https://sms.igama.ir/webservice/sms.asmx?wsdl',
|
||||||
|
'username' => env('RAHYAB_SMS_USERNAME'),
|
||||||
|
'password' => env('RAHYAB_SMS_PASSWORD'),
|
||||||
|
'from' => env('RAHYAB_SMS_NUMBER_ADVERTISE'),
|
||||||
|
'fee' => 100
|
||||||
|
],
|
||||||
|
'rahyab_service' => [
|
||||||
|
'url' => 'https://sms.igama.ir/webservice/sms.asmx?wsdl',
|
||||||
|
'username' => env('RAHYAB_SMS_USERNAME'),
|
||||||
|
'password' => env('RAHYAB_SMS_PASSWORD'),
|
||||||
|
'from' => env('RAHYAB_SMS_NUMBER_SERVICE'),
|
||||||
|
'fee' => 80
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Class Maps
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is the array of Classes that maps to Drivers above.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'map' => [
|
||||||
|
'advertise' => Sms::class,
|
||||||
|
'service' => Sms::class,
|
||||||
|
'simcard' => Sms::class,
|
||||||
|
'pattern' => SmsPattern::class,
|
||||||
|
'rahyab_advertise' => HelloWorld::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Fields Pattern
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is the array of fields that used in sms patterns.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'fields' => [
|
||||||
|
'time' => now('Asia/Tehran')->format('H:i:s'),
|
||||||
|
'date' => now('Asia/Tehran')->format('Y/m/d')
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| MAXIMUM NUMBER OF PHONE NUMBERS IN ONE BATCH
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| CAUTION!! DONT TOUCH THESE NUMBERS
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'max_phone_size' => [
|
||||||
|
'do_send_sms' => 83,
|
||||||
|
'do_send_sms_array_c' => 100,
|
||||||
|
],
|
||||||
|
'max_update_devlivery_status_bulk_items' => 100,
|
||||||
|
'sms_length_calculator' => [
|
||||||
|
'encoding' => '8', //bit
|
||||||
|
'chars_in_every_sms_part' => 63
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
'config_system' => [],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -27,7 +27,7 @@ class ItemFactory extends Factory
|
|||||||
'udi' => $this->faker->uuid,
|
'udi' => $this->faker->uuid,
|
||||||
'repair' => $this->faker->boolean,
|
'repair' => $this->faker->boolean,
|
||||||
'creator_id' => \App\Models\User::factory(),
|
'creator_id' => \App\Models\User::factory(),
|
||||||
'status' => $this->faker->randomElement(['approved', 'rejected', 'suspended']),
|
'status' => $this->faker->randomElement(['approved', 'rejected', 'pending']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class PackageFactory extends Factory
|
|||||||
'bar_code' => $this->faker->optional()->word,
|
'bar_code' => $this->faker->optional()->word,
|
||||||
'qr_code' => $this->faker->optional()->word,
|
'qr_code' => $this->faker->optional()->word,
|
||||||
'creator_id' => User::factory(), // ایجاد کاربر دیگر به عنوان creator
|
'creator_id' => User::factory(), // ایجاد کاربر دیگر به عنوان creator
|
||||||
'status' => $this->faker->randomElement(['approved', 'rejected', 'suspended']),
|
'status' => $this->faker->randomElement(['approved', 'rejected', 'pending']),
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class CreateTransfersTable extends Migration
|
|||||||
$table->foreign('user_id')->references('id')->on('users');
|
$table->foreign('user_id')->references('id')->on('users');
|
||||||
$table->dateTime('from_date')->nullable();
|
$table->dateTime('from_date')->nullable();
|
||||||
$table->dateTime('to_date')->nullable();
|
$table->dateTime('to_date')->nullable();
|
||||||
$table->enum( 'status' , [ StatusTypeEnum::APPROVED , StatusTypeEnum::REJECTED , StatusTypeEnum::SUSPENDED ] )->default( StatusTypeEnum::SUSPENDED );
|
$table->enum( 'status' , [ StatusTypeEnum::APPROVED , StatusTypeEnum::REJECTED , StatusTypeEnum::PENDING ] )->default( StatusTypeEnum::PENDING );
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class UpdateItemsTable4 extends Migration
|
|||||||
{
|
{
|
||||||
Schema::drop('item_package');
|
Schema::drop('item_package');
|
||||||
Schema::table('items', function (Blueprint $table) {
|
Schema::table('items', function (Blueprint $table) {
|
||||||
$table->unsignedBigInteger('package_id')->nullable()->after("id");
|
$table->unsignedBigInteger('package_id')->nullable()->after("id")->nullOnDelete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class AddStatusToItemsTable extends Migration
|
|||||||
$table->dropColumn( 'status' );
|
$table->dropColumn( 'status' );
|
||||||
} );
|
} );
|
||||||
Schema::table( 'items' , function ( Blueprint $table ) {
|
Schema::table( 'items' , function ( Blueprint $table ) {
|
||||||
$table->enum( 'status' , [ StatusTypeEnum::APPROVED , StatusTypeEnum::REJECTED , StatusTypeEnum::SUSPENDED ] )->default( StatusTypeEnum::SUSPENDED );
|
$table->enum( 'status' , [ StatusTypeEnum::APPROVED , StatusTypeEnum::REJECTED , StatusTypeEnum::PENDING ] )->default( StatusTypeEnum::PENDING );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class AddStatusToPackagesTable extends Migration
|
|||||||
$table->dropColumn( 'verified' );
|
$table->dropColumn( 'verified' );
|
||||||
} );
|
} );
|
||||||
Schema::table( 'packages' , function ( Blueprint $table ) {
|
Schema::table( 'packages' , function ( Blueprint $table ) {
|
||||||
$table->enum( 'status' , [ StatusTypeEnum::APPROVED , StatusTypeEnum::REJECTED , StatusTypeEnum::SUSPENDED ] )->default( StatusTypeEnum::SUSPENDED );
|
$table->enum( 'status' , [ StatusTypeEnum::APPROVED , StatusTypeEnum::REJECTED , StatusTypeEnum::PENDING ] )->default( StatusTypeEnum::PENDING );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('labels', function (Blueprint $table) {
|
||||||
|
$table->boolean('enable')->default(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('labels', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('enable');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('enable', 'enabled');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('labels', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('enabled', 'enable');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('sms', function (Blueprint $table) {
|
||||||
|
$table->increments( 'id' );
|
||||||
|
$table->unsignedBigInteger( 'client_id' )->nullable();
|
||||||
|
$table->string( 'status' );
|
||||||
|
$table->string( 'message' , 100 );
|
||||||
|
$table->unsignedInteger( 'rel_id' );
|
||||||
|
$table->string( 'rel_type' , 50 );
|
||||||
|
$table->string( 'cell_number' , 20 );
|
||||||
|
$table->unsignedInteger( 'fee' )->default( 0 );
|
||||||
|
$table->unsignedInteger( 'sms_batch_id' );
|
||||||
|
$table->index( 'sms_batch_id' );
|
||||||
|
$table->integer( 'segment_count' )->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sms');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('sms_batch', function (Blueprint $table) {
|
||||||
|
$table->increments( 'id' );
|
||||||
|
$table->string( 'category' );
|
||||||
|
$table->string( 'operator' , 100 );
|
||||||
|
$table->enum( 'type' , [ 'service' , 'simcard' , 'advertise' ] );
|
||||||
|
$table->string( 'code' , 40 );
|
||||||
|
$table->string( 'pattern' )->nullable();
|
||||||
|
$table->boolean( 'is_admin' )->default( 0 );
|
||||||
|
$table->boolean( 'is_systematic' )->default( 0 );
|
||||||
|
$table->string( 'from' )->nullable();
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sms_batch');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
class TempSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Seed the application's database.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$roles = [
|
||||||
|
['name' => 'Admin','guard_name'=>'api'],
|
||||||
|
['name' => 'Supervisor','guard_name'=>'api'],
|
||||||
|
['name' => 'User','guard_name'=>'api']
|
||||||
|
];
|
||||||
|
Role::insert($roles);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => 'user',
|
||||||
|
'email' => 'user@user',
|
||||||
|
'country_code' => '0098',
|
||||||
|
'cell_number' => '09392349878',
|
||||||
|
'gender' => 'Male',
|
||||||
|
'verified' => 'Verified',
|
||||||
|
'status' => 'Active',
|
||||||
|
'medical_center_id' => 1, // ایجاد مرکز پزشکی به طور خودکار
|
||||||
|
'password' => bcrypt('password'), // رمز عبور پیشفرض
|
||||||
|
'address' => 'yyop.st 45 5.No',
|
||||||
|
'remember_token' => '1234567891',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
$admin = User::create([
|
||||||
|
'name' => 'admin',
|
||||||
|
'email' => 'admin@admin',
|
||||||
|
'country_code' => '0098',
|
||||||
|
'cell_number' => '09121231234',
|
||||||
|
'gender' => 'Male',
|
||||||
|
'verified' => 'Verified',
|
||||||
|
'status' => 'Active',
|
||||||
|
'medical_center_id' => 1, // ایجاد مرکز پزشکی به طور خودکار
|
||||||
|
'password' => bcrypt('password'), // رمز عبور پیشفرض
|
||||||
|
'address' => 'rgdforp.st 49 8.No',
|
||||||
|
'remember_token' => '5432123459',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
$supervisor=User::create([
|
||||||
|
'name' => 'supervisor',
|
||||||
|
'email' => 'supervisor@supervisor',
|
||||||
|
'country_code' => '0098',
|
||||||
|
'cell_number' => '09101231232',
|
||||||
|
'gender' => 'Male',
|
||||||
|
'verified' => 'Verified',
|
||||||
|
'status' => 'Active',
|
||||||
|
'medical_center_id' => 1, // ایجاد مرکز پزشکی به طور خودکار
|
||||||
|
'password' => bcrypt('password'), // رمز عبور پیشفرض
|
||||||
|
'address' => 'yyhdfghop.st 43 6.No',
|
||||||
|
'remember_token' => '1234543212',
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->assignRole('User');
|
||||||
|
$admin->assignRole('Admin');
|
||||||
|
$supervisor->assignRole('Supervisor');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
index index.php index.html;
|
||||||
|
server_name localhost;
|
||||||
|
root /var/www/html/public;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass app:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.dev
|
||||||
|
image: cssd_app
|
||||||
|
container_name: cssd_app
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- cssd-network
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
ports:
|
||||||
|
- "8089:80"
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
- ./developement/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
- mysql
|
||||||
|
networks:
|
||||||
|
- cssd-network
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: 'docker-proxy.meshkee.com/mysql/mysql-server:8.0'
|
||||||
|
container_name: cssd_mysql
|
||||||
|
ports:
|
||||||
|
- "3312:3306"
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_HOST: '%'
|
||||||
|
MYSQL_DATABASE: "${DB_DATABASE:-cssd}"
|
||||||
|
MYSQL_PORT: "${DB_PORT:-3306}"
|
||||||
|
MYSQL_USERNAME: "${DB_USERNAME:-root}"
|
||||||
|
MYSQL_PASSWORD: "${DB_PASSWORD:-secret}"
|
||||||
|
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD:-secret}"
|
||||||
|
volumes:
|
||||||
|
- db_volume:/var/lib/mysql
|
||||||
|
networks:
|
||||||
|
- cssd-network
|
||||||
|
redis:
|
||||||
|
image: 'docker-proxy.meshkee.com/redis:alpine'
|
||||||
|
container_name: cssd_redis
|
||||||
|
ports:
|
||||||
|
- "6385:6379"
|
||||||
|
networks:
|
||||||
|
- cssd-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_volume:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
cssd-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
|
||||||
Generated
-17224
File diff suppressed because it is too large
Load Diff
@@ -4,10 +4,12 @@ namespace Packages\Auth;
|
|||||||
|
|
||||||
use App\Http\Controllers\Api\Auth\LoginController;
|
use App\Http\Controllers\Api\Auth\LoginController;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Services\Notification\SmsNotification;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Packages\Messaging\src\Facades\MessageResponse;
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
use Packages\SMSSender\SMSSender;
|
// use Packages\SMSSender\SMSSender;
|
||||||
|
|
||||||
trait SendsPasswordResetEmails
|
trait SendsPasswordResetEmails
|
||||||
{
|
{
|
||||||
@@ -37,17 +39,15 @@ trait SendsPasswordResetEmails
|
|||||||
*/
|
*/
|
||||||
public function checkDisposablePassword(Request $request)
|
public function checkDisposablePassword(Request $request)
|
||||||
{
|
{
|
||||||
if ( \Cache::has($request->code) ) {
|
$userid = \Cache::pull($request->code);
|
||||||
$userid = \Cache::pull($request->code);
|
if ( !is_null($userid) ) {
|
||||||
$user = User::where('id', $userid)->first();
|
$user = User::findOrFail($userid);
|
||||||
if($user) {
|
if($user) {
|
||||||
|
$user->password = \Hash::make($request->code);
|
||||||
|
$user->save();
|
||||||
|
|
||||||
$password = rand(10000000, 999999999);
|
$request->merge([ 'cell_number' => $user->cell_number, 'password' => $request->code ]);
|
||||||
$user->password = \Hash::make($password);
|
return (new LoginController())->login($request);
|
||||||
$user->save();
|
|
||||||
|
|
||||||
$request->merge([ 'cell_number' => $user->cell_number, 'password' => $password ]);
|
|
||||||
return (new LoginController())->login($request);
|
|
||||||
}
|
}
|
||||||
return MessageResponse::error('User Not Found');
|
return MessageResponse::error('User Not Found');
|
||||||
}
|
}
|
||||||
@@ -57,11 +57,18 @@ trait SendsPasswordResetEmails
|
|||||||
|
|
||||||
protected function generateAndSendCode($request)
|
protected function generateAndSendCode($request)
|
||||||
{
|
{
|
||||||
$user = User::where('cell_number', $request->cell_number)->where('status', 'Active')->first();
|
$userModel = User::where('cell_number', $request->cell_number)->where('status', 'Active');
|
||||||
|
$user = $userModel->first();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$code = rand(100000, 999999);
|
$code = rand(100000, 999999);
|
||||||
\Cache::put($code, $user->id, Carbon::now()->addMinutes(30));
|
\Cache::put($code, $user->id, Carbon::now()->addMinutes(30));
|
||||||
SMSSender::instance()->patternSend($request->cell_number, 'jqomyn42wo', ["verification-code" => $code]);
|
SmsNotification::to( $userModel )->isSystematic()->send(
|
||||||
|
trans( 'sms.reset_password' , [
|
||||||
|
'activation_code' => $code
|
||||||
|
] ) ,
|
||||||
|
'service'
|
||||||
|
);
|
||||||
|
// SMSSender::instance()->patternSend($request->cell_number, 'jqomyn42wo', ["verification-code" => $code]);
|
||||||
return MessageResponse::success('Send Disposable Password');
|
return MessageResponse::success('Send Disposable Password');
|
||||||
}
|
}
|
||||||
return MessageResponse::error('User Not Found');
|
return MessageResponse::error('User Not Found');
|
||||||
|
|||||||
Vendored
+6
-3
@@ -3,10 +3,14 @@ const urls = {
|
|||||||
return `/ShowTestResult/${id}`;
|
return `/ShowTestResult/${id}`;
|
||||||
},
|
},
|
||||||
showItem: function(id) {
|
showItem: function(id) {
|
||||||
return `/ShowItem/${id}`;
|
// return `/ShowItem/${id}`;
|
||||||
|
return `/api/show-item/${id}`;
|
||||||
|
},
|
||||||
|
showItemByUdi: function(udi) {
|
||||||
|
return `/api/show-item/udi/${udi}`;
|
||||||
},
|
},
|
||||||
showPackage: function(id) {
|
showPackage: function(id) {
|
||||||
return `/ShowPackage/${id}`;
|
return `/api/show-package/${id}`;
|
||||||
},
|
},
|
||||||
showLabel: function(id) {
|
showLabel: function(id) {
|
||||||
return `/ShowLabel/${id}`;
|
return `/ShowLabel/${id}`;
|
||||||
@@ -15,7 +19,6 @@ const urls = {
|
|||||||
return `/ShowCycle/${id}`;
|
return `/ShowCycle/${id}`;
|
||||||
},
|
},
|
||||||
Barcode: function(code, type) {
|
Barcode: function(code, type) {
|
||||||
console.log(code, type,'aaa');
|
|
||||||
return `/BarCode/${code}/${type}`;
|
return `/BarCode/${code}/${type}`;
|
||||||
},
|
},
|
||||||
packageBarcode: function(code) {
|
packageBarcode: function(code) {
|
||||||
|
|||||||
Vendored
-1
@@ -30,7 +30,6 @@ function route (options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
console.log(paths);
|
|
||||||
// Create a new router
|
// Create a new router
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
|
|||||||
Vendored
+44
-33
@@ -5,37 +5,48 @@
|
|||||||
*/
|
*/
|
||||||
export default [
|
export default [
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'home',
|
name: 'home',
|
||||||
view: 'Home/Intro',
|
view: 'Home/Intro',
|
||||||
// meta : {
|
// meta : {
|
||||||
// onlyWhenLoggedOut : true
|
// onlyWhenLoggedOut : true
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/Show/Item/:item',
|
path: '/Show/Item/:item',
|
||||||
name: 'ShowItem',
|
name: 'ShowItem',
|
||||||
view: 'Item/ShowItem'
|
view: 'Item/ShowItem',
|
||||||
},
|
meta: {public: true}
|
||||||
{
|
},
|
||||||
path: '/Show/Package/:package',
|
{
|
||||||
name: 'ShowPackage',
|
path: '/Show/UDI/:udi',
|
||||||
view: 'Package/ShowPackage'
|
name: 'ShowItem',
|
||||||
},
|
view: 'Item/ShowItem',
|
||||||
{
|
meta: {public: true}
|
||||||
path: '/Show/Label/:label',
|
},
|
||||||
name: 'ShowLabel',
|
{
|
||||||
view: 'Label/ShowLabel'
|
path: '/Show/Package/:package',
|
||||||
},
|
name: 'ShowPackage',
|
||||||
{
|
view: 'Package/ShowPackage',
|
||||||
path: '/Show/Cycle/:cycle',
|
meta: { public: true }
|
||||||
name: 'ShowCycle',
|
},
|
||||||
view: 'Cycle/ShowCycle'
|
{
|
||||||
},
|
path: '/Show/Label/:label',
|
||||||
{
|
name: 'ShowLabel',
|
||||||
path: '/Show/TestResult/:id',
|
view: 'Label/ShowLabel',
|
||||||
name: 'ShowTestResult',
|
meta: { public: true }
|
||||||
view: 'TestResult/ShowTestResult'
|
},
|
||||||
},
|
{
|
||||||
|
path: '/Show/Cycle/:cycle',
|
||||||
|
name: 'ShowCycle',
|
||||||
|
view: 'Cycle/ShowCycle',
|
||||||
|
meta: { public: true }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/Show/TestResult/:id',
|
||||||
|
name: 'ShowTestResult',
|
||||||
|
view: 'TestResult/ShowTestResult',
|
||||||
|
meta: { public: true }
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,125 +1,184 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container grid-list-xs>
|
<v-container grid-list-xs>
|
||||||
<material-card color="black" title="Show Cycle">
|
<material-card color="black" title="Show Cycle">
|
||||||
<v-layout id="printMe" align-left justify-left wrap class="px-5 my-3">
|
<v-layout align-left justify-left wrap id="printMe" class="px-3 my-3">
|
||||||
<h3 class="ml-3">Cycle - {{ MedicalCenter }}</h3>
|
<h3 class="mt-0">
|
||||||
|
Cycle - {{ (data.user && data.user.medical_center) ? data.user.medical_center.name : "" }}
|
||||||
|
</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<hr class="v-divider theme--light">
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<span class="title">Cycle ID :</span>
|
|
||||||
<span class="headline ml-1" style="letter-spacing:0 !important">{{ data.id }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div>
|
|
||||||
<span class="title">Sterilizer ID :</span>
|
|
||||||
<span class="headline ml-1" style="letter-spacing:0 !important">{{ data.sterilizer_id }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-user"></v-icon>
|
|
||||||
<span class="headline ml-2" style="letter-spacing:0 !important">{{ data.user ? data.user.name : '' }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<span class="title">Cycle Number :</span>
|
|
||||||
<span class="headline ml-2" style="letter-spacing:0 !important">{{ data.cycle_number }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-Industry"></v-icon>
|
|
||||||
<span class="headline ml-2" style="letter-spacing:0 !important">{{ data.date }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-pencil"></v-icon>
|
|
||||||
<span class="headline ml-1" style="letter-spacing:0 !important">{{ data.note }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
|
||||||
<h3 class="ml-3">Barcode And QRCode Image</h3>
|
|
||||||
<v-flex xs12>
|
|
||||||
<hr class="v-divider theme--light">
|
|
||||||
</v-flex>
|
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
|
||||||
<img :src="barcodeimg" class="WM-Width-350"><br />
|
|
||||||
<span>Cycle ID : {{data.id}}</span>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6 v-if="QRCodeimg">
|
|
||||||
<img :src="QRCodeimg" class="WM-Width-150">
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
</v-layout>
|
|
||||||
|
|
||||||
</v-layout>
|
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
|
||||||
<h3 class="ml-3">Labels</h3>
|
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<v-layout row wrap class="">
|
||||||
|
<v-flex xs12 sm6 md4>
|
||||||
|
<div>
|
||||||
|
<span class="title">Cycle ID :</span>
|
||||||
|
<span class="headline ml-1" style="letter-spacing:0 !important">{{ data.id }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md4>
|
||||||
|
<div>
|
||||||
|
<span class="title">Sterilizer ID :</span>
|
||||||
|
<span class="headline ml-1"
|
||||||
|
style="letter-spacing:0 !important">{{ data.sterilizer_id }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md4>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-user"/>
|
||||||
|
<span class="headline ml-2"
|
||||||
|
style="letter-spacing:0 !important">{{ data.user ? data.user.name : '' }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md4>
|
||||||
|
<div>
|
||||||
|
<span class="title">Cycle Number :</span>
|
||||||
|
<span class="headline ml-2"
|
||||||
|
style="letter-spacing:0 !important">{{ data.cycle_number }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md4>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-Industry"/>
|
||||||
|
<span class="headline ml-2" style="letter-spacing:0 !important">{{ data.date }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md4>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-pencil"/>
|
||||||
|
<span class="headline ml-1" style="letter-spacing:0 !important">{{ data.note }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
<v-flex xs12>
|
||||||
<v-layout row wrap style="margin-left: 20px !important;">
|
<v-layout row wrap class="my-3">
|
||||||
|
<h3 class="mt-0">Barcode And QRCode Image</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light">
|
||||||
|
</v-flex>
|
||||||
|
<v-layout row wrap class="align-center mt-3">
|
||||||
|
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
||||||
|
<img :src="barcodeimg" class="barcode-container"><br/>
|
||||||
|
<span>Cycle ID : {{ data.id }}</span>
|
||||||
|
</v-flex>
|
||||||
|
|
||||||
<template>
|
<v-flex xs12 md6 sm6 v-if="QRCodeimg" class="WM-Align-R">
|
||||||
<v-expansion-panel class="WM-Panel" v-for="(label, key) in data.labels" :key="key">
|
<a :href="'https://www.cssd-doc.com/Show/Cycle/'+data.id+''" target="_blank">
|
||||||
<v-expansion-panel-content>
|
<img :src="QRCodeimg" class="WM-Width-150">
|
||||||
<template v-slot:header>
|
</a>
|
||||||
<div>{{ label.id }} ({{ label.pivot.count }})</div>
|
</v-flex>
|
||||||
</template>
|
</v-layout>
|
||||||
<v-card>
|
</v-layout>
|
||||||
<v-card-text> Package :
|
</v-flex>
|
||||||
<v-expansion-panel class="WM-Panel">
|
<v-flex xs12 v-if="data.labels && data.labels.length">
|
||||||
<v-expansion-panel-content>
|
<v-layout row wrap class="my-3">
|
||||||
<template v-slot:header>
|
<h3 class="mt-0">Labels</h3>
|
||||||
<div>{{ label.package.name }} </div>
|
<v-flex xs12>
|
||||||
</template>
|
<hr class="v-divider theme--light">
|
||||||
<v-card>
|
</v-flex>
|
||||||
<v-card-text>note : {{ label.package.note }}</v-card-text>
|
<v-layout row wrap>
|
||||||
<v-card-text>
|
<template>
|
||||||
Items :
|
<v-expansion-panel class="WM-Panel" v-for="(label, key) in data.labels" :key="key">
|
||||||
<v-expansion-panel class="WM-Panel" v-for="item in label.package.items" :key="item.key">
|
<v-expansion-panel-content>
|
||||||
|
<template v-slot:header>
|
||||||
|
<v-layout row wrap class="CSSD-font">
|
||||||
|
<span class="item-counter">{{ key + 1 }}</span>
|
||||||
|
|
||||||
|
<v-layout row wrap class="pl-2">
|
||||||
|
<v-flex xs12 sm6 md6>
|
||||||
|
<span class="sub-text">Label ID:</span>
|
||||||
|
{{label.id}}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md6>
|
||||||
|
<span class="sub-text">Label Pivot counter:</span>
|
||||||
|
{{ label.pivot.count }}
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
</template>
|
||||||
|
<v-card>
|
||||||
|
<v-card-text class="pa-0 pl-sm-3" v-if="label.package">
|
||||||
|
Package :
|
||||||
|
<template>
|
||||||
|
<v-expansion-panel class="WM-Panel">
|
||||||
<v-expansion-panel-content>
|
<v-expansion-panel-content>
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<div>{{ item.name }} ({{ item.pivot.count }})</div>
|
<v-layout row wrap class="CSSD-font">
|
||||||
|
<span class="item-counter">{{ key + 1 }}</span>
|
||||||
|
|
||||||
|
<v-layout row wrap class="pl-2">
|
||||||
|
<v-flex xs12 sm6 md6>
|
||||||
|
<span class="sub-text">Package ID:</span>
|
||||||
|
{{label.package.id}}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md6>
|
||||||
|
<span class="sub-text">Package Name:</span>
|
||||||
|
{{ label.package.name }}
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
</template>
|
</template>
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-text>note : {{ item.note }}</v-card-text>
|
<v-card-text class="pa-0 pl-sm-3">
|
||||||
|
note : {{label.package.note }}
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-text class="pa-0 pl-sm-3"
|
||||||
|
v-if="label.package && label.package.items && label.package.items.length">
|
||||||
|
Items :
|
||||||
|
<v-expansion-panel class="WM-Panel"
|
||||||
|
v-for="(item, key) in label.package.items"
|
||||||
|
:key="key">
|
||||||
|
<v-expansion-panel-content>
|
||||||
|
<template v-slot:header>
|
||||||
|
<v-layout row wrap class="CSSD-font">
|
||||||
|
<span class="item-counter">{{ key + 1 }}</span>
|
||||||
|
|
||||||
|
<v-layout row wrap class="pl-2">
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<span class="sub-text">Item ID:</span>
|
||||||
|
{{ item.id }}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<span class="sub-text">Item Name:</span>
|
||||||
|
{{ item.name }}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4 class="WM-Align-R">
|
||||||
|
<span v-if="item.pivot">
|
||||||
|
({{ item.pivot.count }})
|
||||||
|
</span>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
</template>
|
||||||
|
<v-card>
|
||||||
|
<v-card-text>note : {{ item.note }}
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-expansion-panel-content>
|
||||||
|
</v-expansion-panel>
|
||||||
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-expansion-panel-content>
|
</v-expansion-panel-content>
|
||||||
</v-expansion-panel>
|
</v-expansion-panel>
|
||||||
|
</template>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-expansion-panel-content>
|
</v-expansion-panel-content>
|
||||||
</v-expansion-panel>
|
</v-expansion-panel>
|
||||||
</v-card-text>
|
</template>
|
||||||
</v-card>
|
</v-layout>
|
||||||
</v-expansion-panel-content>
|
</v-layout>
|
||||||
</v-expansion-panel>
|
</v-flex>
|
||||||
</template>
|
|
||||||
|
|
||||||
</v-layout>
|
</v-layout>
|
||||||
|
|
||||||
|
|
||||||
<v-layout row wrap align-center justify-center style="text-align:center">
|
<v-layout row wrap align-center justify-center style="text-align:center">
|
||||||
<v-flex class xs12 md12 sm12 >
|
<v-flex class xs12 md12 sm12>
|
||||||
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addCycle()">
|
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addCycle()">
|
||||||
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
||||||
<span class="black--text">Back</span>
|
<span class="black--text">Back</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
||||||
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
||||||
<span class="white--text">Print</span>
|
<span class="white--text">Print</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -136,35 +195,36 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { urls } from "@show/config/urls";
|
import {urls} from "@show/config/urls";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
data : {},
|
data: {},
|
||||||
barcodeimg : '',
|
barcodeimg: '',
|
||||||
QRCodeimg : '',
|
QRCodeimg: '',
|
||||||
MedicalCenter : ''
|
MedicalCenter: ''
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
async load(id) {
|
async load(id) {
|
||||||
const result = await axios.get(urls.showCycle(id));
|
const result = await axios.get(urls.showCycle(id));
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
this.data = result.data.data;
|
this.data = result.data.data;
|
||||||
this.generateBarcode(this.data.id);
|
this.generateBarcode(this.data.id);
|
||||||
this.MedicalCenter = this.data.user.medical_center.name;
|
this.MedicalCenter = this.data.user.medical_center.name;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async generateBarcode(cycleId) {
|
async generateBarcode(cycleId) {
|
||||||
const result = await axios.post(urls.Barcode(cycleId, 'Cycle'));
|
const result = await axios.post(urls.Barcode(cycleId, 'Cycle'));
|
||||||
if (result && result.status == 200) {
|
if (result && result.status == 200) {
|
||||||
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
||||||
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editCycle(cycleId){
|
editCycle(cycleId) {
|
||||||
window.location.href = '/cycle/'+cycleId+'/edit';
|
window.location.href = '/cycle/' + cycleId + '/edit';
|
||||||
},
|
},
|
||||||
addCycle(cycleId){
|
addCycle(cycleId) {
|
||||||
window.location.href = '/add-cycle';
|
window.location.href = '/add-cycle';
|
||||||
},
|
},
|
||||||
print() {
|
print() {
|
||||||
@@ -203,9 +263,30 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.$route.params.cycle) {
|
if (this.$route.params.cycle) {
|
||||||
this.load(this.$route.params.cycle);
|
this.load(this.$route.params.cycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.barcode-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 290px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-counter {
|
||||||
|
font-size: 44px;
|
||||||
|
opacity: .3;
|
||||||
|
font-family: 'Montserrat-Bold';
|
||||||
|
line-height: 44px;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
color: #b7b7b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub-text {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,75 +1,112 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container grid-list-xs>
|
<v-container grid-list-xs>
|
||||||
<material-card color="black" title="Show Item">
|
<material-card color="black" title="Show Item">
|
||||||
<v-layout align-left id="printMe" justify-left wrap class="px-5 my-3">
|
<v-layout align-left id="printMe" justify-left wrap class="my-3">
|
||||||
<h3 class="ml-3 CSSD-font"> Item - {{ MedicalCenter }}</h3>
|
<h3 class="ml-3 CSSD-font"> Item - {{ MedicalCenter }}</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<hr class="v-divider theme--light">
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
<v-layout row wrap class="ml-4 align-center">
|
||||||
<v-flex xs12 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Item ID :</span>
|
<span class="title CSSD-font">Item ID :</span>
|
||||||
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">{{ data.id }}</span>
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.id }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Name :</span>
|
<span class="title CSSD-font">Name :</span>
|
||||||
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">{{ data.name }}</span>
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.name }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Size :</span>
|
<span class="title CSSD-font">Size :</span>
|
||||||
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">{{ data.size }}</span>
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.size }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 md6 sm6>
|
||||||
|
<div class>
|
||||||
|
<span class="title CSSD-font">UDI :</span>
|
||||||
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.udi }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Specific :</span>
|
<span class="title CSSD-font">Specific :</span>
|
||||||
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">{{ data.specific }}</span>
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.specific }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Register User :</span>
|
<span class="title CSSD-font">Register User :</span>
|
||||||
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">{{ data.user ? data.user.name : '' }}</span>
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.user ? data.user.name : '' }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Date Register:</span>
|
<span class="title CSSD-font">Date Register:</span>
|
||||||
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">{{ data.created_at }}</span>
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.created_at }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
|
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
<v-layout align-left justify-left row wrap class="my-3" v-if="data.files && data.files.length">
|
||||||
|
<h3 class="CSSD-font">Image</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light"/>
|
||||||
|
</v-flex>
|
||||||
|
<v-layout row wrap class="mt-3">
|
||||||
|
<v-flex xs6 md2 sm2 v-for="(file, key) in data.files" :key="key">
|
||||||
|
<template v-if="file.file_type == 'document'">
|
||||||
|
<a target="_blank" :href="'/'+file.thumbnail">
|
||||||
|
<v-icon class="mr-2 caption">fas fa-check</v-icon>
|
||||||
|
{{ file.file_name }}</a>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<img :src="file.thumbnail" style="width: 100%" @click="openLightbox(key)"/>
|
||||||
|
</template>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
<v-flex xs12></v-flex>
|
||||||
|
<v-layout align-left justify-left row wrap class="my-3">
|
||||||
<h3 class="ml-3 CSSD-font">Barcode And QRCode Image</h3>
|
<h3 class="ml-3 CSSD-font">Barcode And QRCode Image</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<hr class="v-divider theme--light">
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
<v-layout row wrap class="ml-4 align-center mt-2">
|
||||||
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
||||||
<img :src="barcodeimg" class="WM-Width-350"><br />
|
<img :src="barcodeimg" class="barcode-container"><br/>
|
||||||
<span class="CSSD-font">Item ID : {{data.id}}</span>
|
<span class="CSSD-font">Item ID : {{ data.id }}</span>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
<v-flex xs12 md6 sm6 v-if="QRCodeimg" class="WM-Align-C">
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6 v-if="QRCodeimg">
|
|
||||||
<img :src="QRCodeimg" class="WM-Width-150">
|
<img :src="QRCodeimg" class="WM-Width-150">
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout row wrap align-center justify-center style="text-align:center">
|
<v-layout row wrap align-center justify-center style="text-align:center">
|
||||||
<v-flex class xs12 md12 sm12 >
|
<v-flex class xs12 md12 sm12>
|
||||||
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addItem()">
|
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addItem()">
|
||||||
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
||||||
<span class="black--text">Back</span>
|
<span class="black--text">Back</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
||||||
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
||||||
<span class="white--text">Print</span>
|
<span class="white--text">Print</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -80,49 +117,85 @@
|
|||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</material-card>
|
</material-card>
|
||||||
|
<vue-image-lightbox
|
||||||
|
v-if="showLightbox"
|
||||||
|
:media="lightboxImages"
|
||||||
|
:index="lightboxIndex"
|
||||||
|
@close="showLightbox = false"
|
||||||
|
/>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import {urls} from "@show/config/urls";
|
||||||
data: () => ({
|
|
||||||
data: {}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
import { urls } from "@show/config/urls";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import toast from "@/services/global/toast.service";
|
||||||
|
import VueImageLightbox from "vue-image-lightbox";
|
||||||
|
import 'vue-image-lightbox/dist/vue-image-lightbox.min.css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
data : {},
|
data: {},
|
||||||
QRCodeimg : '',
|
QRCodeimg: '',
|
||||||
barcodeimg : '',
|
barcodeimg: '',
|
||||||
MedicalCenter : ''
|
MedicalCenter: '',
|
||||||
|
showLightbox: false,
|
||||||
|
lightboxIndex: 0,
|
||||||
|
lightboxImages: [],
|
||||||
}),
|
}),
|
||||||
|
components: {
|
||||||
|
VueImageLightbox,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
imagesOnly() {
|
||||||
|
return this.data.files && this.data.files.length ? this.data.files.filter(file => file.file_type !== 'document') : [];
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async load(id) {
|
async load(id) {
|
||||||
const result = await axios.get(urls.showItem(id));
|
try {
|
||||||
|
const result = await axios.get(urls.showItem(id));
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
this.data = result.data.data;
|
this.data = result.data.data;
|
||||||
this.generateBarcode(this.data.id);
|
if (this.data) {
|
||||||
this.MedicalCenter = this.data.user.medical_center.name;
|
this.generateBarcode(this.data);
|
||||||
}
|
this.MedicalCenter = this.data.user.medical_center.name;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
async generateBarcode(itemId) {
|
} catch (error) {
|
||||||
const result = await axios.post(urls.Barcode(itemId, 'Item'));
|
console.error("Error loading data:", error);
|
||||||
if (result && result.status == 200) {
|
|
||||||
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
|
||||||
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editItem(itemId){
|
async loadByUdi(udi) {
|
||||||
window.location.href = '/item/'+itemId+'/edit';
|
try {
|
||||||
|
const result = await axios.get(urls.showItemByUdi(udi));
|
||||||
|
if (result.status == 200) {
|
||||||
|
this.data = result.data.data;
|
||||||
|
if (this.data) {
|
||||||
|
this.generateBarcode(this.data);
|
||||||
|
this.MedicalCenter = this.data.user.medical_center.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading data:", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
addItem(){
|
async generateBarcode(item) {
|
||||||
|
let code = item.udi;
|
||||||
|
if (code) {
|
||||||
|
const result = await axios.post(urls.Barcode(code, 'Item'));
|
||||||
|
if (result && result.status == 200) {
|
||||||
|
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
||||||
|
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
toast.error('An error occurred while generating the barcode . please first set UDI');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
editItem(itemId) {
|
||||||
|
window.location.href = '/item/' + itemId + '/edit';
|
||||||
|
},
|
||||||
|
addItem() {
|
||||||
window.location.href = '/add-item';
|
window.location.href = '/add-item';
|
||||||
},
|
},
|
||||||
print() {
|
print() {
|
||||||
@@ -143,30 +216,38 @@ export default {
|
|||||||
"left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0"
|
"left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0"
|
||||||
);
|
);
|
||||||
|
|
||||||
WinPrint.document.write(`<!DOCTYPE html>
|
WinPrint.document.write(`<!DOCTYPE html><html><head>${stylesHtml}</head><body> ${prtHtml}</body></html>`);
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
${stylesHtml}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
${prtHtml}
|
|
||||||
</body>
|
|
||||||
</html>`);
|
|
||||||
|
|
||||||
WinPrint.document.close();
|
WinPrint.document.close();
|
||||||
WinPrint.focus();
|
WinPrint.focus();
|
||||||
WinPrint.print();
|
WinPrint.print();
|
||||||
WinPrint.close();
|
WinPrint.close();
|
||||||
|
},
|
||||||
|
openLightbox(index) {
|
||||||
|
this.lightboxIndex = index;
|
||||||
|
this.showLightbox = false;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.showLightbox = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.$route.params.item) {
|
if (this.$route.params.item) {
|
||||||
// console.log(this.$route.params.item);
|
this.load(this.$route.params.item);
|
||||||
this.load(this.$route.params.item);
|
} else if (this.$route.params.udi) {
|
||||||
}
|
this.loadByUdi(this.$route.params.udi);
|
||||||
|
}
|
||||||
|
this.lightboxImages = this.imagesOnly && this.imagesOnly.length ? this.imagesOnly.map(file => ({
|
||||||
|
src: file.thumbnail,
|
||||||
|
thumb: file.thumbnail,
|
||||||
|
})) : [];
|
||||||
},
|
},
|
||||||
// mounted() {
|
|
||||||
// this.generateBarcode(this.data.id);
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.barcode-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 290px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,195 +1,235 @@
|
|||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<v-container grid-list-xs>
|
<v-container grid-list-xs>
|
||||||
<material-card color="black" title="Show Label">
|
<material-card color="black" title="Show Label">
|
||||||
<v-layout align-left justify-left wrap class="px-2 my-3">
|
<v-layout align-left justify-left wrap class="px-2 my-3">
|
||||||
<h3 class="ml-3">Label</h3>
|
<h3 class="ml-3">Label</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<hr class="v-divider theme--light">
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout id="printMe">
|
<v-layout id="printMe">
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<!-- ________ row1::Begin ________ -->
|
<!-- ________ row1::Begin ________ -->
|
||||||
<v-layout row wrap>
|
<v-layout row wrap>
|
||||||
<!-- ________ Column1::Begin ________ -->
|
<!-- ________ Column1::Begin ________ -->
|
||||||
<v-flex xs6 md6 sm6>
|
<v-flex xs12 md6 sm6>
|
||||||
<v-layout row wrap class="ml-4">
|
<v-layout row wrap class="">
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<div class="WM-d-flex">
|
<div class="WM-d-flex">
|
||||||
<span class="headline ml-1 mb-1" style="letter-spacing:0 !important">{{ MedicalCenter }}</span>
|
<span class="headline ml-1 mb-1" style="letter-spacing:0 !important">
|
||||||
</div>
|
{{ MedicalCenter }}
|
||||||
</v-flex>
|
</span>
|
||||||
<v-flex xs12 md12 sm12 class="">
|
</div>
|
||||||
<div class="WM-d-flex">
|
</v-flex>
|
||||||
<v-icon class="WMi-location"></v-icon>
|
<v-flex xs12 md12 sm12 class="">
|
||||||
<span class="headline ml-1 mb-1" style="letter-spacing:0 !important" v-if="dataLoaded">{{data.package.name}}</span>
|
<div class="WM-d-flex">
|
||||||
</div>
|
<v-icon class="WMi-location"/>
|
||||||
</v-flex>
|
<span class="headline ml-1 mb-1" style="letter-spacing:0 !important"
|
||||||
<v-flex xs12 md12 sm12>
|
v-if="dataLoaded">{{ data.package.name }}</span>
|
||||||
<div class="WM-d-flex">
|
</div>
|
||||||
<v-icon class="WMi-Industry"></v-icon>
|
</v-flex>
|
||||||
<span class="headline ml-2 mb-1" style="letter-spacing:0 !important">{{ data.sterile_date }}</span>
|
<v-flex xs12 md12 sm12>
|
||||||
</div>
|
<div class="WM-d-flex">
|
||||||
</v-flex>
|
<v-icon class="WMi-Industry"/>
|
||||||
<v-flex xs12 md12 sm12>
|
<span class="headline ml-2 mb-1"
|
||||||
<div class="WM-d-flex">
|
style="letter-spacing:0 !important">{{ data.sterile_date }}</span>
|
||||||
<v-icon class="WMi-hourglass"></v-icon>
|
</div>
|
||||||
<span class="headline ml-2 mb-1" style="letter-spacing:0 !important">{{ data.expire_date }}</span>
|
</v-flex>
|
||||||
</div>
|
<v-flex xs12 md12 sm12>
|
||||||
</v-flex>
|
<div class="WM-d-flex">
|
||||||
<v-flex xs12 md12 sm12>
|
<v-icon class="WMi-hourglass"/>
|
||||||
<div class="WM-d-flex">
|
<span class="headline ml-2 mb-1"
|
||||||
<v-icon class="WMi-user"></v-icon>
|
style="letter-spacing:0 !important">{{ data.expire_date }}</span>
|
||||||
<span class="headline ml-2 mb-1" style="letter-spacing:0 !important">{{ data.user ? data.user.name : '' }}</span>
|
</div>
|
||||||
</div>
|
</v-flex>
|
||||||
</v-flex>
|
<v-flex xs12 md12 sm12>
|
||||||
</v-layout>
|
<div class="WM-d-flex">
|
||||||
</v-flex>
|
<v-icon class="WMi-user"/>
|
||||||
<!-- ________ Column1::End ________ -->
|
<span class="headline ml-2 mb-1" style="letter-spacing:0 !important">
|
||||||
<!-- ________ Column2::Begin ________ -->
|
{{ data.user ? data.user.name : '' }}
|
||||||
<v-flex xs6 md6 sm6>
|
</span>
|
||||||
<v-layout row wrap class="">
|
</div>
|
||||||
<v-flex xs12 md12 sm12>
|
</v-flex>
|
||||||
<div>
|
</v-layout>
|
||||||
<v-flex xs6 md6 sm6 v-if="QRCodeimg">
|
</v-flex>
|
||||||
<a :href="'/Show/Package/'+data.package.id+''" target="_blank"><img :src="QRCodeimg" class="WM-Width-120"></a>
|
<!-- ________ Column1::End ________ -->
|
||||||
</v-flex>
|
<!-- ________ Column2::Begin ________ -->
|
||||||
</div>
|
<v-flex xs12 md6 sm6>
|
||||||
</v-flex>
|
<v-layout row wrap class="mt-4">
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<div class>
|
<div>
|
||||||
<span class="title">Sterilizer ID :</span>
|
<v-flex xs6 md6 sm6 v-if="QRCodeimg">
|
||||||
<span class="headline ml-1 mb-1" style="letter-spacing:0 !important">{{ data.sterilizer_id}}</span>
|
<a :href="'/Show/Package/'+data.package.id+''" target="_blank">
|
||||||
</div>
|
<img :src="QRCodeimg" class="WM-Width-120">
|
||||||
</v-flex>
|
</a>
|
||||||
<v-flex xs12 md12 sm12>
|
</v-flex>
|
||||||
<div class>
|
</div>
|
||||||
<span class="title">Cycle No :</span>
|
</v-flex>
|
||||||
<span class="headline ml-2 mb-1" style="letter-spacing:0 !important">{{ data.cycle_number }}</span>
|
<v-flex xs12 md12 sm12>
|
||||||
</div>
|
<div class>
|
||||||
</v-flex>
|
<span class="headline">Sterilizer ID :</span>
|
||||||
</v-layout>
|
<span class="title ml-1 mb-1"
|
||||||
</v-flex>
|
style="letter-spacing:0 !important">{{ data.sterilizer_id }}</span>
|
||||||
<!-- ________ Column2::End ________ -->
|
</div>
|
||||||
</v-layout>
|
</v-flex>
|
||||||
<!-- ________ row1::Begin ________ -->
|
<v-flex xs12 md12 sm12>
|
||||||
|
<div class>
|
||||||
|
<span class="headline">Cycle No :</span>
|
||||||
|
<span class="title ml-2 mb-1"
|
||||||
|
style="letter-spacing:0 !important">{{ data.cycle_number }}</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-flex>
|
||||||
|
<!-- ________ Column2::End ________ -->
|
||||||
|
</v-layout>
|
||||||
|
<!-- ________ row1::Begin ________ -->
|
||||||
|
<!-- ________ row2::Begin ________ -->
|
||||||
|
<v-layout row wrap>
|
||||||
|
<v-flex xs12 md12 sm12>
|
||||||
|
<div class="mt-4" style="text-align:center">
|
||||||
|
<v-layout row wrap>
|
||||||
|
<v-flex xs12 md12 sm12 v-if="barcodeimg">
|
||||||
|
<img :src="barcodeimg" class="barcode-container"><br/>
|
||||||
|
<span class="WM-Font-14">Lebel ID :</span>
|
||||||
|
<span>{{ data.id }}</span>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
<!-- ________ row2::End ________ -->
|
||||||
|
<v-layout wrap row v-if="dataLoaded">
|
||||||
|
<h3 class="ml-3">Package</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light">
|
||||||
|
</v-flex>
|
||||||
|
<v-layout row wrap class="mx-sm-3">
|
||||||
|
<template>
|
||||||
|
<v-expansion-panel class="WM-Panel">
|
||||||
|
<v-expansion-panel-content>
|
||||||
|
<template v-slot:header>
|
||||||
|
<v-layout row wrap class="CSSD-font">
|
||||||
|
<span class="item-counter">{{ key + 1 }}</span>
|
||||||
|
|
||||||
|
<v-layout row wrap class="pl-2">
|
||||||
|
<v-flex xs12 sm6 md6>
|
||||||
|
<span class="sub-text">Package ID:</span>
|
||||||
|
{{data.package.id}}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm6 md6>
|
||||||
|
<span class="sub-text">Package Name:</span>
|
||||||
|
{{ data.package.name }}
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
</template>
|
||||||
|
<v-card>
|
||||||
|
<v-card-text>note : {{ data.package.note }}</v-card-text>
|
||||||
|
<v-card-text class="pa-0 pl-sm-3"
|
||||||
|
v-if="data.package && data.package.items && data.package.items.length">
|
||||||
|
Items :
|
||||||
|
<v-expansion-panel class="WM-Panel"
|
||||||
|
v-for="(item, key) in data.package.items"
|
||||||
|
:key="key">
|
||||||
|
<v-expansion-panel-content>
|
||||||
|
<template v-slot:header>
|
||||||
|
<v-layout row wrap class="CSSD-font">
|
||||||
|
<span class="item-counter">{{ key + 1 }}</span>
|
||||||
|
|
||||||
<!-- ________ row2::Begin ________ -->
|
<v-layout row wrap class="pl-2">
|
||||||
<v-layout row wrap>
|
<v-flex xs12 sm4 md4>
|
||||||
<v-flex xs12 md12 sm12>
|
<span class="sub-text">Item ID:</span>
|
||||||
<div class="mt-4" style="text-align:center">
|
{{ item.id }}
|
||||||
<v-layout row wrap>
|
</v-flex>
|
||||||
<v-flex xs6 md12 sm12 v-if="barcodeimg">
|
<v-flex xs12 sm4 md4>
|
||||||
<img :src="barcodeimg" class="WM-Width-350"><br />
|
<span class="sub-text">Item Name:</span>
|
||||||
<span>{{data.id}}</span>
|
{{ item.name }}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4 class="WM-Align-R">
|
||||||
|
<span v-if="item.pivot">
|
||||||
|
({{ item.pivot.count }})
|
||||||
|
</span>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
</template>
|
||||||
|
<v-card>
|
||||||
|
<v-card-text>note : {{ item.note }}</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-expansion-panel-content>
|
||||||
|
</v-expansion-panel>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-expansion-panel-content>
|
||||||
|
</v-expansion-panel>
|
||||||
|
</template>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<!-- ________ row2::End ________ -->
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
</v-layout>
|
|
||||||
<v-layout align-left justify-left wrap class="px-2 my-3" v-if="dataLoaded">
|
|
||||||
<h3 class="ml-3">Package</h3>
|
|
||||||
<v-flex xs12>
|
|
||||||
<hr class="v-divider theme--light">
|
|
||||||
</v-flex>
|
|
||||||
<v-layout row wrap class="mx-3">
|
|
||||||
<template>
|
|
||||||
<v-expansion-panel class="WM-Panel">
|
|
||||||
<v-expansion-panel-content>
|
|
||||||
<template v-slot:header>
|
|
||||||
<div>{{ data.package.name }}</div>
|
|
||||||
</template>
|
|
||||||
<v-card>
|
|
||||||
<v-card-text>note : {{ data.package.note }}</v-card-text>
|
|
||||||
<v-card-text> Items :
|
|
||||||
<v-expansion-panel class="WM-Panel" v-for="item in data.package.items" :key="item.key">
|
|
||||||
<v-expansion-panel-content>
|
|
||||||
<template v-slot:header>
|
|
||||||
<div>{{ item.name }} ({{ item.pivot.count }})</div>
|
|
||||||
</template>
|
|
||||||
<v-card>
|
|
||||||
<v-card-text>note : {{ item.note }}</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-expansion-panel-content>
|
|
||||||
</v-expansion-panel>
|
|
||||||
</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-expansion-panel-content>
|
|
||||||
</v-expansion-panel>
|
|
||||||
</template>
|
|
||||||
</v-layout>
|
|
||||||
</v-layout>
|
|
||||||
<v-layout row wrap align-center justify-center style="text-align:center">
|
|
||||||
<v-flex class xs12 md12 sm12 >
|
|
||||||
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addLabel()">
|
|
||||||
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
|
||||||
<span class="black--text">Back</span>
|
|
||||||
</v-btn>
|
|
||||||
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
|
||||||
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
|
||||||
<span class="white--text">Print</span>
|
|
||||||
</v-btn>
|
|
||||||
<v-btn color="orange" class="mr-2" style="padding:10px 60px" @click="editLabel(data.id)">
|
|
||||||
<v-icon class="white--text mr-1 caption">fas fa-pen</v-icon>
|
|
||||||
<span>Edit</span>
|
|
||||||
</v-btn>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
|
|
||||||
</material-card>
|
<v-layout row wrap align-center justify-center style="text-align:center">
|
||||||
</v-container>
|
<v-flex class xs12 md12 sm12>
|
||||||
|
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="goToAddLabel()">
|
||||||
|
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
||||||
|
<span class="black--text">Back</span>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
||||||
|
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
||||||
|
<span class="white--text">Print</span>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn color="orange" class="mr-2" style="padding:10px 60px" @click="editLabel(data.id)">
|
||||||
|
<v-icon class="white--text mr-1 caption">fas fa-pen</v-icon>
|
||||||
|
<span>Edit</span>
|
||||||
|
</v-btn>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
|
||||||
|
</material-card>
|
||||||
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style media="screen">
|
|
||||||
.WM-d-flex{
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { urls } from "@show/config/urls";
|
import {urls} from "@show/config/urls";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
data : {},
|
data: {},
|
||||||
QRCodeimg : '',
|
QRCodeimg: '',
|
||||||
barcodeimg : '',
|
barcodeimg: '',
|
||||||
MedicalCenter : '',
|
MedicalCenter: '',
|
||||||
dataLoaded : false
|
dataLoaded: false
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
async load(id) {
|
async load(id) {
|
||||||
const result = await axios.get(urls.showLabel(id));
|
const result = await axios.get(urls.showLabel(id));
|
||||||
|
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
this.data = result.data.data;
|
this.data = result.data.data;
|
||||||
this.generateBarcode(this.data.id);
|
this.generateBarcode(this.data.id);
|
||||||
this.generateQRcodePackage(this.data.package.id);
|
this.generateQRcodePackage(this.data.package.id);
|
||||||
this.MedicalCenter = this.data.user.medical_center.name;
|
this.MedicalCenter = this.data.user.medical_center.name;
|
||||||
this.dataLoaded = true;
|
this.dataLoaded = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async generateQRcodePackage(packageId) {
|
async generateQRcodePackage(packageId) {
|
||||||
const result = await axios.post(urls.packageQRCode(packageId));
|
const result = await axios.post(urls.packageQRCode(packageId));
|
||||||
if (result && result.status == 200) {
|
if (result && result.status == 200) {
|
||||||
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async generateBarcode(labelId) {
|
async generateBarcode(labelId) {
|
||||||
const result = await axios.post(urls.Barcode(labelId, 'Label'));
|
const result = await axios.post(urls.Barcode(labelId, 'Label'));
|
||||||
if (result && result.status == 200) {
|
if (result && result.status == 200) {
|
||||||
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editLabel(LabelId){
|
editLabel(LabelId) {
|
||||||
window.location.href = '/label/'+LabelId+'/edit';
|
window.location.href = '/label/' + LabelId + '/edit';
|
||||||
},
|
},
|
||||||
addLabel(LabelId){
|
goToAddLabel(LabelId) {
|
||||||
window.location.href = '/add-label';
|
window.location.href = '/add-label';
|
||||||
},
|
},
|
||||||
print() {
|
print() {
|
||||||
@@ -228,10 +268,36 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.$route.params.label) {
|
if (this.$route.params.label) {
|
||||||
console.log(this.$route.params);
|
this.load(this.$route.params.label);
|
||||||
this.load(this.$route.params.label);
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style media="screen">
|
||||||
|
.WM-d-flex {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.barcode-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 290px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-counter {
|
||||||
|
font-size: 44px;
|
||||||
|
opacity: .3;
|
||||||
|
font-family: 'Montserrat-Bold';
|
||||||
|
line-height: 44px;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
color: #b7b7b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub-text {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,87 +1,116 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container grid-list-xs>
|
<v-container grid-list-xs>
|
||||||
<material-card color="black" title="Show Package">
|
<material-card color="black" title="Show Package">
|
||||||
<v-layout id="printMe" align-left justify-left wrap class="px-5 my-3">
|
<v-layout id="printMe" align-left justify-left wrap class="px-3 mb-3">
|
||||||
<h3 class="ml-3 CSSD-font">Package - {{ MedicalCenter }}</h3>
|
<h3 class="CSSD-font mt-0">
|
||||||
|
{{ data.name }} - MC
|
||||||
|
{{ (data.user != null && data.user.medical_center != null) ? data.user.medical_center.name : '' }}
|
||||||
|
</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<hr class="v-divider theme--light">
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-info"></v-icon>
|
|
||||||
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">{{ data.name }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-Industry"></v-icon>
|
|
||||||
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">{{ data.created_at }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-user"></v-icon>
|
|
||||||
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">{{ data.user ? data.user.name : '' }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
<v-flex xs12 md6 sm6>
|
|
||||||
<div class="WM-d-flex">
|
|
||||||
<v-icon class="WMi-pencil"></v-icon>
|
|
||||||
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">{{ data.note }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
|
||||||
<h3 class="ml-3 CSSD-font">Barcode And QRCode Image</h3>
|
|
||||||
<v-flex xs12>
|
|
||||||
<hr class="v-divider theme--light">
|
|
||||||
</v-flex>
|
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
|
||||||
<img :src="barcodeimg" class="WM-Width-350"><br />
|
|
||||||
<span class="CSSD-font">Package ID : {{data.id}}</span>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs12 md6 sm6 v-if="QRCodeimg">
|
|
||||||
<img :src="QRCodeimg" class="WM-Width-150">
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
</v-layout>
|
|
||||||
|
|
||||||
</v-layout>
|
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
|
||||||
<h3 class="ml-3 CSSD-font">Items</h3>
|
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light">
|
<v-layout align-left justify-left wrap class="pt-3">
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-info"/>
|
||||||
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.name }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-Industry"/>
|
||||||
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.created_at }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-user"/>
|
||||||
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.user ? data.user.name : '' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm12 md12>
|
||||||
|
<div class="WM-d-flex">
|
||||||
|
<v-icon class="WMi-pencil"/>
|
||||||
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.note }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12>
|
||||||
|
<v-layout align-left justify-left wrap class="pt-3">
|
||||||
|
<h3 class="CSSD-font">Barcode And QRCode Image</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light">
|
||||||
|
</v-flex>
|
||||||
|
<v-layout row wrap class="align-center mt-2">
|
||||||
|
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
||||||
|
<img :src="barcodeimg" class="barcode-container"><br/>
|
||||||
|
<span class="CSSD-font">Package ID : {{ data.id }}</span>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 md6 sm6 v-if="QRCodeimg" class="WM-Align-R">
|
||||||
|
<a :href="'https://www.cssd-doc.com/Show/Package/'+data.id+''" target="_blank">
|
||||||
|
<img :src="QRCodeimg" class="WM-Width-150">
|
||||||
|
</a>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12>
|
||||||
|
<v-layout align-left justify-left wrap class="pt-3">
|
||||||
|
<h3 class="CSSD-font mt-0">Items</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light">
|
||||||
|
</v-flex>
|
||||||
|
<v-layout row wrap class="ml-sm-4 WM-Relative">
|
||||||
|
<template v-if="data.items && data.items.length">
|
||||||
|
<v-expansion-panel class="WM-Panel">
|
||||||
|
<v-expansion-panel-content v-for="(item, key) in data.items" :key="key">
|
||||||
|
<template v-slot:header>
|
||||||
|
<v-layout row wrap class="CSSD-font">
|
||||||
|
<span class="item-counter">{{ key + 1 }}</span>
|
||||||
|
<v-layout row wrap class="pl-2">
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<span class="sub-text">Item ID:</span> {{ item.id }}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4>
|
||||||
|
<span class="sub-text">Item Name:</span> {{ item.name }}
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 sm4 md4 class="WM-Align-R">
|
||||||
|
<span v-if="item.pivot">({{ item.pivot.count }})</span>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
</template>
|
||||||
|
<v-card>
|
||||||
|
<v-card-text>note : {{ item.note }}</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-expansion-panel-content>
|
||||||
|
</v-expansion-panel>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<p class="mt-3" style="width: 100%;"> No Item Has Been Selected</p>
|
||||||
|
</template>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<template>
|
|
||||||
<v-expansion-panel class="WM-Panel">
|
|
||||||
<v-expansion-panel-content
|
|
||||||
v-for="(item, key) in data.items" :key="key"
|
|
||||||
>
|
|
||||||
<template v-slot:header>
|
|
||||||
<div>{{ key+1 + ": " + item.name }} ({{ item.pivot.count }})</div>
|
|
||||||
</template>
|
|
||||||
<v-card>
|
|
||||||
<v-card-text>note : {{ item.note }}</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-expansion-panel-content>
|
|
||||||
</v-expansion-panel>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</v-layout>
|
|
||||||
</v-layout>
|
</v-layout>
|
||||||
|
|
||||||
<v-layout row wrap align-center justify-center style="text-align:center">
|
<v-layout row wrap align-center justify-center style="text-align:center">
|
||||||
<v-flex class xs12 md12 sm12 >
|
<v-flex class xs12 md12 sm12>
|
||||||
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addPackage()">
|
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black" @click="addPackage()">
|
||||||
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
<v-icon class="black--text">keyboard_arrow_left</v-icon>
|
||||||
<span class="black--text">Back</span>
|
<span class="black--text">Back</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
<v-btn class="WM-CyanBlueGradient-BG" @click="print" style="padding:10px 60px">
|
||||||
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
<v-icon class="white--text mr-2 caption">fas fa-print</v-icon>
|
||||||
<span class="white--text">Print</span>
|
<span class="white--text">Print</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -91,43 +120,45 @@
|
|||||||
</v-btn>
|
</v-btn>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
|
|
||||||
</material-card>
|
</material-card>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { urls } from "@show/config/urls";
|
import {urls} from "@show/config/urls";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
data : {},
|
data: {},
|
||||||
barcodeimg : '',
|
barcodeimg: '',
|
||||||
QRCodeimg : '',
|
QRCodeimg: '',
|
||||||
MedicalCenter : ''
|
MedicalCenter: ''
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
async load(id) {
|
async load(id) {
|
||||||
const result = await axios.get(urls.showPackage(id));
|
const result = await axios.get(urls.showPackage(id));
|
||||||
|
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
this.data = result.data.data;
|
this.data = result.data.data;
|
||||||
this.generateBarcode(this.data.id);
|
if (this.data) {
|
||||||
this.MedicalCenter = this.data.user.medical_center.name;
|
this.generateBarcode(this.data.id);
|
||||||
}
|
this.MedicalCenter = this.data.user.medical_center.name;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async generateBarcode(packageId) {
|
async generateBarcode(packageId) {
|
||||||
const result = await axios.post(urls.Barcode(packageId, 'Package'));
|
const result = await axios.post(urls.Barcode(packageId, 'Package'));
|
||||||
if (result && result.status == 200) {
|
if (result && result.status == 200) {
|
||||||
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
||||||
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editPackage(packageId){
|
editPackage(packageId) {
|
||||||
window.location.href = '/packages/'+packageId+'/edit';
|
window.location.href = '/packages/' + packageId + '/edit';
|
||||||
},
|
},
|
||||||
addPackage(){
|
addPackage() {
|
||||||
window.location.href = '/add-package';
|
window.location.href = '/add-package';
|
||||||
},
|
},
|
||||||
print() {
|
print() {
|
||||||
@@ -148,15 +179,7 @@ export default {
|
|||||||
"left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0"
|
"left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0"
|
||||||
);
|
);
|
||||||
|
|
||||||
WinPrint.document.write(`<!DOCTYPE html>
|
WinPrint.document.write(`<!DOCTYPE html><html><head>${stylesHtml} </head> <body>${prtHtml}</body></html>`);
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
${stylesHtml}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
${prtHtml}
|
|
||||||
</body>
|
|
||||||
</html>`);
|
|
||||||
|
|
||||||
WinPrint.document.close();
|
WinPrint.document.close();
|
||||||
WinPrint.focus();
|
WinPrint.focus();
|
||||||
@@ -166,9 +189,30 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.$route.params.package) {
|
if (this.$route.params.package) {
|
||||||
this.load(this.$route.params.package);
|
this.load(this.$route.params.package);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.barcode-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 290px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-counter {
|
||||||
|
font-size: 44px;
|
||||||
|
opacity: .3;
|
||||||
|
font-family: 'Montserrat-Bold';
|
||||||
|
line-height: 44px;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
color: #b7b7b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub-text {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,141 +1,111 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<v-container grid-list-xs>
|
<v-container grid-list-xs>
|
||||||
<material-card color="black" title="Show Test Result" id="printMe">
|
<material-card color="black" title="Show Test Result" id="printMe">
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
<v-layout align-left justify-left wrap class="my-3">
|
||||||
<h3 class="ml-3 CSSD-font">Test Type : {{ TestType }}</h3>
|
|
||||||
|
<h3 class="ml-4 CSSD-font" style="font-size: 18px!important;">
|
||||||
|
<span class="WM-Font-16">Test Type :</span>
|
||||||
|
<span class="font-weight-bold">{{ TestType }}</span>
|
||||||
|
</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light" />
|
<hr class="v-divider theme--light"/>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
<v-layout row wrap class="ml-4">
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">{{ data.device_label || 'AutoclaveID' }} :</span>
|
<span class="title CSSD-font">{{ data.device_label || 'AutoclaveID' }} :</span>
|
||||||
<span
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
class="headline ml-2 CSSD-font"
|
{{ data.device_id }}
|
||||||
style="letter-spacing:0 !important"
|
</span>
|
||||||
>{{ data.device_id }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md12 sm12>
|
|
||||||
<div class>
|
<v-flex xs12 sm12 class="py-1">
|
||||||
<span class="title CSSD-font">Result :</span>
|
<span class="subtitle-1">Result :</span>
|
||||||
<span v-if="data.result === 'Reject'" class="NotVerified">
|
<v-icon size="20"
|
||||||
<v-icon class="caption fa fa-times NotVerified"></v-icon>
|
:class="['caption fa ml-2', data.result == 'Reject'?'NotVerified':( data.result == 'Accept'?'Verified':'')]">
|
||||||
|
{{ data.result == 'Reject' ? 'fa-times' : (data.result == 'Accept' ? 'fa-check' : '') }}
|
||||||
|
</v-icon>
|
||||||
|
<span class="headline ml-1 CSSD-font" style="letter-spacing:0 !important">
|
||||||
|
{{ data.result }}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="data.result === 'Accept'" class="">
|
|
||||||
<v-icon class="caption fa fa-check Verified"></v-icon>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="headline ml-1 CSSD-font"
|
|
||||||
style="letter-spacing:0 !important"
|
|
||||||
>{{ data.result }}</span>
|
|
||||||
</div>
|
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">verify :</span>
|
<span class="title CSSD-font">verify :</span>
|
||||||
<span v-if="data.verified === 'NotVerified'" class="NotVerified">
|
<v-icon size="20"
|
||||||
<v-icon class="caption fa fa-times NotVerified"></v-icon>
|
:class="['caption fa ml-2', data.verified == 'NotVerified'?'NotVerified':(data.verified == 'Verified'? 'Verified' : '')]">
|
||||||
|
{{ data.verified == 'NotVerified' ? 'fa-times' :(data.verified == 'Verified' ? 'fa-check':'') }}
|
||||||
|
</v-icon>
|
||||||
|
<span class="headline ml-1" style="letter-spacing:0 !important">
|
||||||
|
{{ data.verified }}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="data.verified === 'Verified'" class="">
|
|
||||||
<v-icon class="caption fa fa-check Verified"></v-icon>
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="headline ml-1"
|
|
||||||
style="letter-spacing:0 !important"
|
|
||||||
>{{ data.verified }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Register User :</span>
|
<span class="title CSSD-font">Register User :</span>
|
||||||
<span
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
class="headline ml-2 CSSD-font"
|
{{ User }}
|
||||||
style="letter-spacing:0 !important"
|
</span>
|
||||||
>{{ User }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md12 sm12>
|
<v-flex xs12 md12 sm12>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Date :</span>
|
<span class="title CSSD-font">Date :</span>
|
||||||
<span
|
<span class="headline ml-2" style="letter-spacing:0 !important">
|
||||||
class="headline ml-2"
|
{{ data.created_at }}
|
||||||
style="letter-spacing:0 !important"
|
</span>
|
||||||
>{{ data.created_at }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md6 sm12>
|
<v-flex xs12 md6 sm12>
|
||||||
<div class>
|
<div class>
|
||||||
<span class="title CSSD-font">Medical Center :</span>
|
<span class="title CSSD-font">Medical Center :</span>
|
||||||
<span
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
class="headline ml-2 CSSD-font"
|
{{ MedicalCenter }}
|
||||||
style="letter-spacing:0 !important"
|
</span>
|
||||||
>{{ MedicalCenter }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
<v-layout align-left justify-left wrap class="my-3">
|
||||||
<h3 class="ml-3 CSSD-font">Special Info</h3>
|
<h3 class="ml-3 CSSD-font">Special Info</h3>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<hr class="v-divider theme--light" />
|
<hr class="v-divider theme--light"/>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-layout row wrap class="ml-4">
|
<v-layout row wrap class="ml-4">
|
||||||
<template v-if="data.inputs">
|
<template v-if="data.inputs">
|
||||||
<v-flex
|
<v-flex xs12 md12 sm12 v-for="(inputData, keyInputs) in data.inputs" :key="keyInputs">
|
||||||
xs12
|
<span class="title">{{ keyInputs }} :</span>
|
||||||
md12
|
<span class="headline ml-2 CSSD-font" style="letter-spacing:0 !important">
|
||||||
sm12
|
{{ inputData }}
|
||||||
v-for="(inputData, keyInputs) in data.inputs"
|
</span>
|
||||||
:key="keyInputs"
|
|
||||||
>
|
|
||||||
<span class="title">{{keyInputs}} :</span>
|
|
||||||
<span
|
|
||||||
class="headline ml-2 CSSD-font"
|
|
||||||
style="letter-spacing:0 !important"
|
|
||||||
>{{inputData}}</span>
|
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="data.options">
|
<template v-if="data.options">
|
||||||
<v-flex
|
<v-flex xs12 md12 sm12 v-for="(optionData, keyOptions) in data.options" :key="keyOptions">
|
||||||
xs12
|
<span class="title CSSD-font">{{ keyOptions }} :</span>
|
||||||
md12
|
<span style="letter-spacing:0 !important" class="headline ml-2 CSSD-font"
|
||||||
sm12
|
v-for="(data, dataKey) in optionData" :key="dataKey">
|
||||||
v-for="(optionData, keyOptions) in data.options"
|
{{ data }},
|
||||||
:key="keyOptions"
|
</span>
|
||||||
>
|
|
||||||
<span class="title CSSD-font">{{keyOptions}} :</span>
|
|
||||||
<span
|
|
||||||
style="letter-spacing:0 !important"
|
|
||||||
class="headline ml-2 CSSD-font"
|
|
||||||
v-for="(data, dataKey) in optionData"
|
|
||||||
:key="dataKey"
|
|
||||||
>{{data}},</span>
|
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="data.children">
|
<template v-if="data.children">
|
||||||
<v-flex class="mt-4 pb-4" style="border-left:3px solid #32c5d2;border-bottom:1px solid #ddd"
|
<v-flex class="mt-4 pb-4" style="border-left:3px solid #32c5d2;border-bottom:1px solid #ddd"
|
||||||
xs12
|
xs12 md12 sm12 v-for="(formData, keyForm) in data.children" :key="keyForm">
|
||||||
md12
|
<h3 class="ml-3 CSSD-font">{{ keyForm }}</h3>
|
||||||
sm12
|
|
||||||
v-for="(formData, keyForm) in data.children"
|
|
||||||
:key="keyForm"
|
|
||||||
>
|
|
||||||
<h3 class="ml-3 CSSD-font">{{keyForm}}</h3>
|
|
||||||
<div v-for="(childData, keyChild) in formData" :key="keyChild">
|
<div v-for="(childData, keyChild) in formData" :key="keyChild">
|
||||||
<div class="ml-4">
|
<div class="ml-4">
|
||||||
<span class="title CSSD-font">{{keyChild}} :</span>
|
<span class="title CSSD-font">{{ keyChild }} :</span>
|
||||||
<template v-if="Array.isArray(childData)">
|
<template v-if="Array.isArray(childData)">
|
||||||
<span
|
<span style="letter-spacing:0 !important" class="headline ml-2 CSSD-font"
|
||||||
style="letter-spacing:0 !important"
|
v-for="(data, dataKey) in childData" :key="dataKey">
|
||||||
class="headline ml-2 CSSD-font"
|
{{ data }},
|
||||||
v-for="(data, dataKey) in childData"
|
</span>
|
||||||
:key="dataKey"
|
|
||||||
>{{data}},</span>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span class="headline ml-2 CSSD-font">{{childData}}</span>
|
<span class="headline ml-2 CSSD-font">{{ childData }}</span>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -143,71 +113,116 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout align-left justify-left wrap class="px-5 my-3">
|
|
||||||
<h3 class="ml-3 CSSD-font">Image</h3>
|
|
||||||
<v-flex xs12>
|
|
||||||
<hr class="v-divider theme--light" />
|
|
||||||
</v-flex>
|
|
||||||
<v-layout row wrap class="ml-4">
|
|
||||||
<v-flex xs6 md2 sm2 v-for="(file, key) in data.files" :key="key">
|
|
||||||
<template v-if="file.file_type == 'document'">
|
|
||||||
<a target="_blank" :href="'/'+file.path"><v-icon class="mr-2 caption">fas fa-check</v-icon>{{ file.file_name }}</a>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-else>
|
<v-layout align-left justify-left wrap class="my-3">
|
||||||
<img :src="'/'+file.path" style="width: 100%" />
|
<v-layout align-left justify-left wrap class="my-3" v-if="data.media && data.media.length">
|
||||||
</template>
|
<h3 class="CSSD-font">Image</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light"/>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
|
<v-layout row wrap class="align-center">
|
||||||
|
<v-flex xs6 md2 sm2 v-for="(file, key) in data.media" :key="key">
|
||||||
|
<template v-if="file.file_type == 'document'">
|
||||||
|
<a target="_blank" :href="'/'+file.original_url">
|
||||||
|
<v-icon class="mr-2 caption">fas fa-check</v-icon>
|
||||||
|
{{ file.file_name }}
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<img :src="file.original_url" style="width: 100%" class="mx-2" @click="openLightbox(key)"/>
|
||||||
|
</template>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-layout>
|
||||||
|
<v-layout align-left justify-left wrap class="my-3">
|
||||||
|
<h3 class="ml-3 CSSD-font">Barcode And QRCode Image</h3>
|
||||||
|
<v-flex xs12>
|
||||||
|
<hr class="v-divider theme--light">
|
||||||
|
</v-flex>
|
||||||
|
<v-layout row wrap class="ml-4 align-center mt-2">
|
||||||
|
<v-flex xs12 md6 sm6 v-if="barcodeimg">
|
||||||
|
<img :src="barcodeimg" class="barcode-container" style="width: 100%;max-width: 300px;"><br/>
|
||||||
|
<span class="CSSD-font">Item ID : {{ data.id }}</span>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12 md6 sm6 v-if="QRCodeimg" class="WM-Align-C">
|
||||||
|
<img :src="QRCodeimg" class="WM-Width-150">
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout row wrap style="text-align:center">
|
<v-layout row wrap style="text-align:center">
|
||||||
<v-flex class xs12 md2 sm12>
|
<v-flex class xs12 md2 sm12>
|
||||||
<v-btn
|
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Gray" @click="print">
|
||||||
class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Gray"
|
|
||||||
@click="print"
|
|
||||||
>
|
|
||||||
<v-icon class="black--text mr-2 caption">fas fa-print</v-icon>
|
<v-icon class="black--text mr-2 caption">fas fa-print</v-icon>
|
||||||
<span class="black--text">Print</span>
|
<span class="black--text">Print</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</material-card>
|
</material-card>
|
||||||
|
<vue-image-lightbox
|
||||||
|
v-if="showLightbox"
|
||||||
|
:media="lightboxImages"
|
||||||
|
:index="lightboxIndex"
|
||||||
|
@close="showLightbox = false"
|
||||||
|
/>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from "vuex";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { urls } from "@show/config/urls";
|
import {urls} from "@show/config/urls";
|
||||||
|
import VueImageLightbox from 'vue-image-lightbox'
|
||||||
|
import 'vue-image-lightbox/dist/vue-image-lightbox.min.css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
data : {},
|
data: {},
|
||||||
TestType : '',
|
TestType: '',
|
||||||
MedicalCenter : '',
|
MedicalCenter: '',
|
||||||
User : ''
|
User: '',
|
||||||
|
QRCodeimg: '',
|
||||||
|
barcodeimg: '',
|
||||||
|
showLightbox: false,
|
||||||
|
lightboxIndex: 0,
|
||||||
|
lightboxImages: [],
|
||||||
}),
|
}),
|
||||||
|
components: {
|
||||||
|
VueImageLightbox,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
imagesOnly() {
|
||||||
|
return this.data.media && this.data.media.length ? this.data.media.filter(file => file.mime_type !== 'document') : [];
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async load(id) {
|
async load(id) {
|
||||||
const result = await axios.get(urls.showTestResult(id));
|
const result = await axios.get(urls.showTestResult(id));
|
||||||
|
|
||||||
if (result.status == 200) {
|
if (result.status == 200) {
|
||||||
this.data = result.data.data;
|
this.data = result.data.data;
|
||||||
this.TestType = result.data.data.test_type.name;
|
this.TestType = result.data.data.test_type.name;
|
||||||
this.MedicalCenter = result.data.data.user.medical_center.name;
|
this.MedicalCenter = result.data.data.user.medical_center.name;
|
||||||
this.User = this.data.user.name;
|
this.User = this.data.user.name;
|
||||||
}
|
if (this.data) {
|
||||||
},
|
this.generateBarcode(this.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async generateBarcode(item) {
|
||||||
|
const result = await axios.post(urls.Barcode(item.id, 'TestResult'));
|
||||||
|
if (result && result.status == 200) {
|
||||||
|
this.QRCodeimg = result.data.data.QRCode ? result.data.data.QRCode : null;
|
||||||
|
this.barcodeimg = result.data.data.Barcode ? result.data.data.Barcode : null;
|
||||||
|
}
|
||||||
|
},
|
||||||
print() {
|
print() {
|
||||||
const prtHtml = document.getElementById("printMe").innerHTML;
|
const prtHtml = document.getElementById("printMe").innerHTML;
|
||||||
|
|
||||||
// Get all stylesheets HTML
|
// Get all stylesheets HTML
|
||||||
let stylesHtml = "";
|
let stylesHtml = "";
|
||||||
for (const node of [
|
for (const node of [...document.querySelectorAll('link[rel="stylesheet"], style')])
|
||||||
...document.querySelectorAll('link[rel="stylesheet"], style')
|
{stylesHtml += node.outerHTML;}
|
||||||
]) {
|
|
||||||
stylesHtml += node.outerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open the print window
|
// Open the print window
|
||||||
const WinPrint = window.open(
|
const WinPrint = window.open(
|
||||||
@@ -216,26 +231,28 @@ export default {
|
|||||||
"left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0"
|
"left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0"
|
||||||
);
|
);
|
||||||
|
|
||||||
WinPrint.document.write(`<!DOCTYPE html>
|
WinPrint.document.write(`<!DOCTYPE html><html><head>${stylesHtml} </head><body>${prtHtml} </body></html>`);
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
${stylesHtml}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
${prtHtml}
|
|
||||||
</body>
|
|
||||||
</html>`);
|
|
||||||
|
|
||||||
WinPrint.document.close();
|
WinPrint.document.close();
|
||||||
WinPrint.focus();
|
WinPrint.focus();
|
||||||
WinPrint.print();
|
WinPrint.print();
|
||||||
WinPrint.close();
|
WinPrint.close();
|
||||||
|
},
|
||||||
|
openLightbox(index) {
|
||||||
|
this.lightboxIndex = index;
|
||||||
|
this.showLightbox = false;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.showLightbox = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.$route.params.id) {
|
if (this.$route.params.id) {
|
||||||
this.load(this.$route.params.id);
|
this.load(this.$route.params.id);
|
||||||
}
|
}
|
||||||
|
this.lightboxImages = this.imagesOnly && this.imagesOnly.length ? this.imagesOnly.map(file => ({
|
||||||
|
src: file.original_url,
|
||||||
|
thumb: file.original_url,
|
||||||
|
})) : [];
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+1
@@ -117,6 +117,7 @@ export default [
|
|||||||
view: 'TestResult/Show',
|
view: 'TestResult/Show',
|
||||||
meta: {
|
meta: {
|
||||||
public: true,
|
public: true,
|
||||||
|
title:'Show Test Result | CSSD Dashboard'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,12 +23,12 @@
|
|||||||
></v-autocomplete>
|
></v-autocomplete>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
|
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
|
||||||
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"></v-icon>
|
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
|
||||||
<v-text-field class="py-3" v-model="filter.sterilizer_id" label="Sterilizer ID" color="black"></v-text-field>
|
<v-text-field class="py-3" v-model="filter.sterilizer_id" label="Sterilizer ID" color="black"/>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
|
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
|
||||||
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"></v-icon>
|
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
|
||||||
<v-text-field class="py-3" v-model="filter.cycle_number" label="Cycle Number" color="black"></v-text-field>
|
<v-text-field class="py-3" v-model="filter.cycle_number" label="Cycle Number" color="black"/>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex xs12 md2 sm3>
|
<v-flex xs12 md2 sm3>
|
||||||
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px" @click="load()">
|
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px" @click="load()">
|
||||||
@@ -78,8 +78,7 @@
|
|||||||
<router-link
|
<router-link
|
||||||
class="LinkBtn"
|
class="LinkBtn"
|
||||||
v-if="$hasRole('Admin') || item.user_id == $store.state.user.id"
|
v-if="$hasRole('Admin') || item.user_id == $store.state.user.id"
|
||||||
:to="{name: 'EditLabel', params: {label: item.id}}"
|
:to="{name: 'EditLabel', params: {label: item.id}}">
|
||||||
>
|
|
||||||
<v-btn v-bind="attrs" v-on="on" color="orange" class="mr-2">
|
<v-btn v-bind="attrs" v-on="on" color="orange" class="mr-2">
|
||||||
<v-icon class="white--text mr-1 caption">fas fa-pen</v-icon>
|
<v-icon class="white--text mr-1 caption">fas fa-pen</v-icon>
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
@@ -95,8 +94,7 @@
|
|||||||
color="pink"
|
color="pink"
|
||||||
class="WM-ActionButton mr-2"
|
class="WM-ActionButton mr-2"
|
||||||
@click="remove(item.id)"
|
@click="remove(item.id)"
|
||||||
v-if="$hasRole('Admin') || item.user_id == $store.state.user.id"
|
v-if="$hasRole('Admin') || item.user_id == $store.state.user.id">
|
||||||
>
|
|
||||||
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
|
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
|
||||||
<span>Remove</span>
|
<span>Remove</span>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -119,7 +117,7 @@
|
|||||||
</v-layout>
|
</v-layout>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<div class="text-xs-center" v-if="lastPage > 1">
|
<div class="text-xs-center" v-if="lastPage > 1">
|
||||||
<v-pagination color="black" v-model="currentPage" :length="lastPage" :total-visible="6"></v-pagination>
|
<v-pagination color="black" v-model="currentPage" :length="lastPage" :total-visible="6"/>
|
||||||
</div>
|
</div>
|
||||||
<v-layout row wrap align-center justify-center class="mt-3">
|
<v-layout row wrap align-center justify-center class="mt-3">
|
||||||
<router-link to="/dashboard">
|
<router-link to="/dashboard">
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'reset_password' => "کد فعالسازی شما: :activation_code
|
||||||
|
لغو ۱۱",
|
||||||
|
];
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'reset_password' => "کد فعالسازی شما: :activation_code
|
||||||
|
لغو ۱۱",
|
||||||
|
];
|
||||||
+9
-2
@@ -31,11 +31,11 @@ Route::group(['namespace' => 'Api'], function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware('auth:api')->group(function () {
|
Route::middleware('auth:api')->group(function () {
|
||||||
Route::get('TestTypes/ListNames', [TestTypeController::class, 'listNames']);
|
Route::get('TestTypes/List', [TestTypeController::class, 'list']);
|
||||||
Route::post('/TestTypes/Barcode/{TestType}', [TestTypeController::class, 'generateBarcode']);
|
Route::post('/TestTypes/Barcode/{TestType}', [TestTypeController::class, 'generateBarcode']);
|
||||||
Route::resource('TestTypes', TestTypeController::class);
|
Route::resource('TestTypes', TestTypeController::class);
|
||||||
Route::resource('MedicalCenters', MedicalCenterController::class);
|
Route::resource('MedicalCenters', MedicalCenterController::class);
|
||||||
Route::post('/GetInputs', [TestTypeController::class, 'getInputs']);
|
Route::get('/GetInputs/{idOrCode}', [TestTypeController::class, 'getInputs']); // Route::post('/GetInputs', [TestTypeController::class, 'getInputs']) این بود قبلا
|
||||||
|
|
||||||
Route::get('/GetInfo', [UserController::class, 'getInfo']);
|
Route::get('/GetInfo', [UserController::class, 'getInfo']);
|
||||||
Route::get('Users/MedicalCenter/{MedicalCenter}', [UserController::class, 'getByMedicalCenter']);
|
Route::get('Users/MedicalCenter/{MedicalCenter}', [UserController::class, 'getByMedicalCenter']);
|
||||||
@@ -90,8 +90,15 @@ Route::middleware('auth:api')->group(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/show-item/{Item}',[ItemController::class, 'show'])->middleware('guest');
|
||||||
|
Route::get('/show-item/udi/{udi}',[ItemController::class, 'showUdi'])->middleware('guest');
|
||||||
|
Route::get('/show-package/{Package}',[PackageController::class, 'show'])->middleware('guest');
|
||||||
Route::post('/BarCode/{Code}/{Type?}', [BarCodeController::class, 'generateBarcode']);
|
Route::post('/BarCode/{Code}/{Type?}', [BarCodeController::class, 'generateBarcode']);
|
||||||
Route::post('Package/Barcode/{Code}', [BarCodeController::class, 'generatePackageBarcode']);
|
Route::post('Package/Barcode/{Code}', [BarCodeController::class, 'generatePackageBarcode']);
|
||||||
Route::post('Package/QRCode/{Package}', [BarCodeController::class, 'generatePackageQRCode']);
|
Route::post('Package/QRCode/{Package}', [BarCodeController::class, 'generatePackageQRCode']);
|
||||||
|
|
||||||
Route::get('TestResults/{id}', [TestResultController::class, 'show']);
|
Route::get('TestResults/{id}', [TestResultController::class, 'show']);
|
||||||
|
|
||||||
|
Route::get('smstesting',function(){
|
||||||
|
dd(env('SMS_WEBSERVICE', ''),env('SMS_USERNAME', ''),env('SMS_PASSWORD', ''),env('SMS_FROM_NUMBER', ''));
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user