Merge branch 'develop' into 'main'
IMPORTANT: upgraded framework. refactored to make things work. See merge request witelgroup/rms_v2!19
This commit is contained in:
60
.env.example
Normal file
60
.env.example
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=false
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=
|
||||||
|
DB_USERNAME=
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_DRIVER=smtp
|
||||||
|
MAIL_HOST=smtp.mailtrap.io
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
PUSHER_APP_KEY=
|
||||||
|
PUSHER_APP_SECRET=
|
||||||
|
PUSHER_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
|
|
||||||
|
|
||||||
|
PAYMENT_USERNAME=
|
||||||
|
PAYMENT_PASSWORD=
|
||||||
|
PAYMENT_LINK=
|
||||||
|
|
||||||
|
RMS_VERSION=3.0
|
||||||
|
RMS_CTO_PHONE_NUMBER=
|
||||||
|
|
||||||
|
TELESCOPE_RESPONSE_SIZE_LIMIT=128
|
||||||
|
|
||||||
|
DEBUGBAR_ENABLED=false
|
||||||
|
|
||||||
|
IS_DEVELOPMENT_ENV=
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@
|
|||||||
.env
|
.env
|
||||||
.env.backup
|
.env.backup
|
||||||
.env.production
|
.env.production
|
||||||
|
.env.testing
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
Homestead.json
|
Homestead.json
|
||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
|
|||||||
58
Dockerfile
Normal file
58
Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
FROM alpine:3.18
|
||||||
|
|
||||||
|
RUN apk update && apk add --no-cache\
|
||||||
|
bash \
|
||||||
|
wget \
|
||||||
|
curl \
|
||||||
|
nano \
|
||||||
|
unzip \
|
||||||
|
libzip-dev \
|
||||||
|
libxml2 \
|
||||||
|
libxml2-dev \
|
||||||
|
git \
|
||||||
|
zlib-dev \
|
||||||
|
libpng-dev \
|
||||||
|
php81 \
|
||||||
|
php81-common \
|
||||||
|
php81-fpm \
|
||||||
|
php81-pdo \
|
||||||
|
php81-opcache \
|
||||||
|
php81-soap \
|
||||||
|
php81-zip \
|
||||||
|
php81-phar \
|
||||||
|
php81-iconv \
|
||||||
|
php81-cli \
|
||||||
|
php81-curl \
|
||||||
|
php81-openssl \
|
||||||
|
php81-mbstring \
|
||||||
|
php81-tokenizer \
|
||||||
|
php81-fileinfo \
|
||||||
|
php81-json \
|
||||||
|
php81-xml \
|
||||||
|
php81-xmlwriter \
|
||||||
|
php81-xmlreader \
|
||||||
|
php81-simplexml \
|
||||||
|
php81-dom \
|
||||||
|
php81-pdo_mysql \
|
||||||
|
php81-pdo_pgsql \
|
||||||
|
php81-pdo_sqlite \
|
||||||
|
php81-tokenizer \
|
||||||
|
php81-pecl-redis \
|
||||||
|
php81-gd
|
||||||
|
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
|
ARG MOUNT_PATH
|
||||||
|
|
||||||
|
COPY . /var/www/app
|
||||||
|
|
||||||
|
WORKDIR /var/www/app
|
||||||
|
|
||||||
|
CMD composer install;\
|
||||||
|
php artisan key:generate;\
|
||||||
|
# php artisan migrate ;\
|
||||||
|
# php artisan db:seed;\
|
||||||
|
# php artisan storege:link;\
|
||||||
|
php artisan serve --host=0.0.0.0
|
||||||
@@ -35,7 +35,7 @@ class Cities implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
return $query->where('province_id', $province);
|
return $query->where('province_id', $province);
|
||||||
})->get() as $item) {
|
})->get() as $item) {
|
||||||
$array[$item->province_id]['city'][$item->id]['name']= $item->name_fa;
|
$array[$item->province_id]['city'][$item->id]['name']= $item->name_fa;
|
||||||
$array[$item->province_id]['province_name']= $item ->province->name_fa;
|
$array[$item->province_id]['province_name']= $item->province->name_fa;
|
||||||
|
|
||||||
$array[$item->province_id]['city'][$item->id]['data']['MarematRooyeCount']= 0;
|
$array[$item->province_id]['city'][$item->id]['data']['MarematRooyeCount']= 0;
|
||||||
$array[$item->province_id]['city'][$item->id]['data']['PaksaziCount']= 0;
|
$array[$item->province_id]['city'][$item->id]['data']['PaksaziCount']= 0;
|
||||||
@@ -98,9 +98,9 @@ class Cities implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
|
|
||||||
$query .= " group by edarat_id order by province_id ASC;";
|
$query .= " group by edarat_id order by province_id ASC;";
|
||||||
|
|
||||||
$item_data = DB::select(DB::raw($query));
|
$item_data = DB::select($query);
|
||||||
|
|
||||||
|
$array = array();
|
||||||
foreach ($item_data as $key => $value) {
|
foreach ($item_data as $key => $value) {
|
||||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['MarematRooyeCount']= $value->MarematRooyeCount;
|
$array[$value->province_id]['city'][$value->edarat_id]['data']['MarematRooyeCount']= $value->MarematRooyeCount;
|
||||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['PaksaziCount']= $value->PaksaziCount;
|
$array[$value->province_id]['city'][$value->edarat_id]['data']['PaksaziCount']= $value->PaksaziCount;
|
||||||
@@ -165,7 +165,8 @@ class Cities implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
return view('excel.CurrentActivities.Report1-City', [
|
return view('excel.CurrentActivities.Report1-City', [
|
||||||
'roads' => $array,
|
'roads' => $array,
|
||||||
'fromFa' => $fromDate,
|
'fromFa' => $fromDate,
|
||||||
'toFa' => $toDate
|
'toFa' => $toDate,
|
||||||
|
'has_province_filter' => $province ? true : false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class Provinces implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
|
|
||||||
$query .= " group by province_id;";
|
$query .= " group by province_id;";
|
||||||
|
|
||||||
$item_data = DB::select(DB::raw($query));
|
$item_data = DB::select($query);
|
||||||
|
|
||||||
$sum['MarematRooyeCount'] = 0;
|
$sum['MarematRooyeCount'] = 0;
|
||||||
$sum['PaksaziCount'] = 0;
|
$sum['PaksaziCount'] = 0;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class Cities implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
|
|
||||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$temp =[];
|
$temp =[];
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
|
|
||||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
|
|
||||||
$countryQuery = "SELECT
|
$countryQuery = "SELECT
|
||||||
@@ -121,7 +121,7 @@ class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
|
|
||||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||||
|
|
||||||
$country = DB::select(DB::raw($countryQuery));
|
$country = DB::select($countryQuery);
|
||||||
|
|
||||||
|
|
||||||
return view('excel.CurrentActivities.Report2-Province', [
|
return view('excel.CurrentActivities.Report2-Province', [
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 101 THEN operation_type_amount3
|
WHEN operation_type_id3 = 101 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 101 THEN operation_type_amount4
|
WHEN operation_type_id4 = 101 THEN operation_type_amount4
|
||||||
END)) AS AsphaltGarmDoing,
|
END)) AS AsphaltGarmDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 101 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 101 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 101 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 101 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 101 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 101 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 101 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 101 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS AsphaltGarmDone,
|
END)) AS AsphaltGarmDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 102 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 102 THEN operation_type_amount1
|
||||||
@@ -85,10 +85,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 102 THEN operation_type_amount3
|
WHEN operation_type_id3 = 102 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 102 THEN operation_type_amount4
|
WHEN operation_type_id4 = 102 THEN operation_type_amount4
|
||||||
END)) AS MaseAsphaltDoing,
|
END)) AS MaseAsphaltDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 102 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 102 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 102 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 102 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 102 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 102 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 102 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 102 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS MaseAsphaltDone,
|
END)) AS MaseAsphaltDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 103 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 103 THEN operation_type_amount1
|
||||||
@@ -96,10 +96,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 103 THEN operation_type_amount3
|
WHEN operation_type_id3 = 103 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 103 THEN operation_type_amount4
|
WHEN operation_type_id4 = 103 THEN operation_type_amount4
|
||||||
END)) AS BazyaftSardGarmDoing,
|
END)) AS BazyaftSardGarmDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 103 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 103 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 103 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 103 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 103 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 103 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 103 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 103 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS BazyaftSardGarmDone,
|
END)) AS BazyaftSardGarmDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 104 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 104 THEN operation_type_amount1
|
||||||
@@ -107,10 +107,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 104 THEN operation_type_amount3
|
WHEN operation_type_id3 = 104 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 104 THEN operation_type_amount4
|
WHEN operation_type_id4 = 104 THEN operation_type_amount4
|
||||||
END)) AS mirosurfacingDoing,
|
END)) AS mirosurfacingDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 104 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 104 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 104 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 104 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 104 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 104 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 104 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 104 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS mirosurfacingDone,
|
END)) AS mirosurfacingDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 105 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 105 THEN operation_type_amount1
|
||||||
@@ -118,10 +118,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 105 THEN operation_type_amount3
|
WHEN operation_type_id3 = 105 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 105 THEN operation_type_amount4
|
WHEN operation_type_id4 = 105 THEN operation_type_amount4
|
||||||
END)) AS ChipSailDoing,
|
END)) AS ChipSailDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 105 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 105 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 105 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 105 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 105 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 105 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 105 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 105 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS ChipSailDone,
|
END)) AS ChipSailDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 106 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 106 THEN operation_type_amount1
|
||||||
@@ -129,10 +129,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 106 THEN operation_type_amount3
|
WHEN operation_type_id3 = 106 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 106 THEN operation_type_amount4
|
WHEN operation_type_id4 = 106 THEN operation_type_amount4
|
||||||
END)) AS SlarySaildDoing,
|
END)) AS SlarySaildDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 106 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 106 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 106 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 106 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 106 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 106 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 106 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 106 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS SlarySaildDone,
|
END)) AS SlarySaildDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 107 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 107 THEN operation_type_amount1
|
||||||
@@ -140,10 +140,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 107 THEN operation_type_amount3
|
WHEN operation_type_id3 = 107 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 107 THEN operation_type_amount4
|
WHEN operation_type_id4 = 107 THEN operation_type_amount4
|
||||||
END)) AS ScrubSailDoing,
|
END)) AS ScrubSailDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 107 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 107 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 107 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 107 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 107 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 107 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 107 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 107 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS ScrubSailDone,
|
END)) AS ScrubSailDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 108 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 108 THEN operation_type_amount1
|
||||||
@@ -151,10 +151,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 108 THEN operation_type_amount3
|
WHEN operation_type_id3 = 108 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 108 THEN operation_type_amount4
|
WHEN operation_type_id4 = 108 THEN operation_type_amount4
|
||||||
END)) AS FogSailDoing,
|
END)) AS FogSailDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 108 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 108 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 108 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 108 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 108 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 108 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 108 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 108 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS FogSailDone,
|
END)) AS FogSailDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 109 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 109 THEN operation_type_amount1
|
||||||
@@ -162,10 +162,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 109 THEN operation_type_amount3
|
WHEN operation_type_id3 = 109 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 109 THEN operation_type_amount4
|
WHEN operation_type_id4 = 109 THEN operation_type_amount4
|
||||||
END)) AS SailKatDoing,
|
END)) AS SailKatDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 109 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 109 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 109 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 109 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 109 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 109 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 109 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 109 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS SailKatDone,
|
END)) AS SailKatDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 110 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 110 THEN operation_type_amount1
|
||||||
@@ -173,10 +173,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 110 THEN operation_type_amount3
|
WHEN operation_type_id3 = 110 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 110 THEN operation_type_amount4
|
WHEN operation_type_id4 = 110 THEN operation_type_amount4
|
||||||
END)) AS KipSailDoing,
|
END)) AS KipSailDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 110 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 110 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 110 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 110 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 110 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 110 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 110 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 110 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS KipSailDone,
|
END)) AS KipSailDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 111 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 111 THEN operation_type_amount1
|
||||||
@@ -184,10 +184,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 111 THEN operation_type_amount3
|
WHEN operation_type_id3 = 111 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 111 THEN operation_type_amount4
|
WHEN operation_type_id4 = 111 THEN operation_type_amount4
|
||||||
END)) AS AsphaltRedmixDoing,
|
END)) AS AsphaltRedmixDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 111 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 111 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 111 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 111 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 111 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 111 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 111 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 111 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS AsphaltRedmixDone,
|
END)) AS AsphaltRedmixDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 112 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 112 THEN operation_type_amount1
|
||||||
@@ -195,10 +195,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 112 THEN operation_type_amount3
|
WHEN operation_type_id3 = 112 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 112 THEN operation_type_amount4
|
WHEN operation_type_id4 = 112 THEN operation_type_amount4
|
||||||
END)) AS LakegiriDoing,
|
END)) AS LakegiriDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 112 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 112 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 112 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 112 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 112 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 112 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 112 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 112 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS LakegiriDone,
|
END)) AS LakegiriDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 113 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 113 THEN operation_type_amount1
|
||||||
@@ -206,10 +206,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 113 THEN operation_type_amount3
|
WHEN operation_type_id3 = 113 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 113 THEN operation_type_amount4
|
WHEN operation_type_id4 = 113 THEN operation_type_amount4
|
||||||
END)) AS DarzgiriDoing,
|
END)) AS DarzgiriDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 113 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 113 THEN (CAST(operation_type_amount1 AS signed) * CAST(operation_type_progress1 AS signed))/100
|
||||||
WHEN operation_type_id2 = 113 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 113 THEN (CAST(operation_type_amount2 AS signed) * CAST(operation_type_progress2 AS signed))/100
|
||||||
WHEN operation_type_id3 = 113 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 113 THEN (CAST(operation_type_amount3 AS signed) * CAST(operation_type_progress3 AS signed))/100
|
||||||
WHEN operation_type_id4 = 113 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 113 THEN (CAST(operation_type_amount4 AS signed) * CAST(operation_type_progress4 AS signed))/100
|
||||||
END)) AS DarzgiriDone,
|
END)) AS DarzgiriDone,
|
||||||
COUNT(*) AS countAll
|
COUNT(*) AS countAll
|
||||||
FROM contract_subitems
|
FROM contract_subitems
|
||||||
@@ -223,7 +223,7 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'AsphaltGarmDoingSum' => 0,
|
'AsphaltGarmDoingSum' => 0,
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ class summaryAcidentPerformanceCity implements FromView, ShouldAutoSize, WithEve
|
|||||||
$query .= " GROUP BY city_id
|
$query .= " GROUP BY city_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$array[$value->city_id] = [
|
$array[$value->city_id] = [
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class summaryAcidentPerformanceProject implements FromView, ShouldAutoSize, With
|
|||||||
$query .= " GROUP BY unique_code
|
$query .= " GROUP BY unique_code
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
|
|
||||||
return view('excel.Maintanance.summaryAccidentPerformanceProject', [
|
return view('excel.Maintanance.summaryAccidentPerformanceProject', [
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ class summaryAcidentPerformanceProvince implements FromView, ShouldAutoSize, Wit
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'AsphaltGarmDone' => 0,
|
'AsphaltGarmDone' => 0,
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
|
|
||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'TarizRahCount' => 0,
|
'TarizRahCount' => 0,
|
||||||
@@ -262,31 +262,31 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
foreach ($data as $value) {
|
foreach ($data as $value) {
|
||||||
$array[$value->province_id] = [
|
$array[$value->province_id] = [
|
||||||
'province_fa' => $value->province_fa,
|
'province_fa' => $value->province_fa,
|
||||||
'TarizRahCount' => $value->TarizRahCount ?? '-',
|
'TarizRahCount' => $value->TarizRahCount ?? 0,
|
||||||
'EslahGhosCount' => $value->EslahGhosCount ?? '-',
|
'EslahGhosCount' => $value->EslahGhosCount ?? 0,
|
||||||
'TaransheBardariCount' => $value->TaransheBardariCount ?? '-',
|
'TaransheBardariCount' => $value->TaransheBardariCount ?? 0,
|
||||||
'EhdasMeydanCount' => $value->EhdasMeydanCount ?? '-',
|
'EhdasMeydanCount' => $value->EhdasMeydanCount ?? 0,
|
||||||
'EhdasTaghatoCount' => $value->EhdasTaghatoCount ?? '-',
|
'EhdasTaghatoCount' => $value->EhdasTaghatoCount ?? 0,
|
||||||
'ImenSaziCount' => $value->ImenSaziCount ?? '-',
|
'ImenSaziCount' => $value->ImenSaziCount ?? 0,
|
||||||
'EslahVoroodiCount' => $value->EslahVoroodiCount ?? '-',
|
'EslahVoroodiCount' => $value->EslahVoroodiCount ?? 0,
|
||||||
'EhdasToonelCount' => $value->EhdasToonelCount ?? '-',
|
'EhdasToonelCount' => $value->EhdasToonelCount ?? 0,
|
||||||
'EhdasVariantCount' => $value->EhdasVariantCount ?? '-',
|
'EhdasVariantCount' => $value->EhdasVariantCount ?? 0,
|
||||||
'TarizAbnieFaniCount' => $value->TarizAbnieFaniCount ?? '-',
|
'TarizAbnieFaniCount' => $value->TarizAbnieFaniCount ?? 0,
|
||||||
'SakhtHaelCount' => $value->SakhtHaelCount ?? '-',
|
'SakhtHaelCount' => $value->SakhtHaelCount ?? 0,
|
||||||
'SayerCount' => $value->SakhtHaelCount ?? '-',
|
'SayerCount' => $value->SakhtHaelCount ?? 0,
|
||||||
'countAll' => $value->countAll ?? '-',
|
'countAll' => $value->countAll ?? 0,
|
||||||
'TarizRahAvg' => $value->TarizRahAvg ?? '-',
|
'TarizRahAvg' => $value->TarizRahAvg ?? 0,
|
||||||
'EslahGhosAvg' => $value->EslahGhosAvg ?? '-',
|
'EslahGhosAvg' => $value->EslahGhosAvg ?? 0,
|
||||||
'TaransheBardariAvg' => $value->TaransheBardariAvg ?? '-',
|
'TaransheBardariAvg' => $value->TaransheBardariAvg ?? 0,
|
||||||
'EhdasMeydanAvg' => $value->EhdasMeydanAvg ?? '-',
|
'EhdasMeydanAvg' => $value->EhdasMeydanAvg ?? 0,
|
||||||
'EhdasTaghatoAvg' => $value->EhdasTaghatoAvg ?? '-',
|
'EhdasTaghatoAvg' => $value->EhdasTaghatoAvg ?? 0,
|
||||||
'ImenSaziAvg' => $value->ImenSaziAvg ?? '-',
|
'ImenSaziAvg' => $value->ImenSaziAvg ?? 0,
|
||||||
'EslahVoroodiAvg' => $value->EslahVoroodiAvg ?? '-',
|
'EslahVoroodiAvg' => $value->EslahVoroodiAvg ?? 0,
|
||||||
'EhdasToonelAvg' => $value->EhdasToonelAvg ?? '-',
|
'EhdasToonelAvg' => $value->EhdasToonelAvg ?? 0,
|
||||||
'EhdasVariantAvg' => $value->EhdasVariantAvg ?? '-',
|
'EhdasVariantAvg' => $value->EhdasVariantAvg ?? 0,
|
||||||
'TarizAbnieFaniAvg' => $value->TarizAbnieFaniAvg ?? '-',
|
'TarizAbnieFaniAvg' => $value->TarizAbnieFaniAvg ?? 0,
|
||||||
'SakhtHaelAvg' => $value->SakhtHaelAvg ?? '-',
|
'SakhtHaelAvg' => $value->SakhtHaelAvg ?? 0,
|
||||||
'SayerAvg' => $value->SakhtHaelAvg ?? '-',
|
'SayerAvg' => $value->SakhtHaelAvg ?? 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
$sum['TarizRahCount'] += $value->TarizRahCount;
|
$sum['TarizRahCount'] += $value->TarizRahCount;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'BotoniDoing' => 0,
|
'BotoniDoing' => 0,
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ class RoadUpgradeSafeties implements FromView, ShouldAutoSize, WithEvents, WithD
|
|||||||
'RoshanayiNoghteyi' => $road->operation_type_id1 == '304' ? $road->operation_type_amount1 :
|
'RoshanayiNoghteyi' => $road->operation_type_id1 == '304' ? $road->operation_type_amount1 :
|
||||||
($road->operation_type_id2 == '304' ? $road->operation_type_amount2 :
|
($road->operation_type_id2 == '304' ? $road->operation_type_amount2 :
|
||||||
($road->operation_type_id3 == '304' ? $road->operation_type_amount3 :
|
($road->operation_type_id3 == '304' ? $road->operation_type_amount3 :
|
||||||
($road->operation_type_id4 == '304' ? $road->operation_type_amount4 : "-"))),
|
($road->operation_type_id4 == '304' ? $road->operation_type_amount4 : 0))),
|
||||||
'AlaemImeni' => $road->operation_type_id1 == '305' ? $road->operation_type_amount1 :
|
'AlaemImeni' => $road->operation_type_id1 == '305' ? $road->operation_type_amount1 :
|
||||||
($road->operation_type_id2 == '305' ? $road->operation_type_amount2 :
|
($road->operation_type_id2 == '305' ? $road->operation_type_amount2 :
|
||||||
($road->operation_type_id3 == '305' ? $road->operation_type_amount3 :
|
($road->operation_type_id3 == '305' ? $road->operation_type_amount3 :
|
||||||
($road->operation_type_id4 == '305' ? $road->operation_type_amount4 : "-"))),
|
($road->operation_type_id4 == '305' ? $road->operation_type_amount4 : 0))),
|
||||||
'Khatkeshi' => $road->operation_type_id1 == '306' ? $road->operation_type_amount1 :
|
'Khatkeshi' => $road->operation_type_id1 == '306' ? $road->operation_type_amount1 :
|
||||||
($road->operation_type_id2 == '306' ? $road->operation_type_amount2 :
|
($road->operation_type_id2 == '306' ? $road->operation_type_amount2 :
|
||||||
($road->operation_type_id3 == '306' ? $road->operation_type_amount3 :
|
($road->operation_type_id3 == '306' ? $road->operation_type_amount3 :
|
||||||
@@ -101,11 +101,11 @@ class RoadUpgradeSafeties implements FromView, ShouldAutoSize, WithEvents, WithD
|
|||||||
'RoshanayiNoghteyi' => $road->operation_type_id1 == '304' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
'RoshanayiNoghteyi' => $road->operation_type_id1 == '304' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||||
($road->operation_type_id2 == '304' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
($road->operation_type_id2 == '304' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||||
($road->operation_type_id3 == '304' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
($road->operation_type_id3 == '304' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||||
($road->operation_type_id4 == '304' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
($road->operation_type_id4 == '304' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : 0))),
|
||||||
'AlaemImeni' => $road->operation_type_id1 == '305' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
'AlaemImeni' => $road->operation_type_id1 == '305' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||||
($road->operation_type_id2 == '305' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
($road->operation_type_id2 == '305' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||||
($road->operation_type_id3 == '305' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
($road->operation_type_id3 == '305' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||||
($road->operation_type_id4 == '305' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
($road->operation_type_id4 == '305' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : 0))),
|
||||||
'Khatkeshi' => $road->operation_type_id1 == '306' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
'Khatkeshi' => $road->operation_type_id1 == '306' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||||
($road->operation_type_id2 == '306' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
($road->operation_type_id2 == '306' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||||
($road->operation_type_id3 == '306' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
($road->operation_type_id3 == '306' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ class summaryAccidentPerformanceCity implements FromView, ShouldAutoSize, WithEv
|
|||||||
$query .= " GROUP BY city_id
|
$query .= " GROUP BY city_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$array[$value->city_id] = [
|
$array[$value->city_id] = [
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ class summaryAccidentPerformanceProject implements FromView, ShouldAutoSize, Wit
|
|||||||
$query .= " GROUP BY unique_code
|
$query .= " GROUP BY unique_code
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
return view('excel.Upgrade.summaryAccidentPerformanceProject', [
|
return view('excel.Upgrade.summaryAccidentPerformanceProject', [
|
||||||
'array' => $data,
|
'array' => $data,
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ class summaryAccidentPerformanceProvince implements FromView, ShouldAutoSize, Wi
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$provinces = \App\Models\Province::select('id', 'name_fa')
|
$provinces = \App\Models\Province::select('id', 'name_fa')
|
||||||
->when($province, function($query, $province) {
|
->when($province, function($query, $province) {
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'EhdasCount' => 0,
|
'EhdasCount' => 0,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class summaryAccidentPerformanceCity implements FromView, ShouldAutoSize, WithEv
|
|||||||
$array[$value->city_id] = [
|
$array[$value->city_id] = [
|
||||||
'province_fa' => $value->province_fa,
|
'province_fa' => $value->province_fa,
|
||||||
'city_fa' => $value->city_fa,
|
'city_fa' => $value->city_fa,
|
||||||
'avg' => '-',
|
'avg' => 0,
|
||||||
'count' => '-'
|
'count' => '-'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ class UserActivity implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
|||||||
ORDER BY cnt desc";
|
ORDER BY cnt desc";
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'activity_time' => $ids_list ? DB::select(DB::raw($temp_sql_for_activity_time))[0]->activity : null,
|
'activity_time' => $ids_list ? DB::select($temp_sql_for_activity_time)[0]->activity : null,
|
||||||
'average' => round(($ids_list ? DB::select(DB::raw($temp_sql_for_activity_time))[0]->activity : 0) / count($role->users()->get()),2) ,
|
'average' => round(($ids_list ? DB::select($temp_sql_for_activity_time)[0]->activity : 0) / count($role->users()->get()),2) ,
|
||||||
'activity_list' => $ids_list ? DB::select(DB::raw($temp_sql_for_activity_list)) : null,
|
'activity_list' => $ids_list ? DB::select($temp_sql_for_activity_list) : null,
|
||||||
'group_name' => $role->name_fa,
|
'group_name' => $role->name_fa,
|
||||||
'user_count' => count($role->users()->get()),
|
'user_count' => count($role->users()->get()),
|
||||||
'group_id' => $role->id
|
'group_id' => $role->id
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Exports\V2\Receipt\ReceiptTable;
|
namespace App\Exports\V2\Receipt\RecieptTable;
|
||||||
|
|
||||||
use App\Exports\V2\Receipt\ReceiptTable\Provinces;
|
use App\Exports\V2\Receipt\RecieptTable\Provinces;
|
||||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||||
use App\Exports\V2\Receipt\ReceiptTable\Cities;
|
use App\Exports\V2\Receipt\RecieptTable\Cities;
|
||||||
|
|
||||||
class AllSheets implements WithMultipleSheets
|
class AllSheets implements WithMultipleSheets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Exports\V2\Receipt\ReceiptTable;
|
namespace App\Exports\V2\Receipt\RecieptTable;
|
||||||
|
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Maatwebsite\Excel\Concerns\FromView;
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Exports\V2\Receipt\ReceiptTable;
|
namespace App\Exports\V2\Receipt\RecieptTable;
|
||||||
|
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Maatwebsite\Excel\Concerns\FromView;
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ class ReportComplaintsExport implements FromView, ShouldAutoSize, WithEvents, Wi
|
|||||||
$fromDate = $this->fromDate ? $this->fromDate . ' 00:00:00': null;
|
$fromDate = $this->fromDate ? $this->fromDate . ' 00:00:00': null;
|
||||||
$toDate = $this->toDate ? $this->toDate . ' 23:59:59': null;
|
$toDate = $this->toDate ? $this->toDate . ' 23:59:59': null;
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
if (auth()->user()->hasPermissionTo('show-fast-react')) {
|
if (auth()->user()->hasPermissionTo('show-fast-react')) {
|
||||||
$data = RoadObserved::leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
$data = RoadObserved::leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||||
->where('rms_status', "<>", 0)
|
->where('rms_status', "<>", 0)
|
||||||
@@ -101,6 +103,7 @@ class ReportComplaintsExport implements FromView, ShouldAutoSize, WithEvents, Wi
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('excel.V2.RoadObservation.report_complaints', [
|
return view('excel.V2.RoadObservation.report_complaints', [
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
'fromDate' => $fromDate,
|
'fromDate' => $fromDate,
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 601 THEN operation_type_amount3
|
WHEN operation_type_id3 = 601 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 601 THEN operation_type_amount4
|
WHEN operation_type_id4 = 601 THEN operation_type_amount4
|
||||||
END)) AS KhakiDoing,
|
END)) AS KhakiDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 601 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 601 THEN (cast(operation_type_amount1 as unsigned) * cast(operation_type_progress1 as unsigned))/100
|
||||||
WHEN operation_type_id2 = 601 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 601 THEN (cast(operation_type_amount2 as unsigned) * cast(operation_type_progress2 as unsigned))/100
|
||||||
WHEN operation_type_id3 = 601 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 601 THEN (cast(operation_type_amount3 as unsigned) * cast(operation_type_progress3 as unsigned))/100
|
||||||
WHEN operation_type_id4 = 601 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 601 THEN (cast(operation_type_amount4 as unsigned) * cast(operation_type_progress4 as unsigned))/100
|
||||||
END)) AS KhakiDone,
|
END)) AS KhakiDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 602 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 602 THEN operation_type_amount1
|
||||||
@@ -68,10 +68,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 602 THEN operation_type_amount3
|
WHEN operation_type_id3 = 602 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 602 THEN operation_type_amount4
|
WHEN operation_type_id4 = 602 THEN operation_type_amount4
|
||||||
END)) AS RosaziDoing,
|
END)) AS RosaziDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 602 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 602 THEN (cast(operation_type_amount1 as unsigned) * cast(operation_type_progress1 as unsigned))/100
|
||||||
WHEN operation_type_id2 = 602 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 602 THEN (cast(operation_type_amount2 as unsigned) * cast(operation_type_progress2 as unsigned))/100
|
||||||
WHEN operation_type_id3 = 602 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 602 THEN (cast(operation_type_amount3 as unsigned) * cast(operation_type_progress3 as unsigned))/100
|
||||||
WHEN operation_type_id4 = 602 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 602 THEN (cast(operation_type_amount4 as unsigned) * cast(operation_type_progress4 as unsigned))/100
|
||||||
END)) AS RosaziDone,
|
END)) AS RosaziDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 603 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 603 THEN operation_type_amount1
|
||||||
@@ -79,10 +79,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 603 THEN operation_type_amount3
|
WHEN operation_type_id3 = 603 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 603 THEN operation_type_amount4
|
WHEN operation_type_id4 = 603 THEN operation_type_amount4
|
||||||
END)) AS AbneyehDoing,
|
END)) AS AbneyehDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 603 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 603 THEN (cast(operation_type_amount1 as unsigned) * cast(operation_type_progress1 as unsigned))/100
|
||||||
WHEN operation_type_id2 = 603 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 603 THEN (cast(operation_type_amount2 as unsigned) * cast(operation_type_progress2 as unsigned))/100
|
||||||
WHEN operation_type_id3 = 603 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 603 THEN (cast(operation_type_amount3 as unsigned) * cast(operation_type_progress3 as unsigned))/100
|
||||||
WHEN operation_type_id4 = 603 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 603 THEN (cast(operation_type_amount4 as unsigned) * cast(operation_type_progress4 as unsigned))/100
|
||||||
END)) AS AbneyehDone,
|
END)) AS AbneyehDone,
|
||||||
|
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 604 THEN operation_type_amount1
|
ROUND(SUM(CASE WHEN operation_type_id1 = 604 THEN operation_type_amount1
|
||||||
@@ -90,10 +90,10 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
WHEN operation_type_id3 = 604 THEN operation_type_amount3
|
WHEN operation_type_id3 = 604 THEN operation_type_amount3
|
||||||
WHEN operation_type_id4 = 604 THEN operation_type_amount4
|
WHEN operation_type_id4 = 604 THEN operation_type_amount4
|
||||||
END)) AS AsphaltDoing,
|
END)) AS AsphaltDoing,
|
||||||
ROUND(SUM(CASE WHEN operation_type_id1 = 604 THEN (cast(operation_type_amount1 as int) * cast(operation_type_progress1 as int))/100
|
ROUND(SUM(CASE WHEN operation_type_id1 = 604 THEN (cast(operation_type_amount1 as unsigned) * cast(operation_type_progress1 as unsigned))/100
|
||||||
WHEN operation_type_id2 = 604 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
WHEN operation_type_id2 = 604 THEN (cast(operation_type_amount2 as unsigned) * cast(operation_type_progress2 as unsigned))/100
|
||||||
WHEN operation_type_id3 = 604 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
WHEN operation_type_id3 = 604 THEN (cast(operation_type_amount3 as unsigned) * cast(operation_type_progress3 as unsigned))/100
|
||||||
WHEN operation_type_id4 = 604 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
WHEN operation_type_id4 = 604 THEN (cast(operation_type_amount4 as unsigned) * cast(operation_type_progress4 as unsigned))/100
|
||||||
END)) AS AsphaltDone,
|
END)) AS AsphaltDone,
|
||||||
COUNT(*) AS countAll,
|
COUNT(*) AS countAll,
|
||||||
province_fa,
|
province_fa,
|
||||||
@@ -113,7 +113,7 @@ class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents,
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'KhakiDoing' => 0,
|
'KhakiDoing' => 0,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Village implements FromView, ShouldAutoSize, WithEvents, WithDrawings, Wit
|
|||||||
'Abnie' => $road->operation_type_id1 == '603' ? $road->operation_type_amount1 :
|
'Abnie' => $road->operation_type_id1 == '603' ? $road->operation_type_amount1 :
|
||||||
($road->operation_type_id2 == '603' ? $road->operation_type_amount2 :
|
($road->operation_type_id2 == '603' ? $road->operation_type_amount2 :
|
||||||
($road->operation_type_id3 == '603' ? $road->operation_type_amount3 :
|
($road->operation_type_id3 == '603' ? $road->operation_type_amount3 :
|
||||||
($road->operation_type_id4 == '603' ? $road->operation_type_amount4 : "-"))),
|
($road->operation_type_id4 == '603' ? $road->operation_type_amount4 : 0))),
|
||||||
|
|
||||||
'Asphalt' => $road->operation_type_id1 == '604' ? $road->operation_type_amount1 :
|
'Asphalt' => $road->operation_type_id1 == '604' ? $road->operation_type_amount1 :
|
||||||
($road->operation_type_id2 == '604' ? $road->operation_type_amount2 :
|
($road->operation_type_id2 == '604' ? $road->operation_type_amount2 :
|
||||||
@@ -82,7 +82,7 @@ class Village implements FromView, ShouldAutoSize, WithEvents, WithDrawings, Wit
|
|||||||
'Abnie' => $road->operation_type_id1 == '603' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
'Abnie' => $road->operation_type_id1 == '603' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||||
($road->operation_type_id2 == '603' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
($road->operation_type_id2 == '603' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||||
($road->operation_type_id3 == '603' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
($road->operation_type_id3 == '603' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||||
($road->operation_type_id4 == '603' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
($road->operation_type_id4 == '603' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : 0))),
|
||||||
|
|
||||||
'Asphalt' => $road->operation_type_id1 == '604' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
'Asphalt' => $road->operation_type_id1 == '604' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||||
($road->operation_type_id2 == '604' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
($road->operation_type_id2 == '604' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class summaryAcidentPerformanceCity implements FromView, ShouldAutoSize, WithEve
|
|||||||
$query .= " GROUP BY city_id
|
$query .= " GROUP BY city_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$array[$value->city_id] = [
|
$array[$value->city_id] = [
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class summaryAcidentPerformanceProject implements FromView, ShouldAutoSize, With
|
|||||||
$query .= " GROUP BY unique_code
|
$query .= " GROUP BY unique_code
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
return view('excel.Village.summaryAccidentPerformanceProject', [
|
return view('excel.Village.summaryAccidentPerformanceProject', [
|
||||||
'array' => $data,
|
'array' => $data,
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class summaryAcidentPerformanceProvince implements FromView, ShouldAutoSize, Wit
|
|||||||
$query .= " GROUP BY province_id
|
$query .= " GROUP BY province_id
|
||||||
ORDER BY province_id ASC;";
|
ORDER BY province_id ASC;";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($query));
|
$data = DB::select($query);
|
||||||
|
|
||||||
$sum = [
|
$sum = [
|
||||||
'KhakiDone' => 0,
|
'KhakiDone' => 0,
|
||||||
|
|||||||
64
app/Facades/DataTable/DataTable.php
Normal file
64
app/Facades/DataTable/DataTable.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\DataTable;
|
||||||
|
|
||||||
|
use App\Services\DataTable\DataTableInput;
|
||||||
|
use App\Services\DataTable\DataTableService;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidParameterInterface;
|
||||||
|
|
||||||
|
class DataTable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Extracts data from request, passes to datatable service and prepares data for response.
|
||||||
|
* @param Model|Builder $mixed
|
||||||
|
* @param Request $request
|
||||||
|
* @param array $allowedFilters
|
||||||
|
* @param array $allowedRelations
|
||||||
|
* @param array $allowedSortings
|
||||||
|
* @param array $allowedSelects
|
||||||
|
* @return array
|
||||||
|
* @throws InvalidParameterInterface if input parameters are invalid.
|
||||||
|
*/
|
||||||
|
public function run(
|
||||||
|
Model|Builder $mixed,
|
||||||
|
Request $request,
|
||||||
|
array $allowedFilters = [],
|
||||||
|
array $allowedRelations = [],
|
||||||
|
array $allowedSortings = [],
|
||||||
|
array $allowedSelects = []
|
||||||
|
): array
|
||||||
|
{
|
||||||
|
|
||||||
|
$filters = json_decode($request->filters);
|
||||||
|
$sorting = json_decode($request->sorting);
|
||||||
|
$rels = $request->rels ?: array();
|
||||||
|
|
||||||
|
$dataTableInput = new DataTableInput(
|
||||||
|
$request->start,
|
||||||
|
$request->size,
|
||||||
|
$filters,
|
||||||
|
$sorting,
|
||||||
|
$rels,
|
||||||
|
$allowedFilters,
|
||||||
|
$allowedSortings
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = $this->makeQueryFromModel($mixed);
|
||||||
|
|
||||||
|
$dataTableService = (new DataTableService($query, $dataTableInput))
|
||||||
|
->setAllowedFilters($allowedFilters)
|
||||||
|
->setAllowedRelations($allowedRelations)
|
||||||
|
->setAllowedSortings($allowedSortings)
|
||||||
|
->setAllowedSelects($allowedSelects);
|
||||||
|
|
||||||
|
return $dataTableService->getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function makeQueryFromModel(Model|Builder $mixed): Builder
|
||||||
|
{
|
||||||
|
return ($mixed instanceof Model) ? $mixed->query() : $mixed;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Facades/DataTable/DataTableFacade.php
Normal file
13
app/Facades/DataTable/DataTableFacade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\DataTable;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class DataTableFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return 'datatable';
|
||||||
|
}
|
||||||
|
}
|
||||||
107
app/Facades/File/File.php
Normal file
107
app/Facades/File/File.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\File;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Http\File as HttpFile;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class File
|
||||||
|
{
|
||||||
|
public function save(HttpFile|UploadedFile $file, string $path, string $name = null, string $disk = 'public'): string
|
||||||
|
{
|
||||||
|
return Storage::disk($disk)->putFileAs(
|
||||||
|
$path,
|
||||||
|
$file,
|
||||||
|
$name ?? Str::uuid() . '.' . $file->extension()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filePath
|
||||||
|
* @param bool $url_is_absolute
|
||||||
|
* @param string $disk
|
||||||
|
* @return void
|
||||||
|
* @throws \InvalidArgumentException when filePath is empty.
|
||||||
|
*/
|
||||||
|
public function delete(string $filePath, bool $url_is_absolute = false, string $disk = 'public'): void
|
||||||
|
{
|
||||||
|
if (!$filePath){
|
||||||
|
throw new \InvalidArgumentException('File path is invalid.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($url_is_absolute) {
|
||||||
|
$needle = 'storage/';
|
||||||
|
$pos = strpos($filePath, $needle);
|
||||||
|
$filePath = substr($filePath, $pos + strlen($needle));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Storage::disk($disk)->exists($filePath)) {
|
||||||
|
Storage::disk($disk)->delete($filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteContent($file_path): bool
|
||||||
|
{
|
||||||
|
if (file_exists($file_path)) {
|
||||||
|
file_put_contents($file_path, '');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tail($file_path, $lines = 100, $buffer = 2048): bool|string
|
||||||
|
{
|
||||||
|
// Open file
|
||||||
|
$file = @fopen($file_path, "rb");
|
||||||
|
if ($file === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jump to last character
|
||||||
|
fseek($file, -1, SEEK_END);
|
||||||
|
|
||||||
|
// Read it and adjust line number if necessary
|
||||||
|
// (Otherwise the result would be wrong if file doesn't end with a blank line)
|
||||||
|
if (fread($file, 1) != "\n") {
|
||||||
|
$lines -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start reading
|
||||||
|
$output = '';
|
||||||
|
$chunk = '';
|
||||||
|
|
||||||
|
// While we would like more
|
||||||
|
while (ftell($file) > 0 && $lines >= 0) {
|
||||||
|
|
||||||
|
// Figure out how far back we should jump
|
||||||
|
$seek = min(ftell($file), $buffer);
|
||||||
|
|
||||||
|
// Do the jump (backwards, relative to where we are)
|
||||||
|
fseek($file, -$seek, SEEK_CUR);
|
||||||
|
|
||||||
|
// Read a chunk and prepend it to our output
|
||||||
|
$output = ($chunk = fread($file, $seek)) . $output;
|
||||||
|
|
||||||
|
// Jump back to where we started reading
|
||||||
|
fseek($file, -mb_strlen($chunk, '8bit'), SEEK_CUR);
|
||||||
|
|
||||||
|
// Decrease our line counter
|
||||||
|
$lines -= substr_count($chunk, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// While we have too many lines
|
||||||
|
// (Because of buffer size we might have read too many)
|
||||||
|
while ($lines++ < 0) {
|
||||||
|
|
||||||
|
// Find first newline and remove all text before that
|
||||||
|
$output = substr($output, strpos($output, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close file and return
|
||||||
|
fclose($file);
|
||||||
|
return trim($output);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Facades/File/FileFacade.php
Normal file
13
app/Facades/File/FileFacade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\File;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class FileFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor(): string
|
||||||
|
{
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Facades\Sms;
|
namespace App\Facades\Sms;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use SoapFault;
|
use SoapFault;
|
||||||
@@ -11,28 +12,30 @@ class SmsClass
|
|||||||
{
|
{
|
||||||
public function sendSms($mobile, $msg)
|
public function sendSms($mobile, $msg)
|
||||||
{
|
{
|
||||||
|
if (App::environment('production')) {
|
||||||
|
|
||||||
|
|
||||||
|
$client = new SoapClient("http://sms1000.ir/webservice/sms.asmx?WSDL");
|
||||||
|
$date = date('d-m-y h:i:s');
|
||||||
|
$date = str_replace(" ", "T", $date);
|
||||||
|
$result = $client->Send(
|
||||||
|
array(
|
||||||
|
'Username' => 'admin',
|
||||||
|
'Password' => 'admin141',
|
||||||
|
'ShortCode' => '1000141',
|
||||||
|
'Cellphones' => $mobile,
|
||||||
|
'Message' => $msg,
|
||||||
|
'Farsi' => true,
|
||||||
|
// 'SendDate' => $date
|
||||||
|
// 'uTopic' => false,
|
||||||
|
// 'uFlash' => false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result->SendResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$client = new SoapClient("http://sms1000.ir/webservice/sms.asmx?WSDL");
|
|
||||||
$date = date('d-m-y h:i:s');
|
|
||||||
$date = str_replace(" ", "T", $date);
|
|
||||||
$result = $client->Send(
|
|
||||||
array(
|
|
||||||
'Username' => 'admin',
|
|
||||||
'Password' => 'admin141',
|
|
||||||
'ShortCode' => '1000141',
|
|
||||||
'Cellphones' => $mobile,
|
|
||||||
'Message' => $msg,
|
|
||||||
'Farsi' => true,
|
|
||||||
// 'SendDate' => $date
|
|
||||||
// 'uTopic' => false,
|
|
||||||
// 'uFlash' => false
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$x = $result->SendResult;
|
|
||||||
|
|
||||||
return $x;
|
|
||||||
|
|
||||||
// $client = new SoapClient("http://sms1000.ir/webservice/smspro.asmx?WSDL");
|
// $client = new SoapClient("http://sms1000.ir/webservice/smspro.asmx?WSDL");
|
||||||
// $result = $client->doSendSMS(
|
// $result = $client->doSendSMS(
|
||||||
// array(
|
// array(
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ if (! function_exists('process_datatable')) {
|
|||||||
$value = $attributes['value'];
|
$value = $attributes['value'];
|
||||||
|
|
||||||
if ($attributes['type'] == 'text') {
|
if ($attributes['type'] == 'text') {
|
||||||
$data = $data->where($field, 'LIKE', "%${value}%");
|
$data = $data->where($field, 'LIKE', "%{$value}%");
|
||||||
} elseif ($attributes['type'] == 'between') {
|
} elseif ($attributes['type'] == 'between') {
|
||||||
$date_values = explode('&', $value);
|
$date_values = explode('&', $value);
|
||||||
$date_values[0] .= " 00:00:00";
|
$date_values[0] .= " 00:00:00";
|
||||||
@@ -89,7 +89,7 @@ if (! function_exists('process_datatable')) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} elseif ($attributes['type'] == 'select') {
|
} elseif ($attributes['type'] == 'select') {
|
||||||
$data = $data->where($field, "${value}");
|
$data = $data->where($field, "{$value}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// following types have been added for making finance table serverside.
|
// following types have been added for making finance table serverside.
|
||||||
|
|||||||
@@ -7,17 +7,19 @@ use App\Models\CMMS_Form;
|
|||||||
use App\Models\CMMS_Forms_histories;
|
use App\Models\CMMS_Forms_histories;
|
||||||
use App\Models\CMMS_Province;
|
use App\Models\CMMS_Province;
|
||||||
use App\Models\CmmsDemo;
|
use App\Models\CmmsDemo;
|
||||||
|
use App\Services\FMSService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Hekmatinasser\Verta\Verta;
|
use Hekmatinasser\Verta\Verta;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
|
||||||
class CMMSController extends Controller
|
class CMMSController extends Controller
|
||||||
{
|
{
|
||||||
public function getVehicleActivity(Request $request)
|
public function getVehicleActivity(Request $request, FMSService $FMSService)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$request->machineCode || !$request->startDT || !$request->endDT || !$request->minStopDuration) {
|
if (!$request->machineCode || !$request->startDT || !$request->endDT || !$request->minStopDuration) {
|
||||||
@@ -25,22 +27,8 @@ class CMMSController extends Controller
|
|||||||
'message' => 'error'
|
'message' => 'error'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$r = $request->machineCode;
|
$server_output = $FMSService->getVehicleActivity($request);
|
||||||
$s = $request->startDT;
|
|
||||||
$e = $request->endDT;
|
|
||||||
$d = $request->minStopDuration;
|
|
||||||
$url = 'http://fms.141.ir/api/RMS/GetVehicleActivity?';
|
|
||||||
$query = "username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}&minStopDuration={$d}";
|
|
||||||
$full_url = $url . $query;
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $full_url);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
|
||||||
"username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}&minStopDuration={$d}");
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$server_output = curl_exec($ch);
|
|
||||||
|
|
||||||
$d = json_decode($server_output, true);
|
$d = json_decode($server_output, true);
|
||||||
|
|
||||||
@@ -57,7 +45,7 @@ class CMMSController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVehicleLastPoints(Request $request)
|
public function getVehicleLastPoints(Request $request, FMSService $FMSService)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$request->machineCode) {
|
if (!$request->machineCode) {
|
||||||
@@ -65,19 +53,8 @@ class CMMSController extends Controller
|
|||||||
'message' => 'error'
|
'message' => 'error'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$r = $request->machineCode;
|
$server_output = $FMSService->getVehicleLastPoints($request);
|
||||||
$url = 'http://fms.141.ir/api/RMS/GetVehicleLastPoints?';
|
|
||||||
$query = "username=RMS&password=XSW@1qaz&machineCodes={$r}";
|
|
||||||
$full_url = $url . $query;
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $full_url);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
|
||||||
"username=RMS&password=XSW@1qaz&machineCode={$r}");
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$server_output = curl_exec($ch);
|
|
||||||
|
|
||||||
$d = json_decode($server_output, true);
|
$d = json_decode($server_output, true);
|
||||||
return $d;
|
return $d;
|
||||||
@@ -94,7 +71,7 @@ class CMMSController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVehicleActivitySummary(Request $request)
|
public function getVehicleActivitySummary(Request $request, FMSService $FMSService)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$request->machineCode || !$request->startDT || !$request->endDT) {
|
if (!$request->machineCode || !$request->startDT || !$request->endDT) {
|
||||||
@@ -102,21 +79,8 @@ class CMMSController extends Controller
|
|||||||
'message' => 'error'
|
'message' => 'error'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$r = $request->machineCode;
|
$server_output = $FMSService->getVehicleActivitySummary($request);
|
||||||
$s = $request->startDT;
|
|
||||||
$e = $request->endDT;
|
|
||||||
$url = 'http://fms.141.ir/api/RMS/GetVehicleActivitySummary?';
|
|
||||||
$query = "username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}";
|
|
||||||
$full_url = $url . $query;
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $full_url);
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
|
||||||
"username=RMS&password=XSW@1qaz&machineCode={$r}&startDT={$s}&endDT={$e}");
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$server_output = curl_exec($ch);
|
|
||||||
|
|
||||||
$d = json_decode($server_output, true);
|
$d = json_decode($server_output, true);
|
||||||
|
|
||||||
@@ -134,17 +98,9 @@ class CMMSController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getVehicleData(Request $request)
|
public function getVehicleData(Request $request, FMSService $FMSService)
|
||||||
{
|
{
|
||||||
$r = $request->machine;
|
$server_output = $FMSService->getVehicleData($request);
|
||||||
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL,"http://fms.141.ir/api/RMS/GetVehicleLastPoints?username=RMS&password=XSW@1qaz&machineCodes={$r}");
|
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,
|
|
||||||
"username=RMS&password=XSW@1qaz&machineCodes={$r}");
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$server_output = curl_exec($ch);
|
|
||||||
|
|
||||||
$d = json_decode($server_output);
|
$d = json_decode($server_output);
|
||||||
|
|
||||||
@@ -199,7 +155,7 @@ class CMMSController extends Controller
|
|||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$uuid = \Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
|
|
||||||
foreach (CMMS_Province::where('province_id', $request->only('province_id'))->get() as $prov_item) {
|
foreach (CMMS_Province::where('province_id', $request->only('province_id'))->get() as $prov_item) {
|
||||||
$province_fa = $prov_item->province_fa;
|
$province_fa = $prov_item->province_fa;
|
||||||
@@ -394,7 +350,7 @@ class CMMSController extends Controller
|
|||||||
|
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$uuid = \Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
|
|
||||||
foreach (CMMS_Province::where('province_id', $request->only('province_id'))->get() as $prov_item) {
|
foreach (CMMS_Province::where('province_id', $request->only('province_id'))->get() as $prov_item) {
|
||||||
$province_fa = $prov_item->province_fa;
|
$province_fa = $prov_item->province_fa;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ use SoapClient;
|
|||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Facades\Sms\Sms;
|
use App\Facades\Sms\Sms;
|
||||||
|
use App\Services\NominatimService;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class ContractSubItemsController extends Controller
|
class ContractSubItemsController extends Controller
|
||||||
{
|
{
|
||||||
@@ -101,7 +103,7 @@ class ContractSubItemsController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeForDevelop(Request $request)
|
public function storeForDevelop(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($request->has('operation_type_id1') && $request->operation_type_progress1 == null) {
|
if ($request->has('operation_type_id1') && $request->operation_type_progress1 == null) {
|
||||||
@@ -137,9 +139,9 @@ class ContractSubItemsController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
$contract = Contracts::where('id', $request->contract_id)->first();
|
$contract = Contracts::where('id', $request->contract_id)->first();
|
||||||
|
|
||||||
$parent_contract_date = explode('-', $contract->contract_date);
|
$parent_contract_date = explode('-', $contract->contract_date);
|
||||||
$parent_contract_date = Verta::getGregorian($parent_contract_date[0], $parent_contract_date[1], $parent_contract_date[2]);
|
// dd(Verta::jalaliToGregorian($parent_contract_date[0], $parent_contract_date[1], $parent_contract_date[2]));
|
||||||
|
$parent_contract_date = Verta::jalaliToGregorian($parent_contract_date[0], $parent_contract_date[1], $parent_contract_date[2]);
|
||||||
|
|
||||||
$city_fa = City::where('id', $request->city_id)->first();
|
$city_fa = City::where('id', $request->city_id)->first();
|
||||||
$province_fa = Province::where('id', $request->province_id)->first();
|
$province_fa = Province::where('id', $request->province_id)->first();
|
||||||
@@ -204,8 +206,8 @@ class ContractSubItemsController extends Controller
|
|||||||
$contractSubItem->contract_date_from_parent_contract = $parent_contract_date[0].'-'.$parent_contract_date[1].'-'.$parent_contract_date[2];
|
$contractSubItem->contract_date_from_parent_contract = $parent_contract_date[0].'-'.$parent_contract_date[1].'-'.$parent_contract_date[2];
|
||||||
$contractSubItem->created_at_fa = Verta::instance(Verta::now());
|
$contractSubItem->created_at_fa = Verta::instance(Verta::now());
|
||||||
$contractSubItem->updated_at_fa = Verta::instance(Verta::now());
|
$contractSubItem->updated_at_fa = Verta::instance(Verta::now());
|
||||||
$contractSubItem->start_way_id = self::get_way_id_from_nominatim($request->start_lat, $request->start_lng);
|
$contractSubItem->start_way_id = $nominatimService->get_way_id_from_nominatim($request->start_lat, $request->start_lng);
|
||||||
$contractSubItem->end_way_id = self::get_way_id_from_nominatim($request->end_lat, $request->end_lng);
|
$contractSubItem->end_way_id = $nominatimService->get_way_id_from_nominatim($request->end_lat, $request->end_lng);
|
||||||
$contractSubItem->user_id = Auth::user()->id;
|
$contractSubItem->user_id = Auth::user()->id;
|
||||||
$contractSubItem->contract_moshaver_tarahi = $contract->contract_moshaver_tarahi;
|
$contractSubItem->contract_moshaver_tarahi = $contract->contract_moshaver_tarahi;
|
||||||
$contractSubItem->contract_moshaver_nezarat = $contract->contract_moshaver_nezarat;
|
$contractSubItem->contract_moshaver_nezarat = $contract->contract_moshaver_nezarat;
|
||||||
@@ -238,7 +240,7 @@ class ContractSubItemsController extends Controller
|
|||||||
$countRoadFiles = count($roadProjectHistoriesFiles);
|
$countRoadFiles = count($roadProjectHistoriesFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
$uuid = \Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
if ($request->has('image1')) {
|
if ($request->has('image1')) {
|
||||||
$file1 = $request->file('image1');
|
$file1 = $request->file('image1');
|
||||||
$destinationPath1 = 'storage/contract_subitems/' . now()->year . '/' . now()->month . '/';
|
$destinationPath1 = 'storage/contract_subitems/' . now()->year . '/' . now()->month . '/';
|
||||||
@@ -296,7 +298,7 @@ class ContractSubItemsController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateForDevelop(Request $request, $id)
|
public function updateForDevelop(Request $request, $id, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
if ($request->operation_type_id1 != 0 && $request->operation_type_progress1 == null) {
|
if ($request->operation_type_id1 != 0 && $request->operation_type_progress1 == null) {
|
||||||
return response()->json(['message' => 'Operation type progress1 is NULL'], 400);
|
return response()->json(['message' => 'Operation type progress1 is NULL'], 400);
|
||||||
@@ -462,8 +464,8 @@ class ContractSubItemsController extends Controller
|
|||||||
$contractSubItem->last_function_operator = $request->last_function_operator;
|
$contractSubItem->last_function_operator = $request->last_function_operator;
|
||||||
$contractSubItem->last_payable_operator = $request->last_payable_operator;
|
$contractSubItem->last_payable_operator = $request->last_payable_operator;
|
||||||
$contractSubItem->complete_payable = $request->complete_payable;
|
$contractSubItem->complete_payable = $request->complete_payable;
|
||||||
$contractSubItem->start_way_id = self::get_way_id_from_nominatim($request->start_lat, $request->start_lng);
|
$contractSubItem->start_way_id = $nominatimService->get_way_id_from_nominatim($request->start_lat, $request->start_lng);
|
||||||
$contractSubItem->end_way_id = self::get_way_id_from_nominatim($request->end_lat, $request->end_lng);
|
$contractSubItem->end_way_id = $nominatimService->get_way_id_from_nominatim($request->end_lat, $request->end_lng);
|
||||||
$contractSubItem->updated_at_fa = Verta::instance(Verta::now());
|
$contractSubItem->updated_at_fa = Verta::instance(Verta::now());
|
||||||
$contractSubItem->user_id = Auth::user()->id;
|
$contractSubItem->user_id = Auth::user()->id;
|
||||||
$contractSubItem->last_date_update = Carbon::now();
|
$contractSubItem->last_date_update = Carbon::now();
|
||||||
@@ -474,7 +476,7 @@ class ContractSubItemsController extends Controller
|
|||||||
|
|
||||||
$contractSubItem->save();
|
$contractSubItem->save();
|
||||||
|
|
||||||
$uuid = \Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
if ($request->has('image1')) {
|
if ($request->has('image1')) {
|
||||||
$file1 = $request->file('image1');
|
$file1 = $request->file('image1');
|
||||||
$destinationPath1 = 'storage/contract_subitems/' . now()->year . '/' . now()->month . '/';
|
$destinationPath1 = 'storage/contract_subitems/' . now()->year . '/' . now()->month . '/';
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Hekmatinasser\Verta\Verta;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class CampController extends Controller
|
class CampController extends Controller
|
||||||
@@ -332,7 +333,7 @@ class CampController extends Controller
|
|||||||
$camp->submited_at = new Verta();
|
$camp->submited_at = new Verta();
|
||||||
$camp->save();
|
$camp->save();
|
||||||
|
|
||||||
$uuid = \Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
|
|
||||||
$id = $camp->id;
|
$id = $camp->id;
|
||||||
if ($request->file('image_1')) {
|
if ($request->file('image_1')) {
|
||||||
@@ -646,7 +647,7 @@ class CampController extends Controller
|
|||||||
$camp->block_axis_desc = $request->block_axis_desc;
|
$camp->block_axis_desc = $request->block_axis_desc;
|
||||||
$camp->submited_at = new Verta();
|
$camp->submited_at = new Verta();
|
||||||
$camp->save();
|
$camp->save();
|
||||||
$uuid = \Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
|
|
||||||
$id = $camp->id;
|
$id = $camp->id;
|
||||||
if ($request->file('image_1')) {
|
if ($request->file('image_1')) {
|
||||||
|
|||||||
@@ -436,11 +436,10 @@ class ContractsController extends Controller
|
|||||||
$contract->save();
|
$contract->save();
|
||||||
// document end
|
// document end
|
||||||
|
|
||||||
|
|
||||||
// for updating sub contract contract date
|
// for updating sub contract contract date
|
||||||
foreach ($contract->subitems as $key => $value) {
|
foreach ($contract->subitems as $key => $value) {
|
||||||
$tmp = explode('-', $request->contract_date);
|
$tmp = explode('-', $request->contract_date);
|
||||||
$tmp = Verta::getGregorian($tmp[0], $tmp[1], $tmp[2]);
|
$tmp = Verta::jalaliToGregorian($tmp[0], $tmp[1], $tmp[2]);
|
||||||
$value->contract_date_from_parent_contract = $tmp[0].'-'.$tmp[1].'-'.$tmp[2];
|
$value->contract_date_from_parent_contract = $tmp[0].'-'.$tmp[1].'-'.$tmp[2];
|
||||||
$value->save();
|
$value->save();
|
||||||
}
|
}
|
||||||
@@ -540,7 +539,7 @@ class ContractsController extends Controller
|
|||||||
order by project_type_id"
|
order by project_type_id"
|
||||||
;
|
;
|
||||||
|
|
||||||
foreach (DB::select(DB::raw($summaryProjectsStatus)) as $key => $value) {
|
foreach (DB::select($summaryProjectsStatus) as $key => $value) {
|
||||||
$summaryProjectsStatusExecute[$value->project_type_id] = [
|
$summaryProjectsStatusExecute[$value->project_type_id] = [
|
||||||
'project_count' => $value->project_count,
|
'project_count' => $value->project_count,
|
||||||
'AvgProgressProjects' => $value->AvgProgressProjects,
|
'AvgProgressProjects' => $value->AvgProgressProjects,
|
||||||
@@ -555,7 +554,7 @@ class ContractsController extends Controller
|
|||||||
where province_id = {$request->province}"
|
where province_id = {$request->province}"
|
||||||
;
|
;
|
||||||
|
|
||||||
$summaryProjectsAllExecute = DB::select(DB::raw($summaryProjectsAll));
|
$summaryProjectsAllExecute = DB::select($summaryProjectsAll);
|
||||||
|
|
||||||
/// summary project status by last status
|
/// summary project status by last status
|
||||||
$summaryProjectsStatusByLastStatus = "SELECT
|
$summaryProjectsStatusByLastStatus = "SELECT
|
||||||
@@ -572,7 +571,7 @@ class ContractsController extends Controller
|
|||||||
GROUP BY last_status_id"
|
GROUP BY last_status_id"
|
||||||
;
|
;
|
||||||
|
|
||||||
$summaryProjectsStatusByLastStatusExecute = DB::select(DB::raw($summaryProjectsStatusByLastStatus));
|
$summaryProjectsStatusByLastStatusExecute = DB::select($summaryProjectsStatusByLastStatus);
|
||||||
|
|
||||||
/// project status divide by cities
|
/// project status divide by cities
|
||||||
$projectsStatusByCities = "SELECT
|
$projectsStatusByCities = "SELECT
|
||||||
@@ -591,7 +590,7 @@ class ContractsController extends Controller
|
|||||||
GROUP BY city_id"
|
GROUP BY city_id"
|
||||||
;
|
;
|
||||||
|
|
||||||
$projectsStatusByCitiesExecute = DB::select(DB::raw($projectsStatusByCities));
|
$projectsStatusByCitiesExecute = DB::select($projectsStatusByCities);
|
||||||
|
|
||||||
/// important maintanance projects
|
/// important maintanance projects
|
||||||
$importantMaintananceProjects = "SELECT
|
$importantMaintananceProjects = "SELECT
|
||||||
@@ -613,7 +612,7 @@ class ContractsController extends Controller
|
|||||||
GROUP BY unique_code) AS temp_table"
|
GROUP BY unique_code) AS temp_table"
|
||||||
;
|
;
|
||||||
|
|
||||||
$importantMaintananceProjectsExecute = DB::select(DB::raw($importantMaintananceProjects));
|
$importantMaintananceProjectsExecute = DB::select($importantMaintananceProjects);
|
||||||
|
|
||||||
|
|
||||||
/// important danger points projects
|
/// important danger points projects
|
||||||
@@ -632,7 +631,7 @@ class ContractsController extends Controller
|
|||||||
AND project_type_id = 2"
|
AND project_type_id = 2"
|
||||||
;
|
;
|
||||||
|
|
||||||
$importantDangerPointsProjectExecute = DB::select(DB::raw($importantDangerPointsProject));
|
$importantDangerPointsProjectExecute = DB::select($importantDangerPointsProject);
|
||||||
|
|
||||||
/// important road upgrade safeties projects
|
/// important road upgrade safeties projects
|
||||||
$importantRoadUpgradeSafetiesProject = "SELECT
|
$importantRoadUpgradeSafetiesProject = "SELECT
|
||||||
@@ -655,7 +654,7 @@ class ContractsController extends Controller
|
|||||||
GROUP BY unique_code) AS temp_table"
|
GROUP BY unique_code) AS temp_table"
|
||||||
;
|
;
|
||||||
|
|
||||||
$importantRoadUpgradeSafetiesProjectExecute = DB::select(DB::raw($importantRoadUpgradeSafetiesProject));
|
$importantRoadUpgradeSafetiesProjectExecute = DB::select($importantRoadUpgradeSafetiesProject);
|
||||||
|
|
||||||
/// important techincal projects
|
/// important techincal projects
|
||||||
$importantTechnicalProject = "SELECT
|
$importantTechnicalProject = "SELECT
|
||||||
@@ -673,7 +672,7 @@ class ContractsController extends Controller
|
|||||||
AND project_type_id = 4"
|
AND project_type_id = 4"
|
||||||
;
|
;
|
||||||
|
|
||||||
$importantTechnicalProjectExecute = DB::select(DB::raw($importantTechnicalProject));
|
$importantTechnicalProjectExecute = DB::select($importantTechnicalProject);
|
||||||
|
|
||||||
/// important Tollhouse projects
|
/// important Tollhouse projects
|
||||||
$importantTollhouseProject = "SELECT
|
$importantTollhouseProject = "SELECT
|
||||||
@@ -691,7 +690,7 @@ class ContractsController extends Controller
|
|||||||
AND project_type_id = 5"
|
AND project_type_id = 5"
|
||||||
;
|
;
|
||||||
|
|
||||||
$importantTollhouseProjectExecute = DB::select(DB::raw($importantTollhouseProject));
|
$importantTollhouseProjectExecute = DB::select($importantTollhouseProject);
|
||||||
|
|
||||||
/// important VillageRoad projects
|
/// important VillageRoad projects
|
||||||
$importantVillageRoadProject = "SELECT
|
$importantVillageRoadProject = "SELECT
|
||||||
@@ -713,7 +712,7 @@ class ContractsController extends Controller
|
|||||||
GROUP BY unique_code) AS temp_table"
|
GROUP BY unique_code) AS temp_table"
|
||||||
;
|
;
|
||||||
|
|
||||||
$importantVillageRoadProjectExecute = DB::select(DB::raw($importantVillageRoadProject));
|
$importantVillageRoadProjectExecute = DB::select($importantVillageRoadProject);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Coridor;
|
use App\Models\Coridor;
|
||||||
|
use App\Models\RoadPatrol;
|
||||||
use App\Models\RoutePath;
|
use App\Models\RoutePath;
|
||||||
use App\Models\RoadItemsProject;
|
use App\Models\RoadItemsProject;
|
||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
|
|
||||||
|
use App\Services\NominatimService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -484,7 +486,7 @@ class CoridorsController extends Controller
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function axisReportByLatAndLng(Request $request)
|
public function axisReportByLatAndLng(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
if (! $request->type) {
|
if (! $request->type) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -496,7 +498,7 @@ class CoridorsController extends Controller
|
|||||||
$date_from = $request->date_from;
|
$date_from = $request->date_from;
|
||||||
$info_id = $request->daily_activity;
|
$info_id = $request->daily_activity;
|
||||||
$roadObservedTypes = $request->road_type;
|
$roadObservedTypes = $request->road_type;
|
||||||
$idArrays = self::getIDFromNominatim($request->slng, $request->slat, $request->dlng, $request->dlat);
|
$idArrays = $nominatimService->getIDFromNominatim($request->slng, $request->slat, $request->dlng, $request->dlat);
|
||||||
$typeArrays = $request->type;
|
$typeArrays = $request->type;
|
||||||
$contractStatusArrays = $request->contract_status ?? [];
|
$contractStatusArrays = $request->contract_status ?? [];
|
||||||
$projectTypeArrays = $request->project_type ?? [];
|
$projectTypeArrays = $request->project_type ?? [];
|
||||||
@@ -514,13 +516,13 @@ class CoridorsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( in_array(2, $typeArrays) ) {
|
if ( in_array(2, $typeArrays) ) {
|
||||||
$roadPatrolProject = RoadPatrolProject::where(function($query) use($idArrays){
|
$roadPatrolProject = RoadPatrol::where(function($query) use($idArrays){
|
||||||
$query->whereIn("start_way_id", $idArrays)
|
$query->whereIn("start_way_id", $idArrays)
|
||||||
->orWhereIn("end_way_id", $idArrays);
|
->orWhereIn("end_way_id", $idArrays);
|
||||||
})
|
})
|
||||||
->whereBetween('created_at', [$date_from . ' 00:00:00', $date_to . ' 23:59:59'])
|
->whereBetween('created_at', [$date_from . ' 00:00:00', $date_to . ' 23:59:59'])
|
||||||
->whereNotNull('start_lat')
|
->whereNotNull('start_lat')
|
||||||
->select('start_lat', 'start_lng', 'id')
|
->select('start_lat', 'start_lon', 'id')
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,7 +688,7 @@ class CoridorsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function axisReportExcelRedirector(Request $request)
|
public function axisReportExcelRedirector(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
if (! $request->type) {
|
if (! $request->type) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -698,7 +700,7 @@ class CoridorsController extends Controller
|
|||||||
$date_from = $request->date_from;
|
$date_from = $request->date_from;
|
||||||
$info_id = $request->daily_activity;
|
$info_id = $request->daily_activity;
|
||||||
$roadObservedTypes = $request->road_type;
|
$roadObservedTypes = $request->road_type;
|
||||||
$idArrays = self::getIDFromNominatim($request->slng, $request->slat, $request->dlng, $request->dlat);
|
$idArrays = $nominatimService->getIDFromNominatim($request->slng, $request->slat, $request->dlng, $request->dlat);
|
||||||
$typeArrays = $request->type;
|
$typeArrays = $request->type;
|
||||||
$contractStatusArrays = $request->contract_status ?? [];
|
$contractStatusArrays = $request->contract_status ?? [];
|
||||||
$projectTypeArrays = $request->project_type ?? [];
|
$projectTypeArrays = $request->project_type ?? [];
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Http\Requests\DailyAccidentRequest;
|
use App\Http\Requests\DailyAccidentRequest;
|
||||||
use Spatie\Permission\Models\Permission;
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use App\Services\NominatimService;
|
||||||
|
|
||||||
|
|
||||||
class DailyAccidentController extends Controller
|
class DailyAccidentController extends Controller
|
||||||
@@ -131,9 +131,9 @@ class DailyAccidentController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(DailyAccidentRequest $request)
|
public function store(DailyAccidentRequest $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request) {
|
DB::transaction(function () use ($request, $nominatimService) {
|
||||||
$new_daily_accident = new DailyAccident();
|
$new_daily_accident = new DailyAccident();
|
||||||
|
|
||||||
$new_daily_accident->province_id = $request->province_id;
|
$new_daily_accident->province_id = $request->province_id;
|
||||||
@@ -217,7 +217,7 @@ class DailyAccidentController extends Controller
|
|||||||
$new_daily_accident->accident_reason_ebham_dar_masir = $request->accident_reason_ebham_dar_masir ?? 0;
|
$new_daily_accident->accident_reason_ebham_dar_masir = $request->accident_reason_ebham_dar_masir ?? 0;
|
||||||
$new_daily_accident->accident_reason_qus_tond_ofoghi = $request->accident_reason_qus_tond_ofoghi ?? 0;
|
$new_daily_accident->accident_reason_qus_tond_ofoghi = $request->accident_reason_qus_tond_ofoghi ?? 0;
|
||||||
|
|
||||||
$new_daily_accident->way_id = self::get_way_id_from_nominatim($request->lat, $request->lng);
|
$new_daily_accident->way_id = $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng);
|
||||||
|
|
||||||
$new_daily_accident->save();
|
$new_daily_accident->save();
|
||||||
|
|
||||||
@@ -521,9 +521,9 @@ class DailyAccidentController extends Controller
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(DailyAccident $accident, Request $request)
|
public function update(DailyAccident $accident, Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request, $accident) {
|
DB::transaction(function () use ($request, $accident, $nominatimService) {
|
||||||
;
|
;
|
||||||
auth()->user()->addActivityComplete(1119, $accident);
|
auth()->user()->addActivityComplete(1119, $accident);
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ class DailyAccidentController extends Controller
|
|||||||
$accident->accident_reason_ebham_dar_masir = $request->accident_reason_ebham_dar_masir ?? 0;
|
$accident->accident_reason_ebham_dar_masir = $request->accident_reason_ebham_dar_masir ?? 0;
|
||||||
$accident->accident_reason_qus_tond_ofoghi = $request->accident_reason_qus_tond_ofoghi ?? 0;
|
$accident->accident_reason_qus_tond_ofoghi = $request->accident_reason_qus_tond_ofoghi ?? 0;
|
||||||
|
|
||||||
$accident->way_id = self::get_way_id_from_nominatim($request->lat, $request->lng);
|
$accident->way_id = $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng);
|
||||||
|
|
||||||
$accident->save();
|
$accident->save();
|
||||||
|
|
||||||
@@ -708,6 +708,8 @@ class DailyAccidentController extends Controller
|
|||||||
'day_part' => 'in:day,night',
|
'day_part' => 'in:day,night',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// dd($request->province_ids);
|
||||||
|
|
||||||
$from_date = $request->from_date;
|
$from_date = $request->from_date;
|
||||||
$to_date = $request->to_date;
|
$to_date = $request->to_date;
|
||||||
|
|
||||||
@@ -744,6 +746,7 @@ class DailyAccidentController extends Controller
|
|||||||
})
|
})
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'succuss' => true,
|
'succuss' => true,
|
||||||
'data' => $data
|
'data' => $data
|
||||||
|
|||||||
@@ -74,49 +74,50 @@ class HomeProjectController extends Controller
|
|||||||
'data' => $projectsArray
|
'data' => $projectsArray
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
// sharareh begin
|
||||||
|
// public function getFastReactionProjectPoints(Request $request)
|
||||||
|
// {
|
||||||
|
// $province = $request->province_id;
|
||||||
|
// $edare_shahri = $request->edare_shahri_id;
|
||||||
|
// $status = $request->status;
|
||||||
|
// $rms_status = $request->rms_status;
|
||||||
|
|
||||||
public function getFastReactionProjectPoints(Request $request)
|
// if ($request->date_from && $request->date_to) {
|
||||||
{
|
// $date_from = $request->date_from.' 00:00:00';
|
||||||
$province = $request->province_id;
|
// $date_to = $request->date_to.' 23:59:59';
|
||||||
$edare_shahri = $request->edare_shahri_id;
|
// } else {
|
||||||
$status = $request->status;
|
// $date_from = Date('Y-m-d');
|
||||||
$rms_status = $request->rms_status;
|
// $date_to = new \DateTime('tomorrow');
|
||||||
|
// $date_to = $date_to->format('Y-m-d');
|
||||||
|
// }
|
||||||
|
|
||||||
if ($request->date_from && $request->date_to) {
|
// $projects = RoadObserved::select('id', 'lng', 'lat','status')
|
||||||
$date_from = $request->date_from.' 00:00:00';
|
// ->whereBetween('created_at', [$date_from, $date_to])
|
||||||
$date_to = $request->date_to.' 23:59:59';
|
// ->when($province, function ($query) use ($province) {
|
||||||
} else {
|
// return $query->where('province_id', $province);
|
||||||
$date_from = Date('Y-m-d');
|
// })
|
||||||
$date_to = new \DateTime('tomorrow');
|
// ->when($rms_status, function ($query) use ($rms_status) {
|
||||||
$date_to = $date_to->format('Y-m-d');
|
// if ($rms_status == 2) {
|
||||||
}
|
// return $query->where('rms_status', '<>',0);
|
||||||
|
// } else {
|
||||||
$projects = RoadObserved::select('id', 'lng', 'lat','status')
|
// return $query->where('rms_status', 0);
|
||||||
->whereBetween('created_at', [$date_from, $date_to])
|
// }
|
||||||
->when($province, function ($query) use ($province) {
|
// })
|
||||||
return $query->where('province_id', $province);
|
// ->when($edare_shahri, function ($query) use ($edare_shahri) {
|
||||||
})
|
// return $query->where('edarate_shahri_id', $edare_shahri);
|
||||||
->when($rms_status, function ($query) use ($rms_status) {
|
// })
|
||||||
if ($rms_status == 2) {
|
// ->when($status, function ($query) use ($status) {
|
||||||
return $query->where('rms_status', '<>',0);
|
// return $query->where('status', $status);
|
||||||
} else {
|
// })
|
||||||
return $query->where('rms_status', 0);
|
// // ->toSql();
|
||||||
}
|
// ->get();
|
||||||
})
|
// return response()->json([
|
||||||
->when($edare_shahri, function ($query) use ($edare_shahri) {
|
// 'status' => 'succeed',
|
||||||
return $query->where('edarate_shahri_id', $edare_shahri);
|
// 'message' => '',
|
||||||
})
|
// 'data' => $projects
|
||||||
->when($status, function ($query) use ($status) {
|
// ], 200);
|
||||||
return $query->where('status', $status);
|
// }
|
||||||
})
|
// sharareh begin
|
||||||
// ->toSql();
|
|
||||||
->get();
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'succeed',
|
|
||||||
'message' => '',
|
|
||||||
'data' => $projects
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFastReactionProjectPointsFor141(Request $request)
|
public function getFastReactionProjectPointsFor141(Request $request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use Webpatser\Uuid\Uuid;
|
|||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use App\Models\RandDVoting;
|
use App\Models\RandDVoting;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use App\Models\RandDVotingPaperAnswer;
|
use App\Models\RandDVotingPaperAnswer;
|
||||||
|
|
||||||
class NewRandDCtrl extends Controller
|
class NewRandDCtrl extends Controller
|
||||||
@@ -204,7 +205,7 @@ class NewRandDCtrl extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make Unique Code
|
// Make Unique Code
|
||||||
$uuid = Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
|
|
||||||
// Upload Final report 1
|
// Upload Final report 1
|
||||||
if ($request->has('proj_rfp_file')) {
|
if ($request->has('proj_rfp_file')) {
|
||||||
@@ -308,7 +309,7 @@ class NewRandDCtrl extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make Unique Code
|
// Make Unique Code
|
||||||
$uuid = Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
// Upload Final report 1
|
// Upload Final report 1
|
||||||
$rfp_file = $newRandD->rfp_file;
|
$rfp_file = $newRandD->rfp_file;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Services\PaymentService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
use App\Models\City;
|
use App\Models\City;
|
||||||
@@ -14,6 +15,8 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use App\Facades\Sms\Sms;
|
use App\Facades\Sms\Sms;
|
||||||
|
use App\Services\NominatimService;
|
||||||
|
|
||||||
|
|
||||||
class ReceiptController extends Controller
|
class ReceiptController extends Controller
|
||||||
{
|
{
|
||||||
@@ -68,9 +71,9 @@ class ReceiptController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request) {
|
DB::transaction(function () use ($request, $nominatimService) {
|
||||||
$new_accident = new Accident();
|
$new_accident = new Accident();
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +99,8 @@ class ReceiptController extends Controller
|
|||||||
$new_accident->accident_date = $request->accident_date;
|
$new_accident->accident_date = $request->accident_date;
|
||||||
$new_accident->accident_time = $request->accident_time;
|
$new_accident->accident_time = $request->accident_time;
|
||||||
|
|
||||||
$new_accident->way_id = get_way_id_from_nominatim($request->lat, $request->lng);
|
// $new_accident->way_id = get_way_id_from_nominatim($request->lat, $request->lng);
|
||||||
|
$new_accident->way_id = $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng);
|
||||||
|
|
||||||
$new_accident->save();
|
$new_accident->save();
|
||||||
|
|
||||||
@@ -152,9 +156,9 @@ class ReceiptController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Accident $accident, Request $request)
|
public function update(Accident $accident, Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request, $accident) {
|
DB::transaction(function () use ($request, $accident, $nominatimService) {
|
||||||
$accident->province_fa = Province::where('id', $request->province_id)->first()->name_fa;
|
$accident->province_fa = Province::where('id', $request->province_id)->first()->name_fa;
|
||||||
$accident->province_id = $request->province_id;
|
$accident->province_id = $request->province_id;
|
||||||
|
|
||||||
@@ -175,7 +179,7 @@ class ReceiptController extends Controller
|
|||||||
$accident->accident_date = $request->accident_date;
|
$accident->accident_date = $request->accident_date;
|
||||||
$accident->accident_time = $request->accident_time;
|
$accident->accident_time = $request->accident_time;
|
||||||
|
|
||||||
$accident->way_id = get_way_id_from_nominatim($request->lat, $request->lng);
|
$accident->way_id = $nominatimService->get_way_id_from_nominatim($request->lat, $request->lng);
|
||||||
|
|
||||||
$accident->save();
|
$accident->save();
|
||||||
|
|
||||||
@@ -350,10 +354,10 @@ class ReceiptController extends Controller
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoiceBill(Request $request, Accident $accident)
|
public function invoiceBill(Request $request, Accident $accident, PaymentService $paymentService)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::transaction(function () use ($request, $accident) {
|
DB::transaction(function () use ($request, $accident, $paymentService) {
|
||||||
|
|
||||||
$final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
|
$final_amount = $accident->sum - ($accident->deposit_insurance_amount + $accident->deposit_daghi_amount);
|
||||||
|
|
||||||
@@ -363,7 +367,7 @@ class ReceiptController extends Controller
|
|||||||
|
|
||||||
$accident->final_amount = $final_amount;
|
$accident->final_amount = $final_amount;
|
||||||
|
|
||||||
$accident->bill_code = $this->invoiceBillApi($accident->driver_national_code, $final_amount);
|
$accident->bill_code = $paymentService->invoiceBillApi($accident->driver_national_code, $final_amount);
|
||||||
|
|
||||||
$accident->invoiceBill();
|
$accident->invoiceBill();
|
||||||
|
|
||||||
@@ -393,13 +397,13 @@ class ReceiptController extends Controller
|
|||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function callPaymentStatus(Request $request, Accident $accident)
|
public function callPaymentStatus(Request $request, Accident $accident, PaymentService $paymentService)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::transaction(function () use ($request, $accident) {
|
DB::transaction(function () use ($request, $accident, $paymentService) {
|
||||||
if ($accident->final_amount > 0) {
|
if ($accident->final_amount > 0) {
|
||||||
|
|
||||||
$response = json_decode($this->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0]));
|
$response = json_decode($paymentService->callPaymentStatusBillApi(explode("/", $accident->bill_code)[0]));
|
||||||
|
|
||||||
if ($response->isPayed) {
|
if ($response->isPayed) {
|
||||||
$accident->payBill();
|
$accident->payBill();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use Illuminate\View\View;
|
|||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
use App\Exports\V2\Receipt\ReceiptTable\AllSheets as ReceiptTable;
|
use App\Exports\V2\Receipt\RecieptTable\AllSheets as ReceiptTable;
|
||||||
|
|
||||||
|
|
||||||
class ReceiptReportController extends Controller
|
class ReceiptReportController extends Controller
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
use App\Models\SetadProvince;
|
use App\Models\SetadProvince;
|
||||||
use phpDocumentor\Reflection\Utils;
|
use phpDocumentor\Reflection\Utils;
|
||||||
use Webpatser\Uuid\Uuid;
|
use Webpatser\Uuid\Uuid;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ResearchDevController extends Controller
|
class ResearchDevController extends Controller
|
||||||
@@ -370,7 +371,7 @@ class ResearchDevController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make Unique Code
|
// Make Unique Code
|
||||||
$uuid = Uuid::generate();
|
$uuid = Str::uuid();
|
||||||
|
|
||||||
|
|
||||||
switch ($request->domain_id) {
|
switch ($request->domain_id) {
|
||||||
|
|||||||
@@ -430,56 +430,58 @@ class RoadItemsProjectController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
////// function show items on map
|
////// function show items on map
|
||||||
public function show_item(Request $request)
|
// sharareh begin
|
||||||
{
|
// public function show_item(Request $request)
|
||||||
$province = $request->province_id;
|
// {
|
||||||
$city = $request->city_id;
|
// $province = $request->province_id;
|
||||||
$sub = $request->sub_id;
|
// $city = $request->city_id;
|
||||||
|
// $sub = $request->sub_id;
|
||||||
|
|
||||||
if ($request->date_from && $request->date_to) {
|
// if ($request->date_from && $request->date_to) {
|
||||||
$date_from = $request->date_from.' 00:00:00';
|
// $date_from = $request->date_from.' 00:00:00';
|
||||||
$date_to = $request->date_to.' 23:59:59';
|
// $date_to = $request->date_to.' 23:59:59';
|
||||||
} else {
|
// } else {
|
||||||
$date_from = Date('Y-m-d');
|
// $date_from = Date('Y-m-d');
|
||||||
$date_to = new \DateTime('tomorrow');
|
// $date_to = new \DateTime('tomorrow');
|
||||||
$date_to = $date_to->format('Y-m-d');
|
// $date_to = $date_to->format('Y-m-d');
|
||||||
}
|
// }
|
||||||
|
// $datass = DB::table('road_items_projects')
|
||||||
|
// ->where('is_new', 1)
|
||||||
|
// ->when($province, function ($query, $province) {
|
||||||
|
// return $query->where('road_items_projects.province_id', $province);
|
||||||
|
// })
|
||||||
|
// ->when($city, function ($query, $city) {
|
||||||
|
// return $query->where('road_items_projects.city_id', $city);
|
||||||
|
// })
|
||||||
|
// ->when($sub, function ($query, $sub) {
|
||||||
|
// return $query->where('sub_items', 'like', '%"'.$sub.'"%');
|
||||||
|
// })
|
||||||
|
// ->when($request->item, function ($query) use ($request) {
|
||||||
|
// if ($request->item > 0) {
|
||||||
|
// return $query->where('item', $request->item);
|
||||||
|
// }
|
||||||
|
// return $query;
|
||||||
|
// })
|
||||||
|
// ->when(!is_null($request->status), function ($query) use ($request) {
|
||||||
|
// return $query->where('status', $request->status);
|
||||||
|
// })
|
||||||
|
// ->leftJoin('users', 'users.id', '=', 'road_items_projects.user_id')
|
||||||
|
// ->whereBetween('road_items_projects.activity_date', [
|
||||||
|
// $date_from,
|
||||||
|
// $date_to,
|
||||||
|
// ])
|
||||||
|
// ->select('road_items_projects.id as i', 'start_lat as l', 'start_lng as g', 'status')
|
||||||
|
// ->get();
|
||||||
|
// // dd($datass);
|
||||||
|
|
||||||
$datass = DB::table('road_items_projects')
|
// return response()->json([
|
||||||
->where('is_new', 1)
|
// 'status' => 'succeed',
|
||||||
->when($province, function ($query, $province) {
|
// 'count' => count($datass),
|
||||||
return $query->where('road_items_projects.province_id', $province);
|
// 'message' => '',
|
||||||
})
|
// 'data' => $datass
|
||||||
->when($city, function ($query, $city) {
|
// ], 200);
|
||||||
return $query->where('road_items_projects.city_id', $city);
|
// }
|
||||||
})
|
// sharareh end
|
||||||
->when($sub, function ($query, $sub) {
|
|
||||||
return $query->where('sub_items', 'like', '%"'.$sub.'"%');
|
|
||||||
})
|
|
||||||
->when($request->item, function ($query) use ($request) {
|
|
||||||
if ($request->item > 0) {
|
|
||||||
return $query->where('item', $request->item);
|
|
||||||
}
|
|
||||||
return $query;
|
|
||||||
})
|
|
||||||
->when(!is_null($request->status), function ($query) use ($request) {
|
|
||||||
return $query->where('status', $request->status);
|
|
||||||
})
|
|
||||||
->leftJoin('users', 'users.id', '=', 'road_items_projects.user_id')
|
|
||||||
->whereBetween('road_items_projects.activity_date', [
|
|
||||||
$date_from,
|
|
||||||
$date_to,
|
|
||||||
])
|
|
||||||
->select('road_items_projects.id as i', 'start_lat as l', 'start_lng as g', 'status')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'succeed',
|
|
||||||
'count' => count($datass),
|
|
||||||
'message' => '',
|
|
||||||
'data' => $datass
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function table3InRoadItemProject(Request $request)
|
public function table3InRoadItemProject(Request $request)
|
||||||
|
|||||||
@@ -219,14 +219,14 @@ class UserActivityController extends Controller
|
|||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
ORDER BY majmoe desc;";
|
ORDER BY majmoe desc;";
|
||||||
|
|
||||||
foreach (DB::select(DB::raw($user_activity_quantity_sql)) as $key => $value) {
|
foreach (DB::select($user_activity_quantity_sql) as $key => $value) {
|
||||||
$user_activity_quantity_temp[$value->user_id] = [
|
$user_activity_quantity_temp[$value->user_id] = [
|
||||||
"majmoe" => $value->quantity ?? 0,
|
"majmoe" => $value->quantity ?? 0,
|
||||||
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (DB::select(DB::raw($user_activity_time_sql)) as $key => $value) {
|
foreach (DB::select($user_activity_time_sql) as $key => $value) {
|
||||||
$user_activity_time_temp[$value->user_id] = [
|
$user_activity_time_temp[$value->user_id] = [
|
||||||
"majmoe" => $value->majmoe ?? 0,
|
"majmoe" => $value->majmoe ?? 0,
|
||||||
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
||||||
@@ -245,7 +245,7 @@ class UserActivityController extends Controller
|
|||||||
LIMIT 5
|
LIMIT 5
|
||||||
";
|
";
|
||||||
|
|
||||||
$activity_list = DB::select(DB::raw($user_activity_top_5_temp_sql));
|
$activity_list = DB::select($user_activity_top_5_temp_sql);
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
foreach ($activity_list as $index => $item) {
|
foreach ($activity_list as $index => $item) {
|
||||||
$sum += (int) $item->quantity;
|
$sum += (int) $item->quantity;
|
||||||
@@ -263,17 +263,17 @@ class UserActivityController extends Controller
|
|||||||
'fromDate' => $request->fromDate ? $request->fromDate : null,
|
'fromDate' => $request->fromDate ? $request->fromDate : null,
|
||||||
'toDate' => $request->toDate ? $request->toDate : null,
|
'toDate' => $request->toDate ? $request->toDate : null,
|
||||||
'user_activity_time' => $ids_list ? $user_activity_time_temp : null,
|
'user_activity_time' => $ids_list ? $user_activity_time_temp : null,
|
||||||
'hourly_activity_chart' => $ids_list ? DB::select(DB::raw($hourly_activity_chart_sql)): null,
|
'hourly_activity_chart' => $ids_list ? DB::select($hourly_activity_chart_sql): null,
|
||||||
'quantitative_activity_chart' => $ids_list ? DB::select(DB::raw($quantitative_activity_chart_sql)): null,
|
'quantitative_activity_chart' => $ids_list ? DB::select($quantitative_activity_chart_sql): null,
|
||||||
'total_activity_quantity' => $ids_list ? DB::select(DB::raw($total_activity_quantity_sql))[0]->total_activity_quantity : null,
|
'total_activity_quantity' => $ids_list ? DB::select($total_activity_quantity_sql)[0]->total_activity_quantity : null,
|
||||||
'total_activity_time' => $ids_list ? DB::select(DB::raw($total_activity_time_sql))[0]->activity : null,
|
'total_activity_time' => $ids_list ? DB::select($total_activity_time_sql)[0]->activity : null,
|
||||||
'top_10_activity_list' => $ids_list ? DB::select(DB::raw($top_10_activity_list_sql)) : null,
|
'top_10_activity_list' => $ids_list ? DB::select($top_10_activity_list_sql) : null,
|
||||||
'user_activity_quantity' => $ids_list ? $user_activity_quantity_temp : null,
|
'user_activity_quantity' => $ids_list ? $user_activity_quantity_temp : null,
|
||||||
'group_name' => $role->name_fa,
|
'group_name' => $role->name_fa,
|
||||||
'average' => round(($ids_list ? DB::select(DB::raw($total_activity_time_sql))[0]->activity : 0) / count($users), 2) ,
|
'average' => round(($ids_list ? DB::select($total_activity_time_sql)[0]->activity : 0) / count($users), 2) ,
|
||||||
'user_activity_top_5_temp' => $user_activity_top_5_temp,
|
'user_activity_top_5_temp' => $user_activity_top_5_temp,
|
||||||
'total_user_count' => count($users),
|
'total_user_count' => count($users),
|
||||||
'active_user_count' => $ids_list ? DB::select(DB::raw($active_user_count_sql))[0]->active_user_count : null,
|
'active_user_count' => $ids_list ? DB::select($active_user_count_sql)[0]->active_user_count : null,
|
||||||
'group_id' => $role->id
|
'group_id' => $role->id
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ class UserActivityController extends Controller
|
|||||||
) user_activity_by_hour_and_
|
) user_activity_by_hour_and_
|
||||||
GROUP BY user_id) AS calculated_table;";
|
GROUP BY user_id) AS calculated_table;";
|
||||||
|
|
||||||
$activity = DB::select(DB::raw($temp_sql))[0]->activity;
|
$activity = DB::select($temp_sql)[0]->activity;
|
||||||
$users_activity[] = [
|
$users_activity[] = [
|
||||||
'activity_time' => $ids_list ? $activity : null,
|
'activity_time' => $ids_list ? $activity : null,
|
||||||
'average' => round(($ids_list ? $activity : 0) / count($users), 2) ,
|
'average' => round(($ids_list ? $activity : 0) / count($users), 2) ,
|
||||||
@@ -424,8 +424,8 @@ class UserActivityController extends Controller
|
|||||||
GROUP BY user_id) AS calculated_table;";
|
GROUP BY user_id) AS calculated_table;";
|
||||||
|
|
||||||
$users_activity[] = [
|
$users_activity[] = [
|
||||||
'activity_time' => $country_group_ids_list ? DB::select(DB::raw($country_temp_sql))[0]->activity : null,
|
'activity_time' => $country_group_ids_list ? DB::select($country_temp_sql)[0]->activity : null,
|
||||||
'average' => round(($country_group_ids_list ? DB::select(DB::raw($country_temp_sql))[0]->activity : 0) / $country_group_user_quantity, 2) ,
|
'average' => round(($country_group_ids_list ? DB::select($country_temp_sql)[0]->activity : 0) / $country_group_user_quantity, 2) ,
|
||||||
'group_name' => 'کشوری',
|
'group_name' => 'کشوری',
|
||||||
'user_count' => $country_group_user_quantity,
|
'user_count' => $country_group_user_quantity,
|
||||||
'is_static' => 1,
|
'is_static' => 1,
|
||||||
@@ -464,8 +464,8 @@ class UserActivityController extends Controller
|
|||||||
GROUP BY user_id) AS calculated_table;";
|
GROUP BY user_id) AS calculated_table;";
|
||||||
|
|
||||||
$users_activity[] = [
|
$users_activity[] = [
|
||||||
'activity_time' => $organization_group_ids_list ? DB::select(DB::raw($organization_temp_sql))[0]->activity : null,
|
'activity_time' => $organization_group_ids_list ? DB::select($organization_temp_sql)[0]->activity : null,
|
||||||
'average' => round(($organization_group_ids_list ? DB::select(DB::raw($organization_temp_sql))[0]->activity : 0) / $organization_group_user_quantity, 2) ,
|
'average' => round(($organization_group_ids_list ? DB::select($organization_temp_sql)[0]->activity : 0) / $organization_group_user_quantity, 2) ,
|
||||||
'group_name' => 'سازمانی',
|
'group_name' => 'سازمانی',
|
||||||
'user_count' => $organization_group_user_quantity,
|
'user_count' => $organization_group_user_quantity,
|
||||||
'is_static' => 2,
|
'is_static' => 2,
|
||||||
@@ -696,8 +696,8 @@ class UserActivityController extends Controller
|
|||||||
dd;";
|
dd;";
|
||||||
|
|
||||||
$data['labels'][] = $role->name_fa;
|
$data['labels'][] = $role->name_fa;
|
||||||
$data['hourly_activity_chart'][] = isset(DB::select(DB::raw($hourly_activity_chart_sql))[0]->majmoe) ? DB::select(DB::raw($hourly_activity_chart_sql))[0]->majmoe: 0;
|
$data['hourly_activity_chart'][] = isset(DB::select($hourly_activity_chart_sql)[0]->majmoe) ? DB::select($hourly_activity_chart_sql)[0]->majmoe: 0;
|
||||||
$data['quantitative_activity_chart'][] = isset(DB::select(DB::raw($quantitative_activity_chart_sql))[0]->quantity) ? DB::select(DB::raw($quantitative_activity_chart_sql))[0]->quantity: 0;
|
$data['quantitative_activity_chart'][] = isset(DB::select($quantitative_activity_chart_sql)[0]->quantity) ? DB::select($quantitative_activity_chart_sql)[0]->quantity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -707,7 +707,7 @@ class UserActivityController extends Controller
|
|||||||
WHERE created_at between '{$request->fromDate}' and '{$request->toDate}' and user_id IN(".$total_ids_list.")
|
WHERE created_at between '{$request->fromDate}' and '{$request->toDate}' and user_id IN(".$total_ids_list.")
|
||||||
";
|
";
|
||||||
|
|
||||||
$data['total_activity_quantity'] = $total_ids_list ? DB::select(DB::raw($total_activity_quantity_sql))[0]->total_activity_quantity : null;
|
$data['total_activity_quantity'] = $total_ids_list ? DB::select($total_activity_quantity_sql)[0]->total_activity_quantity : null;
|
||||||
|
|
||||||
$data['total_user_count'] = count(explode(',', $total_ids_list));
|
$data['total_user_count'] = count(explode(',', $total_ids_list));
|
||||||
|
|
||||||
@@ -721,7 +721,7 @@ class UserActivityController extends Controller
|
|||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
) grpuped_by_user_id";
|
) grpuped_by_user_id";
|
||||||
|
|
||||||
$data['active_user_count'] = $total_ids_list ? DB::select(DB::raw($active_user_count_sql))[0]->active_user_count : null;
|
$data['active_user_count'] = $total_ids_list ? DB::select($active_user_count_sql)[0]->active_user_count : null;
|
||||||
|
|
||||||
$total_activity_time_sql = "
|
$total_activity_time_sql = "
|
||||||
SELECT sum(majmoe) AS activity FROM (SELECT *,
|
SELECT sum(majmoe) AS activity FROM (SELECT *,
|
||||||
@@ -739,9 +739,9 @@ class UserActivityController extends Controller
|
|||||||
) user_activity_by_hour_and_
|
) user_activity_by_hour_and_
|
||||||
GROUP BY user_id) AS calculated_table;";
|
GROUP BY user_id) AS calculated_table;";
|
||||||
|
|
||||||
$data['total_activity_time'] = $total_ids_list ? DB::select(DB::raw($total_activity_time_sql))[0]->activity : null;
|
$data['total_activity_time'] = $total_ids_list ? DB::select($total_activity_time_sql)[0]->activity : null;
|
||||||
|
|
||||||
$data['average'] = round(($total_ids_list ? DB::select(DB::raw($total_activity_time_sql))[0]->activity : 0) / count(explode(',', $total_ids_list)), 2);
|
$data['average'] = round(($total_ids_list ? DB::select($total_activity_time_sql)[0]->activity : 0) / count(explode(',', $total_ids_list)), 2);
|
||||||
|
|
||||||
$top_10_activity_list_sql = "
|
$top_10_activity_list_sql = "
|
||||||
SELECT *,
|
SELECT *,
|
||||||
@@ -758,7 +758,7 @@ class UserActivityController extends Controller
|
|||||||
ORDER BY quantity desc
|
ORDER BY quantity desc
|
||||||
LIMIT 10";
|
LIMIT 10";
|
||||||
|
|
||||||
$data['top_10_activity_list'] = $total_ids_list ? DB::select(DB::raw($top_10_activity_list_sql)) : null;
|
$data['top_10_activity_list'] = $total_ids_list ? DB::select($top_10_activity_list_sql) : null;
|
||||||
|
|
||||||
|
|
||||||
$data['fromDate'] = $request->fromDate ? $request->fromDate : null;
|
$data['fromDate'] = $request->fromDate ? $request->fromDate : null;
|
||||||
|
|||||||
@@ -187,14 +187,14 @@ class UserController extends Controller
|
|||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
ORDER BY majmoe desc;";
|
ORDER BY majmoe desc;";
|
||||||
|
|
||||||
foreach (DB::select(DB::raw($user_activity_quantity_sql)) as $key => $value) {
|
foreach (DB::select($user_activity_quantity_sql) as $key => $value) {
|
||||||
$user_activity_quantity_temp[$value->user_id] = [
|
$user_activity_quantity_temp[$value->user_id] = [
|
||||||
"majmoe" => $value->quantity ?? 0,
|
"majmoe" => $value->quantity ?? 0,
|
||||||
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (DB::select(DB::raw($user_activity_time_sql)) as $key => $value) {
|
foreach (DB::select($user_activity_time_sql) as $key => $value) {
|
||||||
$user_activity_time_temp[$value->user_id] = [
|
$user_activity_time_temp[$value->user_id] = [
|
||||||
"majmoe" => $value->majmoe ?? 0,
|
"majmoe" => $value->majmoe ?? 0,
|
||||||
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
"name" => $value->user_first_name ? $value->user_first_name." ".$value->user_last_name." (".$value->username.")" : $value->user_name." (".$value->username.")",
|
||||||
@@ -213,7 +213,7 @@ class UserController extends Controller
|
|||||||
LIMIT 5
|
LIMIT 5
|
||||||
";
|
";
|
||||||
|
|
||||||
$activity_list = DB::select(DB::raw($user_activity_top_5_temp_sql));
|
$activity_list = DB::select($user_activity_top_5_temp_sql);
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
foreach ($activity_list as $index => $item) {
|
foreach ($activity_list as $index => $item) {
|
||||||
$sum += (int) $item->quantity;
|
$sum += (int) $item->quantity;
|
||||||
@@ -231,17 +231,17 @@ class UserController extends Controller
|
|||||||
'fromDate' => $request->fromDate ? $request->fromDate : null,
|
'fromDate' => $request->fromDate ? $request->fromDate : null,
|
||||||
'toDate' => $request->toDate ? $request->toDate : null,
|
'toDate' => $request->toDate ? $request->toDate : null,
|
||||||
'user_activity_time' => $ids_list ? $user_activity_time_temp : null,
|
'user_activity_time' => $ids_list ? $user_activity_time_temp : null,
|
||||||
'hourly_activity_chart' => $ids_list ? DB::select(DB::raw($hourly_activity_chart_sql)) : null,
|
'hourly_activity_chart' => $ids_list ? DB::select($hourly_activity_chart_sql) : null,
|
||||||
'quantitative_activity_chart' => $ids_list ? DB::select(DB::raw($quantitative_activity_chart_sql)) : null,
|
'quantitative_activity_chart' => $ids_list ? DB::select($quantitative_activity_chart_sql) : null,
|
||||||
'total_activity_quantity' => $ids_list ? DB::select(DB::raw($total_activity_quantity_sql))[0]->total_activity_quantity : null,
|
'total_activity_quantity' => $ids_list ? DB::select($total_activity_quantity_sql)[0]->total_activity_quantity : null,
|
||||||
'total_activity_time' => $ids_list ? DB::select(DB::raw($total_activity_time_sql))[0]->activity : null,
|
'total_activity_time' => $ids_list ? DB::select($total_activity_time_sql)[0]->activity : null,
|
||||||
'top_10_activity_list' => $ids_list ? DB::select(DB::raw($top_10_activity_list_sql)) : null,
|
'top_10_activity_list' => $ids_list ? DB::select($top_10_activity_list_sql) : null,
|
||||||
'user_activity_quantity' => $ids_list ? $user_activity_quantity_temp : null,
|
'user_activity_quantity' => $ids_list ? $user_activity_quantity_temp : null,
|
||||||
'group_name' => $user->first_name." ".$user->last_name,
|
'group_name' => $user->first_name." ".$user->last_name,
|
||||||
'average' => round(($ids_list ? DB::select(DB::raw($total_activity_time_sql))[0]->activity : 0) / 1, 2) ,
|
'average' => round(($ids_list ? DB::select($total_activity_time_sql)[0]->activity : 0) / 1, 2) ,
|
||||||
'user_activity_top_5_temp' => $user_activity_top_5_temp,
|
'user_activity_top_5_temp' => $user_activity_top_5_temp,
|
||||||
'total_user_count' => 1,
|
'total_user_count' => 1,
|
||||||
'active_user_count' => $ids_list ? DB::select(DB::raw($active_user_count_sql))[0]->active_user_count : null,
|
'active_user_count' => $ids_list ? DB::select($active_user_count_sql)[0]->active_user_count : null,
|
||||||
'group_id' => $user->id
|
'group_id' => $user->id
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -1550,7 +1550,7 @@ class UserController extends Controller
|
|||||||
->leftJoin('users', 'users.id', '=', 'road_items_projects.user_id')
|
->leftJoin('users', 'users.id', '=', 'road_items_projects.user_id')
|
||||||
->leftJoin('cities', 'cities.id', '=', 'users.city_id')
|
->leftJoin('cities', 'cities.id', '=', 'users.city_id')
|
||||||
->where('city_id', '>', 0)
|
->where('city_id', '>', 0)
|
||||||
->select(DB::raw('count(*) as count, item, city_id, name_fa'))
|
->select('count(*) as count, item, city_id, name_fa')
|
||||||
->groupBy('city_id', 'item')
|
->groupBy('city_id', 'item')
|
||||||
->get();
|
->get();
|
||||||
// $items_array = $itemss->toArray();
|
// $items_array = $itemss->toArray();
|
||||||
@@ -1906,9 +1906,9 @@ class UserController extends Controller
|
|||||||
WHERE created_at between '{$request->fromDate}' and '{$request->toDate}' and user_id IN(".$user->id.")
|
WHERE created_at between '{$request->fromDate}' and '{$request->toDate}' and user_id IN(".$user->id.")
|
||||||
ORDER BY cnt desc";
|
ORDER BY cnt desc";
|
||||||
|
|
||||||
$number_of_active_days = (DB::select(DB::raw($number_of_active_days))[0]->cnt ? DB::select(DB::raw($number_of_active_days))[0]->cnt : -1);
|
$number_of_active_days = (DB::select($number_of_active_days)[0]->cnt ? DB::select($number_of_active_days)[0]->cnt : -1);
|
||||||
$activity_time = DB::select(DB::raw($temp_sql_for_activity_time))[0]->activity;
|
$activity_time = DB::select($temp_sql_for_activity_time)[0]->activity;
|
||||||
$number_of_activities = DB::select(DB::raw($number_of_activities))[0]->cnt;
|
$number_of_activities = DB::select($number_of_activities)[0]->cnt;
|
||||||
$data = [
|
$data = [
|
||||||
'number_of_active_days' => $number_of_active_days,
|
'number_of_active_days' => $number_of_active_days,
|
||||||
|
|
||||||
@@ -1917,7 +1917,7 @@ class UserController extends Controller
|
|||||||
'number_of_activities' => $number_of_activities ,
|
'number_of_activities' => $number_of_activities ,
|
||||||
'average_activity_number' => round(($user->id ? $number_of_activities : 0) / $number_of_active_days, 2) ,
|
'average_activity_number' => round(($user->id ? $number_of_activities : 0) / $number_of_active_days, 2) ,
|
||||||
|
|
||||||
'activity_list' => $user->id ? DB::select(DB::raw($temp_sql_for_activity_list)) : null,
|
'activity_list' => $user->id ? DB::select($temp_sql_for_activity_list) : null,
|
||||||
'last_login' => $user->last_login,
|
'last_login' => $user->last_login,
|
||||||
];
|
];
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\Models\RoadItemsProject;
|
|||||||
use App\Models\EdarateShahri;
|
use App\Models\EdarateShahri;
|
||||||
use App\Models\ObservedItem;
|
use App\Models\ObservedItem;
|
||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
|
use App\Services\NominatimService;
|
||||||
use App\Exports\V2\RoadItems\OperatorCartableExport;
|
use App\Exports\V2\RoadItems\OperatorCartableExport;
|
||||||
use App\Exports\V2\RoadItems\SupervisorCartableExport;
|
use App\Exports\V2\RoadItems\SupervisorCartableExport;
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ class RoadItemsProjectController extends Controller
|
|||||||
return view('version2.dashboard_pages.road_items.operation_cartable');
|
return view('version2.dashboard_pages.road_items.operation_cartable');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
if (!Auth::user()->can('create-road-item')) {
|
if (!Auth::user()->can('create-road-item')) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -290,8 +290,8 @@ class RoadItemsProjectController extends Controller
|
|||||||
'city_id' => Auth::user()->city_id,
|
'city_id' => Auth::user()->city_id,
|
||||||
'city_fa' => Auth::user()->city_fa,
|
'city_fa' => Auth::user()->city_fa,
|
||||||
'user_name' => Auth::user()->name,
|
'user_name' => Auth::user()->name,
|
||||||
'start_way_id' => get_way_id_from_nominatim($start_coordinates[0], $start_coordinates[1]),
|
'start_way_id' => $nominatimService->get_way_id_from_nominatim(),
|
||||||
'end_way_id' => $end_coordinates ? get_way_id_from_nominatim($end_coordinates[0], $end_coordinates[1]) : null,
|
'end_way_id' => $end_coordinates ? $nominatimService->get_way_id_from_nominatim() : null,
|
||||||
'unit_fa' => $info_item->sub_item_unit,
|
'unit_fa' => $info_item->sub_item_unit,
|
||||||
'created_at_fa' => verta(\Carbon\Carbon::now())->format('Y-m-d H:i:s'),
|
'created_at_fa' => verta(\Carbon\Carbon::now())->format('Y-m-d H:i:s'),
|
||||||
'info_id' => $info_item->id,
|
'info_id' => $info_item->id,
|
||||||
|
|||||||
@@ -36,20 +36,25 @@ class RoadItemsReportController extends Controller
|
|||||||
if ($request->from_date && $request->date_to) {
|
if ($request->from_date && $request->date_to) {
|
||||||
$from_date = $request->from_date;
|
$from_date = $request->from_date;
|
||||||
$date_to = $request->date_to;
|
$date_to = $request->date_to;
|
||||||
$from_date = $from_date.' 00:00:00';
|
$from_date = $from_date . ' 00:00:00';
|
||||||
$date_to = $date_to.' 23:59:59';
|
$date_to = $date_to . ' 23:59:59';
|
||||||
} else {
|
} else {
|
||||||
$from_date = Date('Y-m-d');
|
$from_date = Date('Y-m-d');
|
||||||
$from_date = $from_date.' 00:00:00';
|
$from_date = $from_date . ' 00:00:00';
|
||||||
$date_to = Date('Y-m-d');
|
$date_to = Date('Y-m-d');
|
||||||
$date_to = $date_to.' 23:59:59';
|
$date_to = $date_to . ' 23:59:59';
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = $request->item;
|
$item = $request->item;
|
||||||
$all = array();
|
$all = array();
|
||||||
$all = DB::select(DB::raw(
|
$all = DB::select(
|
||||||
'SELECT sub_item AS t,COUNT(*) AS c,CAST(SUM(CASE WHEN sub_item_data>0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,province_id AS p FROM road_items_projects WHERE item = '.$item.' AND activity_date_time BETWEEN "'.$from_date.'" AND "'.$date_to.'" and status = 1 GROUP BY p, sub_item'));
|
'SELECT sub_item AS t,COUNT(*) AS c,CAST(SUM(CASE WHEN sub_item_data>0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,province_id AS p FROM road_items_projects WHERE item = ' . $item . ' AND activity_date_time BETWEEN "' . $from_date . '" AND "' . $date_to . '" and status = 1 GROUP BY p, sub_item'
|
||||||
$country =DB::select(DB::raw(
|
);
|
||||||
'SELECT sub_item AS t,COUNT(*) AS c,CAST(SUM(CASE WHEN sub_item_data>0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s, -1 AS p FROM road_items_projects WHERE item = '.$item.' AND activity_date_time BETWEEN "'.$from_date.'" AND "'.$date_to.'" and status = 1 GROUP BY sub_item'));
|
|
||||||
|
$country = DB::select(
|
||||||
|
'SELECT sub_item AS t,COUNT(*) AS c,CAST(SUM(CASE WHEN sub_item_data>0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s, -1 AS p FROM road_items_projects WHERE item = ' . $item . ' AND activity_date_time BETWEEN "' . $from_date . '" AND "' . $date_to . '" and status = 1 GROUP BY sub_item'
|
||||||
|
);
|
||||||
|
|
||||||
$items_fa = InfoItem::where('item', $item)->get();
|
$items_fa = InfoItem::where('item', $item)->get();
|
||||||
foreach ($all as $value) {
|
foreach ($all as $value) {
|
||||||
foreach ($items_fa as $val) {
|
foreach ($items_fa as $val) {
|
||||||
@@ -58,31 +63,37 @@ class RoadItemsReportController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response()->json([
|
return response()->json(
|
||||||
'status' => 'succeed',
|
[
|
||||||
'message' => '',
|
'status' => 'succeed',
|
||||||
'data' => $all,
|
'message' => '',
|
||||||
'country' =>$country,
|
'data' => $all,
|
||||||
'items_fa' => $items_fa
|
'country' => $country,
|
||||||
], 200);
|
'items_fa' => $items_fa
|
||||||
|
],
|
||||||
|
200
|
||||||
|
);
|
||||||
}
|
}
|
||||||
public function get_items_city(Request $request)
|
public function get_items_city(Request $request)
|
||||||
{
|
{
|
||||||
$item = $request->item;
|
$item = $request->item;
|
||||||
if ($request->from_date && $request->date_to) {
|
if ($request->from_date && $request->date_to) {
|
||||||
$from_date = $request->from_date.' 00:00:00';
|
$from_date = $request->from_date . ' 00:00:00';
|
||||||
$date_to = $request->date_to.' 23:59:59';
|
$date_to = $request->date_to . ' 23:59:59';
|
||||||
} else {
|
} else {
|
||||||
$from_date = Date('Y-m-d');
|
$from_date = Date('Y-m-d');
|
||||||
$from_date = $from_date.' 00:00:00';
|
$from_date = $from_date . ' 00:00:00';
|
||||||
$date_to = Date('Y-m-d');
|
$date_to = Date('Y-m-d');
|
||||||
$date_to = $date_to.' 23:59:59';
|
$date_to = $date_to . ' 23:59:59';
|
||||||
}
|
}
|
||||||
$item = $request->item;
|
$item = $request->item;
|
||||||
$province = $request->province_id;
|
$province = $request->province_id;
|
||||||
$all = array();
|
$all = array();
|
||||||
$all = DB::select(DB::raw(
|
$all = DB::select(
|
||||||
'SELECT sub_item AS t,COUNT(*) AS c,CAST(SUM(CASE WHEN sub_item_data>0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,province_id AS p, edarat_id AS ci FROM road_items_projects WHERE item = '.$item.' AND province_id = '.$province.' AND activity_date_time BETWEEN "'.$from_date.'" AND "'.$date_to.'" and status = 1 GROUP BY ci, sub_item'));
|
DB::raw(
|
||||||
|
'SELECT sub_item AS t,COUNT(*) AS c,CAST(SUM(CASE WHEN sub_item_data>0 THEN sub_item_data ELSE ABS(sub_item_data) END) AS UNSIGNED) AS s,province_id AS p, edarat_id AS ci FROM road_items_projects WHERE item = ' . $item . ' AND province_id = ' . $province . ' AND activity_date_time BETWEEN "' . $from_date . '" AND "' . $date_to . '" and status = 1 GROUP BY ci, sub_item'
|
||||||
|
)
|
||||||
|
);
|
||||||
$items_fa = InfoItem::where('item', $item)->get();
|
$items_fa = InfoItem::where('item', $item)->get();
|
||||||
foreach ($all as $value) {
|
foreach ($all as $value) {
|
||||||
foreach ($items_fa as $val) {
|
foreach ($items_fa as $val) {
|
||||||
@@ -114,37 +125,38 @@ class RoadItemsReportController extends Controller
|
|||||||
if (Auth::user()->username == 'witel' || Auth::user()->username == 'drdanesh') {
|
if (Auth::user()->username == 'witel' || Auth::user()->username == 'drdanesh') {
|
||||||
$sql = "SELECT COUNT(*) AS s,province_id AS p,item AS i
|
$sql = "SELECT COUNT(*) AS s,province_id AS p,item AS i
|
||||||
FROM road_items_projects WHERE
|
FROM road_items_projects WHERE
|
||||||
road_items_projects.status = 1 and road_items_projects.activity_date_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59' GROUP BY province_id,item
|
road_items_projects.status = 1 and road_items_projects.activity_date_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59' GROUP BY province_id,item
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,province_id AS p,77 AS i FROM road_patrols
|
SELECT COUNT(*) AS s,province_id AS p,77 AS i FROM road_patrols
|
||||||
WHERE
|
WHERE
|
||||||
start_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59' GROUP BY province_id
|
start_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59' GROUP BY province_id
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,-1 AS p,item AS i FROM road_items_projects
|
SELECT COUNT(*) AS s,-1 AS p,item AS i FROM road_items_projects
|
||||||
WHERE road_items_projects.status = 1 and road_items_projects.activity_date_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59'
|
WHERE road_items_projects.status = 1 and road_items_projects.activity_date_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59'
|
||||||
GROUP BY item
|
GROUP BY item
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,-1 AS p,77 AS i FROM road_patrols
|
SELECT COUNT(*) AS s,-1 AS p,77 AS i FROM road_patrols
|
||||||
WHERE start_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59'";
|
WHERE start_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59'";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$province_id = Auth::user()->province_id;
|
$province_id = Auth::user()->province_id;
|
||||||
$sql = "SELECT COUNT(*) AS s,province_id AS p,item AS i
|
$sql = "SELECT COUNT(*) AS s,province_id AS p,item AS i
|
||||||
FROM road_items_projects WHERE road_items_projects.status = 1 and road_items_projects.province_id = ".$province_id." and
|
FROM road_items_projects WHERE road_items_projects.status = 1 and road_items_projects.province_id = " . $province_id . " and
|
||||||
road_items_projects.activity_date_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59' GROUP BY province_id,item
|
road_items_projects.activity_date_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59' GROUP BY province_id,item
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,province_id AS p,77 AS i FROM road_patrols
|
SELECT COUNT(*) AS s,province_id AS p,77 AS i FROM road_patrols
|
||||||
WHERE road_patrols.province_id = ".$province_id." and
|
WHERE road_patrols.province_id = " . $province_id . " and
|
||||||
road_patrols.start_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59' GROUP BY province_id
|
road_patrols.start_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59' GROUP BY province_id
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,-1 AS p,item AS i FROM road_items_projects
|
SELECT COUNT(*) AS s,-1 AS p,item AS i FROM road_items_projects
|
||||||
WHERE road_items_projects.status = 1 and road_items_projects.province_id = ".$province_id." and road_items_projects.activity_date_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59'
|
WHERE road_items_projects.status = 1 and road_items_projects.province_id = " . $province_id . " and road_items_projects.activity_date_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59'
|
||||||
GROUP BY item
|
GROUP BY item
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,-1 AS p,77 AS i FROM road_patrols
|
SELECT COUNT(*) AS s,-1 AS p,77 AS i FROM road_patrols
|
||||||
WHERE road_patrols.province_id = ".$province_id." and road_patrols.start_time BETWEEN '".$from_date." 00:00:00' and '".$date_to." 23:59:59'";
|
WHERE road_patrols.province_id = " . $province_id . " and road_patrols.start_time BETWEEN '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59'";
|
||||||
}
|
}
|
||||||
$data = DB::select(DB::raw($sql));
|
|
||||||
|
$data = DB::select($sql);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => 'succeed',
|
'status' => 'succeed',
|
||||||
@@ -165,19 +177,70 @@ class RoadItemsReportController extends Controller
|
|||||||
|
|
||||||
$sql = "SELECT COUNT(*) AS s,edarat_id AS c,item AS i
|
$sql = "SELECT COUNT(*) AS s,edarat_id AS c,item AS i
|
||||||
FROM road_items_projects where
|
FROM road_items_projects where
|
||||||
status = 1 and road_items_projects.activity_date_time between '".$from_date." 00:00:00' and '".$date_to." 23:59:59'
|
status = 1 and road_items_projects.activity_date_time between '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59'
|
||||||
and province_id= '".$p."' GROUP BY item,c
|
and province_id= '" . $p . "' GROUP BY item,c
|
||||||
UNION
|
UNION
|
||||||
SELECT COUNT(*) AS s,edare_id AS c,77 AS i FROM road_patrols
|
SELECT COUNT(*) AS s,edare_id AS c,77 AS i FROM road_patrols
|
||||||
where
|
where
|
||||||
road_patrols.start_time between '".$from_date." 00:00:00' and '".$date_to." 23:59:59'
|
road_patrols.start_time between '" . $from_date . " 00:00:00' and '" . $date_to . " 23:59:59'
|
||||||
and province_id= '".$p."' GROUP BY c";
|
and province_id= '" . $p . "' GROUP BY c";
|
||||||
|
|
||||||
$data = DB::select(DB::raw($sql));
|
$data = DB::select($sql);
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => 'succeed',
|
'status' => 'succeed',
|
||||||
'message' => '',
|
'message' => '',
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function map(Request $request)
|
||||||
|
{
|
||||||
|
$province = $request->province_id;
|
||||||
|
$city = $request->city_id;
|
||||||
|
$sub = $request->sub_id;
|
||||||
|
|
||||||
|
if ($request->date_from && $request->date_to) {
|
||||||
|
$date_from = $request->date_from.' 00:00:00';
|
||||||
|
$date_to = $request->date_to.' 23:59:59';
|
||||||
|
} else {
|
||||||
|
$date_from = Date('Y-m-d');
|
||||||
|
$date_to = new \DateTime('tomorrow');
|
||||||
|
$date_to = $date_to->format('Y-m-d');
|
||||||
|
}
|
||||||
|
$datass = DB::table('road_items_projects')
|
||||||
|
->where('is_new', 1)
|
||||||
|
->when($province, function ($query, $province) {
|
||||||
|
return $query->where('road_items_projects.province_id', $province);
|
||||||
|
})
|
||||||
|
->when($city, function ($query, $city) {
|
||||||
|
return $query->where('road_items_projects.city_id', $city);
|
||||||
|
})
|
||||||
|
->when($sub, function ($query, $sub) {
|
||||||
|
return $query->where('sub_items', 'like', '%"'.$sub.'"%');
|
||||||
|
})
|
||||||
|
->when($request->item, function ($query) use ($request) {
|
||||||
|
if ($request->item > 0) {
|
||||||
|
return $query->where('item', $request->item);
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
})
|
||||||
|
->when(!is_null($request->status), function ($query) use ($request) {
|
||||||
|
return $query->where('status', $request->status);
|
||||||
|
})
|
||||||
|
->leftJoin('users', 'users.id', '=', 'road_items_projects.user_id')
|
||||||
|
->whereBetween('road_items_projects.activity_date', [
|
||||||
|
$date_from,
|
||||||
|
$date_to,
|
||||||
|
])
|
||||||
|
->select('road_items_projects.id as i', 'start_lat as l', 'start_lng as g', 'status')
|
||||||
|
->get();
|
||||||
|
// dd($datass);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'succeed',
|
||||||
|
'count' => count($datass),
|
||||||
|
'message' => '',
|
||||||
|
'data' => $datass
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\V2\Dashboard;
|
namespace App\Http\Controllers\V2\Dashboard;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Services\NikarayanService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Hekmatinasser\Verta\Verta;
|
use Hekmatinasser\Verta\Verta;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@@ -24,6 +25,7 @@ use App\Exports\V2\RoadObservation\OperatorCartableExport;
|
|||||||
use App\Exports\V2\RoadObservation\SupervisorCartableExport;
|
use App\Exports\V2\RoadObservation\SupervisorCartableExport;
|
||||||
use App\Exports\V2\RoadObservation\PendingComplaintsExport;
|
use App\Exports\V2\RoadObservation\PendingComplaintsExport;
|
||||||
use App\Exports\V2\RoadObservation\ReportComplaintsExport;
|
use App\Exports\V2\RoadObservation\ReportComplaintsExport;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class RoadObservationController extends Controller
|
class RoadObservationController extends Controller
|
||||||
{
|
{
|
||||||
@@ -210,6 +212,7 @@ class RoadObservationController extends Controller
|
|||||||
public function operatorCartableReport(Request $request)
|
public function operatorCartableReport(Request $request)
|
||||||
{
|
{
|
||||||
$name = 'گزارش از کارتابل عملیات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
$name = 'گزارش از کارتابل عملیات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||||
|
// dd($request->id, $request->status, $request->fromDate, $request->toDate, $name);
|
||||||
return Excel::download(new OperatorCartableExport($request->id, $request->status, $request->fromDate, $request->toDate), $name);
|
return Excel::download(new OperatorCartableExport($request->id, $request->status, $request->fromDate, $request->toDate), $name);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -233,7 +236,7 @@ class RoadObservationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$from_date_array = explode('-', verta()->startYear()->format('Y-m-d'));
|
$from_date_array = explode('-', verta()->startYear()->format('Y-m-d'));
|
||||||
$from_datetime = implode('-', verta()->getGregorian($from_date_array[0], $from_date_array[1], $from_date_array[2])) . ' 00:00:00';
|
$from_datetime = implode('-', verta()->jalaliToGregorian($from_date_array[0], $from_date_array[1], $from_date_array[2])) . ' 00:00:00';
|
||||||
$to_datetime = Carbon::now()->toDateString() . ' 23:59:59';
|
$to_datetime = Carbon::now()->toDateString() . ' 23:59:59';
|
||||||
|
|
||||||
if (auth()->user()->hasPermissionTo('show-fast-react')) {
|
if (auth()->user()->hasPermissionTo('show-fast-react')) {
|
||||||
@@ -423,7 +426,7 @@ class RoadObservationController extends Controller
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(Request $request, RoadObserved $roadObserved)
|
public function handle(Request $request, RoadObserved $roadObserved, NikarayanService $nikarayanService)
|
||||||
{
|
{
|
||||||
if (! auth()->user()->hasAnyPermission(['show-fast-react-edarate-shahri', 'show-fast-react-province', 'show-fast-react'])) {
|
if (! auth()->user()->hasAnyPermission(['show-fast-react-edarate-shahri', 'show-fast-react-province', 'show-fast-react'])) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -434,7 +437,9 @@ class RoadObservationController extends Controller
|
|||||||
$files_path = [];
|
$files_path = [];
|
||||||
$file_index = 0;
|
$file_index = 0;
|
||||||
$file_time = time();
|
$file_time = time();
|
||||||
$uuid = \Uuid::generate();
|
// $uuid = \Uuid::generate();
|
||||||
|
$uuid = (string) Str::uuid();
|
||||||
|
|
||||||
if ($request->file('image-before-1')) {
|
if ($request->file('image-before-1')) {
|
||||||
$roadObserved->files()->where('path', 'like', '%_image-before-1_%')->delete();
|
$roadObserved->files()->where('path', 'like', '%_image-before-1_%')->delete();
|
||||||
|
|
||||||
@@ -494,19 +499,9 @@ class RoadObservationController extends Controller
|
|||||||
// if ($file_index > 0) {
|
// if ($file_index > 0) {
|
||||||
// $roadObserved->files()->createMany($files_path);
|
// $roadObserved->files()->createMany($files_path);
|
||||||
// }
|
// }
|
||||||
$url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
// $url = "https://riws.rmto.ir/WebServices/NRPTrafficStatus.asmx?wsdl";
|
||||||
try {
|
try {
|
||||||
$array = array('strUserName' => 'vaytelrop',
|
$result = $nikarayanService->updateRoadObservedInfoByNikarayan($request, $roadObserved, $files);
|
||||||
'strPassword' => 'VaYtelROP*2024',
|
|
||||||
'strAutoID' => $roadObserved->fk_RegisteredEventMessage,
|
|
||||||
'strStateID' => ($request->input('rms-status') == 1) ? '2' : '3',
|
|
||||||
'strDescription' => $request->input('rms-description') ?? $roadObserved->rms_description,
|
|
||||||
'strPreviousImageLink' => "https://rms.rmto.ir/".$files,
|
|
||||||
'strNextImageLink' => "https://rms.rmto.ir/".$files,
|
|
||||||
'strRMSDateAndTime' => $roadObserved->updated_at
|
|
||||||
);
|
|
||||||
$soap_client = new SoapClient($url);
|
|
||||||
$result = $soap_client->UpdateInfo_RoadObservedProblems($array);
|
|
||||||
} catch (SoapFault $e) {
|
} catch (SoapFault $e) {
|
||||||
|
|
||||||
$msg = "error in send to nikarayan at".date("Y-m-d H:i:s")."\n".'rms: error in get road observation webservice babe!!!!'."\n";
|
$msg = "error in send to nikarayan at".date("Y-m-d H:i:s")."\n".'rms: error in get road observation webservice babe!!!!'."\n";
|
||||||
|
|||||||
@@ -50,48 +50,6 @@ class RoadObservationReportController extends Controller
|
|||||||
|
|
||||||
$data = processDataTable($request, '', $fields, $query);
|
$data = processDataTable($request, '', $fields, $query);
|
||||||
|
|
||||||
// $data = RoadObserved::leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')->select('road_observeds.id', 'province_fa', 'city_fa', 'FeatureTypeTitle', 'road_observeds.created_at', 'Title', 'Description', 'MobileForSendEventSms', 'lat', 'lng', 'rms_description', 'road_observeds.updated_at', 'rms_status', 'rms_last_activity_fa', 'rms_description', 'AutoId', 'edarate_shahri.name_fa')
|
|
||||||
// ->whereIn('fk_FeatureType', ['1', '2', '3', '4', '5', '6'])
|
|
||||||
// ->where('rms_status', "<>", 1)
|
|
||||||
// ->get();
|
|
||||||
|
|
||||||
// $all = DB::select(DB::raw(
|
|
||||||
// 'SELECT
|
|
||||||
// "کشوری" as province_fa,
|
|
||||||
// -1 as province_id,
|
|
||||||
// COUNT(*) tedade,
|
|
||||||
// SUM(tedad_mavarede_moshede_shode) as tedad_mavarede_moshede_shode,
|
|
||||||
// SUM(tedad_mavarede_peygiri_shode) as tedad_mavarede_peygiri_shode,
|
|
||||||
// SUM(tedad_faliyat_sabt_shode) as tedad_faliyat_sabt_shode,
|
|
||||||
// ROUND(SUM(distance)) as masafat_tey_shode
|
|
||||||
// FROM (SELECT
|
|
||||||
// province_id,
|
|
||||||
// province_fa,
|
|
||||||
// distance,
|
|
||||||
// (SELECT COUNT(*) FROM `observed_items` oi WHERE rp.`id`= oi.road_patrol_id) AS tedad_mavarede_moshede_shode,
|
|
||||||
// (SELECT COUNT(*) FROM `observed_items` oii WHERE rp.`id`= oii.road_patrol_id AND oii.road_item_id IS NOT NULL AND priority IS NOT NULL) AS tedad_mavarede_peygiri_shode,
|
|
||||||
// (SELECT COUNT(*) FROM `observed_items` oii WHERE rp.`id`= oii.road_patrol_id AND oii.road_item_id IS NOT NULL AND priority IS NULL) AS tedad_faliyat_sabt_shode
|
|
||||||
// FROM `road_patrols` rp where rp.start_time BETWEEN "'.$from_date.'" AND "'.$date_to.'") temp
|
|
||||||
// union
|
|
||||||
// SELECT
|
|
||||||
// province_fa,
|
|
||||||
// province_id,
|
|
||||||
// COUNT(*) tedade,
|
|
||||||
// SUM(tedad_mavarede_moshede_shode) as tedad_mavarede_moshede_shode,
|
|
||||||
// SUM(tedad_mavarede_peygiri_shode) as tedad_mavarede_peygiri_shode,
|
|
||||||
// SUM(tedad_faliyat_sabt_shode) as tedad_faliyat_sabt_shode,
|
|
||||||
// ROUND(SUM(distance)) as masafat_tey_shode
|
|
||||||
// FROM (SELECT
|
|
||||||
// province_id,
|
|
||||||
// province_fa,
|
|
||||||
// distance,
|
|
||||||
// (SELECT COUNT(*) FROM `observed_items` oi WHERE rp.`id`= oi.road_patrol_id) AS tedad_mavarede_moshede_shode,
|
|
||||||
// (SELECT COUNT(*) FROM `observed_items` oii WHERE rp.`id`= oii.road_patrol_id AND oii.road_item_id IS NOT NULL AND priority IS NOT NULL) AS tedad_mavarede_peygiri_shode,
|
|
||||||
// (SELECT COUNT(*) FROM `observed_items` oii WHERE rp.`id`= oii.road_patrol_id AND oii.road_item_id IS NOT NULL AND priority IS NULL) AS tedad_faliyat_sabt_shode
|
|
||||||
// FROM `road_patrols` rp where rp.start_time BETWEEN "'.$from_date.'" AND "'.$date_to.'") temp
|
|
||||||
// GROUP BY province_id
|
|
||||||
// '
|
|
||||||
// ));
|
|
||||||
return response()->json(
|
return response()->json(
|
||||||
$data,
|
$data,
|
||||||
$data['status'],
|
$data['status'],
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ use App\Facades\Sms\Sms;
|
|||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use App\Facades\Otp\Otp;
|
use App\Facades\Otp\Otp;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use App\Models\RoadObserved;
|
||||||
use App\Models\RoadPatrol;
|
use App\Models\RoadPatrol;
|
||||||
use App\Models\RoadItemsProject;
|
use App\Models\RoadItemsProject;
|
||||||
use App\Models\EdarateShahri;
|
use App\Models\EdarateShahri;
|
||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
|
use App\Services\NominatimService;
|
||||||
use App\Exports\V2\RoadPatrol\OperatorCartableExport;
|
use App\Exports\V2\RoadPatrol\OperatorCartableExport;
|
||||||
use App\Exports\V2\RoadPatrol\SupervisorCartableExport;
|
use App\Exports\V2\RoadPatrol\SupervisorCartableExport;
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ class RoadPatrolProjectController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
if (!auth()->user()->hasPermissionTo('add-road-patrol')) {
|
if (!auth()->user()->hasPermissionTo('add-road-patrol')) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -264,7 +264,7 @@ class RoadPatrolProjectController extends Controller
|
|||||||
$edare_name = auth()->user()->edarate_shahri_id ? auth()->user()->edarate_shahri_name : auth()->user()->edarate_ostani_name;
|
$edare_name = auth()->user()->edarate_shahri_id ? auth()->user()->edarate_shahri_name : auth()->user()->edarate_ostani_name;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$road_patrol = \DB::transaction(function () use ($request, $start_coordinates, $end_coordinates, $edare_id, $edare_name) {
|
$road_patrol = \DB::transaction(function () use ($request, $start_coordinates, $end_coordinates, $edare_id, $edare_name, $nominatimService) {
|
||||||
if (!$request->observed_items && !$request->description) {
|
if (!$request->observed_items && !$request->description) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
"description" => __('validation.required', ['attribute' => 'description']),
|
"description" => __('validation.required', ['attribute' => 'description']),
|
||||||
@@ -287,8 +287,8 @@ class RoadPatrolProjectController extends Controller
|
|||||||
'city_fa' => auth()->user()->city_fa,
|
'city_fa' => auth()->user()->city_fa,
|
||||||
'edare_id' => $edare_id,
|
'edare_id' => $edare_id,
|
||||||
'edare_name' => $edare_name,
|
'edare_name' => $edare_name,
|
||||||
'start_way_id' => get_way_id_from_nominatim($start_coordinates[0], $start_coordinates[1]),
|
'start_way_id' => $nominatimService->get_way_id_from_nominatim($start_coordinates[0], $start_coordinates[1]),
|
||||||
'end_way_id' => get_way_id_from_nominatim($end_coordinates[0], $end_coordinates[1]),
|
'end_way_id' => $nominatimService->get_way_id_from_nominatim($end_coordinates[0], $end_coordinates[1]),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'status_fa' => 'در حال بررسی',
|
'status_fa' => 'در حال بررسی',
|
||||||
'distance' => $request->distance,
|
'distance' => $request->distance,
|
||||||
@@ -397,8 +397,8 @@ class RoadPatrolProjectController extends Controller
|
|||||||
'city_id' => auth()->user()->city_id,
|
'city_id' => auth()->user()->city_id,
|
||||||
'city_fa' => auth()->user()->city_fa,
|
'city_fa' => auth()->user()->city_fa,
|
||||||
'user_name' => auth()->user()->name,
|
'user_name' => auth()->user()->name,
|
||||||
'start_way_id' => get_way_id_from_nominatim($item_start_coordinates[0], $item_start_coordinates[1]),
|
'start_way_id' => $nominatimService->get_way_id_from_nominatim($item_start_coordinates[0], $item_start_coordinates[1]),
|
||||||
'end_way_id' => $item_end_coordinates ? get_way_id_from_nominatim($item_end_coordinates[0], $item_end_coordinates[1]) : null,
|
'end_way_id' => $item_end_coordinates ? $nominatimService->get_way_id_from_nominatim($item_end_coordinates[0], $item_end_coordinates[1]) : null,
|
||||||
'unit_fa' => $info_item->sub_item_unit,
|
'unit_fa' => $info_item->sub_item_unit,
|
||||||
'created_at_fa' => verta(Carbon::now())->format('Y-m-d H:i:s'),
|
'created_at_fa' => verta(Carbon::now())->format('Y-m-d H:i:s'),
|
||||||
'info_id' => $info_item->id,
|
'info_id' => $info_item->id,
|
||||||
@@ -501,6 +501,49 @@ class RoadPatrolProjectController extends Controller
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function map(Request $request)
|
||||||
|
{
|
||||||
|
$province = $request->province_id;
|
||||||
|
$edare_shahri = $request->edare_shahri_id;
|
||||||
|
$status = $request->status;
|
||||||
|
$rms_status = $request->rms_status;
|
||||||
|
|
||||||
|
if ($request->date_from && $request->date_to) {
|
||||||
|
$date_from = $request->date_from.' 00:00:00';
|
||||||
|
$date_to = $request->date_to.' 23:59:59';
|
||||||
|
} else {
|
||||||
|
$date_from = Date('Y-m-d');
|
||||||
|
$date_to = new \DateTime('tomorrow');
|
||||||
|
$date_to = $date_to->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
|
$projects = RoadObserved::select('id', 'lng', 'lat','status')
|
||||||
|
->whereBetween('created_at', [$date_from, $date_to])
|
||||||
|
->when($province, function ($query) use ($province) {
|
||||||
|
return $query->where('province_id', $province);
|
||||||
|
})
|
||||||
|
->when($rms_status, function ($query) use ($rms_status) {
|
||||||
|
if ($rms_status == 2) {
|
||||||
|
return $query->where('rms_status', '<>',0);
|
||||||
|
} else {
|
||||||
|
return $query->where('rms_status', 0);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when($edare_shahri, function ($query) use ($edare_shahri) {
|
||||||
|
return $query->where('edarate_shahri_id', $edare_shahri);
|
||||||
|
})
|
||||||
|
->when($status, function ($query) use ($status) {
|
||||||
|
return $query->where('status', $status);
|
||||||
|
})
|
||||||
|
// ->toSql();
|
||||||
|
->get();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'succeed',
|
||||||
|
'message' => '',
|
||||||
|
'data' => $projects
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
public function detail(RoadPatrol $road_patrol)
|
public function detail(RoadPatrol $road_patrol)
|
||||||
{
|
{
|
||||||
return response()->json($road_patrol, 200);
|
return response()->json($road_patrol, 200);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use App\Models\EdarateShahri;
|
|||||||
use App\Models\Contractor;
|
use App\Models\Contractor;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use App\Models\SafetyAndPrivacy;
|
use App\Models\SafetyAndPrivacy;
|
||||||
|
use App\Services\NominatimService;
|
||||||
use App\Models\InfoItem;
|
use App\Models\InfoItem;
|
||||||
|
|
||||||
class SafetyAndPrivacyController extends Controller
|
class SafetyAndPrivacyController extends Controller
|
||||||
@@ -84,7 +85,7 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
return view('version2.dashboard_pages.safety_and_privacy.operation_create');
|
return view('version2.dashboard_pages.safety_and_privacy.operation_create');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function operatorFirstStepStore(Request $request)
|
public function operatorFirstStepStore(Request $request, NominatimService $nominatimService)
|
||||||
{
|
{
|
||||||
if (! auth()->user()->hasAnyPermission(['add-safety-and-privacy'])) {
|
if (! auth()->user()->hasAnyPermission(['add-safety-and-privacy'])) {
|
||||||
abort(403);
|
abort(403);
|
||||||
@@ -118,7 +119,7 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
$item = InfoItem::where('id', $request->info_id)->where('item', 17)->firstOrFail();
|
$item = InfoItem::where('id', $request->info_id)->where('item', 17)->firstOrFail();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$safety_and_privacy = \DB::transaction(function () use ($request, $coordinates, $item) {
|
$safety_and_privacy = \DB::transaction(function () use ($request, $coordinates, $item, $nominatimService) {
|
||||||
$safety_and_privacy = SafetyAndPrivacy::create([
|
$safety_and_privacy = SafetyAndPrivacy::create([
|
||||||
'lat' => $coordinates[0],
|
'lat' => $coordinates[0],
|
||||||
'lon' => $coordinates[1],
|
'lon' => $coordinates[1],
|
||||||
@@ -133,12 +134,12 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
'activity_date_time' => $request->activity_date." ".$request->activity_time,
|
'activity_date_time' => $request->activity_date." ".$request->activity_time,
|
||||||
'edare_shahri_id' => auth()->user()->edarate_shahri_id,
|
'edare_shahri_id' => auth()->user()->edarate_shahri_id,
|
||||||
'edare_shahri_name' => auth()->user()->edarate_shahri_name,
|
'edare_shahri_name' => auth()->user()->edarate_shahri_name,
|
||||||
'way_id' => get_way_id_from_nominatim($coordinates[0], $coordinates[1]),
|
'way_id' => $nominatimService->get_way_id_from_nominatim(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->has('recognize_picture')) {
|
if ($request->has('recognize_picture')) {
|
||||||
$recognize_picture = $request->file('recognize_picture')->store('safety_and_privacy/'.$safety_and_privacy->id.'/recognize_picture', 'public');
|
$recognize_picture = $request->file('recognize_picture')->store('safety_and_privacy/'.$safety_and_privacy->id.'/recognize_picture', 'public');
|
||||||
$safety_and_privacy->recognize_picture = 'https://rms.rmto.ir/storage/'.$recognize_picture;
|
$safety_and_privacy->recognize_picture = Storage::disk('public')->url($recognize_picture);
|
||||||
// \App\Helpers\Compress::resize("/var/www/rms/public/storage/{$recognize_picture}");
|
// \App\Helpers\Compress::resize("/var/www/rms/public/storage/{$recognize_picture}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
try {
|
try {
|
||||||
\DB::transaction(function () use ($request, $safety_and_privacy) {
|
\DB::transaction(function () use ($request, $safety_and_privacy) {
|
||||||
$action_picture = $request->file('action_picture')->store('safety_and_privacy/'.$safety_and_privacy->id.'/action_picture', 'public');
|
$action_picture = $request->file('action_picture')->store('safety_and_privacy/'.$safety_and_privacy->id.'/action_picture', 'public');
|
||||||
$safety_and_privacy->action_picture = 'https://rms.rmto.ir/storage/'.$action_picture;
|
$safety_and_privacy->action_picture = Storage::disk('public')->url($action_picture);
|
||||||
// \App\Helpers\Compress::resize("/var/www/rms/public/storage/{$action_picture}");
|
// \App\Helpers\Compress::resize("/var/www/rms/public/storage/{$action_picture}");
|
||||||
$safety_and_privacy->action_picture_document_upload_date = now();
|
$safety_and_privacy->action_picture_document_upload_date = now();
|
||||||
|
|
||||||
@@ -254,7 +255,7 @@ class SafetyAndPrivacyController extends Controller
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($datas as $data) {
|
foreach ($datas as $data) {
|
||||||
$result[] = 'https://rms.rmto.ir/storage/'.$data;
|
$result[] = Storage::disk('public')->url($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
164
app/Http/Controllers/V3/Harim/DivarkeshiController.php
Normal file
164
app/Http/Controllers/V3/Harim/DivarkeshiController.php
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3\Harim;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Harim\Divarkeshi;
|
||||||
|
use App\Http\Requests\V3\Harim\Divarkeshi\StoreRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
|
||||||
|
|
||||||
|
class DivarkeshiController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$columns = array(
|
||||||
|
'dabirkhaneh_number',
|
||||||
|
'nameh_date',
|
||||||
|
'nameh_date_fa',
|
||||||
|
'marjae_pasokh',
|
||||||
|
'motaghazi_is_legal_id',
|
||||||
|
'motaghazi_is_legal',
|
||||||
|
'motaghazi_type_id',
|
||||||
|
'motaghazi_type',
|
||||||
|
'motaghazi_firstname',
|
||||||
|
'motaghazi_lastname',
|
||||||
|
'national_id',
|
||||||
|
'shenase_melli',
|
||||||
|
'tel_number',
|
||||||
|
'mobile_number',
|
||||||
|
'address',
|
||||||
|
'edare_kol_id',
|
||||||
|
'edare_kol',
|
||||||
|
'edare_shahri_id',
|
||||||
|
'edare_shahri',
|
||||||
|
'rah_type_id',
|
||||||
|
'rah_type',
|
||||||
|
'name_mehvar_id',
|
||||||
|
'name_mehvar_fa',
|
||||||
|
'mizan_harim',
|
||||||
|
'arze_navar',
|
||||||
|
'samt_id',
|
||||||
|
'samt',
|
||||||
|
'kilometr',
|
||||||
|
'lat',
|
||||||
|
'lon',
|
||||||
|
'zone',
|
||||||
|
'karbari_type_id',
|
||||||
|
'karbari_type',
|
||||||
|
'tarh_title',
|
||||||
|
'masahat_zirbana',
|
||||||
|
'ehdasat_type_id',
|
||||||
|
'ehdasat_type',
|
||||||
|
'divarkeshi_distance',
|
||||||
|
'mostahadesat_distance',
|
||||||
|
'mahale_ejra_id',
|
||||||
|
'mahale_ejra',
|
||||||
|
'traffic_id',
|
||||||
|
'traffic',
|
||||||
|
'vaziat_eghtesadi_id',
|
||||||
|
'vaziat_eghtesadi',
|
||||||
|
'has_access_id',
|
||||||
|
'has_access',
|
||||||
|
'shomare_estelam_harim',
|
||||||
|
'max_month',
|
||||||
|
'max_day',
|
||||||
|
'shomare_tahaodname',
|
||||||
|
'shomare_daftarkhaneh',
|
||||||
|
'description',
|
||||||
|
'ronevesht',
|
||||||
|
);
|
||||||
|
|
||||||
|
$allowedFilters = $columns;
|
||||||
|
$allowedSortings = $columns;
|
||||||
|
|
||||||
|
$query = Divarkeshi::query();
|
||||||
|
$data = DataTableFacade::run(
|
||||||
|
$query,
|
||||||
|
$request,
|
||||||
|
allowedFilters: $allowedFilters,
|
||||||
|
allowedSortings: $allowedSortings
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Divarkeshi::create([
|
||||||
|
'dabirkhaneh_number' => $request->dabirkhaneh_number,
|
||||||
|
'nameh_date' => $request->nameh_date,
|
||||||
|
'nameh_date_fa' => $request->nameh_date_fa,
|
||||||
|
'marjae_pasokh' => $request->marjae_pasokh,
|
||||||
|
'motaghazi_is_legal_id' => $request->motaghazi_is_legal_id,
|
||||||
|
'motaghazi_is_legal' => $request->motaghazi_is_legal,
|
||||||
|
'motaghazi_type_id' => $request->motaghazi_type_id,
|
||||||
|
'motaghazi_type' => $request->motaghazi_type,
|
||||||
|
'motaghazi_firstname' => $request->motaghazi_firstname,
|
||||||
|
'motaghazi_lastname' => $request->motaghazi_lastname,
|
||||||
|
'national_id' => $request->national_id,
|
||||||
|
'shenase_melli' => $request->shenase_melli,
|
||||||
|
'tel_number' => $request->tel_number,
|
||||||
|
'mobile_number' => $request->mobile_number,
|
||||||
|
'address' => $request->address,
|
||||||
|
'edare_kol_id' => $request->edare_kol_id,
|
||||||
|
'edare_kol' => $request->edare_kol,
|
||||||
|
'edare_shahri_id' => $request->edare_shahri_id,
|
||||||
|
'edare_shahri' => $request->edare_shahri,
|
||||||
|
'rah_type_id' => $request->rah_type_id,
|
||||||
|
'rah_type' => $request->rah_type,
|
||||||
|
'name_mehvar_id' => $request->name_mehvar_id,
|
||||||
|
'name_mehvar_fa' => $request->name_mehvar_fa,
|
||||||
|
'mizan_harim' => $request->mizan_harim,
|
||||||
|
'arze_navar' => $request->arze_navar,
|
||||||
|
'samt_id' => $request->samt_id,
|
||||||
|
'samt' => $request->samt,
|
||||||
|
'kilometr' => $request->kilometr,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lon' => $request->lon,
|
||||||
|
'zone' => $request->zone,
|
||||||
|
'karbari_type_id' => $request->karbari_type_id,
|
||||||
|
'karbari_type' => $request->karbari_type,
|
||||||
|
'tarh_title' => $request->tarh_title,
|
||||||
|
'masahat_zirbana' => $request->masahat_zirbana,
|
||||||
|
'ehdasat_type_id' => $request->ehdasat_type_id,
|
||||||
|
'ehdasat_type' => $request->ehdasat_type,
|
||||||
|
'divarkeshi_distance' => $request->divarkeshi_distance,
|
||||||
|
'mostahadesat_distance' => $request->mostahadesat_distance,
|
||||||
|
'mahale_ejra_id' => $request->mahale_ejra_id,
|
||||||
|
'mahale_ejra' => $request->mahale_ejra,
|
||||||
|
'traffic_id' => $request->traffic_id,
|
||||||
|
'traffic' => $request->traffic,
|
||||||
|
'vaziat_eghtesadi_id' => $request->vaziat_eghtesadi_id,
|
||||||
|
'vaziat_eghtesadi' => $request->vaziat_eghtesadi,
|
||||||
|
'has_access_id' => $request->has_access_id,
|
||||||
|
'has_access' => $request->has_access,
|
||||||
|
'shomare_estelam_harim' => $request->shomare_estelam_harim,
|
||||||
|
'max_month' => $request->max_month,
|
||||||
|
'max_day' => $request->max_day,
|
||||||
|
'shomare_tahaodname' => $request->shomare_tahaodname,
|
||||||
|
'shomare_daftarkhaneh' => $request->shomare_daftarkhaneh,
|
||||||
|
'description' => $request->description,
|
||||||
|
'ronevesht' => $request->ronevesht,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
\Log::error($th->getMessage());
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function details(Divarkeshi $divarkeshi): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($divarkeshi);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
78
app/Http/Controllers/V3/ProfileController.php
Normal file
78
app/Http/Controllers/V3/ProfileController.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\V3\Profile\ChangePasswordRequest;
|
||||||
|
use App\Http\Requests\V3\Profile\EditRequest;
|
||||||
|
use App\Http\Traits\ApiResponse;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
public function info(): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
return $this->successResponse([
|
||||||
|
'username' => $user->username,
|
||||||
|
'first_name' => $user->first_name,
|
||||||
|
'last_name' => $user->last_name,
|
||||||
|
'name' => $user->name,
|
||||||
|
'last_login' => $user->last_login,
|
||||||
|
'major' => $user->major,
|
||||||
|
'degree' => $user->degree,
|
||||||
|
'mobile' => $user->mobile,
|
||||||
|
'avatar' => $user->avatar,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(EditRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if ($request->has('avatar'))
|
||||||
|
{
|
||||||
|
if ($user->avatar) {
|
||||||
|
FileFacade::delete($user->avatar);
|
||||||
|
}
|
||||||
|
$destinationPath = 'avatar/' . $user->username;
|
||||||
|
$filename = time() .".". $request->file('avatar')->getClientOriginalExtension();
|
||||||
|
$avatar = FileFacade::save($request->avatar, $destinationPath, $filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'first_name' => $request->first_name,
|
||||||
|
'last_name' => $request->last_name,
|
||||||
|
'major' => $request->major,
|
||||||
|
'degree' => $request->degree,
|
||||||
|
'mobile' => $request->mobile,
|
||||||
|
'avatar' => $avatar ?? $user->avatar
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function changePassword(ChangePasswordRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if (! Hash::check($request->current_password, $user->password))
|
||||||
|
{
|
||||||
|
return $this->errorResponse(__('messages.incorrect_current_password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'password' => Hash::make($request->new_password)
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ class Kernel extends HttpKernel
|
|||||||
\App\Http\Middleware\TrimStrings::class,
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
// \App\Http\Middleware\HttpsProtocol::class,
|
// \App\Http\Middleware\HttpsProtocol::class,
|
||||||
|
\Illuminate\Http\Middleware\HandleCors::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +41,8 @@ class Kernel extends HttpKernel
|
|||||||
// \App\Http\Middleware\HttpsProtocol::class,
|
// \App\Http\Middleware\HttpsProtocol::class,
|
||||||
\App\Http\Middleware\ConfirmUserMiddleware::class,
|
\App\Http\Middleware\ConfirmUserMiddleware::class,
|
||||||
// \App\Http\Middleware\RandDRedirectMiddleware::class,
|
// \App\Http\Middleware\RandDRedirectMiddleware::class,
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ class ConfirmUserMiddleware
|
|||||||
|
|
||||||
// for migrate
|
// for migrate
|
||||||
|
|
||||||
|
|
||||||
if (Auth::check() && !Auth::user()->enabled) {
|
if (Auth::check() && !Auth::user()->enabled) {
|
||||||
return abort(455);
|
return abort(455);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
use \Illuminate\Http\Request;
|
||||||
|
|
||||||
class VerifyCsrfToken extends Middleware
|
class VerifyCsrfToken extends Middleware
|
||||||
{
|
{
|
||||||
@@ -19,16 +20,22 @@ class VerifyCsrfToken extends Middleware
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
'public/cmms-download',
|
// 'public/cmms-download',
|
||||||
'cmms/create',
|
// 'cmms/create',
|
||||||
'webapi/contracts/setad',
|
// 'webapi/contracts/setad',
|
||||||
'webapi/contracts/eblagh',
|
// 'webapi/contracts/eblagh',
|
||||||
'webapi/request',
|
// 'webapi/profile/edit',
|
||||||
'webapi/set-online',
|
// 'webapi/camp/*',
|
||||||
'webapi/set-offline',
|
// 'webapi/*',
|
||||||
'webapi/profile/edit',
|
// 'users/change_confirmed_status'
|
||||||
'webapi/camp/*',
|
|
||||||
'webapi/*',
|
|
||||||
'users/change_confirmed_status'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected function inExceptArray($request)
|
||||||
|
{
|
||||||
|
if (config('global_variables.IS_DEVELOPMENT_ENV')) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return parent::inExceptArray($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
86
app/Http/Requests/V3/Harim/Divarkeshi/StoreRequest.php
Normal file
86
app/Http/Requests/V3/Harim/Divarkeshi/StoreRequest.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Harim\Divarkeshi;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
|
||||||
|
class StoreRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'dabirkhaneh_number' => 'required',
|
||||||
|
'nameh_date' => 'required',
|
||||||
|
'nameh_date_fa' => 'required',
|
||||||
|
'marjae_pasokh' => 'string',
|
||||||
|
'motaghazi_is_legal_id' => 'required',
|
||||||
|
'motaghazi_is_legal' => 'required',
|
||||||
|
'motaghazi_type_id' => 'integer',
|
||||||
|
'motaghazi_type' => 'string',
|
||||||
|
'motaghazi_firstname' => 'required',
|
||||||
|
'motaghazi_lastname' => 'required',
|
||||||
|
|
||||||
|
/// conditional rule
|
||||||
|
'national_id' => 'numeric',
|
||||||
|
'shenase_melli' => 'numeric',
|
||||||
|
///
|
||||||
|
|
||||||
|
'tel_number' => 'numeric',
|
||||||
|
'mobile_number' => 'numeric',
|
||||||
|
'address' => 'required',
|
||||||
|
'edare_kol_id' => 'required',
|
||||||
|
'edare_kol' => 'required',
|
||||||
|
'edare_shahri_id' => 'required',
|
||||||
|
'edare_shahri' => 'required',
|
||||||
|
'rah_type_id' => 'required',
|
||||||
|
'rah_type' => 'required',
|
||||||
|
'name_mehvar_id' => 'integer',
|
||||||
|
'name_mehvar_fa' => 'required',
|
||||||
|
'mizan_harim' => 'required',
|
||||||
|
'arze_navar' => 'string',
|
||||||
|
'samt_id' => 'required',
|
||||||
|
'samt' => 'required',
|
||||||
|
'kilometr' => 'required',
|
||||||
|
'lat' => 'required',
|
||||||
|
'lon' => 'required',
|
||||||
|
'zone' => 'required',
|
||||||
|
'karbari_type_id' => 'required',
|
||||||
|
'karbari_type' => 'required',
|
||||||
|
'tarh_title' => 'required',
|
||||||
|
'masahat_zirbana' => '',
|
||||||
|
'ehdasat_type_id' => 'required',
|
||||||
|
'ehdasat_type' => 'required',
|
||||||
|
'divarkeshi_distance' => '',
|
||||||
|
'mostahadesat_distance' => '',
|
||||||
|
'mahale_ejra_id' => '',
|
||||||
|
'mahale_ejra' => '',
|
||||||
|
'traffic_id' => 'required',
|
||||||
|
'traffic' => 'required',
|
||||||
|
'vaziat_eghtesadi_id' => '',
|
||||||
|
'vaziat_eghtesadi' => '',
|
||||||
|
'has_access_id' => 'required',
|
||||||
|
'has_access' => 'required',
|
||||||
|
'shomare_estelam_harim' => '',
|
||||||
|
'max_month' => 'required',
|
||||||
|
'max_day' => 'required',
|
||||||
|
'shomare_tahaodname' => '',
|
||||||
|
'shomare_daftarkhaneh' => '',
|
||||||
|
'description' => '',
|
||||||
|
'ronevesht' => '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Requests/V3/Profile/ChangePasswordRequest.php
Normal file
29
app/Http/Requests/V3/Profile/ChangePasswordRequest.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Profile;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ChangePasswordRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'current_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8',
|
||||||
|
'new_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Http/Requests/V3/Profile/EditRequest.php
Normal file
33
app/Http/Requests/V3/Profile/EditRequest.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V3\Profile;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class EditRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'first_name' => 'required|string',
|
||||||
|
'last_name' => 'required|string',
|
||||||
|
'degree' => 'required',
|
||||||
|
'major' => 'required',
|
||||||
|
'mobile' => 'required|regex:/^09\d{9}$/|numeric|digits:11',
|
||||||
|
'avatar' => 'mimes:png,jpg,jpeg|max:2048'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Http/Traits/ApiResponse.php
Normal file
31
app/Http/Traits/ApiResponse.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
trait ApiResponse
|
||||||
|
{
|
||||||
|
public function successResponse(mixed $data = null, string $message = null, int $statusCode = 200): JsonResponse
|
||||||
|
{
|
||||||
|
if (!is_null($data)) {
|
||||||
|
return response()->json([
|
||||||
|
'data' => $data
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $message ?? __('messages.successful');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => $message
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function errorResponse(string $message, string $type = 'logical_exception', int $statusCode = 422): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'type' => $type,
|
||||||
|
'message' => $message
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Traits\ReceiptReportAble;
|
use App\Traits\ReceiptReportAble;
|
||||||
|
|
||||||
class Accident extends Model
|
class Accident extends Model
|
||||||
{
|
{
|
||||||
use ReceiptReportAble;
|
use ReceiptReportAble, HasFactory;
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class City extends Model
|
class City extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
/**
|
/**
|
||||||
* The attributes that should be hidden for arrays.
|
* The attributes that should be hidden for arrays.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Models\ContractSubItemsHistory;
|
use App\Models\ContractSubItemsHistory;
|
||||||
use App\Http\Controllers\Api\ContractSubItemsController;
|
use App\Http\Controllers\Api\ContractSubItemsController;
|
||||||
|
|
||||||
class ContractSubItems extends Model
|
class ContractSubItems extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class Contracts extends Model
|
class Contracts extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class EdarateOstani extends Model
|
class EdarateOstani extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $table = 'edarate_ostani';
|
protected $table = 'edarate_ostani';
|
||||||
|
|
||||||
public function roadObserved()
|
public function roadObserved()
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class EdarateShahri extends Model
|
class EdarateShahri extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $table = 'edarate_shahri';
|
protected $table = 'edarate_shahri';
|
||||||
|
|
||||||
public function cities()
|
public function cities()
|
||||||
|
|||||||
13
app/Models/Harim/Divarkeshi.php
Normal file
13
app/Models/Harim/Divarkeshi.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Harim;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Divarkeshi extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'harim_divarkeshi';
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
||||||
@@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class InfoItem extends Model
|
class InfoItem extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
public function roadItemsProjects()
|
public function roadItemsProjects()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class LogList extends Model
|
class LogList extends Model
|
||||||
{
|
{
|
||||||
//
|
use HasFactory;
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class ObservedItem extends Model
|
class ObservedItem extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
public function roadPatrol()
|
public function roadPatrol()
|
||||||
|
|||||||
12
app/Models/Permission.php
Normal file
12
app/Models/Permission.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Spatie\Permission\Models\Permission as SpatiePermission;
|
||||||
|
|
||||||
|
class Permission extends SpatiePermission
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Province extends Model
|
class Province extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
/**
|
/**
|
||||||
* The attributes that should be hidden for arrays.
|
* The attributes that should be hidden for arrays.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class RoadItemsProject extends Model
|
class RoadItemsProject extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
///start_way_id
|
///start_way_id
|
||||||
///end_way_id
|
///end_way_id
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class RoadObservationHistory extends Model
|
class RoadObservationHistory extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class RoadObserved extends Model
|
class RoadObserved extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'AutoID',
|
'AutoID',
|
||||||
'Title',
|
'Title',
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class RoadPatrol extends Model
|
class RoadPatrol extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
public function observedItems()
|
public function observedItems()
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Traits\SafetyAndPrivacyReportAble;
|
use App\Traits\SafetyAndPrivacyReportAble;
|
||||||
|
|
||||||
class SafetyAndPrivacy extends Model
|
class SafetyAndPrivacy extends Model
|
||||||
{
|
{
|
||||||
use SafetyAndPrivacyReportAble;
|
use SafetyAndPrivacyReportAble, HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'recognize_picture',
|
'recognize_picture',
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
use Spatie\Permission\Traits\HasPermissions;
|
use Spatie\Permission\Traits\HasPermissions;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use App\Models\UserActivityLog;
|
use App\Models\UserActivityLog;
|
||||||
use App\Models\LogList;
|
use App\Models\LogList;
|
||||||
use DB;
|
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use Notifiable, HasRoles, HasPermissions;
|
use Notifiable, HasRoles, HasPermissions, HasFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,95 +60,101 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
public function addActivityComplete($log_unique_code, $model = null)
|
public function addActivityComplete($log_unique_code, $model = null)
|
||||||
{
|
{
|
||||||
DB::beginTransaction();
|
// DB::beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$temp = new UserActivityLog();
|
DB::transaction(function () use ($log_unique_code, $model) {
|
||||||
$temp->user_id = $this->id;
|
$temp = new UserActivityLog();
|
||||||
$temp->username = $this->username;
|
$temp->user_id = $this->id;
|
||||||
$temp->user_name = $this->name;
|
$temp->username = $this->username;
|
||||||
$temp->user_first_name = $this->first_name;
|
$temp->user_name = $this->name;
|
||||||
$temp->user_last_name = $this->last_name;
|
$temp->user_first_name = $this->first_name;
|
||||||
$temp->position = $this->position;
|
$temp->user_last_name = $this->last_name;
|
||||||
$temp->mobile = $this->mobile;
|
$temp->position = $this->position;
|
||||||
$temp->province_id = $this->province_id;
|
$temp->mobile = $this->mobile;
|
||||||
$temp->province_fa = $this->province_fa;
|
$temp->province_id = $this->province_id;
|
||||||
$temp->city_id = $this->city_id;
|
$temp->province_fa = $this->province_fa;
|
||||||
$temp->city_fa = $this->city_fa;
|
$temp->city_id = $this->city_id;
|
||||||
|
$temp->city_fa = $this->city_fa;
|
||||||
|
|
||||||
$log = LogList::where('log_unique_code', $log_unique_code)->first();
|
$log = LogList::where('log_unique_code', $log_unique_code)->first();
|
||||||
$temp->log_unique_code = $log_unique_code;
|
$temp->log_unique_code = $log_unique_code;
|
||||||
$temp->description = $log->description;
|
$temp->description = $log->description;
|
||||||
$temp->action_type = $log->action_type;
|
$temp->action_type = $log->action_type;
|
||||||
|
|
||||||
$temp->agent = request()->header('user-agent') ?? null;
|
$temp->agent = request()->header('user-agent') ?? null;
|
||||||
$temp->method = request()->method() ?? null;
|
$temp->method = request()->method() ?? null;
|
||||||
$temp->ip = request()->ip() ?? null;
|
$temp->ip = request()->ip() ?? null;
|
||||||
$temp->url = request()->Url() ?? null;
|
$temp->url = request()->Url() ?? null;
|
||||||
$temp->query_parameter = serialize(request()->all());
|
$temp->query_parameter = serialize(request()->all());
|
||||||
|
|
||||||
$temp->model = serialize($model) ?? null;
|
$temp->model = serialize($model) ?? null;
|
||||||
$temp->save();
|
$temp->save();
|
||||||
DB::commit();
|
});
|
||||||
|
// DB::commit();
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
DB::rollBack();
|
// DB::rollBack();
|
||||||
try {
|
try {
|
||||||
$temp = new UserActivityLog();
|
DB::transaction(function () use ($log_unique_code, $model) {
|
||||||
$temp->user_id = $this->id;
|
$temp = new UserActivityLog();
|
||||||
$temp->username = $this->username;
|
$temp->user_id = $this->id;
|
||||||
$temp->user_name = $this->name;
|
$temp->username = $this->username;
|
||||||
$temp->user_first_name = $this->first_name;
|
$temp->user_name = $this->name;
|
||||||
$temp->user_last_name = $this->last_name;
|
$temp->user_first_name = $this->first_name;
|
||||||
$temp->position = $this->position;
|
$temp->user_last_name = $this->last_name;
|
||||||
$temp->mobile = $this->mobile;
|
$temp->position = $this->position;
|
||||||
$temp->province_id = $this->province_id;
|
$temp->mobile = $this->mobile;
|
||||||
$temp->province_fa = $this->province_fa;
|
$temp->province_id = $this->province_id;
|
||||||
$temp->city_id = $this->city_id;
|
$temp->province_fa = $this->province_fa;
|
||||||
$temp->city_fa = $this->city_fa;
|
$temp->city_id = $this->city_id;
|
||||||
|
$temp->city_fa = $this->city_fa;
|
||||||
|
|
||||||
$log = LogList::where('log_unique_code', $log_unique_code)->first();
|
$log = LogList::where('log_unique_code', $log_unique_code)->first();
|
||||||
$temp->log_unique_code = $log_unique_code;
|
$temp->log_unique_code = $log_unique_code;
|
||||||
$temp->description = $log->description;
|
$temp->description = $log->description;
|
||||||
$temp->action_type = $log->action_type;
|
$temp->action_type = $log->action_type;
|
||||||
|
|
||||||
$temp->agent = request()->header('user-agent') ?? null;
|
$temp->agent = request()->header('user-agent') ?? null;
|
||||||
$temp->method = request()->method() ?? null;
|
$temp->method = request()->method() ?? null;
|
||||||
$temp->ip = request()->ip() ?? null;
|
$temp->ip = request()->ip() ?? null;
|
||||||
$temp->url = request()->Url() ?? null;
|
$temp->url = request()->Url() ?? null;
|
||||||
$temp->query_parameter = serialize(request()->input());
|
$temp->query_parameter = serialize(request()->input());
|
||||||
|
|
||||||
$temp->model = serialize($model) ?? null;
|
$temp->model = serialize($model) ?? null;
|
||||||
$temp->save();
|
$temp->save();
|
||||||
DB::commit();
|
});
|
||||||
|
// DB::commit();
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
DB::rollBack();
|
// DB::rollBack();
|
||||||
$temp = new UserActivityLog();
|
DB::transaction(function () use ($log_unique_code, $model) {
|
||||||
$temp->user_id = $this->id;
|
$temp = new UserActivityLog();
|
||||||
$temp->username = $this->username;
|
$temp->user_id = $this->id;
|
||||||
$temp->user_name = $this->name;
|
$temp->username = $this->username;
|
||||||
$temp->user_first_name = $this->first_name;
|
$temp->user_name = $this->name;
|
||||||
$temp->user_last_name = $this->last_name;
|
$temp->user_first_name = $this->first_name;
|
||||||
$temp->position = $this->position;
|
$temp->user_last_name = $this->last_name;
|
||||||
$temp->mobile = $this->mobile;
|
$temp->position = $this->position;
|
||||||
$temp->province_id = $this->province_id;
|
$temp->mobile = $this->mobile;
|
||||||
$temp->province_fa = $this->province_fa;
|
$temp->province_id = $this->province_id;
|
||||||
$temp->city_id = $this->city_id;
|
$temp->province_fa = $this->province_fa;
|
||||||
$temp->city_fa = $this->city_fa;
|
$temp->city_id = $this->city_id;
|
||||||
|
$temp->city_fa = $this->city_fa;
|
||||||
|
|
||||||
$log = LogList::where('log_unique_code', $log_unique_code)->first();
|
$log = LogList::where('log_unique_code', $log_unique_code)->first();
|
||||||
$temp->log_unique_code = $log_unique_code;
|
$temp->log_unique_code = $log_unique_code;
|
||||||
$temp->description = $log->description;
|
$temp->description = $log->description;
|
||||||
$temp->action_type = $log->action_type;
|
$temp->action_type = $log->action_type;
|
||||||
|
|
||||||
$temp->agent = request()->header('user-agent') ?? null;
|
$temp->agent = request()->header('user-agent') ?? null;
|
||||||
$temp->method = request()->method() ?? null;
|
$temp->method = request()->method() ?? null;
|
||||||
$temp->ip = request()->ip() ?? null;
|
$temp->ip = request()->ip() ?? null;
|
||||||
$temp->url = request()->Url() ?? null;
|
$temp->url = request()->Url() ?? null;
|
||||||
$temp->query_parameter = "Request is to big !!!!!";
|
$temp->query_parameter = "Request is to big !!!!!";
|
||||||
|
|
||||||
$temp->model = serialize($model) ?? null;
|
$temp->model = serialize($model) ?? null;
|
||||||
$temp->save();
|
$temp->save();
|
||||||
DB::commit();
|
});
|
||||||
|
// DB::commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class UserActivityLog extends Model
|
class UserActivityLog extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
|
|||||||
26
app/Providers/DataTableServiceProvider.php
Normal file
26
app/Providers/DataTableServiceProvider.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTable;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class DataTableServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->bind('datatable', function () {
|
||||||
|
return new DataTable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Providers/FileServiceProvider.php
Normal file
30
app/Providers/FileServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Facades\File\File;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class FileServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->bind('file', function () {
|
||||||
|
return new File();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,18 +60,27 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
Route::middleware('web')
|
Route::middleware('web')
|
||||||
// ->middleware('confirmUser')
|
// ->middleware('confirmUser')
|
||||||
->namespace($this->namespace)
|
->namespace($this->namespace)
|
||||||
->group(base_path('routes/web.php'));
|
->group(base_path('routes/web.php'));
|
||||||
|
|
||||||
Route::prefix('v2')
|
Route::prefix('v2')
|
||||||
->middleware('web', 'auth', 'confirmUser')
|
->middleware('web', 'auth', 'confirmUser')
|
||||||
->namespace($this->namespace)
|
->namespace($this->namespace)
|
||||||
->group(base_path('routes/v2.php'));
|
->group(base_path('routes/v2.php'));
|
||||||
|
|
||||||
|
Route::prefix('api/v3')
|
||||||
|
->name('v3.')
|
||||||
|
->middleware(['web', 'auth', 'confirmUser'])
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/v3.php'));
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
Route::prefix('RandD')
|
Route::prefix('RandD')
|
||||||
->middleware('web', 'auth', 'confirmUser', 'randd')
|
->middleware('web', 'auth', 'confirmUser', 'randd')
|
||||||
->namespace($this->namespace)
|
->namespace($this->namespace)
|
||||||
->group(base_path('routes/randd.php'));
|
->group(base_path('routes/randd.php'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,9 +92,6 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected function mapApiRoutes()
|
protected function mapApiRoutes()
|
||||||
{
|
{
|
||||||
Route::prefix('api')
|
|
||||||
->middleware('api')
|
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/api.php'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
62
app/Providers/TelescopeServiceProvider.php
Normal file
62
app/Providers/TelescopeServiceProvider.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Laravel\Telescope\IncomingEntry;
|
||||||
|
use Laravel\Telescope\Telescope;
|
||||||
|
use Laravel\Telescope\TelescopeApplicationServiceProvider;
|
||||||
|
|
||||||
|
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
// Telescope::night();
|
||||||
|
|
||||||
|
$this->hideSensitiveRequestDetails();
|
||||||
|
|
||||||
|
$isLocal = $this->app->environment('local');
|
||||||
|
|
||||||
|
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
|
||||||
|
return $isLocal ||
|
||||||
|
$entry->isReportableException() ||
|
||||||
|
$entry->isFailedRequest() ||
|
||||||
|
$entry->isFailedJob() ||
|
||||||
|
$entry->isScheduledTask() ||
|
||||||
|
$entry->hasMonitoredTag();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent sensitive request details from being logged by Telescope.
|
||||||
|
*/
|
||||||
|
protected function hideSensitiveRequestDetails(): void
|
||||||
|
{
|
||||||
|
if ($this->app->environment('local')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Telescope::hideRequestParameters(['_token']);
|
||||||
|
|
||||||
|
Telescope::hideRequestHeaders([
|
||||||
|
'cookie',
|
||||||
|
'x-csrf-token',
|
||||||
|
'x-xsrf-token',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the Telescope gate.
|
||||||
|
*
|
||||||
|
* This gate determines who can access Telescope in non-local environments.
|
||||||
|
*/
|
||||||
|
protected function gate(): void
|
||||||
|
{
|
||||||
|
Gate::define('viewTelescope', function ($user) {
|
||||||
|
return $user->username == 'witel';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
74
app/Services/DataTable/DataTableInput.php
Normal file
74
app/Services/DataTable/DataTableInput.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Filter\Filter;
|
||||||
|
use App\Services\DataTable\Sort\Sort;
|
||||||
|
|
||||||
|
class DataTableInput
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param int $start
|
||||||
|
* @param int $size
|
||||||
|
* @param array $filters
|
||||||
|
* @param array $sorting
|
||||||
|
* @param array $rels
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private int $start,
|
||||||
|
private ?int $size,
|
||||||
|
private array $filters,
|
||||||
|
private array $sorting,
|
||||||
|
private array $rels,
|
||||||
|
private array $allowedFilters,
|
||||||
|
private array $allowedSortings,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStart(): int
|
||||||
|
{
|
||||||
|
return $this->start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSize(): ?int
|
||||||
|
{
|
||||||
|
return $this->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array returns an array of Filter objects
|
||||||
|
*/
|
||||||
|
public function getFilters(): array
|
||||||
|
{
|
||||||
|
$filters = array();
|
||||||
|
|
||||||
|
foreach ($this->filters as $filter) {
|
||||||
|
$filters[] = new Filter(
|
||||||
|
$filter->id,
|
||||||
|
$filter->value,
|
||||||
|
$filter->fn,
|
||||||
|
$filter->datatype,
|
||||||
|
$this->allowedFilters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Sort|null
|
||||||
|
*/
|
||||||
|
public function getSorting(): ?Sort
|
||||||
|
{
|
||||||
|
return !empty($this->sorting) ?
|
||||||
|
new Sort($this->sorting[0]->id, $this->sorting[0]->desc, $this->allowedSortings) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelations(): array
|
||||||
|
{
|
||||||
|
return $this->rels;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
110
app/Services/DataTable/DataTableService.php
Normal file
110
app/Services/DataTable/DataTableService.php
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Filter\ApplyFilter;
|
||||||
|
use App\Services\DataTable\Sort\ApplySort;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class DataTableService
|
||||||
|
{
|
||||||
|
|
||||||
|
protected array $allowedFilters;
|
||||||
|
protected array $allowedRelations;
|
||||||
|
protected array $allowedSortings;
|
||||||
|
protected array $allowedSelects;
|
||||||
|
private int $totalRowCount;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
protected Builder $query,
|
||||||
|
private DataTableInput $dataTableInput
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedFilters(array $allowedFilters): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedFilters = $allowedFilters;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedRelations(array $allowedRelations): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedRelations = $allowedRelations;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedSortings(array $allowedSortings): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedSortings = $allowedSortings;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedSelects(array $allowedSelects): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedSelects = $allowedSelects;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle 'getData' operations
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
$query = $this->buildQuery();
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'data' => $data,
|
||||||
|
'meta' => [
|
||||||
|
'totalRowCount' => $this->totalRowCount
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildQuery(): Builder
|
||||||
|
{
|
||||||
|
$query = $this->query;
|
||||||
|
|
||||||
|
foreach ($this->dataTableInput->getFilters() as $filter) {
|
||||||
|
$query = (new ApplyFilter($query, $filter))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->applySelect($query, $this->allowedSelects);
|
||||||
|
$query = $this->includeRelationsInQuery($query, $this->allowedRelations);
|
||||||
|
|
||||||
|
$this->totalRowCount = $query->count();
|
||||||
|
|
||||||
|
$query->offset($this->dataTableInput->getStart());
|
||||||
|
|
||||||
|
if(!is_null($this->dataTableInput->getSize())){
|
||||||
|
$query->limit($this->dataTableInput->getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
$sorting = $this->dataTableInput->getSorting();
|
||||||
|
$query = (new ApplySort($query, $sorting))->apply();
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function applySelect(Builder $query, array $selectedFields): Builder
|
||||||
|
{
|
||||||
|
if (!empty($selectedFields)) {
|
||||||
|
$query->select($selectedFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function includeRelationsInQuery(Builder $query, array $rels): Builder
|
||||||
|
{
|
||||||
|
if (!empty($rels)) {
|
||||||
|
$query->with($rels);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
// (later) define mapping of relation names to prevent relation name expose.
|
||||||
|
// (later) define mapping of column names to prevent column name expose.
|
||||||
|
}
|
||||||
15
app/Services/DataTable/Enums/DataType.php
Normal file
15
app/Services/DataTable/Enums/DataType.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Enums;
|
||||||
|
|
||||||
|
enum DataType: string
|
||||||
|
{
|
||||||
|
case NUMERIC = 'numeric';
|
||||||
|
case TEXT = 'text';
|
||||||
|
case DATE = 'date';
|
||||||
|
|
||||||
|
public static function values(): array
|
||||||
|
{
|
||||||
|
return array_column(self::cases(), 'value');
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Services/DataTable/Enums/SearchType.php
Normal file
19
app/Services/DataTable/Enums/SearchType.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Enums;
|
||||||
|
|
||||||
|
enum SearchType: string
|
||||||
|
{
|
||||||
|
case CONTAINS = 'contains';
|
||||||
|
case EQUALS = 'equals';
|
||||||
|
case NOT_EQUALS = 'notEquals';
|
||||||
|
case BETWEEN = 'between';
|
||||||
|
case GREATER_THAN = 'greaterThan';
|
||||||
|
case LESS_THAN = 'lessThan';
|
||||||
|
case FUZZY = 'fuzzy';
|
||||||
|
|
||||||
|
public static function values(): array
|
||||||
|
{
|
||||||
|
return array_column(self::cases(), 'value');
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Services/DataTable/Exceptions/InvalidFilterException.php
Normal file
21
app/Services/DataTable/Exceptions/InvalidFilterException.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class InvalidFilterException extends Exception implements InvalidParameterInterface
|
||||||
|
{
|
||||||
|
protected $fieldName;
|
||||||
|
|
||||||
|
public function __construct($fieldName, $message = "", $code = 400, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldName()
|
||||||
|
{
|
||||||
|
return $this->fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
interface InvalidParameterInterface
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class InvalidRelationException extends Exception implements InvalidParameterInterface
|
||||||
|
{
|
||||||
|
protected $fieldName;
|
||||||
|
|
||||||
|
public function __construct($fieldName, $message = "", $code = 400, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldName()
|
||||||
|
{
|
||||||
|
return $this->fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class InvalidSortingException extends Exception implements InvalidParameterInterface
|
||||||
|
{
|
||||||
|
protected $fieldName;
|
||||||
|
|
||||||
|
public function __construct($fieldName, $message = "", $code = 400, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldName()
|
||||||
|
{
|
||||||
|
return $this->fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
84
app/Services/DataTable/Filter/ApplyFilter.php
Normal file
84
app/Services/DataTable/Filter/ApplyFilter.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\SearchType;
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidFilterException;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterBetween;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterContains;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterEquals;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterGreaterThan;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterLessThan;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterNotEquals;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\SearchFilter;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class ApplyFilter
|
||||||
|
{
|
||||||
|
private SearchFilter $searchFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $query
|
||||||
|
* @param Filter $filter
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private Builder $query,
|
||||||
|
private Filter $filter,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$filter = $this->filter;
|
||||||
|
$query = $this->query;
|
||||||
|
|
||||||
|
$searchType = SearchType::from($filter->getFn());
|
||||||
|
switch ($searchType) {
|
||||||
|
case SearchType::CONTAINS:
|
||||||
|
$this->searchFilter = new FilterContains($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::EQUALS:
|
||||||
|
$this->searchFilter = new FilterEquals($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::NOT_EQUALS:
|
||||||
|
$this->searchFilter = new FilterNotEquals($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::BETWEEN:
|
||||||
|
$this->searchFilter = new FilterBetween($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::GREATER_THAN:
|
||||||
|
$this->searchFilter = new FilterGreaterThan($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::LESS_THAN:
|
||||||
|
$this->searchFilter = new FilterLessThan($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$searchFunction = $filter->getFn();
|
||||||
|
throw new InvalidFilterException($searchFunction, "search function `$searchFunction` is invalid.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$relation = $this->filter->getRelation();
|
||||||
|
return $relation ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function applyFilterToRelation(string $relation): Builder
|
||||||
|
{
|
||||||
|
return $this->query->whereHas($relation, function (Builder $query) {
|
||||||
|
$this->filter->removeRelationFromId();
|
||||||
|
$this->applyFilter($query, $this->filter);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyFilter(Builder $query, Filter $filter): Builder
|
||||||
|
{
|
||||||
|
return (new ApplyFilter($query, $filter))->apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
73
app/Services/DataTable/Filter/Filter.php
Normal file
73
app/Services/DataTable/Filter/Filter.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Validators\FilterValidator;
|
||||||
|
|
||||||
|
class Filter
|
||||||
|
{
|
||||||
|
private static FilterValidator $filterValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @param string|int|array $value
|
||||||
|
* @param string $fn
|
||||||
|
* @param string $datatype
|
||||||
|
* @param array $allowedFilters
|
||||||
|
* @throws \App\Services\DataTable\Exceptions\InvalidFilterException
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private string $id,
|
||||||
|
private string|int|array $value,
|
||||||
|
private string $fn,
|
||||||
|
private string $datatype,
|
||||||
|
private array $allowedFilters
|
||||||
|
)
|
||||||
|
{
|
||||||
|
self::$filterValidator = FilterValidator::getInstance();
|
||||||
|
self::$filterValidator->isValid($this, $this->allowedFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue(): array|int|string
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFn(): string
|
||||||
|
{
|
||||||
|
return $this->fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatatype(): string
|
||||||
|
{
|
||||||
|
return $this->datatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelation(): string
|
||||||
|
{
|
||||||
|
$fieldArray = explode('.', $this->id);
|
||||||
|
return count($fieldArray) > 1 ? $fieldArray[0] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColumn(): string
|
||||||
|
{
|
||||||
|
$fieldArray = explode('.', $this->id);
|
||||||
|
return array_pop($fieldArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeRelationFromId(): void
|
||||||
|
{
|
||||||
|
$this->id = $this->getColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue(int|array|string $value): void
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterBetween extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$query = $this->query;
|
||||||
|
[$minVal, $maxVal] = $this->filter->getValue();
|
||||||
|
|
||||||
|
if ($minVal) {
|
||||||
|
$this->filter->setValue($minVal);
|
||||||
|
$query = (new FilterGreaterThanOrEqual($this->query, $this->filter))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($maxVal) {
|
||||||
|
$this->filter->setValue($maxVal);
|
||||||
|
$query = (new FilterLessThanOrEqual($this->query, $this->filter))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterContains extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$column = $this->filter->getId();
|
||||||
|
$value = '%' . $this->filter->getValue() . '%';
|
||||||
|
|
||||||
|
if ($this->filter->getDatatype() == DataType::TEXT->value) {
|
||||||
|
$query = $this->searchIgnoreCase($column, $value);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$query = $this->query->where($column, 'LIKE', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function searchIgnoreCase(string $column, string $value): Builder
|
||||||
|
{
|
||||||
|
$value = strtolower($value);
|
||||||
|
return $this->query->whereRaw("LOWER($column) LIKE ?", [$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user