inital commit
This commit is contained in:
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
archive.tgz
|
||||
2
README.md
Normal file
2
README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# RMTO Dashboard Project using Laravel
|
||||
git push sshorigin develop
|
||||
10
app/AccidentPoint.php
Normal file
10
app/AccidentPoint.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AccidentPoint extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
633
app/Console/Commands/ReportSummary.php
Normal file
633
app/Console/Commands/ReportSummary.php
Normal file
@@ -0,0 +1,633 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Province;
|
||||
use App\Models\User;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\ContractSubItems;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use App\Models\Accident;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Models\ReportSummary as ReportSummaryModel;
|
||||
|
||||
class ReportSummary extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'reports:rms-summary';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Prepares and Inserts data from specific reports into `rms_reports_summary` table.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
// initializing
|
||||
$from_date_array = explode('-', verta()->startYear()->format('Y-m-d'));
|
||||
$from_date = implode('-', verta()->getGregorian($from_date_array[0], $from_date_array[1], $from_date_array[2])) . ' 00:00:00';
|
||||
$to_date_array = explode('-', verta()->endYear()->format('Y-m-d'));
|
||||
$to_date = implode('-', verta()->getGregorian($to_date_array[0], $to_date_array[1], $to_date_array[2])) . ' 23:59:59';
|
||||
|
||||
|
||||
// (BEGIN) receipt
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'receipt'],
|
||||
[
|
||||
'report_name' => 'receipt',
|
||||
'data' => [
|
||||
'chart' => Accident::select(DB::raw('sum(sum) as sum'), 'province_fa')->where('status', '5')->groupby('province_id')->orderby('sum', 'desc')->get()->take(5)->toArray(),
|
||||
'sum' => Accident::select(DB::raw('sum(sum) - sum(ojrate_nasb) as sum'))->first('sum'),
|
||||
]
|
||||
|
||||
|
||||
]
|
||||
);
|
||||
// (END) receipt
|
||||
|
||||
|
||||
// (BEGIN) safety_and_privacy
|
||||
foreach (InfoItem::where('type', "privacy")->get() as $key => $value) {
|
||||
$finalArray['label'][] = $value['sub_item_str'];
|
||||
}
|
||||
|
||||
for ($step = 1; $step < 4; $step++) {
|
||||
$finalArray['data'][] = SafetyAndPrivacy::select(DB::raw('count(*) as count'))->where('step', $step)->groupby('info_id')->get()->map(function ($item) {
|
||||
return $item->count;
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'safety_and_privacy'],
|
||||
[
|
||||
'report_name' => 'safety_and_privacy',
|
||||
'data' => $finalArray
|
||||
]
|
||||
);
|
||||
|
||||
// (END) safety_and_privacy
|
||||
|
||||
// (BEGIN) road_item
|
||||
$finalArray = [];
|
||||
|
||||
foreach (InfoItem::where('type', "item")->groupby('item')->get() as $key => $value) {
|
||||
$finalArray['label'][$value['item']] = $value['item_str'];
|
||||
$finalArray['data'][$value['item']] = 0;
|
||||
}
|
||||
$data = DB::table('road_items_projects')
|
||||
->select('item_fa as label', 'item')
|
||||
->whereBetween('created_at', [$from_date, $to_date])
|
||||
->get();
|
||||
|
||||
$dataAfter = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$dataAfter[$value->item]['label'] = $value->label;
|
||||
if(!isset($dataAfter[$value->item]['count'])) {
|
||||
$dataAfter[$value->item]['count'] = 0;
|
||||
}
|
||||
$dataAfter[$value->item]['count']++;
|
||||
|
||||
}
|
||||
|
||||
foreach ($dataAfter as $key => $value) {
|
||||
$finalArray['label'][$key] = $value['label'];
|
||||
$finalArray['data'][$key] = $value['count'];
|
||||
}
|
||||
|
||||
$temporary = [];
|
||||
foreach ($finalArray['label'] as $value) {
|
||||
$temporary['label'][] = $value;
|
||||
}
|
||||
|
||||
foreach ($finalArray['data'] as $value) {
|
||||
$temporary['data'][] = $value;
|
||||
}
|
||||
array_multisort($temporary['data'], SORT_DESC, $temporary['label']);
|
||||
|
||||
$myArray = [];
|
||||
|
||||
$myArray['labels'] = $temporary['label'];
|
||||
$myArray['datasets'][] = [
|
||||
'label' => 'به تفکیک نوع پروژه های راهداری',
|
||||
'data' => $temporary['data']
|
||||
];
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'road_item'],
|
||||
[
|
||||
'report_name' => 'road_item',
|
||||
'data' => $myArray
|
||||
]
|
||||
);
|
||||
// (END) road_item
|
||||
|
||||
|
||||
|
||||
|
||||
// (BEGIN) gashte roozaneh
|
||||
$gasht_rozane = DB::table('road_patrols')
|
||||
->select(
|
||||
DB::raw('count(road_patrols.id) as count_number'),
|
||||
DB::raw('sum(distance) as distance'),
|
||||
'road_patrols.province_fa'
|
||||
)
|
||||
->groupBy('road_patrols.province_id')
|
||||
->orderBy('distance', 'desc')
|
||||
->limit(5)
|
||||
->get()->toArray();
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'gasht_rozane'],
|
||||
[
|
||||
'report_name' => 'gasht_rozane',
|
||||
'data' => $gasht_rozane
|
||||
]
|
||||
);
|
||||
|
||||
// (END) gashte roozaneh
|
||||
|
||||
// (BEGIN) [POSTERS CONTROLLER => progressInfo] user activity
|
||||
|
||||
// for ($i = 3; $i >= 0; $i--) {
|
||||
|
||||
// $from_date_array = explode('-', verta()->startYear()->subYear($i)->format('Y-m-d'));
|
||||
// $from_date = implode('-', verta()->getGregorian($from_date_array[0], $from_date_array[1], $from_date_array[2])) . ' 00:00:00';
|
||||
// $to_date_array = explode('-', verta()->subYear($i)->endYear()->format('Y-m-d'));
|
||||
// $to_date = implode('-', verta()->getGregorian($to_date_array[0], $to_date_array[1], $to_date_array[2])) . ' 23:59:59';
|
||||
|
||||
// $user_activity_sql = "
|
||||
// SELECT SUM(majmoe) AS activity
|
||||
// FROM (
|
||||
// SELECT *, COUNT(quantity) AS majmoe
|
||||
// FROM (
|
||||
// SELECT *,
|
||||
// COUNT(*) AS quantity
|
||||
// FROM (
|
||||
// SELECT YEAR (created_at) AS yy,
|
||||
// MONTH (created_at) AS mm,
|
||||
// DAY (created_at) AS dd,
|
||||
// HOUR (created_at) AS hh,
|
||||
// user_id
|
||||
// FROM user_activity_logs
|
||||
// WHERE created_at BETWEEN '{$from_date}' AND '{$to_date}'
|
||||
// ) user_activity_distinct
|
||||
// GROUP BY yy,
|
||||
// mm,
|
||||
// dd,
|
||||
// hh,
|
||||
// user_id
|
||||
// ) user_activity_by_hour_and_
|
||||
// GROUP BY user_id
|
||||
// ) AS calculated_table;";
|
||||
|
||||
// $user_activity = (int) DB::select(DB::raw($user_activity_sql))[0]->activity;
|
||||
// $user_activity_count_sql = "SELECT count(*) as cnt
|
||||
// FROM user_activity_logs WHERE created_at between '{$from_date}' and '{$to_date}'";
|
||||
// $user_activity_count = (int) DB::select(DB::raw($user_activity_count_sql))[0]->cnt;
|
||||
|
||||
// $array[] = [
|
||||
// 'user_activity' => $user_activity,
|
||||
// 'user_activity_count' => $user_activity_count,
|
||||
// 'year' => ($from_date_array[0] == '1400') ? 'نیمه دوم 1400' : $from_date_array[0]
|
||||
// ];
|
||||
|
||||
// }
|
||||
|
||||
|
||||
$number_of_past_days = verta()->startYear()->diffDays();
|
||||
|
||||
|
||||
$user_activity_sql = "
|
||||
SELECT SUM(majmoe) AS activity
|
||||
FROM (
|
||||
SELECT *, COUNT(quantity) AS majmoe
|
||||
FROM (
|
||||
SELECT *,
|
||||
COUNT(*) AS quantity
|
||||
FROM (
|
||||
SELECT YEAR (created_at) AS yy,
|
||||
MONTH (created_at) AS mm,
|
||||
DAY (created_at) AS dd,
|
||||
HOUR (created_at) AS hh,
|
||||
user_id
|
||||
FROM user_activity_logs
|
||||
WHERE created_at BETWEEN '{$from_date}' AND '{$to_date}'
|
||||
) user_activity_distinct
|
||||
GROUP BY yy,
|
||||
mm,
|
||||
dd,
|
||||
hh,
|
||||
user_id
|
||||
) user_activity_by_hour_and_
|
||||
GROUP BY user_id
|
||||
) AS calculated_table;";
|
||||
|
||||
$user_activity = (int) DB::select(DB::raw($user_activity_sql))[0]->activity;
|
||||
// $user_activity_count_sql = "SELECT COUNT(DISTINCT user_id) AS cnt FROM user_activity_logs ;";
|
||||
$user_activity_number = (int) DB::select(DB::raw("SELECT COUNT(DISTINCT user_id) AS cnt FROM user_activity_logs ;"))[0]->cnt;
|
||||
$array[] = [
|
||||
'user_count' => User::count(),
|
||||
'user_activity_avarage' => round(($user_activity / 143) / $user_activity_number),
|
||||
'year' => $from_date_array[0]
|
||||
];
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'user_activity'],
|
||||
[
|
||||
'report_name' => 'user_activity',
|
||||
'data' => $array,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
// (END) [POSTERS CONTROLLER => progressInfo] user activity
|
||||
|
||||
// (BEGIN) [BAMA CONTROLLER => homepage_report] tedad proje be tafkik noe va akharin vaziat
|
||||
$collection = ContractSubItems::groupBy('project_type_id')
|
||||
->select('project_type_id as id', 'project_type_fa as label')
|
||||
->where('progress_project', '<', 100)
|
||||
->get();
|
||||
$array = [];
|
||||
foreach ($collection as $key => $value) {
|
||||
$array['label'][$value->id] = $value->label;
|
||||
$array['data'][$value->id] = 0;
|
||||
}
|
||||
|
||||
$data = DB::table('contract_subitems')
|
||||
->groupBy('project_type_id')
|
||||
->select('project_type_id as id', 'project_type_fa as label', DB::raw('count(*) as count'))
|
||||
->where('progress_project', '<', 100)
|
||||
->get();
|
||||
|
||||
foreach ($data as $key => $item) {
|
||||
$array['data'][$item->id] = $item->count;
|
||||
}
|
||||
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($array['label'] as $index => $value) {
|
||||
$finalArray['label'][] = $value;
|
||||
$finalArray['data'][] = $array['data'][$index];
|
||||
}
|
||||
|
||||
$type_sperate = $finalArray;
|
||||
|
||||
$collection = ContractSubItems::groupBy('last_status_id')
|
||||
->where('last_status_id', '!=', '0')
|
||||
->where('progress_project', '<', 100)
|
||||
->select('last_status_id as id', 'last_status_fa as label')
|
||||
->get();
|
||||
$array = [];
|
||||
foreach ($collection as $key => $value) {
|
||||
$array['label'][$value->id] = $value->label;
|
||||
$array['data'][$value->id] = 0;
|
||||
}
|
||||
|
||||
|
||||
$data = DB::table('contract_subitems')
|
||||
->where('last_status_id', '!=', '0')
|
||||
->where('progress_project', '<', 100)
|
||||
->groupBy('last_status_id')
|
||||
->select('last_status_id as id', 'last_status_fa as label', DB::raw('count(*) as count'))
|
||||
->get();
|
||||
|
||||
foreach ($data as $key => $item) {
|
||||
$array['data'][$item->id] = $item->count;
|
||||
}
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($array['label'] as $index => $value) {
|
||||
$finalArray['label'][] = $value;
|
||||
$finalArray['data'][] = $array['data'][$index];
|
||||
}
|
||||
|
||||
$status_sperate = $finalArray;
|
||||
|
||||
$total_projects_count = ContractSubItems::count();
|
||||
|
||||
$point_data = ContractSubItems::select('id', 'start_lat', 'start_lng', 'project_type_id')
|
||||
->where('progress_project', '<', 100)
|
||||
->whereBetween('contract_date_from_parent_contract', [$from_date , $to_date])
|
||||
->get();
|
||||
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'contract_subitem_projects'],
|
||||
[
|
||||
'report_name' => 'contract_subitem_projects',
|
||||
'data' => [
|
||||
'type_sperate' => $type_sperate,
|
||||
'status_sperate' => $status_sperate,
|
||||
'count' => $total_projects_count,
|
||||
'points' => $point_data,
|
||||
],
|
||||
]
|
||||
);
|
||||
// (END) [BAMA CONTROLLER => homepage_report] tedad proje be tafkik noe va akharin vaziat
|
||||
|
||||
// (BEGIN) [BI CONTROLLER => percentComplaintsHandled] total percent complaints handled
|
||||
$countHandled = RoadObserved::where('rms_status', "<>", 0)
|
||||
->count();
|
||||
|
||||
$countAll = RoadObserved::count();
|
||||
|
||||
$total_percent_complaints_handled = $countAll ? round(($countHandled / $countAll) * 100) : 0;
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'total_percent_complaints_handled'],
|
||||
[
|
||||
'report_name' => 'total_percent_complaints_handled',
|
||||
'data' => $total_percent_complaints_handled
|
||||
]
|
||||
);
|
||||
|
||||
// (END) [BI CONTROLLER => percentComplaintsHandled] total percent complaints handled
|
||||
|
||||
|
||||
// (BEGIN) [BI CONTROLLER => separationComplainTypeRahdariComplains]
|
||||
$dataLabel = RoadObserved::select('fk_FeatureType as id', 'FeatureTypeTitle as label', DB::raw('count(*) as count'))
|
||||
->groupBy('fk_FeatureType')
|
||||
->get();
|
||||
|
||||
$array = [];
|
||||
foreach ($dataLabel as $value) {
|
||||
$array['label'][$value->id] = $value->label;
|
||||
$array['dataVasel'][$value->id] = 0;
|
||||
$array['dataResidegiShode'][$value->id] = 0;
|
||||
}
|
||||
$dataResidegiShode = RoadObserved::where('rms_status', '!=', 0)
|
||||
->select('fk_FeatureType as id', DB::raw('count(*) as count'))
|
||||
->groupBy('fk_FeatureType')
|
||||
->get();
|
||||
|
||||
foreach ($dataResidegiShode as $key => $item) {
|
||||
$array['dataResidegiShode'][$item->id] = $item->count;
|
||||
}
|
||||
|
||||
$dataVasel = RoadObserved::select('fk_FeatureType as id', DB::raw('count(*) as count'))
|
||||
->groupBy('fk_FeatureType')
|
||||
->get();
|
||||
|
||||
foreach ($dataVasel as $key => $item) {
|
||||
$array['dataVasel'][$item->id] = $item->count;
|
||||
}
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($array['label'] as $value) {
|
||||
$finalArray['label'][] = $value;
|
||||
}
|
||||
foreach ($array['dataResidegiShode'] as $value) {
|
||||
$finalArray['dataResidegiShode'][] = $value;
|
||||
}
|
||||
foreach ($array['dataVasel'] as $value) {
|
||||
$finalArray['dataVasel'][] = $value;
|
||||
}
|
||||
|
||||
$number_of_complaints_per_type = [];
|
||||
|
||||
$number_of_complaints_per_type['labels'] = $finalArray['label'];
|
||||
$number_of_complaints_per_type['datasets'][] = [
|
||||
'label' => 'رسیدگی شده',
|
||||
'data' => $finalArray['dataResidegiShode']
|
||||
];
|
||||
$number_of_complaints_per_type['datasets'][] = [
|
||||
'label' => 'واصل شده',
|
||||
'data' => $finalArray['dataVasel']
|
||||
];
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'number_of_complaints_per_type'],
|
||||
[
|
||||
'report_name' => 'number_of_complaints_per_type',
|
||||
'data' => $number_of_complaints_per_type,
|
||||
]
|
||||
);
|
||||
// (END) [BI CONTROLLER => separationComplainTypeRahdariComplains]
|
||||
|
||||
// (BEGIN) [CampController => statics] tool mehvarhaye asib dide
|
||||
$sql = "SELECT blockage_cause,blockage_cause_fa,COUNT(*) AS cnt,SUM(blockage_length)
|
||||
AS lenght FROM camps WHERE is_open = 2 GROUP BY blockage_cause";
|
||||
$pies = DB::select(DB::raw($sql));
|
||||
|
||||
$data = \App\Models\Camp::where('is_open', 2)
|
||||
->groupBy('blockage_cause', 'axis_type')
|
||||
->selectRaw('axis_type, axis_type_fa, blockage_cause, blockage_cause_fa, COUNT(*) AS cnt, SUM(blockage_length) as length')
|
||||
->get()->toArray();
|
||||
|
||||
$stack_result = [
|
||||
['axis_type_fa' => 'آزادراه', 'data' => [['blockage_cause_fa' => 'برف', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سیل', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'رانش و ریزش', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سایر', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'طوفان شن', 'cnt' => 0, 'length' => 0]]],
|
||||
['axis_type_fa' => 'اصلی', 'data' => [['blockage_cause_fa' => 'برف', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سیل', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'رانش و ریزش', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سایر', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'طوفان شن', 'cnt' => 0, 'length' => 0]]],
|
||||
['axis_type_fa' => 'فرعی', 'data' => [['blockage_cause_fa' => 'برف', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سیل', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'رانش و ریزش', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سایر', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'طوفان شن', 'cnt' => 0, 'length' => 0]]],
|
||||
['axis_type_fa' => 'روستایی', 'data' => [['blockage_cause_fa' => 'برف', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سیل', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'رانش و ریزش', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سایر', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'طوفان شن', 'cnt' => 0, 'length' => 0]]],
|
||||
['axis_type_fa' => 'بزرگراه', 'data' => [['blockage_cause_fa' => 'برف', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سیل', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'رانش و ریزش', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'سایر', 'cnt' => 0, 'length' => 0], ['blockage_cause_fa' => 'طوفان شن', 'cnt' => 0, 'length' => 0]]],
|
||||
];
|
||||
|
||||
foreach ($data as $item) {
|
||||
$key = $item['axis_type'] - 1;
|
||||
|
||||
foreach ($stack_result[$key]['data'] as $k => $axis_data) {
|
||||
if ($axis_data['blockage_cause_fa'] == $item['blockage_cause_fa']) {
|
||||
$stack_result[$key]['data'][$k]['cnt'] = $item['cnt'];
|
||||
$stack_result[$key]['data'][$k]['length'] = $item['length'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT money,car,rahdar,polbig+polsmall+other AS dmg, bl_len FROM(
|
||||
SELECT
|
||||
-- COUNT(*) AS cnt,
|
||||
SUM(blockage_damage_money) AS money,
|
||||
SUM(blockage_damage_higher_6_count) AS polbig,
|
||||
SUM(blockage_damage_lower_6_count) AS polsmall,
|
||||
SUM(blockage_damage_count) AS other,
|
||||
SUM(active_cars_count) AS car,
|
||||
SUM(active_rahdar_count) AS rahdar,
|
||||
SUM(blockage_length) AS bl_len
|
||||
FROM
|
||||
camps
|
||||
WHERE is_open = 2
|
||||
)q";
|
||||
$statics = DB::select(DB::raw($sql));
|
||||
|
||||
$mehvar_statistics = [
|
||||
'charts' => [
|
||||
'pies' => $pies,
|
||||
'stack' => $stack_result,
|
||||
'staticks' => $statics
|
||||
]
|
||||
];
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'mehvar_statistics'],
|
||||
[
|
||||
'report_name' => 'mehvar_statistics',
|
||||
'data' => $mehvar_statistics,
|
||||
]
|
||||
);
|
||||
// (END) [CampController => statics] tool mehvarhaye asib dide
|
||||
|
||||
// (BEGIN) [Posters Controller => progressinfo]
|
||||
$top_5_province_at_road_observation_according_to_progress_percent = DB::table('road_observeds')
|
||||
->select(DB::raw('count(road_observeds.id) as count_number'), 'road_observeds.ProvinceName', DB::raw("(count(road_observeds.id) / (SELECT count(ro2.id) FROM road_observeds ro2 WHERE road_observeds.rms_province_id = ro2.rms_province_id) * 100) as progress_percent"))
|
||||
->where('road_observeds.rms_status', '<>', 0)
|
||||
->groupBy('road_observeds.rms_province_id')
|
||||
->orderBy('progress_percent', 'desc')
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'top_provinces_according_to_number_of_complaints_handled'],
|
||||
[
|
||||
'report_name' => 'top_provinces_according_to_number_of_complaints_handled',
|
||||
'data' => $top_5_province_at_road_observation_according_to_progress_percent,
|
||||
]
|
||||
);
|
||||
|
||||
// (END) [Posters Controller => progressinfo]
|
||||
|
||||
// (BEGIN) [Posters Controller => progressinfo] top_provinces_according_to_number_of_complaints_handled
|
||||
$top_5_province_at_road_observation_according_to_progress_percent = DB::table('road_observeds')
|
||||
->select(DB::raw('count(road_observeds.id) as count_number'), 'road_observeds.ProvinceName', DB::raw("(count(road_observeds.id) / (SELECT count(ro2.id) FROM road_observeds ro2 WHERE road_observeds.rms_province_id = ro2.rms_province_id) * 100) as progress_percent"))
|
||||
->where('road_observeds.rms_status', '<>', 0)
|
||||
->groupBy('road_observeds.rms_province_id')
|
||||
->orderBy('progress_percent', 'desc')
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'top_provinces_according_to_percent_of_complaints_handled'],
|
||||
[
|
||||
'report_name' => 'top_provinces_according_to_percent_of_complaints_handled',
|
||||
'data' => $top_5_province_at_road_observation_according_to_progress_percent,
|
||||
]
|
||||
);
|
||||
|
||||
// (END) [Posters Controller => progressinfo]
|
||||
|
||||
// (BEGIN) [Posters Controller => progressinfo] top_provinces_according_to_number_of_complaints_handled
|
||||
$top_5_province_at_road_observation_according_to_quantity = DB::table('road_observeds')
|
||||
->select('ProvinceName', DB::raw('count(id) as count_number'))
|
||||
->where('rms_status', '<>', 0)
|
||||
->groupBy('rms_province_id')
|
||||
->orderBy('count_number', 'desc')
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'top_provinces_according_to_number_of_complaints_handled'],
|
||||
[
|
||||
'report_name' => 'top_provinces_according_to_number_of_complaints_handled',
|
||||
'data' => $top_5_province_at_road_observation_according_to_quantity,
|
||||
]
|
||||
);
|
||||
|
||||
// (END) [Posters Controller => progressinfo]
|
||||
|
||||
|
||||
// (BEGIN) [Posters Controller => progressinfo] naqshe_faaliat_haye_rozaneh
|
||||
|
||||
$provinces = Province::select('id', 'name_fa')->get();
|
||||
$array = [];
|
||||
|
||||
$array = $this->createArrayFromProvincesOrCities($provinces, $array);
|
||||
|
||||
$data = DB::table('road_items_projects')
|
||||
->select('province_id', 'province_fa')
|
||||
->whereBetween('created_at', [$from_date . ' 00:00:00', $to_date . ' 23:59:59'])
|
||||
->get();
|
||||
|
||||
$dataAfter = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$dataAfter[$value->province_id - 1]['province_fa'] = $value->province_fa;
|
||||
$dataAfter[$value->province_id - 1]['province_id'] = $value->province_id;
|
||||
if(!isset($dataAfter[$value->province_id - 1]['count'])) {
|
||||
$dataAfter[$value->province_id - 1]['count'] = 0;
|
||||
}
|
||||
$dataAfter[$value->province_id - 1]['count']++;
|
||||
}
|
||||
|
||||
$array = $this->createDataArray($dataAfter, $array);
|
||||
|
||||
$finalArray = [];
|
||||
foreach ($array['label'] as $index => $value) {
|
||||
$finalArray['label'][] = $value;
|
||||
$finalArray['data'][] = $array['data'][$index];
|
||||
}
|
||||
|
||||
$geoJsonArray = $finalArray['data'];
|
||||
|
||||
array_multisort($finalArray['data'], SORT_DESC, $finalArray['label']);
|
||||
|
||||
$myArray = [];
|
||||
|
||||
$myArray['labels'] = $finalArray['label'];
|
||||
$myArray['datasets'][] = [
|
||||
'label' => 'نمودار وضعیت',
|
||||
'data' => $finalArray['data']
|
||||
];
|
||||
|
||||
ReportSummaryModel::updateOrCreate(
|
||||
['report_name' => 'naqshe_faaliat_haye_rozaneh'],
|
||||
[
|
||||
'report_name' => 'naqshe_faaliat_haye_rozaneh',
|
||||
'data' => [
|
||||
'data' => $myArray,
|
||||
'geojson' => $geoJsonArray
|
||||
],
|
||||
]
|
||||
);
|
||||
// (END) [Posters Controller => progressinfo]
|
||||
}
|
||||
|
||||
public function createArrayFromProvincesOrCities($collection, $array, $default = null)
|
||||
{
|
||||
$newArray = [];
|
||||
foreach ($collection as $key => $value) {
|
||||
$array['label'][$value->id] = $value->name_fa;
|
||||
$array['data'][$value->id] = $default;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function createDataArray($data, $array)
|
||||
{
|
||||
if(gettype($data) == 'array') {
|
||||
foreach ($data as $key => $item) {
|
||||
$array['data'][($item['province_id'] ?? $item['city_id'])] = $item['count'];
|
||||
}
|
||||
} else {
|
||||
foreach ($data as $key => $item) {
|
||||
$array['data'][($item->province_id ?? $item->city_id)] = $item->count;
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
2805
app/Console/Commands/RoadObservationProblems.php
Executable file
2805
app/Console/Commands/RoadObservationProblems.php
Executable file
File diff suppressed because it is too large
Load Diff
71
app/Console/Commands/SendContractSmsNotification.php
Normal file
71
app/Console/Commands/SendContractSmsNotification.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use SoapFault;
|
||||
use SoapClient;
|
||||
use App\Models\ContractSubItems;
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class SendContractSmsNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:sendcontractsmsnotification';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$contractSubItems = ContractSubItems::where('last_date_update', '<' , Carbon::now()->subMonths(2))->where('last_status_id', '<>', 3)->get();
|
||||
|
||||
foreach ($contractSubItems as $key => $value) {
|
||||
$message = "سلام،\n پروژه راهداری با کد یکتای {$value->unique_code} با مسئولیت شما، به مدت بیشتر از یک ماه به روزرسانی نشده است. لطفا نسبت به روز رسانی دقیق پیشرفت پروژه در سامانه اقدام نمایید.\n rms.rmto.ir";
|
||||
|
||||
self::sms_sender($value->operator_phone, $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function sms_sender($mobile, $msg)
|
||||
{
|
||||
$client=new SoapClient("http://sms1000.ir/webservice/smspro.asmx?WSDL");
|
||||
$result=$client->doSendSMS(
|
||||
array(
|
||||
'uUsername' => 'rmto',
|
||||
'uPassword' => 'Rahdari89',
|
||||
'uNumber' => '1000141',
|
||||
'uCellphones' => $mobile,
|
||||
'uMessage' => $msg,
|
||||
'uFarsi' => true,
|
||||
'uTopic' => false,
|
||||
'uFlash' => false
|
||||
)
|
||||
);
|
||||
$x = $result->doSendSMSResult;
|
||||
return $x;
|
||||
}
|
||||
}
|
||||
59
app/Console/Commands/UpdateRoadObserved.php
Normal file
59
app/Console/Commands/UpdateRoadObserved.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\RoadObserved;
|
||||
|
||||
class UpdateRoadObserved extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webservice:update-roadobserved';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update road observed table (province_fa, city_fa)';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$ids = RoadObserved::whereNotNull('province_id')
|
||||
->whereNotNull('city_id')
|
||||
->whereNull('province_fa')
|
||||
->whereNull('city_fa')
|
||||
->select('id')
|
||||
->get()
|
||||
->pluck('id');
|
||||
|
||||
|
||||
foreach ($ids as $id) {
|
||||
|
||||
\DB::update("UPDATE road_observeds set province_fa = (select name_fa from provinces where id = (select province_id from road_observeds where id = ?)),
|
||||
city_fa = (select name_fa from cities where id = (select city_id from road_observeds where id = ?)) where id = ?", [$id, $id, $id]);
|
||||
}
|
||||
|
||||
echo 'done at: '.date("Y-m-d H:i:s")."\n";
|
||||
|
||||
}
|
||||
}
|
||||
52
app/Console/Kernel.php
Executable file
52
app/Console/Kernel.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\RoadObservationProblems', //// road observed webservice from 141 sawaneh
|
||||
'App\Console\Commands\SendContractSmsNotification', //// road observed webservice from 141 sawaneh
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('webservice:roadobserved')
|
||||
->everyFiveMinutes()->appendOutputTo(storage_path('logs/roadobser.log'));
|
||||
|
||||
$schedule->command('command:sendcontractsmsnotification')
|
||||
// ->everyMinute()->appendOutputTo(storage_path('logs/contractSms.log'));
|
||||
->dailyAt('10:00')->appendOutputTo(storage_path('logs/contractSms.log'));
|
||||
|
||||
$schedule->command('reports:rms-summary')
|
||||
->dailyAt('00:00')->appendOutputTo(storage_path('logs/report_summary.log'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
38
app/Exceptions/Handler.php
Normal file
38
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use App\Services\DataTable\Exceptions\InvalidParameterInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
|
||||
$this->renderable(function (InvalidParameterInterface $exception, Request $request) {
|
||||
return response()->json([
|
||||
'error' => $exception->getMessage(),
|
||||
], $exception->getCode());
|
||||
});
|
||||
}
|
||||
}
|
||||
16
app/Exports/Activities/Alaem/City.php
Normal file
16
app/Exports/Activities/Alaem/City.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Alaem;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
|
||||
class City implements FromCollection
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
16
app/Exports/Activities/Alaem/Province.php
Normal file
16
app/Exports/Activities/Alaem/Province.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Alaem;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
|
||||
class Province implements FromCollection
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
16
app/Exports/Activities/One/Activity.php
Normal file
16
app/Exports/Activities/One/Activity.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\One;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
|
||||
class Activity implements FromCollection
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/One/AllSheets.php
Normal file
25
app/Exports/Activities/One/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\One;
|
||||
|
||||
use App\Exports\Activities\One\Provinces;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\One\Cities;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Provinces($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new Cities($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
208
app/Exports/Activities/One/Cities.php
Normal file
208
app/Exports/Activities/One/Cities.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\One;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\City;
|
||||
use App\Models\EdarateShahri;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
|
||||
class Cities implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
if ($this->province) {
|
||||
foreach (EdarateShahri::when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})->get() as $item) {
|
||||
$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]['city'][$item->id]['data']['MarematRooyeCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['PaksaziCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['AlaemCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['HefazCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['RoshanayiCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['KhatkeshiCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['RangamiziCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['WashingCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['ImenSaziCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['HarimCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['PolCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['ToonelCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['AmaliatZemestaniCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['MashinAlatCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['TollhouseCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['EmergencyCount']= 0;
|
||||
$array[$item->province_id]['city'][$item->id]['data']['Count']= 0;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "select
|
||||
COUNT(CASE WHEN item = 1 THEN 1 END) as MarematRooyeCount,
|
||||
COUNT(CASE WHEN item = 2 THEN 1 END) as PaksaziCount,
|
||||
COUNT(CASE WHEN item = 3 THEN 1 END) as AlaemCount,
|
||||
COUNT(CASE WHEN item = 4 THEN 1 END) as HefazCount,
|
||||
COUNT(CASE WHEN item = 5 THEN 1 END) as RoshanayiCount,
|
||||
COUNT(CASE WHEN item = 6 THEN 1 END) as KhatkeshiCount,
|
||||
COUNT(CASE WHEN item = 7 THEN 1 END) as RangamiziCount,
|
||||
COUNT(CASE WHEN item = 8 THEN 1 END) as WashingCount,
|
||||
COUNT(CASE WHEN item = 9 THEN 1 END) as ImenSaziCount,
|
||||
COUNT(CASE WHEN item = 10 THEN 1 END) as HarimCount,
|
||||
COUNT(CASE WHEN item = 11 THEN 1 END) as PolCount,
|
||||
COUNT(CASE WHEN item = 12 THEN 1 END) as ToonelCount,
|
||||
COUNT(CASE WHEN item = 13 THEN 1 END) as AmaliatZemestaniCount,
|
||||
COUNT(CASE WHEN item = 14 THEN 1 END) as MashinAlatCount,
|
||||
COUNT(CASE WHEN item = 15 THEN 1 END) as TollhouseCount,
|
||||
COUNT(CASE WHEN item = 16 THEN 1 END) as EmergencyCount,
|
||||
province_fa,
|
||||
province_id,
|
||||
edarat_name,
|
||||
edarat_id,
|
||||
COUNT(CASE WHEN item != -1 THEN 1 END) as count
|
||||
from (
|
||||
SELECT
|
||||
province_fa,
|
||||
province_id,
|
||||
edarat_name,
|
||||
edarat_id,
|
||||
item,
|
||||
status
|
||||
FROM road_items_projects
|
||||
where activity_date_time BETWEEN '{$fromDate}' and '{$toDate}'
|
||||
) AS merged_table
|
||||
where status=1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " and province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " group by edarat_id order by province_id ASC;";
|
||||
|
||||
$item_data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
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']['PaksaziCount']= $value->PaksaziCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['AlaemCount']= $value->AlaemCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['HefazCount']= $value->HefazCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['RoshanayiCount']= $value->RoshanayiCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['KhatkeshiCount']= $value->KhatkeshiCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['RangamiziCount']= $value->RangamiziCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['WashingCount']= $value->WashingCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['ImenSaziCount']= $value->ImenSaziCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['HarimCount']= $value->HarimCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['PolCount']= $value->PolCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['ToonelCount']= $value->ToonelCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['AmaliatZemestaniCount']= $value->AmaliatZemestaniCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['MashinAlatCount']= $value->MashinAlatCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['TollhouseCount']= $value->TollhouseCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['EmergencyCount']= $value->EmergencyCount;
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['data']['Count']= $value->count;
|
||||
|
||||
$array[$value->province_id]['city'][$value->edarat_id]['name']= $value->edarat_name;
|
||||
$array[$value->province_id]['province_name']= $value->province_fa;
|
||||
|
||||
if (!isset($array[$value->province_id]['all'])) {
|
||||
$array[$value->province_id]['all']['MarematRooyeCount'] = 0;
|
||||
$array[$value->province_id]['all']['PaksaziCount'] = 0;
|
||||
$array[$value->province_id]['all']['AlaemCount'] = 0;
|
||||
$array[$value->province_id]['all']['HefazCount'] = 0;
|
||||
$array[$value->province_id]['all']['RoshanayiCount'] = 0;
|
||||
$array[$value->province_id]['all']['KhatkeshiCount'] = 0;
|
||||
$array[$value->province_id]['all']['RangamiziCount'] = 0;
|
||||
$array[$value->province_id]['all']['WashingCount'] = 0;
|
||||
$array[$value->province_id]['all']['ImenSaziCount'] = 0;
|
||||
$array[$value->province_id]['all']['HarimCount'] = 0;
|
||||
$array[$value->province_id]['all']['PolCount'] = 0;
|
||||
$array[$value->province_id]['all']['ToonelCount'] = 0;
|
||||
$array[$value->province_id]['all']['AmaliatZemestaniCount'] = 0;
|
||||
$array[$value->province_id]['all']['MashinAlatCount'] = 0;
|
||||
$array[$value->province_id]['all']['TollhouseCount'] = 0;
|
||||
$array[$value->province_id]['all']['EmergencyCount'] = 0;
|
||||
$array[$value->province_id]['all']['Count'] = 0;
|
||||
}
|
||||
|
||||
$array[$value->province_id]['all']['MarematRooyeCount'] += $value->MarematRooyeCount;
|
||||
$array[$value->province_id]['all']['PaksaziCount'] += $value->PaksaziCount;
|
||||
$array[$value->province_id]['all']['AlaemCount'] += $value->AlaemCount;
|
||||
$array[$value->province_id]['all']['HefazCount'] += $value->HefazCount;
|
||||
$array[$value->province_id]['all']['RoshanayiCount'] += $value->RoshanayiCount;
|
||||
$array[$value->province_id]['all']['KhatkeshiCount'] += $value->KhatkeshiCount;
|
||||
$array[$value->province_id]['all']['RangamiziCount'] += $value->RangamiziCount;
|
||||
$array[$value->province_id]['all']['WashingCount'] += $value->WashingCount;
|
||||
$array[$value->province_id]['all']['ImenSaziCount'] += $value->ImenSaziCount;
|
||||
$array[$value->province_id]['all']['HarimCount'] += $value->HarimCount;
|
||||
$array[$value->province_id]['all']['PolCount'] += $value->PolCount;
|
||||
$array[$value->province_id]['all']['ToonelCount'] += $value->ToonelCount;
|
||||
$array[$value->province_id]['all']['AmaliatZemestaniCount'] += $value->AmaliatZemestaniCount;
|
||||
$array[$value->province_id]['all']['MashinAlatCount'] += $value->MashinAlatCount;
|
||||
$array[$value->province_id]['all']['TollhouseCount'] += $value->TollhouseCount;
|
||||
$array[$value->province_id]['all']['EmergencyCount'] += $value->EmergencyCount;
|
||||
$array[$value->province_id]['all']['Count'] += $value->count;
|
||||
}
|
||||
|
||||
return view('excel.CurrentActivities.Report1-City', [
|
||||
'roads' => $array,
|
||||
'fromFa' => $fromDate,
|
||||
'toFa' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('R1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
198
app/Exports/Activities/One/Provinces.php
Normal file
198
app/Exports/Activities/One/Provinces.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\One;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Provinces implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
foreach (\App\Models\Province::when($province, function ($query, $province) {
|
||||
return $query->where('id', $province);
|
||||
})->get() as $key => $value) {
|
||||
$array[$value->id] = [
|
||||
'province_id' => $value->id,
|
||||
'province_fa' => $value->name_fa,
|
||||
'MarematRooyeCount' => '0',
|
||||
'PaksaziCount' => '0',
|
||||
'AlaemCount' => '0',
|
||||
'HefazCount' => '0',
|
||||
'RoshanayiCount' => '0',
|
||||
'KhatkeshiCount' => '0',
|
||||
'RangamiziCount' => '0',
|
||||
'WashingCount' => '0',
|
||||
'ImenSaziCount' => '0',
|
||||
'HarimCount' => '0',
|
||||
'PolCount' => '0',
|
||||
'ToonelCount' => '0',
|
||||
'AmaliatZemestaniCount' => '0',
|
||||
'MashinAlatCount' => '0',
|
||||
'TollhouseCount' => '0',
|
||||
'EmergencyCount' => '0',
|
||||
'Count' => '0',
|
||||
];
|
||||
}
|
||||
|
||||
$query = "select
|
||||
COUNT(CASE WHEN item = 1 THEN 1 END) as MarematRooyeCount,
|
||||
COUNT(CASE WHEN item = 2 THEN 1 END) as PaksaziCount,
|
||||
COUNT(CASE WHEN item = 3 THEN 1 END) as AlaemCount,
|
||||
COUNT(CASE WHEN item = 4 THEN 1 END) as HefazCount,
|
||||
COUNT(CASE WHEN item = 5 THEN 1 END) as RoshanayiCount,
|
||||
COUNT(CASE WHEN item = 6 THEN 1 END) as KhatkeshiCount,
|
||||
COUNT(CASE WHEN item = 7 THEN 1 END) as RangamiziCount,
|
||||
COUNT(CASE WHEN item = 8 THEN 1 END) as WashingCount,
|
||||
COUNT(CASE WHEN item = 9 THEN 1 END) as ImenSaziCount,
|
||||
COUNT(CASE WHEN item = 10 THEN 1 END) as HarimCount,
|
||||
COUNT(CASE WHEN item = 11 THEN 1 END) as PolCount,
|
||||
COUNT(CASE WHEN item = 12 THEN 1 END) as ToonelCount,
|
||||
COUNT(CASE WHEN item = 13 THEN 1 END) as AmaliatZemestaniCount,
|
||||
COUNT(CASE WHEN item = 14 THEN 1 END) as MashinAlatCount,
|
||||
COUNT(CASE WHEN item = 15 THEN 1 END) as TollhouseCount,
|
||||
COUNT(CASE WHEN item = 16 THEN 1 END) as EmergencyCount,
|
||||
province_fa,
|
||||
province_id,
|
||||
COUNT(CASE WHEN item != -1 THEN 1 END) as count
|
||||
FROM(
|
||||
SELECT
|
||||
province_fa,
|
||||
province_id,
|
||||
city_fa,
|
||||
city_id,
|
||||
item,
|
||||
status
|
||||
FROM road_items_projects
|
||||
where activity_date_time BETWEEN '{$fromDate} 00:00:00' and '{$toDate} 23:59:59'
|
||||
) AS merged_table
|
||||
where status=1 ";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " and province_id = {$province}";
|
||||
}
|
||||
|
||||
$query .= " group by province_id;";
|
||||
|
||||
$item_data = DB::select(DB::raw($query));
|
||||
|
||||
$sum['MarematRooyeCount'] = 0;
|
||||
$sum['PaksaziCount'] = 0;
|
||||
$sum['AlaemCount'] = 0;
|
||||
$sum['HefazCount'] = 0;
|
||||
$sum['RoshanayiCount'] = 0;
|
||||
$sum['KhatkeshiCount'] = 0;
|
||||
$sum['RangamiziCount'] = 0;
|
||||
$sum['WashingCount'] = 0;
|
||||
$sum['ImenSaziCount'] = 0;
|
||||
$sum['HarimCount'] = 0;
|
||||
$sum['PolCount'] = 0;
|
||||
$sum['ToonelCount'] = 0;
|
||||
$sum['AmaliatZemestaniCount'] = 0;
|
||||
$sum['MashinAlatCount'] = 0;
|
||||
$sum['TollhouseCount'] = 0;
|
||||
$sum['EmergencyCount'] = 0;
|
||||
$sum['Count'] = 0;
|
||||
|
||||
foreach ($item_data as $key => $value) {
|
||||
$array[$value->province_id]['MarematRooyeCount'] = $value->MarematRooyeCount;
|
||||
$array[$value->province_id]['PaksaziCount'] = $value->PaksaziCount;
|
||||
$array[$value->province_id]['AlaemCount'] = $value->AlaemCount;
|
||||
$array[$value->province_id]['HefazCount'] = $value->HefazCount;
|
||||
$array[$value->province_id]['RoshanayiCount'] = $value->RoshanayiCount;
|
||||
$array[$value->province_id]['KhatkeshiCount'] = $value->KhatkeshiCount;
|
||||
$array[$value->province_id]['RangamiziCount'] = $value->RangamiziCount;
|
||||
$array[$value->province_id]['WashingCount'] = $value->WashingCount;
|
||||
$array[$value->province_id]['ImenSaziCount'] = $value->ImenSaziCount;
|
||||
$array[$value->province_id]['HarimCount'] = $value->HarimCount;
|
||||
$array[$value->province_id]['PolCount'] = $value->PolCount;
|
||||
$array[$value->province_id]['ToonelCount'] = $value->ToonelCount;
|
||||
$array[$value->province_id]['AmaliatZemestaniCount'] = $value->AmaliatZemestaniCount;
|
||||
$array[$value->province_id]['MashinAlatCount'] = $value->MashinAlatCount;
|
||||
$array[$value->province_id]['TollhouseCount'] = $value->TollhouseCount;
|
||||
$array[$value->province_id]['EmergencyCount'] = $value->EmergencyCount;
|
||||
$array[$value->province_id]['Count'] = $value->count;
|
||||
|
||||
$sum['MarematRooyeCount'] += $value->MarematRooyeCount;
|
||||
$sum['PaksaziCount'] += $value->PaksaziCount;
|
||||
$sum['AlaemCount'] += $value->AlaemCount;
|
||||
$sum['HefazCount'] += $value->HefazCount;
|
||||
$sum['RoshanayiCount'] += $value->RoshanayiCount;
|
||||
$sum['KhatkeshiCount'] += $value->KhatkeshiCount;
|
||||
$sum['RangamiziCount'] += $value->RangamiziCount;
|
||||
$sum['WashingCount'] += $value->WashingCount;
|
||||
$sum['ImenSaziCount'] += $value->ImenSaziCount;
|
||||
$sum['HarimCount'] += $value->HarimCount;
|
||||
$sum['PolCount'] += $value->PolCount;
|
||||
$sum['ToonelCount'] += $value->ToonelCount;
|
||||
$sum['AmaliatZemestaniCount'] += $value->AmaliatZemestaniCount;
|
||||
$sum['MashinAlatCount'] += $value->MashinAlatCount;
|
||||
$sum['TollhouseCount'] += $value->TollhouseCount;
|
||||
$sum['EmergencyCount'] += $value->EmergencyCount;
|
||||
$sum['Count'] += $value->count ;
|
||||
}
|
||||
|
||||
return view('excel.CurrentActivities.Report1-Province', [
|
||||
'array' => $array,
|
||||
'sum' => $sum,
|
||||
'fromFa' => $fromDate,
|
||||
'sumShow' => $this->province ? 0 :1,
|
||||
'toFa' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('q1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
96
app/Exports/Activities/Three/Activity.php
Normal file
96
app/Exports/Activities/Three/Activity.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Three;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Activity implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? \Carbon\Carbon::now()->subMonth();
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
$road_item_projects = DB::table('road_items_projects')
|
||||
->whereBetween('created_at', [$fromDate, $toDate])
|
||||
->when($this->province , function ($query) use ($province) {
|
||||
return $query->where('province_id',$province);
|
||||
})
|
||||
->orderBy('province_id', 'ASC')
|
||||
->get();
|
||||
|
||||
return view('excel.CurrentActivities.Report3-Activity', [
|
||||
'road_item_projects' => $road_item_projects,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('J1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:Z' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Alaem/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Alaem/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Alaem;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Alaem\Province;
|
||||
use App\Exports\Activities\Two\Alaem\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
103
app/Exports/Activities/Two/Alaem/City.php
Normal file
103
app/Exports/Activities/Two/Alaem/City.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Alaem;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as TabloEkhtariCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as TabloEkhtariSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TabloEtelatiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TabloEtelatiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as ShabrangCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as ShabrangSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BaztabCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BaztabSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as TavizTabloCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as TavizTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MarematSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as EslahKajShodegiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as EslahKajShodegiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as NasbAlaemMovaghatCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as NasbAlaemMovaghatSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as ShibShirvaniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as ShibShirvaniSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 3 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Alaem.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('R1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
136
app/Exports/Activities/Two/Alaem/Province.php
Normal file
136
app/Exports/Activities/Two/Alaem/Province.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Alaem;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as TabloEkhtariCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as TabloEkhtariSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TabloEtelatiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TabloEtelatiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as ShabrangCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as ShabrangSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BaztabCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BaztabSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as TavizTabloCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as TavizTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MarematSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as EslahKajShodegiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as EslahKajShodegiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as NasbAlaemMovaghatCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as NasbAlaemMovaghatSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as ShibShirvaniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as ShibShirvaniSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 3 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as TabloEkhtariCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as TabloEkhtariSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TabloEtelatiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TabloEtelatiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as ShabrangCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as ShabrangSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BaztabCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BaztabSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as TavizTabloCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as TavizTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MarematSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as EslahKajShodegiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as EslahKajShodegiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as NasbAlaemMovaghatCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as NasbAlaemMovaghatSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as ShibShirvaniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as ShibShirvaniSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 3 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Alaem.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('Q1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
26
app/Exports/Activities/Two/AllSheets.php
Normal file
26
app/Exports/Activities/Two/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Province;
|
||||
use App\Exports\Activities\Two\Cities;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new Cities($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Bazrasi/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Bazrasi/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Bazrasi;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Bazrasi\Province;
|
||||
use App\Exports\Activities\Two\Bazrasi\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
99
app/Exports/Activities/Two/Bazrasi/City.php
Normal file
99
app/Exports/Activities/Two/Bazrasi/City.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Bazrasi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as AbniyeFaniCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as AbniyeFaniSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as AlaemCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as AlaemSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TaransheCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TaransheSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as RoyeAphaltCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as RoyeAphaltSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as HarimRahCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as HarimRahSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MashinAlatCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MashinAlatSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 20 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Bazrasi.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('T1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
122
app/Exports/Activities/Two/Bazrasi/Province.php
Normal file
122
app/Exports/Activities/Two/Bazrasi/Province.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Bazrasi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as AbniyeFaniCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as AbniyeFaniSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as AlaemCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as AlaemSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TaransheCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TaransheSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as RoyeAphaltCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as RoyeAphaltSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as HarimRahCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as HarimRahSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MashinAlatCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MashinAlatSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 20 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as AbniyeFaniCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as AbniyeFaniSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as AlaemCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as AlaemSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TaransheCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TaransheSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as RoyeAphaltCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as RoyeAphaltSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as HarimRahCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as HarimRahSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MashinAlatCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MashinAlatSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 20 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Bazrasi.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('S1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
229
app/Exports/Activities/Two/Cities.php
Normal file
229
app/Exports/Activities/Two/Cities.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Cities implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as LabeAsphaltCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as LabeAsphaltSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as ShaneSaziCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as ShaneSaziSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as GodOftadegiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as GodOftadegiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as LakegiriCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as LakegiriSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as MarematSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as BastarHarimCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as BastarHarimSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as DarzgiriCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as DarzgiriSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as MozresCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as MozresSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as TarashRooyeCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as TarashRooyeSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as TighzaniCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as TighzaniSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as ShenriziCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as ShenriziSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as KhakbardariCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as KhakbardariSum,
|
||||
province_id, province_fa, city_id, user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item=1 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$temp =[];
|
||||
foreach ($data as $key => $value) {
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['LabeAsphaltCount']= $value->LabeAsphaltCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['LabeAsphaltSum']= $value->LabeAsphaltSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['ShaneSaziCount']= $value->ShaneSaziCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['ShaneSaziSum']= $value->ShaneSaziSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['GodOftadegiCount']= $value->GodOftadegiCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['GodOftadegiSum']= $value->GodOftadegiSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['LakegiriCount']= $value->LakegiriCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['LakegiriSum']= $value->LakegiriSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['MarematCount']= $value->MarematCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['MarematSum']= $value->MarematSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['BastarHarimCount']= $value->BastarHarimCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['BastarHarimSum']= $value->BastarHarimSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['DarzgiriCount']= $value->DarzgiriCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['DarzgiriSum']= $value->DarzgiriSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['MozresCount']= $value->MozresCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['MozresSum']= $value->MozresSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['TarashRooyeCount']= $value->TarashRooyeCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['TarashRooyeSum']= $value->TarashRooyeSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['TighzaniCount']= $value->TighzaniCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['TighzaniSum']= $value->TighzaniSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['ShenriziCount']= $value->ShenriziCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['ShenriziSum']= $value->ShenriziSum;
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['KhakbardariCount']= $value->KhakbardariCount;
|
||||
$temp[$value->province_id]['city'][$value->city_id]['data']['KhakbardariSum']= $value->KhakbardariSum;
|
||||
|
||||
|
||||
$temp[$value->province_id]['city'][$value->city_id]['name']= $value->city_fa;
|
||||
|
||||
if (!isset($temp[$value->province_id]['all'])) {
|
||||
$temp[$value->province_id]['all']['LabeAsphaltCount'] = 0;
|
||||
$temp[$value->province_id]['all']['LabeAsphaltSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['ShaneSaziCount'] = 0;
|
||||
$temp[$value->province_id]['all']['ShaneSaziSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['GodOftadegiCount'] = 0;
|
||||
$temp[$value->province_id]['all']['GodOftadegiSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['LakegiriCount'] = 0;
|
||||
$temp[$value->province_id]['all']['LakegiriSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['MarematCount'] = 0;
|
||||
$temp[$value->province_id]['all']['MarematSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['BastarHarimCount'] = 0;
|
||||
$temp[$value->province_id]['all']['BastarHarimSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['DarzgiriCount'] = 0;
|
||||
$temp[$value->province_id]['all']['DarzgiriSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['MozresCount'] = 0;
|
||||
$temp[$value->province_id]['all']['MozresSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['TarashRooyeCount'] = 0;
|
||||
$temp[$value->province_id]['all']['TarashRooyeSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['TighzaniCount'] = 0;
|
||||
$temp[$value->province_id]['all']['TighzaniSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['ShenriziCount'] = 0;
|
||||
$temp[$value->province_id]['all']['ShenriziSum'] = 0;
|
||||
|
||||
$temp[$value->province_id]['all']['KhakbardariCount'] = 0;
|
||||
$temp[$value->province_id]['all']['KhakbardariSum'] = 0;
|
||||
}
|
||||
$temp[$value->province_id]['all']['LabeAsphaltCount'] += $value->LabeAsphaltCount;
|
||||
$temp[$value->province_id]['all']['LabeAsphaltSum'] += $value->LabeAsphaltSum;
|
||||
|
||||
$temp[$value->province_id]['all']['ShaneSaziCount'] += $value->ShaneSaziCount;
|
||||
$temp[$value->province_id]['all']['ShaneSaziSum'] += $value->ShaneSaziSum;
|
||||
|
||||
$temp[$value->province_id]['all']['GodOftadegiCount'] += $value->GodOftadegiCount;
|
||||
$temp[$value->province_id]['all']['GodOftadegiSum'] += $value->GodOftadegiSum;
|
||||
|
||||
$temp[$value->province_id]['all']['LakegiriCount'] += $value->LakegiriCount;
|
||||
$temp[$value->province_id]['all']['LakegiriSum'] += $value->LakegiriSum;
|
||||
|
||||
$temp[$value->province_id]['all']['MarematCount'] += $value->MarematCount;
|
||||
$temp[$value->province_id]['all']['MarematSum'] += $value->MarematSum;
|
||||
|
||||
$temp[$value->province_id]['all']['BastarHarimCount'] += $value->BastarHarimCount;
|
||||
$temp[$value->province_id]['all']['BastarHarimSum'] += $value->BastarHarimSum;
|
||||
|
||||
$temp[$value->province_id]['all']['DarzgiriCount'] += $value->DarzgiriCount;
|
||||
$temp[$value->province_id]['all']['DarzgiriSum'] += $value->DarzgiriSum;
|
||||
|
||||
$temp[$value->province_id]['all']['MozresCount'] += $value->MozresCount;
|
||||
$temp[$value->province_id]['all']['MozresSum'] += $value->MozresSum;
|
||||
|
||||
$temp[$value->province_id]['all']['TarashRooyeCount'] += $value->TarashRooyeCount;
|
||||
$temp[$value->province_id]['all']['TarashRooyeSum'] += $value->TarashRooyeSum;
|
||||
|
||||
$temp[$value->province_id]['all']['TighzaniCount'] += $value->TighzaniCount;
|
||||
$temp[$value->province_id]['all']['TighzaniSum'] += $value->TighzaniSum;
|
||||
|
||||
$temp[$value->province_id]['all']['ShenriziCount'] += $value->ShenriziCount;
|
||||
$temp[$value->province_id]['all']['ShenriziSum'] += $value->ShenriziSum;
|
||||
|
||||
$temp[$value->province_id]['all']['KhakbardariCount'] += $value->KhakbardariCount;
|
||||
$temp[$value->province_id]['all']['KhakbardariSum'] += $value->KhakbardariSum;
|
||||
|
||||
$temp[$value->province_id]['province_name']= $value->province_fa;
|
||||
}
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Report2-City', [
|
||||
'roads' => $temp,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('Z1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Ezterari/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Ezterari/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Ezterari;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Ezterari\Province;
|
||||
use App\Exports\Activities\Two\Ezterari\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
105
app/Exports/Activities/Two/Ezterari/City.php
Normal file
105
app/Exports/Activities/Two/Ezterari/City.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Ezterari;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as PaksaziCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as PaksaziSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TaradodCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TaradodSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as BargharariErtebatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as BargharariErtebatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as AbBordegiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as AbBordegiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as ShekastegiPolCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as ShekastegiPolSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as HedayatTrafficiCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as HedayatTrafficiSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as BozgoshaeiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as BozgoshaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as JabejayiCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as JabejayiSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as LaghgiriCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as LaghgiriSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 16 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Ezterari.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('T1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
134
app/Exports/Activities/Two/Ezterari/Province.php
Normal file
134
app/Exports/Activities/Two/Ezterari/Province.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Ezterari;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as PaksaziCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as PaksaziSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TaradodCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TaradodSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as BargharariErtebatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as BargharariErtebatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as AbBordegiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as AbBordegiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as ShekastegiPolCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as ShekastegiPolSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as HedayatTrafficiCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as HedayatTrafficiSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as BozgoshaeiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as BozgoshaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as JabejayiCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as JabejayiSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as LaghgiriCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as LaghgiriSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 16 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as PaksaziCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as PaksaziSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TaradodCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TaradodSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as BargharariErtebatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as BargharariErtebatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as AbBordegiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as AbBordegiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as ShekastegiPolCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as ShekastegiPolSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as HedayatTrafficiCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as HedayatTrafficiSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as BozgoshaeiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as BozgoshaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as JabejayiCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as JabejayiSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as LaghgiriCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as LaghgiriSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 16 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Ezterari.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('S1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Harim/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Harim/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Harim;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Harim\Province;
|
||||
use App\Exports\Activities\Two\Harim\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
98
app/Exports/Activities/Two/Harim/City.php
Normal file
98
app/Exports/Activities/Two/Harim/City.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Harim;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as SakhtoSazCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as SakhtoSazSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as RahDastresiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as RahDastresiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TasisatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TasisatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BarkhordBaDastfrooshCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BarkhordBaDastfrooshSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as JamavariTablooCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as JamavariTablooSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as JamavariBannerCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as JamavariBannerSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 10 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Harim.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('N1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
123
app/Exports/Activities/Two/Harim/Province.php
Normal file
123
app/Exports/Activities/Two/Harim/Province.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Harim;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as SakhtoSazCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as SakhtoSazSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as RahDastresiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as RahDastresiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TasisatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TasisatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BarkhordBaDastfrooshCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BarkhordBaDastfrooshSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as JamavariTablooCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as JamavariTablooSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as JamavariBannerCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as JamavariBannerSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 10 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as SakhtoSazCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as SakhtoSazSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as RahDastresiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as RahDastresiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TasisatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TasisatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BarkhordBaDastfrooshCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BarkhordBaDastfrooshSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as JamavariTablooCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as JamavariTablooSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as JamavariBannerCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as JamavariBannerSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 10 ans status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Harim.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('M1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Hefaz/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Hefaz/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Hefaz;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Hefaz\Province;
|
||||
use App\Exports\Activities\Two\Hefaz\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
92
app/Exports/Activities/Two/Hefaz/City.php
Normal file
92
app/Exports/Activities/Two/Hefaz/City.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Hefaz;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as MianiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as MianiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as PolCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as PolSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as BehsaziCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as BehsaziSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 4 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Hefaz.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('H1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
112
app/Exports/Activities/Two/Hefaz/Province.php
Normal file
112
app/Exports/Activities/Two/Hefaz/Province.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Hefaz;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as MianiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as MianiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as PolCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as PolSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as BehsaziCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as BehsaziSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 4 ans status = 1 ";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as MianiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as MianiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as PolCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as PolSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as BehsaziCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as BehsaziSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 4 and status = 1 ";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Hefaz.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('G1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Imensazi/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Imensazi/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Imensazi;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Imensazi\Province;
|
||||
use App\Exports\Activities\Two\Imensazi\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
110
app/Exports/Activities/Two/Imensazi/City.php
Normal file
110
app/Exports/Activities/Two/Imensazi/City.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Imensazi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ImensaziSarguardCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ImensaziSarguardSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as TamiratCheraqCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as TamiratCheraqSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as IjadShiarCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as IjadShiarSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as IjadLarzanandeCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as IjadLarzanandeSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as ZarbegirCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as ZarbegirSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as OstevaneImeniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as OstevaneImeniSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as NasbSoratgirCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as NasbSoratgirSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as EhdasSoratgirCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as EhdasSoratgirSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as EjrayeNoghteyiCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as EjrayeNoghteyiSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as EjrayeTooliCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as EjrayeTooliSum,
|
||||
COUNT(CASE WHEN sub_item = 14 THEN 1 END) as TarizMaghtaeiCount,
|
||||
SUM(CASE WHEN sub_item = 14 THEN sub_item_data END) as TarizMaghtaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 15 THEN 1 END) as HazfMavaneCount,
|
||||
SUM(CASE WHEN sub_item = 15 THEN sub_item_data END) as HazfMavaneSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 9 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Imensazi.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('Z1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
146
app/Exports/Activities/Two/Imensazi/Province.php
Normal file
146
app/Exports/Activities/Two/Imensazi/Province.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Imensazi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ImensaziSarguardCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ImensaziSarguardSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as TamiratCheraqCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as TamiratCheraqSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as IjadShiarCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as IjadShiarSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as IjadLarzanandeCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as IjadLarzanandeSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as ZarbegirCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as ZarbegirSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as OstevaneImeniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as OstevaneImeniSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as NasbSoratgirCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as NasbSoratgirSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as EhdasSoratgirCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as EhdasSoratgirSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as EjrayeNoghteyiCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as EjrayeNoghteyiSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as EjrayeTooliCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as EjrayeTooliSum,
|
||||
COUNT(CASE WHEN sub_item = 14 THEN 1 END) as TarizMaghtaeiCount,
|
||||
SUM(CASE WHEN sub_item = 14 THEN sub_item_data END) as TarizMaghtaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 15 THEN 1 END) as HazfMavaneCount,
|
||||
SUM(CASE WHEN sub_item = 15 THEN sub_item_data END) as HazfMavaneSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 9 and status = 1 ";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ImensaziSarguardCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ImensaziSarguardSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as TamiratCheraqCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as TamiratCheraqSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as IjadShiarCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as IjadShiarSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as IjadLarzanandeCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as IjadLarzanandeSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as ZarbegirCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as ZarbegirSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as OstevaneImeniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as OstevaneImeniSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as NasbSoratgirCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as NasbSoratgirSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as EhdasSoratgirCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as EhdasSoratgirSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as EjrayeNoghteyiCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as EjrayeNoghteyiSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as EjrayeTooliCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as EjrayeTooliSum,
|
||||
COUNT(CASE WHEN sub_item = 14 THEN 1 END) as TarizMaghtaeiCount,
|
||||
SUM(CASE WHEN sub_item = 14 THEN sub_item_data END) as TarizMaghtaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 15 THEN 1 END) as HazfMavaneCount,
|
||||
SUM(CASE WHEN sub_item = 15 THEN sub_item_data END) as HazfMavaneSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 9 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Imensazi.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('Y1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
26
app/Exports/Activities/Two/Khatkeshi/AllSheets.php
Normal file
26
app/Exports/Activities/Two/Khatkeshi/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Khatkeshi;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Khatkeshi\Province;
|
||||
use App\Exports\Activities\Two\Khatkeshi\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
}
|
||||
97
app/Exports/Activities/Two/Khatkeshi/City.php
Normal file
97
app/Exports/Activities/Two/Khatkeshi/City.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Khatkeshi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as KhatkeshiRangGarmCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as KhatkeshiRangGarmSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as KhatkeshiRangSardCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as KhatkeshiRangSardSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TarsimKhatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TarsimKhatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as EjrayeTooliCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as EjrayeTooliSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as EjrayeArziCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as EjrayeArziSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as PakKardanKhotootCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as PakKardanKhotootSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 6 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Khatkeshi.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('N1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
122
app/Exports/Activities/Two/Khatkeshi/Province.php
Normal file
122
app/Exports/Activities/Two/Khatkeshi/Province.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Khatkeshi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as KhatkeshiRangGarmCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as KhatkeshiRangGarmSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as KhatkeshiRangSardCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as KhatkeshiRangSardSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TarsimKhatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TarsimKhatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as EjrayeTooliCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as EjrayeTooliSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as EjrayeArziCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as EjrayeArziSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as PakKardanKhotootCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as PakKardanKhotootSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 6 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as KhatkeshiRangGarmCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as KhatkeshiRangGarmSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as KhatkeshiRangSardCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as KhatkeshiRangSardSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TarsimKhatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TarsimKhatSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as EjrayeTooliCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as EjrayeTooliSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as EjrayeArziCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as EjrayeArziSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as PakKardanKhotootCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as PakKardanKhotootSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 6 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Khatkeshi.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('M1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Mashinalat/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Mashinalat/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Mashinalat;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Mashinalat\Province;
|
||||
use App\Exports\Activities\Two\Mashinalat\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
107
app/Exports/Activities/Two/Mashinalat/City.php
Normal file
107
app/Exports/Activities/Two/Mashinalat/City.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Mashinalat;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as BenzinMasrafiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as BenzinMasrafiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as GazMasrafiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as GazMasrafiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as MavadNaftiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as MavadNaftiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) BazsaziCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) BazsaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as ServiceCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as ServiceSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as NamakPashCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as NamakPashSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as JabejayiCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as JabejayiSum,
|
||||
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 14 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Mashinalat.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('P1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
134
app/Exports/Activities/Two/Mashinalat/Province.php
Normal file
134
app/Exports/Activities/Two/Mashinalat/Province.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Mashinalat;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as BenzinMasrafiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as BenzinMasrafiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as GazMasrafiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as GazMasrafiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as MavadNaftiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as MavadNaftiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) BazsaziCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) BazsaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as ServiceCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as ServiceSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as NamakPashCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as NamakPashSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as JabejayiCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as JabejayiSum,
|
||||
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 14 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as BenzinMasrafiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as BenzinMasrafiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as GazMasrafiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as GazMasrafiSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as MavadNaftiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as MavadNaftiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) BazsaziCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) BazsaziSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as ServiceCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as ServiceSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as NamakPashCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as NamakPashSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as JabejayiCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as JabejayiSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 14 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Mashinalat.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('O1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Paksazi/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Paksazi/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Paksazi;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Paksazi\Province;
|
||||
use App\Exports\Activities\Two\Paksazi\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
125
app/Exports/Activities/Two/Paksazi/City.php
Normal file
125
app/Exports/Activities/Two/Paksazi/City.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Paksazi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as PaksaziSathRahCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as PaksaziSathRahSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TanfieAbroCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TanfieAbroSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as PaksaziLasheCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as PaksaziLasheSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as PaksaziGhonoCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as PaksaziGhonoSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as PaksaziTasadofatCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as PaksaziTasadofatSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as AlafKaniCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as AlafKaniSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as PaksaziHarimCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as PaksaziHarimSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as JamavariGhateatCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as JamavariGhateatSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as PaksaziParkingCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as PaksaziParkingSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as PaksaziKenarGharnizPolCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as PaksaziKenarGharnizPolSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as PaksaziJazireCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as PaksaziJazireSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as PaksaziTanfieDakhelPolCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as PaksaziTanfieDakhelPolSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as PaksaziSifonCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as PaksaziSifonSum,
|
||||
COUNT(CASE WHEN sub_item = 14 THEN 1 END) as PaksaziShakheDerakhtanCount,
|
||||
SUM(CASE WHEN sub_item = 14 THEN sub_item_data END) as PaksaziShakheDerakhtanSum,
|
||||
COUNT(CASE WHEN sub_item = 15 THEN 1 END) as PaksaziMavadNaftiCount,
|
||||
SUM(CASE WHEN sub_item = 15 THEN sub_item_data END) as PaksaziMavadNaftiSum,
|
||||
COUNT(CASE WHEN sub_item = 16 THEN 1 END) as AlafKaniDastiCount,
|
||||
SUM(CASE WHEN sub_item = 16 THEN sub_item_data END) as AlafKaniDastiSum,
|
||||
COUNT(CASE WHEN sub_item = 17 THEN 1 END) as RizeshBardariCount,
|
||||
SUM(CASE WHEN sub_item = 17 THEN sub_item_data END) as RizeshBardariSum,
|
||||
COUNT(CASE WHEN sub_item = 18 THEN 1 END) as JamavariSangCount,
|
||||
SUM(CASE WHEN sub_item = 18 THEN sub_item_data END) as JamavariSangSum,
|
||||
COUNT(CASE WHEN sub_item = 19 THEN 1 END) as LayeroobiCount,
|
||||
SUM(CASE WHEN sub_item = 19 THEN sub_item_data END) as LayeroobiSum,
|
||||
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 2 and status = 1";
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Paksazi.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('AN1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
|
||||
174
app/Exports/Activities/Two/Paksazi/Province.php
Normal file
174
app/Exports/Activities/Two/Paksazi/Province.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Paksazi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as PaksaziSathRahCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as PaksaziSathRahSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TanfieAbroCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TanfieAbroSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as PaksaziLasheCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as PaksaziLasheSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as PaksaziGhonoCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as PaksaziGhonoSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as PaksaziTasadofatCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as PaksaziTasadofatSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as AlafKaniCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as AlafKaniSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as PaksaziHarimCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as PaksaziHarimSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as JamavariGhateatCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as JamavariGhateatSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as PaksaziParkingCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as PaksaziParkingSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as PaksaziKenarGharnizPolCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as PaksaziKenarGharnizPolSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as PaksaziJazireCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as PaksaziJazireSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as PaksaziTanfieDakhelPolCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as PaksaziTanfieDakhelPolSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as PaksaziSifonCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as PaksaziSifonSum,
|
||||
COUNT(CASE WHEN sub_item = 14 THEN 1 END) as PaksaziShakheDerakhtanCount,
|
||||
SUM(CASE WHEN sub_item = 14 THEN sub_item_data END) as PaksaziShakheDerakhtanSum,
|
||||
COUNT(CASE WHEN sub_item = 15 THEN 1 END) as PaksaziMavadNaftiCount,
|
||||
SUM(CASE WHEN sub_item = 15 THEN sub_item_data END) as PaksaziMavadNaftiSum,
|
||||
COUNT(CASE WHEN sub_item = 16 THEN 1 END) as AlafKaniDastiCount,
|
||||
SUM(CASE WHEN sub_item = 16 THEN sub_item_data END) as AlafKaniDastiSum,
|
||||
COUNT(CASE WHEN sub_item = 17 THEN 1 END) as RizeshBardariCount,
|
||||
SUM(CASE WHEN sub_item = 17 THEN sub_item_data END) as RizeshBardariSum,
|
||||
COUNT(CASE WHEN sub_item = 18 THEN 1 END) as JamavariSangCount,
|
||||
SUM(CASE WHEN sub_item = 18 THEN sub_item_data END) as JamavariSangSum,
|
||||
COUNT(CASE WHEN sub_item = 19 THEN 1 END) as LayeroobiCount,
|
||||
SUM(CASE WHEN sub_item = 19 THEN sub_item_data END) as LayeroobiSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 3 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as PaksaziSathRahCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as PaksaziSathRahSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as TanfieAbroCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as TanfieAbroSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as PaksaziLasheCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as PaksaziLasheSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as PaksaziGhonoCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as PaksaziGhonoSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as PaksaziTasadofatCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as PaksaziTasadofatSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as AlafKaniCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as AlafKaniSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as PaksaziHarimCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as PaksaziHarimSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as JamavariGhateatCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as JamavariGhateatSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as PaksaziParkingCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as PaksaziParkingSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as PaksaziKenarGharnizPolCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as PaksaziKenarGharnizPolSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as PaksaziJazireCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as PaksaziJazireSum,
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as PaksaziTanfieDakhelPolCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as PaksaziTanfieDakhelPolSum,
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as PaksaziSifonCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as PaksaziSifonSum,
|
||||
COUNT(CASE WHEN sub_item = 14 THEN 1 END) as PaksaziShakheDerakhtanCount,
|
||||
SUM(CASE WHEN sub_item = 14 THEN sub_item_data END) as PaksaziShakheDerakhtanSum,
|
||||
COUNT(CASE WHEN sub_item = 15 THEN 1 END) as PaksaziMavadNaftiCount,
|
||||
SUM(CASE WHEN sub_item = 15 THEN sub_item_data END) as PaksaziMavadNaftiSum,
|
||||
COUNT(CASE WHEN sub_item = 16 THEN 1 END) as AlafKaniDastiCount,
|
||||
SUM(CASE WHEN sub_item = 16 THEN sub_item_data END) as AlafKaniDastiSum,
|
||||
COUNT(CASE WHEN sub_item = 17 THEN 1 END) as RizeshBardariCount,
|
||||
SUM(CASE WHEN sub_item = 17 THEN sub_item_data END) as RizeshBardariSum,
|
||||
COUNT(CASE WHEN sub_item = 18 THEN 1 END) as JamavariSangCount,
|
||||
SUM(CASE WHEN sub_item = 18 THEN sub_item_data END) as JamavariSangSum,
|
||||
COUNT(CASE WHEN sub_item = 19 THEN 1 END) as LayeroobiCount,
|
||||
SUM(CASE WHEN sub_item = 19 THEN sub_item_data END) as LayeroobiSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 3 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Paksazi.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('AM1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Pol/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Pol/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Pol;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Pol\Province;
|
||||
use App\Exports\Activities\Two\Pol\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
106
app/Exports/Activities/Two/Pol/City.php
Normal file
106
app/Exports/Activities/Two/Pol/City.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Pol;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as EhdasGharnizPolCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as EhdasGharnizPolSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as LoleCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as LoleSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TatvilCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TatvilSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BazsaziCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BazsaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as TamiratAbroCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as TamiratAbroSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as RadieCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as RadieSum,
|
||||
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 11 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Pol.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('P1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
139
app/Exports/Activities/Two/Pol/Province.php
Normal file
139
app/Exports/Activities/Two/Pol/Province.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Pol;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as EhdasGharnizPolCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as EhdasGharnizPolSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as LoleCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as LoleSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TatvilCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TatvilSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BazsaziCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BazsaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as TamiratAbroCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as TamiratAbroSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as RadieCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as RadieSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 11 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as EhdasGharnizPolCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as EhdasGharnizPolSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as LoleCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as LoleSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as TatvilCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as TatvilSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as BazsaziCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as BazsaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as TamiratAbroCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as TamiratAbroSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as RadieCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as RadieSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 11 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Pol.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('O1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
170
app/Exports/Activities/Two/Province.php
Normal file
170
app/Exports/Activities/Two/Province.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as LabeAsphaltCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as LabeAsphaltSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as ShaneSaziCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as ShaneSaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as GodOftadegiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as GodOftadegiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as LakegiriCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as LakegiriSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as BastarHarimCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as BastarHarimSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as DarzgiriCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as DarzgiriSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as MozresCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as MozresSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as TarashRooyeCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as TarashRooyeSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as TighzaniCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as TighzaniSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as ShenriziCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as ShenriziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as KhakbardariCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as KhakbardariSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 1 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as LabeAsphaltCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as LabeAsphaltSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as ShaneSaziCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as ShaneSaziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as GodOftadegiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as GodOftadegiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as LakegiriCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as LakegiriSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as BastarHarimCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as BastarHarimSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as DarzgiriCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as DarzgiriSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as MozresCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as MozresSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as TarashRooyeCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as TarashRooyeSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as TighzaniCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as TighzaniSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 12 THEN 1 END) as ShenriziCount,
|
||||
SUM(CASE WHEN sub_item = 12 THEN sub_item_data END) as ShenriziSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 13 THEN 1 END) as KhakbardariCount,
|
||||
SUM(CASE WHEN sub_item = 13 THEN sub_item_data END) as KhakbardariSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 1 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Report2-Province', [
|
||||
'roads' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('Y1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Rahdar/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Rahdar/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Rahdar;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Rahdar\Province;
|
||||
use App\Exports\Activities\Two\Rahdar\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
92
app/Exports/Activities/Two/Rahdar/City.php
Normal file
92
app/Exports/Activities/Two/Rahdar/City.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Rahdar;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as TamiratCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as TamiratSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as JalasatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as JalasatSum,
|
||||
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 15 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Rahdar.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('F1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
106
app/Exports/Activities/Two/Rahdar/Province.php
Normal file
106
app/Exports/Activities/Two/Rahdar/Province.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Rahdar;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as TamiratCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as TamiratSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as JalasatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as JalasatSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 15 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as TamiratCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as TamiratSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as JalasatCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as JalasatSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 15 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Rahdar.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('E1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
26
app/Exports/Activities/Two/Rangamizi/AllSheets.php
Normal file
26
app/Exports/Activities/Two/Rangamizi/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Rangamizi;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Rangamizi\Province;
|
||||
use App\Exports\Activities\Two\Rangamizi\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
}
|
||||
105
app/Exports/Activities/Two/Rangamizi/City.php
Normal file
105
app/Exports/Activities/Two/Rangamizi/City.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Rangamizi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as RangamiziTabloCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as RangamiziTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as RangamiziCheraqCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as RangamiziCheraqSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as RangimiziPayeRoshanayiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as RangimiziPayeRoshanayiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as RangamiziPolCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as RangamiziPolSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as RangamiziDarvaziCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as RangamiziDarvaziSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as RangamiziHefazFeleziCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as RangamiziHefazFeleziSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as RangamiziNewjersiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as RangamiziNewjersiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as RangamiziSoratgahCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as RangamiziSoratgahSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as RangamiziPayeCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as RangamiziPayeSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 7 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Rangamizi.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('T1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
134
app/Exports/Activities/Two/Rangamizi/Province.php
Normal file
134
app/Exports/Activities/Two/Rangamizi/Province.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Rangamizi;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as RangamiziTabloCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as RangamiziTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as RangamiziCheraqCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as RangamiziCheraqSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as RangimiziPayeRoshanayiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as RangimiziPayeRoshanayiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as RangamiziPolCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as RangamiziPolSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as RangamiziDarvaziCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as RangamiziDarvaziSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as RangamiziHefazFeleziCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as RangamiziHefazFeleziSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as RangamiziNewjersiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as RangamiziNewjersiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as RangamiziSoratgahCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as RangamiziSoratgahSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as RangamiziPayeCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as RangamiziPayeSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 7 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as RangamiziTabloCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as RangamiziTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as RangamiziCheraqCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as RangamiziCheraqSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as RangimiziPayeRoshanayiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as RangimiziPayeRoshanayiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as RangamiziPolCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as RangamiziPolSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as RangamiziDarvaziCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as RangamiziDarvaziSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as RangamiziHefazFeleziCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as RangamiziHefazFeleziSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as RangamiziNewjersiCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as RangamiziNewjersiSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as RangamiziSoratgahCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as RangamiziSoratgahSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as RangamiziPayeCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as RangamiziPayeSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 7 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Rangamizi.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('S1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
26
app/Exports/Activities/Two/Roshanaei/AllSheets.php
Normal file
26
app/Exports/Activities/Two/Roshanaei/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Roshanaei;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Roshanaei\Province;
|
||||
use App\Exports\Activities\Two\Roshanaei\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
}
|
||||
108
app/Exports/Activities/Two/Roshanaei/City.php
Normal file
108
app/Exports/Activities/Two/Roshanaei/City.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Roshanaei;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as NegahdariToolCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as NegahdariToolSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as NegahdariHashiehCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as NegahdariHashiehSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as NegahdariNoghteyiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as NegahdariNoghteyiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as NegahdariNavahiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as NegahdariNavahiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as NegahdariMehgirCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as NegahdariMehgirSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as NegahdariToonelCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as NegahdariToonelSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as TamiratCableCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as TamiratCableSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as TamiratKaleCheraghCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as TamiratKaleCheraghSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as TamiratMafselzaniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as TamiratMafselzaniSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as TamiratTabloCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as TamiratTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as TamiratBorjNooriCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as TamiratBorjNooriSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 5 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Roshanaei.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('X1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
143
app/Exports/Activities/Two/Roshanaei/Province.php
Normal file
143
app/Exports/Activities/Two/Roshanaei/Province.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Roshanaei;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as NegahdariToolCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as NegahdariToolSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as NegahdariHashiehCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as NegahdariHashiehSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as NegahdariNoghteyiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as NegahdariNoghteyiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as NegahdariNavahiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as NegahdariNavahiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as NegahdariMehgirCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as NegahdariMehgirSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as NegahdariToonelCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as NegahdariToonelSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as TamiratCableCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as TamiratCableSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as TamiratKaleCheraghCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as TamiratKaleCheraghSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as TamiratMafselzaniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as TamiratMafselzaniSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as TamiratTabloCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as TamiratTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as TamiratBorjNooriCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as TamiratBorjNooriSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 5 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as NegahdariToolCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as NegahdariToolSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as NegahdariHashiehCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as NegahdariHashiehSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as NegahdariNoghteyiCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as NegahdariNoghteyiSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as NegahdariNavahiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as NegahdariNavahiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as NegahdariMehgirCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as NegahdariMehgirSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as NegahdariToonelCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as NegahdariToonelSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as TamiratCableCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as TamiratCableSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as TamiratKaleCheraghCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as TamiratKaleCheraghSum,
|
||||
COUNT(CASE WHEN sub_item = 9 THEN 1 END) as TamiratMafselzaniCount,
|
||||
SUM(CASE WHEN sub_item = 9 THEN sub_item_data END) as TamiratMafselzaniSum,
|
||||
COUNT(CASE WHEN sub_item = 10 THEN 1 END) as TamiratTabloCount,
|
||||
SUM(CASE WHEN sub_item = 10 THEN sub_item_data END) as TamiratTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 11 THEN 1 END) as TamiratBorjNooriCount,
|
||||
SUM(CASE WHEN sub_item = 11 THEN sub_item_data END) as TamiratBorjNooriSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 5 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Roshanaei.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('W1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Shosteshoo/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Shosteshoo/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Shosteshoo;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Shosteshoo\Province;
|
||||
use App\Exports\Activities\Two\Shosteshoo\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
99
app/Exports/Activities/Two/Shosteshoo/City.php
Normal file
99
app/Exports/Activities/Two/Shosteshoo/City.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Shosteshoo;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ShosteshooAlaemCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ShosteshooAlaemSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as ShosteshooTabloCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as ShosteshooTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as ShosteshooJadvalCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as ShosteshooJadvalSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as ShosteshooNewjersiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as ShosteshooNewjersiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as ShosteshooGuardrailCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as ShosteshooGuardrailSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as ShosteshooToonelCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as ShosteshooToonelSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as ShosteshooPolCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as ShosteshooPolSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 8 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Shosteshoo.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('P1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
126
app/Exports/Activities/Two/Shosteshoo/Province.php
Normal file
126
app/Exports/Activities/Two/Shosteshoo/Province.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Shosteshoo;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ShosteshooAlaemCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ShosteshooAlaemSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as ShosteshooTabloCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as ShosteshooTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as ShosteshooJadvalCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as ShosteshooJadvalSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as ShosteshooNewjersiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as ShosteshooNewjersiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as ShosteshooGuardrailCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as ShosteshooGuardrailSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as ShosteshooToonelCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as ShosteshooToonelSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as ShosteshooPolCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as ShosteshooPolSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 8 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ShosteshooAlaemCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ShosteshooAlaemSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as ShosteshooTabloCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as ShosteshooTabloSum,
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as ShosteshooJadvalCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as ShosteshooJadvalSum,
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as ShosteshooNewjersiCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as ShosteshooNewjersiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as ShosteshooGuardrailCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as ShosteshooGuardrailSum,
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as ShosteshooToonelCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as ShosteshooToonelSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as ShosteshooPolCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as ShosteshooPolSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 8 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
return view('excel.CurrentActivities.Shosteshoo.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('O1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
25
app/Exports/Activities/Two/Toonel/AllSheets.php
Normal file
25
app/Exports/Activities/Two/Toonel/AllSheets.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Toonel;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Toonel\Province;
|
||||
use App\Exports\Activities\Two\Toonel\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province)
|
||||
];
|
||||
}
|
||||
}
|
||||
106
app/Exports/Activities/Two/Toonel/City.php
Normal file
106
app/Exports/Activities/Two/Toonel/City.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Toonel;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ZehkeshiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ZehkeshiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as LiningCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as LiningSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as TamirGalleryCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as TamirGallerySum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as GabaritCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as GabaritSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as DoorbinCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as DoorbinSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as TahvieCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as TahvieSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 12 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Toonel.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('P1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
140
app/Exports/Activities/Two/Toonel/Province.php
Normal file
140
app/Exports/Activities/Two/Toonel/Province.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Toonel;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ZehkeshiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ZehkeshiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as LiningCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as LiningSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as TamirGalleryCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as TamirGallerySum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as GabaritCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as GabaritSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as DoorbinCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as DoorbinSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as TahvieCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as TahvieSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 12 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as ZehkeshiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as ZehkeshiSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as MarematCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as MarematSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 3 THEN 1 END) as LiningCount,
|
||||
SUM(CASE WHEN sub_item = 3 THEN sub_item_data END) as LiningSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 4 THEN 1 END) as TamirGalleryCount,
|
||||
SUM(CASE WHEN sub_item = 4 THEN sub_item_data END) as TamirGallerySum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as GabaritCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as GabaritSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 6 THEN 1 END) as DoorbinCount,
|
||||
SUM(CASE WHEN sub_item = 6 THEN sub_item_data END) as DoorbinSum,
|
||||
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as TahvieCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as TahvieSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 12 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Toonel.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('O1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
26
app/Exports/Activities/Two/Zemestani/AllSheets.php
Normal file
26
app/Exports/Activities/Two/Zemestani/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Zemestani;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Activities\Two\Zemestani\Province;
|
||||
use App\Exports\Activities\Two\Zemestani\City;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new Province($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new City($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
}
|
||||
97
app/Exports/Activities/Two/Zemestani/City.php
Normal file
97
app/Exports/Activities/Two/Zemestani/City.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Zemestani;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class City implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as YakhzodaeiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as YakhzodaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as BarfRoobiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as BarfRoobiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as MizanNamakCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as MizanNamakSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as MosaferinCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as MosaferinSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as KomakResaniCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as KomakResaniSum,
|
||||
province_id,
|
||||
province_fa,
|
||||
user_name as city_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 13 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY city_id ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
return view('excel.CurrentActivities.Zemestani.City', [
|
||||
'data' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('L1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
120
app/Exports/Activities/Two/Zemestani/Province.php
Normal file
120
app/Exports/Activities/Two/Zemestani/Province.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Activities\Two\Zemestani;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class Province implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as YakhzodaeiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as YakhzodaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as BarfRoobiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as BarfRoobiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as MizanNamakCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as MizanNamakSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as MosaferinCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as MosaferinSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as KomakResaniCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as KomakResaniSum,
|
||||
province_id,
|
||||
province_fa
|
||||
FROM road_items_projects
|
||||
WHERE item = 13 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$query .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}' GROUP BY province_id ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
|
||||
$countryQuery = "SELECT
|
||||
COUNT(CASE WHEN sub_item = 1 THEN 1 END) as YakhzodaeiCount,
|
||||
SUM(CASE WHEN sub_item = 1 THEN sub_item_data END) as YakhzodaeiSum,
|
||||
COUNT(CASE WHEN sub_item = 2 THEN 1 END) as BarfRoobiCount,
|
||||
SUM(CASE WHEN sub_item = 2 THEN sub_item_data END) as BarfRoobiSum,
|
||||
COUNT(CASE WHEN sub_item = 5 THEN 1 END) as MizanNamakCount,
|
||||
SUM(CASE WHEN sub_item = 5 THEN sub_item_data END) as MizanNamakSum,
|
||||
COUNT(CASE WHEN sub_item = 7 THEN 1 END) as MosaferinCount,
|
||||
SUM(CASE WHEN sub_item = 7 THEN sub_item_data END) as MosaferinSum,
|
||||
COUNT(CASE WHEN sub_item = 8 THEN 1 END) as KomakResaniCount,
|
||||
SUM(CASE WHEN sub_item = 8 THEN sub_item_data END) as KomakResaniSum
|
||||
FROM road_items_projects
|
||||
WHERE item = 13 and status = 1";
|
||||
|
||||
if ($this->province) {
|
||||
$countryQuery .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
$countryQuery .= " AND activity_date_time BETWEEN '{$fromDate}' AND '{$toDate}';";
|
||||
|
||||
$country = DB::select(DB::raw($countryQuery));
|
||||
|
||||
|
||||
return view('excel.CurrentActivities.Zemestani.Province', [
|
||||
'data' => $data,
|
||||
'country' => $country,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('K1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
102
app/Exports/AxisReport/ActivityReports.php
Normal file
102
app/Exports/AxisReport/ActivityReports.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\AxisReport;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ActivityReports implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($activities, $date_to, $date_from)
|
||||
{
|
||||
$this->activities = $activities ?? null;
|
||||
$this->date_to = $date_to;
|
||||
$this->date_from = $date_from;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$ids = $this->activities;
|
||||
$roadItemsProject = RoadItemsProject::whereIn('id', $ids ?? [])
|
||||
->select('user_id' ,'province_fa', 'item_fa', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'created_at_fa', 'start_lat', 'start_lng')
|
||||
->with('user:id,name')
|
||||
->get();
|
||||
$array = [];
|
||||
foreach ($roadItemsProject as $item) {
|
||||
$array[] = [
|
||||
'province_fa' => $item->province_fa,
|
||||
'item_fa' => $item->item_fa,
|
||||
'sub_item_fa' => $item->sub_item_fa,
|
||||
'sub_item_data' => $item->sub_item_data,
|
||||
'unit_fa' => $item->unit_fa,
|
||||
'created_at_fa' => $item->created_at_fa,
|
||||
'start_lat' => $item->start_lat,
|
||||
'start_lng' => $item->start_lng,
|
||||
'user' => $item->user->name
|
||||
];
|
||||
}
|
||||
return view('axisReport.activity-reports', [
|
||||
'array' => $array,
|
||||
'dateFrom' => $this->date_from,
|
||||
'dateTo' => $this->date_to
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
48
app/Exports/AxisReport/AllSheet.php
Normal file
48
app/Exports/AxisReport/AllSheet.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\AxisReport;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\AxisReport\ActivityReports;
|
||||
use App\Exports\AxisReport\Projects;
|
||||
use App\Exports\AxisReport\RoadObserved;
|
||||
use App\Exports\AxisReport\RoadPatrol;
|
||||
|
||||
class AllSheet implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($patrols, $activities, $projects, $observeds, $date_to, $date_from)
|
||||
{
|
||||
$this->patrols = $patrols;
|
||||
$this->activities = $activities;
|
||||
$this->projects = $projects;
|
||||
$this->observeds = $observeds;
|
||||
$this->date_to = $date_to;
|
||||
$this->date_from = $date_from;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
$result = null;
|
||||
if ($this->activities != null) {
|
||||
$result[] = new ActivityReports($this->activities, $this->date_to, $this->date_from);
|
||||
}
|
||||
if ($this->patrols != null) {
|
||||
$result[] = new RoadPatrol($this->patrols, $this->date_to, $this->date_from);
|
||||
}
|
||||
if ($this->observeds != null) {
|
||||
$result[] = new RoadObserved($this->observeds, $this->date_to, $this->date_from);
|
||||
}
|
||||
if ($this->projects != null) {
|
||||
$result[] = new Projects($this->projects, $this->date_to, $this->date_from);
|
||||
}
|
||||
if ($result) {
|
||||
return $result;
|
||||
} else {
|
||||
dd("داده ای برای گزارش گیری وجود ندارد لطفا بعد از بررسی مقادیر فیلتر شده، مجدد اقدام نمایید.");
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
86
app/Exports/AxisReport/Projects.php
Normal file
86
app/Exports/AxisReport/Projects.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\AxisReport;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class Projects implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($projects, $date_to, $date_from)
|
||||
{
|
||||
$this->projects = $projects ?? null;
|
||||
$this->date_to = $date_to;
|
||||
$this->date_from = $date_from;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$ids = $this->projects;
|
||||
$data = ContractSubItems::whereIn('id', $ids ?? [])
|
||||
->get();
|
||||
return view('axisReport.projects', [
|
||||
'data' => $data,
|
||||
'dateFrom' => $this->date_from,
|
||||
'dateTo' => $this->date_to
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
88
app/Exports/AxisReport/RoadObserved.php
Normal file
88
app/Exports/AxisReport/RoadObserved.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\AxisReport;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadObserved as db;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class RoadObserved implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($observeds, $date_to, $date_from)
|
||||
{
|
||||
$this->observeds = $observeds ?? null;
|
||||
$this->date_to = $date_to;
|
||||
$this->date_from = $date_from;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$ids = $this->observeds;
|
||||
$data = db::whereIn('id', $ids ?? [])
|
||||
->select('AutoID', 'ProvinceName', 'TownName', 'FeatureTypeTitle', 'Title', 'Description', 'MobileForSendEventSms', 'StartTime_DateTime_fa', 'updated_at_fa', 'lat', 'lng', 'rms_description')
|
||||
->get();
|
||||
|
||||
return view('axisReport.road-observed', [
|
||||
'data' => $data,
|
||||
'dateFrom' => $this->date_from,
|
||||
'dateTo' => $this->date_to
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
101
app/Exports/AxisReport/RoadPatrol.php
Normal file
101
app/Exports/AxisReport/RoadPatrol.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\AxisReport;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadPatrolProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class RoadPatrol implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($patrols, $date_to, $date_from)
|
||||
{
|
||||
$this->patrols = $patrols;
|
||||
$this->date_to = $date_to;
|
||||
$this->date_from = $date_from;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$ids = $this->patrols;
|
||||
$roadPatrol = RoadPatrolProject::whereIn('id', $ids ?? [])
|
||||
->select('user_id', 'province_fa', 'created_at', 'start_lat', 'start_lng', 'end_lat', 'end_lng')
|
||||
->with('user:id,name')
|
||||
->get();
|
||||
|
||||
foreach ($roadPatrol as $item) {
|
||||
$array[] = [
|
||||
'province_fa' => $item->province_fa,
|
||||
'start_lat' => $item->start_lat,
|
||||
'start_lng' => $item->start_lng,
|
||||
'end_lat' => $item->end_lat,
|
||||
'end_lng' => $item->end_lng,
|
||||
'created_at_fa' => verta($item->created_at)->format('Y/m/d H:m'),
|
||||
'user' => $item->user->name
|
||||
];
|
||||
}
|
||||
|
||||
return view('axisReport.road-patrol', [
|
||||
'array' => $array,
|
||||
'dateFrom' => $this->date_from,
|
||||
'dateTo' => $this->date_to
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
119
app/Exports/ContractsExport.php
Normal file
119
app/Exports/ContractsExport.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\Contracts;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ContractsExport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $status = null, $projectType = null, $statusRel = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->status = $status ?? null;
|
||||
$this->projectType = $projectType ?? null;
|
||||
$this->status_rel = $statusRel ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = isset($this->province) ? explode(',', $this->province) : null;
|
||||
$status = isset($this->status) ? explode(',', $this->status) : null;
|
||||
$projectType = $this->projectType ? explode(',', $this->projectType) : null;
|
||||
$statusRel = $this->status_rel;
|
||||
|
||||
$data = Contracts::when($fromDate, function ($query) use ($fromDate, $toDate) {
|
||||
return $query->whereBetween('contract_date', [$fromDate, $toDate]);
|
||||
})
|
||||
->when($province, function ($query) use ($province) {
|
||||
return $query->whereIn('contracts.province_id', $province);
|
||||
})
|
||||
->when($status, function ($query) use ($status) {
|
||||
return $query->whereIn('contracts.status_id', $status);
|
||||
})
|
||||
->when($statusRel, function ($query) use ($statusRel) {
|
||||
return $query->where('contracts.status_rel', $statusRel);
|
||||
})
|
||||
->with('subitems')
|
||||
->when($projectType, function ($query) use ($projectType) {
|
||||
return $query->whereHas('subitems', function ($query) use ($projectType) {
|
||||
$query->whereIn('project_type_id', $projectType ?? []);
|
||||
});
|
||||
})
|
||||
->orderBy('province_id')
|
||||
->get();
|
||||
$array = [];
|
||||
foreach ($data as $key => $item) {
|
||||
$array[] = $item;
|
||||
$array[$key]['projects_count'] = count($item->subitems);
|
||||
}
|
||||
|
||||
return view('excel.contract', [
|
||||
'roads' => $array,
|
||||
'fromFa' => $fromDate,
|
||||
'toFa' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
26
app/Exports/DailyAccident/AllSheets.php
Normal file
26
app/Exports/DailyAccident/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\DailyAccident;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\DailyAccident\ReceiptProvinceReport;
|
||||
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new ProvinceDailyAccidentReport($this->fromDate, $this->toDate, $this->province),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
94
app/Exports/DailyAccident/ProvinceDailyAccidentReport.php
Normal file
94
app/Exports/DailyAccident/ProvinceDailyAccidentReport.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\DailyAccident;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\DailyAccident;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ProvinceDailyAccidentReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
|
||||
$province = $this->province ?? null;
|
||||
$fromDate = $this->fromDate ?? \Carbon\Carbon::now()->subDays(7);
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$data = \App\Models\DailyAccident::whereBetween('accident_date', [$fromDate . ' 00:00:00', $toDate . ' 23:59:59'])
|
||||
->select('*')
|
||||
->when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->get();
|
||||
|
||||
return view('excel.DailyAccident.Province', [
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
126
app/Exports/FastNewReactDoneExport.php
Normal file
126
app/Exports/FastNewReactDoneExport.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadObserved;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class FastNewReactDoneExport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? \Carbon\Carbon::now()->subDays(3);
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
$data = \App\Models\RoadObserved::select('id', 'ProvinceName', 'TownName', 'FeatureTypeTitle', 'created_at', 'Title', 'Description', 'MobileForSendEventSms', 'lat', 'lng', 'rms_description', 'updated_at', 'rms_status')
|
||||
->where('rms_status', '!=','0')
|
||||
->whereIn('fk_FeatureType', ['1', '2', '3', '4', '5', '6'])
|
||||
->whereBetween('created_at', [$fromDate . ' 00:00:00', $toDate . ' 23:59:59'])
|
||||
->when($province, function ($query, $province) {
|
||||
return $query->where('rms_province_id', $province);
|
||||
})
|
||||
->get();
|
||||
// $array = [];
|
||||
// foreach ($data as $item) {
|
||||
// // switch ($item->rms_status) {
|
||||
// // case '0':
|
||||
// // $rms_status_fa = 'رسیدگی نشده';
|
||||
// // break;
|
||||
// // case '1':
|
||||
// // $rms_status_fa = 'رسیدگی شده';
|
||||
// // break;
|
||||
// // case '2':
|
||||
// // $rms_status_fa = 'رسیدگی شده';
|
||||
// // break;
|
||||
// // }
|
||||
|
||||
// $array[] = [
|
||||
// 'id' => $item->id,
|
||||
// 'ProvinceName' => $item->ProvinceName,
|
||||
// 'TownName' => $item->TownName,
|
||||
// 'FeatureTypeTitle' => $item->FeatureTypeTitle,
|
||||
// 'Title' => $item->Title,
|
||||
// 'created_at' => verta($item->created_at)->format('Y/m/d'),
|
||||
// 'Description' => $item->Description,
|
||||
// 'MobileForSendEventSms' => $item->MobileForSendEventSms,
|
||||
// 'lat' => $item->lat,
|
||||
// 'lng' => $item->lng,
|
||||
// 'rms_description' => $item->rms_description,
|
||||
// 'updated_at' => verta($item->updated_at)->format('Y/m/d'),
|
||||
// 'rms_status' => $item->rms_status,
|
||||
// ];
|
||||
// }
|
||||
|
||||
return view('excel.FastNewReactDone', [
|
||||
'roads' => $data,
|
||||
'fromFa' => $fromDate,
|
||||
'toFa' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
126
app/Exports/FastNewReactPendingExport.php
Normal file
126
app/Exports/FastNewReactPendingExport.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadObserved;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class FastNewReactPendingExport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? \Carbon\Carbon::now()->subDays(3);
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
$data = \App\Models\RoadObserved::select('id', 'ProvinceName', 'TownName', 'FeatureTypeTitle', 'created_at', 'Title', 'Description', 'MobileForSendEventSms', 'lat', 'lng', 'rms_description', 'updated_at', 'rms_status')
|
||||
->where('rms_status', "<>", '0')
|
||||
->whereIn('fk_FeatureType', ['1', '2', '3', '4', '5', '6'])
|
||||
->whereBetween('created_at', [$fromDate . ' 00:00:00', $toDate . ' 23:59:59'])
|
||||
->when($province, function ($query, $province) {
|
||||
return $query->where('rms_province_id', $province);
|
||||
})
|
||||
->get();
|
||||
// $array = [];
|
||||
// foreach ($data as $item) {
|
||||
// switch ($item->rms_status) {
|
||||
// case '0':
|
||||
// $rms_status_fa = 'رسیدگی نشده';
|
||||
// break;
|
||||
// case '1':
|
||||
// $rms_status_fa = 'رسیدگی شده';
|
||||
// break;
|
||||
// case '2':
|
||||
// $rms_status_fa = 'رسیدگی شده';
|
||||
// break;
|
||||
// }
|
||||
|
||||
// $array[] = [
|
||||
// 'id' => $item->id,
|
||||
// 'ProvinceName' => $item->ProvinceName,
|
||||
// 'TownName' => $item->TownName,
|
||||
// 'FeatureTypeTitle' => $item->FeatureTypeTitle,
|
||||
// 'Title' => $item->Title,
|
||||
// 'created_at' => verta($item->created_at)->format('Y/m/d'),
|
||||
// 'Description' => $item->Description,
|
||||
// 'MobileForSendEventSms' => $item->MobileForSendEventSms,
|
||||
// 'lat' => $item->lat,
|
||||
// 'lng' => $item->lng,
|
||||
// 'rms_description' => $item->rms_description,
|
||||
// 'updated_at' => verta($item->updated_at)->format('Y/m/d'),
|
||||
// 'rms_status' => $rms_status_fa,
|
||||
// ];
|
||||
// }
|
||||
|
||||
return view('excel.FastNewReactPending', [
|
||||
'roads' => $data,
|
||||
'fromFa' => $fromDate,
|
||||
'toFa' => $toDate
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
92
app/Exports/LawmakersExport.php
Normal file
92
app/Exports/LawmakersExport.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\LawmakersCorrespondence as Lawmaker;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class LawmakersExport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($constituency = null, $province = null)
|
||||
{
|
||||
$this->constituency = $constituency ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$province = $this->province ?? null;
|
||||
$constituency = $this->constituency ?? null;
|
||||
|
||||
$data = Lawmaker::when($constituency, function ($query, $constituency) {
|
||||
return $query->where('constituency_id', $constituency);
|
||||
})
|
||||
->when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->get();
|
||||
|
||||
|
||||
return view('excel.lawmaker', [
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
375
app/Exports/Maintanance/CompareProgramAndFunction.php
Normal file
375
app/Exports/Maintanance/CompareProgramAndFunction.php
Normal file
@@ -0,0 +1,375 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Maintanance;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use App\Models\Province;
|
||||
use App\Models\City;
|
||||
|
||||
class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
public function view(): View
|
||||
{
|
||||
$array = [];
|
||||
$province = $this->province;
|
||||
|
||||
foreach (Province::when($province, function ($query, $province) {
|
||||
return $query->where('id', $province);
|
||||
})->get() as $item) {
|
||||
$array[$item->id] = [
|
||||
'province_fa' => $item->name_fa,
|
||||
|
||||
'AsphaltGarmDoing' => 0,
|
||||
'MaseAsphaltDoing' => 0,
|
||||
'BazyaftSardGarmDoing' => 0,
|
||||
'mirosurfacingDoing' => 0,
|
||||
'ChipSailDoing' => 0,
|
||||
'SlarySaildDoing' => 0,
|
||||
'ScrubSailDoing' => 0,
|
||||
'FogSailDoing' => 0,
|
||||
'SailKatDoing' => 0,
|
||||
'KipSailDoing' => 0,
|
||||
'AsphaltRedmixDoing' => 0,
|
||||
'LakegiriDoing' => 0,
|
||||
'DarzgiriDoing' => 0,
|
||||
|
||||
'AsphaltGarmDone' => 0,
|
||||
'MaseAsphaltDone' => 0,
|
||||
'BazyaftSardGarmDone' => 0,
|
||||
'mirosurfacingDone' => 0,
|
||||
'ChipSailDone' => 0,
|
||||
'SlarySaildDone' => 0,
|
||||
'ScrubSailDone' => 0,
|
||||
'FogSailDone' => 0,
|
||||
'SailKatDone' => 0,
|
||||
'KipSailDone' => 0,
|
||||
'AsphaltRedmixDone' => 0,
|
||||
'LakegiriDone' => 0,
|
||||
'DarzgiriDone' => 0,
|
||||
|
||||
'countAll' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$query = "SELECT province_fa, province_id,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 101 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 101 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 101 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 101 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 101 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 101 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 101 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS AsphaltGarmDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 102 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 102 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 102 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 102 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 102 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 102 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 102 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS MaseAsphaltDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 103 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 103 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 103 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 103 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 103 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 103 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 103 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS BazyaftSardGarmDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 104 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 104 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 104 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 104 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 104 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 104 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 104 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS mirosurfacingDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 105 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 105 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 105 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 105 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 105 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 105 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 105 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS ChipSailDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 106 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 106 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 106 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 106 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 106 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 106 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 106 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS SlarySaildDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 107 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 107 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 107 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 107 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 107 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 107 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 107 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS ScrubSailDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 108 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 108 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 108 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 108 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 108 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 108 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 108 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS FogSailDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 109 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 109 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 109 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 109 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 109 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 109 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 109 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS SailKatDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 110 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 110 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 110 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 110 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 110 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 110 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 110 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS KipSailDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 111 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 111 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 111 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 111 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 111 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 111 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 111 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS AsphaltRedmixDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 112 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 112 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 112 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 112 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 112 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 112 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 112 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS LakegiriDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 113 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 113 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 113 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 113 THEN operation_type_amount4
|
||||
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
|
||||
WHEN operation_type_id2 = 113 THEN (cast(operation_type_amount2 as int) * cast(operation_type_progress2 as int))/100
|
||||
WHEN operation_type_id3 = 113 THEN (cast(operation_type_amount3 as int) * cast(operation_type_progress3 as int))/100
|
||||
WHEN operation_type_id4 = 113 THEN (cast(operation_type_amount4 as int) * cast(operation_type_progress4 as int))/100
|
||||
END)) AS DarzgiriDone,
|
||||
COUNT(*) AS countAll
|
||||
FROM contract_subitems
|
||||
WHERE project_type_id = 1
|
||||
";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}\n";
|
||||
}
|
||||
|
||||
$query .= " GROUP BY province_id
|
||||
ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$sum = [
|
||||
'AsphaltGarmDoingSum' => 0,
|
||||
'MaseAsphaltDoingSum' => 0,
|
||||
'BazyaftSardGarmDoingSum' => 0,
|
||||
'mirosurfacingDoingSum' => 0,
|
||||
'ChipSailDoingSum' => 0,
|
||||
'SlarySaildDoingSum' => 0,
|
||||
'ScrubSailDoingSum' => 0,
|
||||
'FogSailDoingSum' => 0,
|
||||
'SailKatDoingSum' => 0,
|
||||
'KipSailDoingSum' => 0,
|
||||
'AsphaltRedmixDoingSum' => 0,
|
||||
'LakegiriDoingSum' => 0,
|
||||
'DarzgiriDoingSum' => 0,
|
||||
'AsphaltGarmDoneSum' => 0,
|
||||
'MaseAsphaltDoneSum' => 0,
|
||||
'BazyaftSardGarmDoneSum' => 0,
|
||||
'mirosurfacingDoneSum' => 0,
|
||||
'ChipSailDoneSum' => 0,
|
||||
'SlarySaildDoneSum' => 0,
|
||||
'ScrubSailDoneSum' => 0,
|
||||
'FogSailDoneSum' => 0,
|
||||
'SailKatDoneSum' => 0,
|
||||
'KipSailDoneSum' => 0,
|
||||
'AsphaltRedmixDoneSum' => 0,
|
||||
'LakegiriDoneSum' => 0,
|
||||
'DarzgiriDoneSum' => 0,
|
||||
'countAll' => 0,
|
||||
];
|
||||
|
||||
foreach ($data as $value) {
|
||||
$array[$value->province_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
|
||||
'AsphaltGarmDoing' => $value->AsphaltGarmDoing,
|
||||
'MaseAsphaltDoing' => $value->MaseAsphaltDoing,
|
||||
'BazyaftSardGarmDoing' => $value->BazyaftSardGarmDoing,
|
||||
'mirosurfacingDoing' => $value->mirosurfacingDoing,
|
||||
'ChipSailDoing' => $value->ChipSailDoing,
|
||||
'SlarySaildDoing' => $value->SlarySaildDoing,
|
||||
'ScrubSailDoing' => $value->ScrubSailDoing,
|
||||
'FogSailDoing' => $value->FogSailDoing,
|
||||
'SailKatDoing' => $value->SailKatDoing,
|
||||
'KipSailDoing' => $value->KipSailDoing,
|
||||
'AsphaltRedmixDoing' => $value->AsphaltRedmixDoing,
|
||||
'LakegiriDoing' => $value->LakegiriDoing,
|
||||
'DarzgiriDoing' => $value->DarzgiriDoing,
|
||||
'AsphaltGarmDone' => $value->AsphaltGarmDone,
|
||||
'MaseAsphaltDone' => $value->MaseAsphaltDone,
|
||||
'BazyaftSardGarmDone' => $value->BazyaftSardGarmDone,
|
||||
'mirosurfacingDone' => $value->mirosurfacingDone,
|
||||
'ChipSailDone' => $value->ChipSailDone,
|
||||
'SlarySaildDone' => $value->SlarySaildDone,
|
||||
'ScrubSailDone' => $value->ScrubSailDone,
|
||||
'FogSailDone' => $value->FogSailDone,
|
||||
'SailKatDone' => $value->SailKatDone,
|
||||
'KipSailDone' => $value->KipSailDone,
|
||||
'AsphaltRedmixDone' => $value->AsphaltRedmixDone,
|
||||
'LakegiriDone' => $value->LakegiriDone,
|
||||
'DarzgiriDone' => $value->DarzgiriDone,
|
||||
|
||||
'countAll' => $value->countAll,
|
||||
|
||||
];
|
||||
$sum['AsphaltGarmDoingSum'] += $value->AsphaltGarmDoing;
|
||||
$sum['MaseAsphaltDoingSum'] += $value->MaseAsphaltDoing;
|
||||
$sum['BazyaftSardGarmDoingSum'] += $value->BazyaftSardGarmDoing;
|
||||
$sum['mirosurfacingDoingSum'] += $value->mirosurfacingDoing;
|
||||
$sum['ChipSailDoingSum'] += $value->ChipSailDoing;
|
||||
$sum['SlarySaildDoingSum'] += $value->SlarySaildDoing;
|
||||
$sum['ScrubSailDoingSum'] += $value->ScrubSailDoing;
|
||||
$sum['FogSailDoingSum'] += $value->FogSailDoing;
|
||||
$sum['SailKatDoingSum'] += $value->SailKatDoing;
|
||||
$sum['KipSailDoingSum'] += $value->KipSailDoing;
|
||||
$sum['AsphaltRedmixDoingSum'] += $value->AsphaltRedmixDoing;
|
||||
$sum['LakegiriDoingSum'] += $value->LakegiriDoing;
|
||||
$sum['DarzgiriDoingSum'] += $value->DarzgiriDoing;
|
||||
$sum['AsphaltGarmDoneSum'] += $value->AsphaltGarmDone;
|
||||
$sum['MaseAsphaltDoneSum'] += $value->MaseAsphaltDone;
|
||||
$sum['BazyaftSardGarmDoneSum'] += $value->BazyaftSardGarmDone;
|
||||
$sum['mirosurfacingDoneSum'] += $value->mirosurfacingDone;
|
||||
$sum['ChipSailDoneSum'] += $value->ChipSailDone;
|
||||
$sum['SlarySaildDoneSum'] += $value->SlarySaildDone;
|
||||
$sum['ScrubSailDoneSum'] += $value->ScrubSailDone;
|
||||
$sum['FogSailDoneSum'] += $value->FogSailDone;
|
||||
$sum['SailKatDoneSum'] += $value->SailKatDone;
|
||||
$sum['KipSailDoneSum'] += $value->KipSailDone;
|
||||
$sum['AsphaltRedmixDoneSum'] += $value->AsphaltRedmixDone;
|
||||
$sum['LakegiriDoneSum'] += $value->LakegiriDone;
|
||||
$sum['DarzgiriDoneSum'] += $value->DarzgiriDone;
|
||||
$sum['countAll'] += $value->countAll;
|
||||
}
|
||||
|
||||
return view('excel.Maintanance.CompareProgramAndFunction', [
|
||||
'sum' => $sum,
|
||||
'roads' => $array,
|
||||
'sumShow' => $this->province ? 0 :1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
234
app/Exports/Maintanance/RoadMaintanance.php
Normal file
234
app/Exports/Maintanance/RoadMaintanance.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Maintanance;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
class RoadMaintanance implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$province = $this->province;
|
||||
|
||||
$data = ContractSubItems::where('project_type_id', 1)
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->orderBy('province_id', 'ASC')
|
||||
->get();
|
||||
|
||||
$array = [];
|
||||
foreach ($data as $road) {
|
||||
$array[] = [
|
||||
|
||||
'province' => $road->province_fa,
|
||||
'city' => $road->city_fa,
|
||||
'axis_type_fa' => $road->axis_type_fa,
|
||||
'axis_name_fa' => $road->axis_name_fa,
|
||||
'project_title' => $road->project_title,
|
||||
'contract_date_from_parent_contract' => verta($road->contract_date_from_parent_contract)->format('Y/n/j'),
|
||||
'last_status_fa' => $road->last_status_fa,
|
||||
'progress_project' => $road->progress_project,
|
||||
'last_digit_project' => $road->last_digit_project,
|
||||
'last_function_operator' => $road->last_function_operator,
|
||||
'last_payable_operator' => $road->last_payable_operator,
|
||||
'complete_payable' => $road->complete_payable,
|
||||
'contract_peymankar' => $road->contracts->contract_peymankar,
|
||||
'contract_moshaver_tarahi' => $road->contract_moshaver_tarahi,
|
||||
'contract_moshaver_nezarat' => $road->contract_moshaver_nezarat,
|
||||
'priority_project_fa' => $road->priority_project_fa,
|
||||
'followup_priority_project' => $road->followup_priority_project,
|
||||
'operator_name' => $road->operator_name,
|
||||
'operator_phone' => $road->operator_phone,
|
||||
'updated_at_fa' => verta($road->last_date_update)->format('Y/n/j'),
|
||||
'code' => $road->unique_code,
|
||||
|
||||
'isDefined' => [
|
||||
'rokeshAsphalt' => $road->operation_type_id1 == '101' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '101' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '101' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '101' ? $road->operation_type_amount4 : "-"))),
|
||||
'maseAsphalt' => $road->operation_type_id1 == '102' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '102' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '102' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '102' ? $road->operation_type_amount4 : "-"))),
|
||||
'baziaftSard' => $road->operation_type_id1 == '103' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '103' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '103' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '103' ? $road->operation_type_amount4 : "-"))),
|
||||
|
||||
'microsurfacing' => $road->operation_type_id1 == '104' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '104' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '104' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '104' ? $road->operation_type_amount4 : "-"))),
|
||||
'chipSail' => $road->operation_type_id1 == '105' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '105' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '105' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '105' ? $road->operation_type_amount4 : "-"))),
|
||||
'slarySail' => $road->operation_type_id1 == '106' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '106' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '106' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '106' ? $road->operation_type_amount4 : "-"))),
|
||||
'scrubSail' => $road->operation_type_id1 == '107' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '107' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '107' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '107' ? $road->operation_type_amount4 : "-"))),
|
||||
'fogSail' => $road->operation_type_id1 == '108' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '108' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '108' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '108' ? $road->operation_type_amount4 : "-"))),
|
||||
'sailKat' => $road->operation_type_id1 == '109' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '109' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '109' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '109' ? $road->operation_type_amount4 : "-"))),
|
||||
'kipSail' => $road->operation_type_id1 == '110' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '110' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '110' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '110' ? $road->operation_type_amount4 : "-"))),
|
||||
'redmix' => $road->operation_type_id1 == '111' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '111' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '111' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '111' ? $road->operation_type_amount4 : "-"))),
|
||||
|
||||
'lakeGiri' => $road->operation_type_id1 == '112' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '112' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '112' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '112' ? $road->operation_type_amount4 : "-"))),
|
||||
'darzGiri' => $road->operation_type_id1 == '113' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '113' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '113' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '113' ? $road->operation_type_amount4 : "-"))),
|
||||
|
||||
],
|
||||
|
||||
'isDone' => [
|
||||
'rokeshAsphalt' => $road->operation_type_id1 == '101' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '101' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '101' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '101' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'maseAsphalt' => $road->operation_type_id1 == '102' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '102' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '102' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '102' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'baziaftSard' => $road->operation_type_id1 == '103' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '103' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '103' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '103' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
|
||||
'microsurfacing' => $road->operation_type_id1 == '104' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '104' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '104' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '104' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'chipSail' => $road->operation_type_id1 == '105' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '105' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '105' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '105' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'slarySail' => $road->operation_type_id1 == '106' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '106' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '106' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '106' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'scrubSail' => $road->operation_type_id1 == '107' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '107' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '107' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '107' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'fogSail' => $road->operation_type_id1 == '108' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '108' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '108' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '108' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'sailKat' => $road->operation_type_id1 == '109' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '109' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '109' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '109' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'kipSail' => $road->operation_type_id1 == '110' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '110' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '110' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '110' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'redmix' => $road->operation_type_id1 == '111' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '111' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '111' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '111' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
|
||||
'lakeGiri' => $road->operation_type_id1 == '112' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '112' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '112' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '112' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'darzGiri' => $road->operation_type_id1 == '113' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '113' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '113' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '113' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return view('excel.Maintanance.RoadMaintanance', [
|
||||
'roads' => $array,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Exports/Maintanance/allSheet.php
Normal file
32
app/Exports/Maintanance/allSheet.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Maintanance;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Maintanance\RoadMaintanance;
|
||||
use App\Exports\Maintanance\summaryAcidentPerformanceProvince;
|
||||
use App\Exports\Maintanance\summaryAcidentPerformanceCity;
|
||||
use App\Exports\Maintanance\summaryAcidentPerformanceProject;
|
||||
use App\Exports\Maintanance\CompareProgramAndFunction;
|
||||
|
||||
class allSheet implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new RoadMaintanance($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new summaryAcidentPerformanceProvince($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
2 => new summaryAcidentPerformanceCity($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
3 => new summaryAcidentPerformanceProject($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
4 => new CompareProgramAndFunction($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
}
|
||||
527
app/Exports/Maintanance/summaryAcidentPerformanceCity.php
Normal file
527
app/Exports/Maintanance/summaryAcidentPerformanceCity.php
Normal file
@@ -0,0 +1,527 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Maintanance;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use App\Models\City;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class summaryAcidentPerformanceCity implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
|
||||
$array = [];
|
||||
$province = $this->province;
|
||||
|
||||
if ($this->province) {
|
||||
foreach (City::when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})->get() as $item) {
|
||||
$array[$item->id] = [
|
||||
'province_fa' => $item->province->name_fa,
|
||||
'city_fa' => $item->name_fa,
|
||||
|
||||
'AsphaltGarmDone' => 0,
|
||||
'MaseAsphaltDone' => 0,
|
||||
'BazyaftSardGarmDone' => 0,
|
||||
'mirosurfacingDone' => 0,
|
||||
'ChipSailDone' => 0,
|
||||
'SlarySaildDone' => 0,
|
||||
'ScrubSailDone' => 0,
|
||||
'FogSailDone' => 0,
|
||||
'SailKatDone' => 0,
|
||||
'KipSailDone' => 0,
|
||||
'AsphaltRedmixDone' => 0,
|
||||
'LakegiriDone' => 0,
|
||||
'DarzgiriDone' => 0,
|
||||
|
||||
'qty' => 0,
|
||||
'progress_project' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT COUNT(
|
||||
CASE
|
||||
WHEN progress_project > 0 THEN 1
|
||||
WHEN operation_type_progress1 > 0 THEN 1
|
||||
WHEN operation_type_progress2 > 0 THEN 1
|
||||
WHEN operation_type_progress3 > 0 THEN 1
|
||||
WHEN operation_type_progress4 > 0 THEN 1
|
||||
END
|
||||
) AS qty,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
date_,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 101 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 101 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 101 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 101 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS AsphaltGarmDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 102 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 102 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 102 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 102 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS MaseAsphaltDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 103 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 103 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 103 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 103 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS BazyaftSardGarmDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 101 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 101 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 101 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 101 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 102 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 102 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 102 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 102 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 103 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 103 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 103 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 103 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS RokeshTghviyatiTonajeKol,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 104 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 104 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 104 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 104 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS mirosurfacingDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 105 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 105 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 105 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 105 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS ChipSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 106 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 106 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 106 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 106 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS SlarySaildDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 107 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 107 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 107 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 107 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS ScrubSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 108 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 108 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 108 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 108 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS FogSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 109 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 109 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 109 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 109 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS SailKatDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 110 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 110 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 110 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 110 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS KipSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 111 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 111 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 111 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 111 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS AsphaltRedmixDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 104 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 104 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 104 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 104 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 105 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 105 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 105 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 105 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 106 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 106 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 106 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 106 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 107 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 107 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 107 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 107 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 108 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 108 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 108 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 108 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 109 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 109 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 109 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 109 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 110 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 110 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 110 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 110 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 111 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 111 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 111 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 111 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS RokeshHefazatiTonajeKol,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 112 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 112 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 112 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 112 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS LakegiriDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 113 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 113 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 113 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 113 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS DarzgiriDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 112 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 112 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 112 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 112 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 113 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 113 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 113 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 113 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS LakeGiriTonajkol,
|
||||
ROUND(AVG(progress_project)) as progress_project
|
||||
FROM (
|
||||
SELECT unique_code,
|
||||
date_,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
MAX(operation_type_tonaj1) - MIN(operation_type_tonaj1) AS operation_type_tonaj1,
|
||||
MAX(operation_type_progress1) - MIN(operation_type_progress1) AS operation_type_progress1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
MAX(operation_type_tonaj2) - MIN(operation_type_tonaj2) AS operation_type_tonaj2,
|
||||
MAX(operation_type_progress2) - MIN(operation_type_progress2) AS operation_type_progress2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
MAX(operation_type_tonaj3) - MIN(operation_type_tonaj3) AS operation_type_tonaj3,
|
||||
MAX(operation_type_progress3) - MIN(operation_type_progress3) AS operation_type_progress3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
MAX(operation_type_tonaj4) - MIN(operation_type_tonaj4) AS operation_type_tonaj4,
|
||||
MAX(operation_type_progress4) - MIN(operation_type_progress4) AS operation_type_progress4,
|
||||
MAX(progress_project) - MIN(progress_project) AS progress_project
|
||||
FROM (
|
||||
SELECT project_type_id,
|
||||
unique_code,
|
||||
last_date_update AS date_,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
operation_type_progress1,
|
||||
operation_type_tonaj1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
operation_type_progress2,
|
||||
operation_type_tonaj2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
operation_type_progress3,
|
||||
operation_type_tonaj3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
operation_type_progress4,
|
||||
operation_type_tonaj4,
|
||||
progress_project
|
||||
FROM contract_subitems
|
||||
UNION
|
||||
SELECT project_type_id,
|
||||
unique_code,
|
||||
last_date_update AS date_,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
operation_type_progress1,
|
||||
operation_type_tonaj1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
operation_type_progress2,
|
||||
operation_type_tonaj2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
operation_type_progress3,
|
||||
operation_type_tonaj3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
operation_type_progress4,
|
||||
operation_type_tonaj4,
|
||||
progress_project
|
||||
FROM contract_sub_items_histories
|
||||
) AS merged_table
|
||||
WHERE project_type_id = 1
|
||||
GROUP BY unique_code
|
||||
) AS mreged_statistics_table WHERE ( progress_project > 0 OR operation_type_progress1 > 0 OR operation_type_progress2 > 0 OR operation_type_progress3 > 0 OR operation_type_progress4 > 0 ) ";
|
||||
|
||||
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
if ($this->fromDate) {
|
||||
$query .= " AND date_ BETWEEN '{$this->fromDate} 00:00:00' AND '{$this->toDate} 23:59:59'";
|
||||
}
|
||||
|
||||
$query .= " GROUP BY city_id
|
||||
ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$array[$value->city_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
'city_fa' => $value->city_fa,
|
||||
|
||||
'AsphaltGarmDone' => $value->AsphaltGarmDone,
|
||||
'MaseAsphaltDone' => $value->MaseAsphaltDone,
|
||||
'BazyaftSardGarmDone' => $value->BazyaftSardGarmDone,
|
||||
'RokeshTghviyatiTonajeKol' => $value->RokeshTghviyatiTonajeKol,
|
||||
'mirosurfacingDone' => $value->mirosurfacingDone,
|
||||
'ChipSailDone' => $value->ChipSailDone,
|
||||
'SlarySaildDone' => $value->SlarySaildDone,
|
||||
'ScrubSailDone' => $value->ScrubSailDone,
|
||||
'FogSailDone' => $value->FogSailDone,
|
||||
'SailKatDone' => $value->SailKatDone,
|
||||
'KipSailDone' => $value->KipSailDone,
|
||||
'AsphaltRedmixDone' => $value->AsphaltRedmixDone,
|
||||
'RokeshHefazatiTonajeKol' => $value->RokeshHefazatiTonajeKol,
|
||||
'LakegiriDone' => $value->LakegiriDone,
|
||||
'DarzgiriDone' => $value->DarzgiriDone,
|
||||
'LakeGiriTonajkol' => $value->LakeGiriTonajkol,
|
||||
|
||||
'qty' => $value->qty,
|
||||
'progress_project' => $value->progress_project,
|
||||
];
|
||||
}
|
||||
|
||||
return view('excel.Maintanance.summaryAccidentPerformanceCity', [
|
||||
'array' => $array,
|
||||
'fromFa' => $this->fromDate ?? null,
|
||||
'toFa' => $this->toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
476
app/Exports/Maintanance/summaryAcidentPerformanceProject.php
Normal file
476
app/Exports/Maintanance/summaryAcidentPerformanceProject.php
Normal file
@@ -0,0 +1,476 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Maintanance;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class summaryAcidentPerformanceProject implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$query = "SELECT
|
||||
project_title,
|
||||
axis_type_fa,
|
||||
axis_name_fa,
|
||||
COUNT(*) AS qty,
|
||||
unique_code,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
date_,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 101 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 101 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 101 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 101 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS AsphaltGarmDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 102 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 102 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 102 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 102 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS MaseAsphaltDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 103 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 103 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 103 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 103 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS BazyaftSardGarmDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 101 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 101 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 101 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 101 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 102 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 102 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 102 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 102 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 103 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 103 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 103 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 103 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS RokeshTghviyatiTonajeKol,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 104 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 104 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 104 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 104 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS mirosurfacingDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 105 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 105 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 105 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 105 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS ChipSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 106 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 106 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 106 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 106 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS SlarySaildDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 107 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 107 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 107 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 107 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS ScrubSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 108 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 108 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 108 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 108 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS FogSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 109 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 109 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 109 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 109 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS SailKatDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 110 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 110 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 110 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 110 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS KipSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 111 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 111 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 111 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 111 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS AsphaltRedmixDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 104 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 104 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 104 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 104 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 105 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 105 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 105 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 105 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 106 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 106 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 106 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 106 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 107 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 107 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 107 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 107 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 108 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 108 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 108 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 108 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 109 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 109 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 109 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 109 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 110 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 110 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 110 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 110 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 111 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 111 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 111 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 111 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS RokeshHefazatiTonajeKol,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 112 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 112 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 112 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 112 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS LakegiriDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 113 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 113 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 113 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 113 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS DarzgiriDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 112 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 112 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 112 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 112 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 113 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 113 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 113 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 113 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS LakeGiriTonajkol,
|
||||
ROUND(AVG(progress_project)) as progress_project
|
||||
FROM (
|
||||
SELECT
|
||||
project_title,
|
||||
axis_type_fa,
|
||||
axis_name_fa,
|
||||
date_,
|
||||
unique_code,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
MAX(operation_type_tonaj1) - MIN(operation_type_tonaj1) AS operation_type_tonaj1,
|
||||
MAX(operation_type_progress1) - MIN(operation_type_progress1) AS operation_type_progress1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
MAX(operation_type_tonaj2) - MIN(operation_type_tonaj2) AS operation_type_tonaj2,
|
||||
MAX(operation_type_progress2) - MIN(operation_type_progress2) AS operation_type_progress2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
MAX(operation_type_tonaj3) - MIN(operation_type_tonaj3) AS operation_type_tonaj3,
|
||||
MAX(operation_type_progress3) - MIN(operation_type_progress3) AS operation_type_progress3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
MAX(operation_type_tonaj4) - MIN(operation_type_tonaj4) AS operation_type_tonaj4,
|
||||
MAX(operation_type_progress4) - MIN(operation_type_progress4) AS operation_type_progress4,
|
||||
MAX(progress_project) - MIN(progress_project) AS progress_project
|
||||
FROM (
|
||||
SELECT project_type_id,
|
||||
unique_code,
|
||||
last_date_update AS date_,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
project_title,
|
||||
axis_type_fa,
|
||||
axis_name_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
operation_type_progress1,
|
||||
operation_type_tonaj1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
operation_type_progress2,
|
||||
operation_type_tonaj2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
operation_type_progress3,
|
||||
operation_type_tonaj3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
operation_type_progress4,
|
||||
operation_type_tonaj4,
|
||||
progress_project
|
||||
FROM contract_subitems
|
||||
UNION
|
||||
SELECT project_type_id,
|
||||
unique_code,
|
||||
last_date_update AS date_,
|
||||
city_id,
|
||||
city_fa,
|
||||
province_id,
|
||||
province_fa,
|
||||
project_title,
|
||||
axis_type_fa,
|
||||
axis_name_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
operation_type_progress1,
|
||||
operation_type_tonaj1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
operation_type_progress2,
|
||||
operation_type_tonaj2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
operation_type_progress3,
|
||||
operation_type_tonaj3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
operation_type_progress4,
|
||||
operation_type_tonaj4,
|
||||
progress_project
|
||||
FROM contract_sub_items_histories
|
||||
) AS merged_table
|
||||
WHERE project_type_id = 1
|
||||
GROUP BY unique_code
|
||||
) AS mreged_statistics_table WHERE ( progress_project > 0 OR operation_type_progress1 > 0 OR operation_type_progress2 > 0 OR operation_type_progress3 > 0 OR operation_type_progress4 > 0 ) ";
|
||||
|
||||
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
if ($this->fromDate) {
|
||||
$query .= " AND date_ BETWEEN '{$this->fromDate} 00:00:00' AND '{$this->toDate} 23:59:59'";
|
||||
}
|
||||
|
||||
$query .= " GROUP BY unique_code
|
||||
ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
|
||||
return view('excel.Maintanance.summaryAccidentPerformanceProject', [
|
||||
'array' => $data,
|
||||
'fromFa' => $this->fromDate ?? null,
|
||||
'toFa' => $this->toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
559
app/Exports/Maintanance/summaryAcidentPerformanceProvince.php
Normal file
559
app/Exports/Maintanance/summaryAcidentPerformanceProvince.php
Normal file
@@ -0,0 +1,559 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Maintanance;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use App\Models\Province;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
|
||||
class summaryAcidentPerformanceProvince implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$array = [];
|
||||
|
||||
$province = $this->province;
|
||||
foreach (Province::when($province, function ($query, $province) {
|
||||
return $query->where('id', $province);
|
||||
})->get() as $item) {
|
||||
$array[$item->id] = [
|
||||
'province_fa' => $item->name_fa,
|
||||
|
||||
'AsphaltGarmDone' => 0,
|
||||
'MaseAsphaltDone' => 0,
|
||||
'BazyaftSardGarmDone' => 0,
|
||||
'RokeshTghviyatiTonajeKol' => 0,
|
||||
'mirosurfacingDone' => 0,
|
||||
'ChipSailDone' => 0,
|
||||
'SlarySaildDone' => 0,
|
||||
'ScrubSailDone' => 0,
|
||||
'FogSailDone' => 0,
|
||||
'SailKatDone' => 0,
|
||||
'KipSailDone' => 0,
|
||||
'AsphaltRedmixDone' => 0,
|
||||
'RokeshHefazatiTonajeKol' => 0,
|
||||
'LakegiriDone' => 0,
|
||||
'DarzgiriDone' => 0,
|
||||
'LakeGiriTonajkol' => 0,
|
||||
|
||||
'qty' => 0,
|
||||
'progress_project' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$query = "SELECT COUNT(
|
||||
CASE
|
||||
WHEN progress_project > 0 THEN 1
|
||||
WHEN operation_type_progress1 > 0 THEN 1
|
||||
WHEN operation_type_progress2 > 0 THEN 1
|
||||
WHEN operation_type_progress3 > 0 THEN 1
|
||||
WHEN operation_type_progress4 > 0 THEN 1
|
||||
END
|
||||
) AS qty,
|
||||
province_fa,
|
||||
province_id,
|
||||
date_,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 101 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 101 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 101 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 101 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS AsphaltGarmDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 102 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 102 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 102 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 102 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS MaseAsphaltDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 103 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 103 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 103 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 103 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS BazyaftSardGarmDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 101 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 101 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 101 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 101 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 102 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 102 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 102 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 102 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 103 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 103 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 103 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 103 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS RokeshTghviyatiTonajeKol,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 104 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 104 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 104 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 104 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS mirosurfacingDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 105 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 105 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 105 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 105 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS ChipSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 106 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 106 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 106 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 106 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS SlarySaildDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 107 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 107 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 107 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 107 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS ScrubSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 108 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 108 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 108 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 108 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS FogSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 109 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 109 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 109 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 109 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS SailKatDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 110 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 110 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 110 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 110 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS KipSailDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 111 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 111 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 111 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 111 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS AsphaltRedmixDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 104 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 104 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 104 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 104 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 105 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 105 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 105 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 105 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 106 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 106 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 106 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 106 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 107 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 107 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 107 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 107 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 108 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 108 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 108 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 108 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 109 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 109 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 109 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 109 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 110 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 110 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 110 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 110 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 111 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 111 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 111 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 111 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS RokeshHefazatiTonajeKol,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 112 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 112 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 112 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 112 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS LakegiriDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 113 THEN (
|
||||
operation_type_amount1 * operation_type_progress1
|
||||
) / 100
|
||||
WHEN operation_type_id2 = 113 THEN (
|
||||
operation_type_amount2 * operation_type_progress2
|
||||
) / 100
|
||||
WHEN operation_type_id3 = 113 THEN (
|
||||
operation_type_amount3 * operation_type_progress3
|
||||
) / 100
|
||||
WHEN operation_type_id4 = 113 THEN (
|
||||
operation_type_amount4 * operation_type_progress4
|
||||
) / 100
|
||||
END
|
||||
),2) AS DarzgiriDone,
|
||||
ROUND(SUM(
|
||||
CASE
|
||||
WHEN operation_type_id1 = 112 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 112 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 112 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 112 THEN operation_type_tonaj4
|
||||
WHEN operation_type_id1 = 113 THEN operation_type_tonaj1
|
||||
WHEN operation_type_id2 = 113 THEN operation_type_tonaj2
|
||||
WHEN operation_type_id3 = 113 THEN operation_type_tonaj3
|
||||
WHEN operation_type_id4 = 113 THEN operation_type_tonaj4
|
||||
END
|
||||
),2) AS LakeGiriTonajkol,
|
||||
ROUND(AVG(progress_project)) as progress_project
|
||||
FROM (
|
||||
SELECT unique_code,
|
||||
date_,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
MAX(operation_type_tonaj1) - MIN(operation_type_tonaj1) AS operation_type_tonaj1,
|
||||
MAX(operation_type_progress1) - MIN(operation_type_progress1) AS operation_type_progress1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
MAX(operation_type_tonaj2) - MIN(operation_type_tonaj2) AS operation_type_tonaj2,
|
||||
MAX(operation_type_progress2) - MIN(operation_type_progress2) AS operation_type_progress2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
MAX(operation_type_tonaj3) - MIN(operation_type_tonaj3) AS operation_type_tonaj3,
|
||||
MAX(operation_type_progress3) - MIN(operation_type_progress3) AS operation_type_progress3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
MAX(operation_type_tonaj4) - MIN(operation_type_tonaj4) AS operation_type_tonaj4,
|
||||
MAX(operation_type_progress4) - MIN(operation_type_progress4) AS operation_type_progress4,
|
||||
MAX(progress_project) - MIN(progress_project) AS progress_project
|
||||
FROM (
|
||||
SELECT project_type_id,
|
||||
unique_code,
|
||||
last_date_update AS date_,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
operation_type_progress1,
|
||||
operation_type_tonaj1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
operation_type_progress2,
|
||||
operation_type_tonaj2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
operation_type_progress3,
|
||||
operation_type_tonaj3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
operation_type_progress4,
|
||||
operation_type_tonaj4,
|
||||
progress_project
|
||||
FROM contract_subitems
|
||||
UNION
|
||||
SELECT project_type_id,
|
||||
unique_code,
|
||||
last_date_update AS date_,
|
||||
province_id,
|
||||
province_fa,
|
||||
operation_type_id1,
|
||||
operation_type_amount1,
|
||||
operation_type_progress1,
|
||||
operation_type_tonaj1,
|
||||
operation_type_id2,
|
||||
operation_type_amount2,
|
||||
operation_type_progress2,
|
||||
operation_type_tonaj2,
|
||||
operation_type_id3,
|
||||
operation_type_amount3,
|
||||
operation_type_progress3,
|
||||
operation_type_tonaj3,
|
||||
operation_type_id4,
|
||||
operation_type_amount4,
|
||||
operation_type_progress4,
|
||||
operation_type_tonaj4,
|
||||
progress_project
|
||||
FROM contract_sub_items_histories
|
||||
) AS merged_table
|
||||
WHERE project_type_id = 1
|
||||
GROUP BY unique_code
|
||||
) AS mreged_statistics_table WHERE 1=1 ";
|
||||
|
||||
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$this->province}";
|
||||
}
|
||||
|
||||
if ($this->fromDate) {
|
||||
$query .= " AND date_ BETWEEN '{$this->fromDate} 00:00:00' AND '{$this->toDate} 23:59:59'";
|
||||
}
|
||||
|
||||
$query .= " GROUP BY province_id
|
||||
ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$sum = [
|
||||
'AsphaltGarmDone' => 0,
|
||||
'MaseAsphaltDone' => 0,
|
||||
'BazyaftSardGarmDone' => 0,
|
||||
'RokeshTghviyatiTonajeKol' => 0,
|
||||
'mirosurfacingDone' => 0,
|
||||
'ChipSailDone' => 0,
|
||||
'SlarySaildDone' => 0,
|
||||
'ScrubSailDone' => 0,
|
||||
'FogSailDone' => 0,
|
||||
'SailKatDone' => 0,
|
||||
'KipSailDone' => 0,
|
||||
'AsphaltRedmixDone' => 0,
|
||||
'RokeshHefazatiTonajeKol' => 0,
|
||||
'LakegiriDone' => 0,
|
||||
'DarzgiriDone' => 0,
|
||||
'LakeGiriTonajkol' => 0,
|
||||
'qty' => 0,
|
||||
'progress_project' => 0
|
||||
];
|
||||
|
||||
foreach ($data as $value) {
|
||||
$array[$value->province_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
|
||||
'AsphaltGarmDone' => $value->AsphaltGarmDone,
|
||||
'MaseAsphaltDone' => $value->MaseAsphaltDone,
|
||||
'BazyaftSardGarmDone' => $value->BazyaftSardGarmDone,
|
||||
'RokeshTghviyatiTonajeKol' => $value->RokeshTghviyatiTonajeKol,
|
||||
'mirosurfacingDone' => $value->mirosurfacingDone,
|
||||
'ChipSailDone' => $value->ChipSailDone,
|
||||
'SlarySaildDone' => $value->SlarySaildDone,
|
||||
'ScrubSailDone' => $value->ScrubSailDone,
|
||||
'FogSailDone' => $value->FogSailDone,
|
||||
'SailKatDone' => $value->SailKatDone,
|
||||
'KipSailDone' => $value->KipSailDone,
|
||||
'AsphaltRedmixDone' => $value->AsphaltRedmixDone,
|
||||
'RokeshHefazatiTonajeKol' => $value->RokeshHefazatiTonajeKol,
|
||||
'LakegiriDone' => $value->LakegiriDone,
|
||||
'DarzgiriDone' => $value->DarzgiriDone,
|
||||
'LakeGiriTonajkol' => $value->LakeGiriTonajkol,
|
||||
|
||||
'qty' => $value->qty,
|
||||
'progress_project' => $value->progress_project,
|
||||
];
|
||||
$sum['AsphaltGarmDone'] += $value->AsphaltGarmDone;
|
||||
$sum['MaseAsphaltDone'] += $value->MaseAsphaltDone;
|
||||
$sum['BazyaftSardGarmDone'] += $value->BazyaftSardGarmDone;
|
||||
$sum['RokeshTghviyatiTonajeKol'] += $value->RokeshTghviyatiTonajeKol;
|
||||
$sum['mirosurfacingDone'] += $value->mirosurfacingDone;
|
||||
$sum['ChipSailDone'] += $value->ChipSailDone;
|
||||
$sum['SlarySaildDone'] += $value->SlarySaildDone;
|
||||
$sum['ScrubSailDone'] += $value->ScrubSailDone;
|
||||
$sum['FogSailDone'] += $value->FogSailDone;
|
||||
$sum['SailKatDone'] += $value->SailKatDone;
|
||||
$sum['KipSailDone'] += $value->KipSailDone;
|
||||
$sum['AsphaltRedmixDone'] += $value->AsphaltRedmixDone;
|
||||
$sum['RokeshHefazatiTonajeKol'] += $value->RokeshHefazatiTonajeKol;
|
||||
$sum['LakegiriDone'] += $value->LakegiriDone;
|
||||
$sum['DarzgiriDone'] += $value->DarzgiriDone;
|
||||
$sum['LakeGiriTonajkol'] += $value->LakeGiriTonajkol;
|
||||
$sum['qty'] += $value->qty;
|
||||
$sum['progress_project'] += $value->progress_project;
|
||||
}
|
||||
|
||||
return view('excel.Maintanance.summaryAccidentPerformanceProvince', [
|
||||
'sum' => $sum,
|
||||
'array' => $array,
|
||||
'sumShow' => $this->province ? 0 :1,
|
||||
'fromFa' => $this->fromDate ?? null,
|
||||
'toFa' => $this->toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
86
app/Exports/ProposalExport.php
Normal file
86
app/Exports/ProposalExport.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\Proposal as Proposal;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ProposalExport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($province = null)
|
||||
{
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$province = $this->province ?? null;
|
||||
|
||||
$data = Proposal::when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->get();
|
||||
|
||||
return view('excel.Proposal', [
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
26
app/Exports/Receipts/AllSheets.php
Normal file
26
app/Exports/Receipts/AllSheets.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Receipts;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\Receipts\ReceiptAllReport;
|
||||
use App\Exports\Receipts\ReceiptCityReport;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new ReceiptAllReport($this->fromDate, $this->toDate, $this->province),
|
||||
// 1 => new ReceiptCityReport($this->fromDate, $this->toDate, $this->province),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
93
app/Exports/Receipts/ReceiptAllReport.php
Normal file
93
app/Exports/Receipts/ReceiptAllReport.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Receipts;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\Accident;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class ReceiptAllReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
|
||||
$province = $this->province ?? null;
|
||||
$fromDate = $this->fromDate ?? \Carbon\Carbon::now()->subDays(7);
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province;
|
||||
|
||||
$data = \App\Models\Accident::whereBetween('created_at', [$fromDate . ' 00:00:00', $toDate . ' 23:59:59'])
|
||||
->select(DB::raw('*'))
|
||||
->when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->with('damages')
|
||||
->get();
|
||||
return view('excel.Receipt.All', [
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
112
app/Exports/Receipts/ReceiptCityReport.php
Normal file
112
app/Exports/Receipts/ReceiptCityReport.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\Receipts;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\Accident;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use App\Models\User as UserORM;
|
||||
|
||||
class ReceiptCityReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
|
||||
$fromDate = $this->fromDate ?? null;
|
||||
$toDate = $this->toDate ?? null;
|
||||
$province = $this->province_id ?? null;
|
||||
|
||||
$data['list'] = UserORM::When($fromDate, function ($query) use ($fromDate, $toDate) {
|
||||
return $query->whereBetween('created_at', [$fromDate, $toDate]);
|
||||
})
|
||||
->when($province, function ($query) use ($province) {
|
||||
return $query->whereIn('province_id', $province);
|
||||
})
|
||||
->get();
|
||||
|
||||
return view('excel.user-list', [
|
||||
'array' => $data,
|
||||
'fromDate' => $fromDate,
|
||||
'toDate' => $toDate
|
||||
]);
|
||||
|
||||
|
||||
$province = $this->province ?? null;
|
||||
$fromDate = $this->fromDate ?? \Carbon\Carbon::now()->subDays(7);
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
|
||||
$data = \App\Models\Accident::whereBetween('accident_date', [$fromDate . ' 00:00:00', $toDate . ' 23:59:59'])
|
||||
->select(DB::raw('COUNT(*) as all_items'), DB::raw('COUNT(CASE WHEN status = 2 OR status=3 THEN 1 END) as tedad_vosol_shode'), DB::raw('sum(CASE WHEN status = 2 OR status=3 THEN deposit_amount END) as majmoee_vosol_shode'),'province_fa', DB::raw('SUM(deposit_amount) as sum'), 'city_fa')
|
||||
->when($province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->groupBy('city_id')
|
||||
->get();
|
||||
return view('excel.Receipt.City', [
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
103
app/Exports/RoadDanger/AccidentHotspotProjectsSheet.php
Normal file
103
app/Exports/RoadDanger/AccidentHotspotProjectsSheet.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadDanger;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class AccidentHotspotProjectsSheet implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = $this->province;
|
||||
$last_status_id = $this->last_status_id;
|
||||
|
||||
$data = ContractSubItems::where('project_type_id', 2)
|
||||
->when($this->fromDate, function ($query) use ($fromDate, $toDate) {
|
||||
return $query->whereBetween('created_at', [$fromDate, $toDate]);
|
||||
})
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->when($this->last_status_id, function ($query, $last_status_id) {
|
||||
return $query->where('last_status_id', $last_status_id);
|
||||
})
|
||||
->orderBy('province_id', 'ASC')
|
||||
->with('Contracts:id,contract_peymankar')
|
||||
->get();
|
||||
|
||||
return view('excel.RoadDanger.AccidentHotspotProjects', [
|
||||
'roads' => $data,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
380
app/Exports/RoadDanger/CompareProgramAndFunction.php
Normal file
380
app/Exports/RoadDanger/CompareProgramAndFunction.php
Normal file
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadDanger;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = $this->province;
|
||||
$last_status_id = $this->last_status_id;
|
||||
$provinces = \App\Models\Province::when($province, function($query, $province) {
|
||||
return $query->where('id', $province);
|
||||
})
|
||||
->get();
|
||||
|
||||
$array = [];
|
||||
foreach ($provinces as $item) {
|
||||
$array[$item->id] = [
|
||||
'province_fa' => $item->name_fa,
|
||||
'TarizRahCount' => 0,
|
||||
'EslahGhosCount' => 0,
|
||||
'TaransheBardariCount' => 0,
|
||||
'EhdasMeydanCount' => 0,
|
||||
'EhdasTaghatoCount' => 0,
|
||||
'ImenSaziCount' => 0,
|
||||
'EslahVoroodiCount' => 0,
|
||||
'EhdasToonelCount' => 0,
|
||||
'EhdasVariantCount' => 0,
|
||||
'TarizAbnieFaniCount' => 0,
|
||||
'SakhtHaelCount' => 0,
|
||||
'SayerCount' => 0,
|
||||
'countAll' => 0,
|
||||
'TarizRahAvg' => 0,
|
||||
'EslahGhosAvg' => 0,
|
||||
'TaransheBardariAvg' => 0,
|
||||
'EhdasMeydanAvg' => 0,
|
||||
'EhdasTaghatoAvg' => 0,
|
||||
'ImenSaziAvg' => 0,
|
||||
'EslahVoroodiAvg' => 0,
|
||||
'EhdasToonelAvg' => 0,
|
||||
'EhdasVariantAvg' => 0,
|
||||
'TarizAbnieFaniAvg' => 0,
|
||||
'SakhtHaelAvg' => 0,
|
||||
'SayerAvg' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$query = "SELECT
|
||||
COUNT(CASE WHEN operation_type_id1 = 201 OR
|
||||
operation_type_id2 = 201
|
||||
OR
|
||||
operation_type_id3 = 201
|
||||
OR
|
||||
operation_type_id4 = 201
|
||||
THEN 1 END) AS TarizRahCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 201 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 201 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 201 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 201 THEN operation_type_progress4
|
||||
END) AS TarizRahAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 202 OR
|
||||
operation_type_id2 = 202
|
||||
OR
|
||||
operation_type_id3 = 202
|
||||
OR
|
||||
operation_type_id4 = 202
|
||||
THEN 1 END) AS EslahGhosCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 202 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 202 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 202 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 202 THEN operation_type_progress4
|
||||
END) AS EslahGhosAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 203 OR
|
||||
operation_type_id2 = 203
|
||||
OR
|
||||
operation_type_id3 = 203
|
||||
OR
|
||||
operation_type_id4 = 203
|
||||
THEN 1 END) AS TaransheBardariCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 203 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 203 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 203 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 203 THEN operation_type_progress4
|
||||
END) AS TaransheBardariAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 204 OR
|
||||
operation_type_id2 = 204
|
||||
OR
|
||||
operation_type_id3 = 204
|
||||
OR
|
||||
operation_type_id4 = 204
|
||||
THEN 1 END) AS EhdasMeydanCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 204 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 204 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 204 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 204 THEN operation_type_progress4
|
||||
END) AS EhdasMeydanAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 205 OR
|
||||
operation_type_id2 = 205
|
||||
OR
|
||||
operation_type_id3 = 205
|
||||
OR
|
||||
operation_type_id4 = 205
|
||||
THEN 1 END) AS EhdasTaghatoCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 205 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 205 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 205 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 205 THEN operation_type_progress4
|
||||
END) AS EhdasTaghatoAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 206 OR
|
||||
operation_type_id2 = 206
|
||||
OR
|
||||
operation_type_id3 = 206
|
||||
OR
|
||||
operation_type_id4 = 206
|
||||
THEN 1 END) AS ImenSaziCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 206 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 206 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 206 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 206 THEN operation_type_progress4
|
||||
END) AS ImenSaziAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 207 OR
|
||||
operation_type_id2 = 207
|
||||
OR
|
||||
operation_type_id3 = 207
|
||||
OR
|
||||
operation_type_id4 = 207
|
||||
THEN 1 END) AS EslahVoroodiCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 207 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 207 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 207 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 207 THEN operation_type_progress4
|
||||
END) AS EslahVoroodiAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 208 OR
|
||||
operation_type_id2 = 208
|
||||
OR
|
||||
operation_type_id3 = 208
|
||||
OR
|
||||
operation_type_id4 = 208
|
||||
THEN 1 END) AS EhdasToonelCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 208 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 208 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 208 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 208 THEN operation_type_progress4
|
||||
END) AS EhdasToonelAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 209 OR
|
||||
operation_type_id2 = 209
|
||||
OR
|
||||
operation_type_id3 = 209
|
||||
OR
|
||||
operation_type_id4 = 209
|
||||
THEN 1 END) AS EhdasVariantCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 209 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 209 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 209 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 209 THEN operation_type_progress4
|
||||
END) AS EhdasVariantAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 210 OR
|
||||
operation_type_id2 = 210
|
||||
OR
|
||||
operation_type_id3 = 210
|
||||
OR
|
||||
operation_type_id4 = 210
|
||||
THEN 1 END) AS TarizAbnieFaniCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 210 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 210 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 210 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 210 THEN operation_type_progress4
|
||||
END) AS TarizAbnieFaniAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 211 OR
|
||||
operation_type_id2 = 211
|
||||
OR
|
||||
operation_type_id3 = 211
|
||||
OR
|
||||
operation_type_id4 = 211
|
||||
THEN 1 END) AS SakhtHaelCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 211 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 211 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 211 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 211 THEN operation_type_progress4
|
||||
END) AS SakhtHaelAvg,
|
||||
COUNT(CASE WHEN operation_type_id1 = 212 OR
|
||||
operation_type_id2 = 212
|
||||
OR
|
||||
operation_type_id3 = 212
|
||||
OR
|
||||
operation_type_id4 = 212
|
||||
THEN 1 END) AS SayerCount,
|
||||
AVG(CASE WHEN operation_type_id1 = 212 THEN operation_type_progress1
|
||||
WHEN operation_type_id2 = 212 THEN operation_type_progress2
|
||||
WHEN operation_type_id3 = 212 THEN operation_type_progress3
|
||||
WHEN operation_type_id4 = 212 THEN operation_type_progress4
|
||||
END) AS SayerAvg,
|
||||
COUNT(*) AS countAll,province_fa,province_id FROM contract_subitems
|
||||
WHERE project_type_id = 2
|
||||
|
||||
";
|
||||
if ($this->fromDate && $this->toDate) {
|
||||
$query .= " AND contract_date_from_parent_contract BETWEEN '{$fromDate} 00:00:00' and '{$toDate} 23:59:59'\n";
|
||||
}
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$province}\n";
|
||||
}
|
||||
|
||||
if ($this->last_status_id) {
|
||||
$query .= " AND last_status_id = {$last_status_id}\n";
|
||||
}
|
||||
|
||||
$query .= " GROUP BY province_id
|
||||
ORDER BY province_id ASC;";
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$sum = [
|
||||
'TarizRahCount' => 0,
|
||||
'EslahGhosCount' => 0,
|
||||
'TaransheBardariCount' => 0,
|
||||
'EhdasMeydanCount' => 0,
|
||||
'EhdasTaghatoCount' => 0,
|
||||
'ImenSaziCount' => 0,
|
||||
'EslahVoroodiCount' => 0,
|
||||
'EhdasToonelCount' => 0,
|
||||
'EhdasVariantCount' => 0,
|
||||
'TarizAbnieFaniCount' => 0,
|
||||
'SakhtHaelCount' => 0,
|
||||
'SayerCount' => 0,
|
||||
'countAll' => 0,
|
||||
'TarizRahAvg' => 0,
|
||||
'EslahGhosAvg' => 0,
|
||||
'TaransheBardariAvg' => 0,
|
||||
'EhdasMeydanAvg' => 0,
|
||||
'EhdasTaghatoAvg' => 0,
|
||||
'ImenSaziAvg' => 0,
|
||||
'EslahVoroodiAvg' => 0,
|
||||
'EhdasToonelAvg' => 0,
|
||||
'EhdasVariantAvg' => 0,
|
||||
'TarizAbnieFaniAvg' => 0,
|
||||
'SakhtHaelAvg' => 0,
|
||||
'SayerAvg' => 0,
|
||||
];
|
||||
|
||||
foreach ($data as $value) {
|
||||
$array[$value->province_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
'TarizRahCount' => $value->TarizRahCount ?? '-',
|
||||
'EslahGhosCount' => $value->EslahGhosCount ?? '-',
|
||||
'TaransheBardariCount' => $value->TaransheBardariCount ?? '-',
|
||||
'EhdasMeydanCount' => $value->EhdasMeydanCount ?? '-',
|
||||
'EhdasTaghatoCount' => $value->EhdasTaghatoCount ?? '-',
|
||||
'ImenSaziCount' => $value->ImenSaziCount ?? '-',
|
||||
'EslahVoroodiCount' => $value->EslahVoroodiCount ?? '-',
|
||||
'EhdasToonelCount' => $value->EhdasToonelCount ?? '-',
|
||||
'EhdasVariantCount' => $value->EhdasVariantCount ?? '-',
|
||||
'TarizAbnieFaniCount' => $value->TarizAbnieFaniCount ?? '-',
|
||||
'SakhtHaelCount' => $value->SakhtHaelCount ?? '-',
|
||||
'SayerCount' => $value->SakhtHaelCount ?? '-',
|
||||
'countAll' => $value->countAll ?? '-',
|
||||
'TarizRahAvg' => $value->TarizRahAvg ?? '-',
|
||||
'EslahGhosAvg' => $value->EslahGhosAvg ?? '-',
|
||||
'TaransheBardariAvg' => $value->TaransheBardariAvg ?? '-',
|
||||
'EhdasMeydanAvg' => $value->EhdasMeydanAvg ?? '-',
|
||||
'EhdasTaghatoAvg' => $value->EhdasTaghatoAvg ?? '-',
|
||||
'ImenSaziAvg' => $value->ImenSaziAvg ?? '-',
|
||||
'EslahVoroodiAvg' => $value->EslahVoroodiAvg ?? '-',
|
||||
'EhdasToonelAvg' => $value->EhdasToonelAvg ?? '-',
|
||||
'EhdasVariantAvg' => $value->EhdasVariantAvg ?? '-',
|
||||
'TarizAbnieFaniAvg' => $value->TarizAbnieFaniAvg ?? '-',
|
||||
'SakhtHaelAvg' => $value->SakhtHaelAvg ?? '-',
|
||||
'SayerAvg' => $value->SakhtHaelAvg ?? '-',
|
||||
];
|
||||
|
||||
$sum['TarizRahCount'] += $value->TarizRahCount;
|
||||
$sum['EslahGhosCount'] += $value->EslahGhosCount;
|
||||
$sum['TaransheBardariCount'] += $value->TaransheBardariCount;
|
||||
$sum['EhdasMeydanCount'] += $value->EhdasMeydanCount;
|
||||
$sum['EhdasTaghatoCount'] += $value->EhdasTaghatoCount;
|
||||
$sum['ImenSaziCount'] += $value->ImenSaziCount;
|
||||
$sum['EslahVoroodiCount'] += $value->EslahVoroodiCount;
|
||||
$sum['EhdasToonelCount'] += $value->EhdasToonelCount;
|
||||
$sum['EhdasVariantCount'] += $value->EhdasVariantCount;
|
||||
$sum['TarizAbnieFaniCount'] += $value->TarizAbnieFaniCount;
|
||||
$sum['SakhtHaelCount'] += $value->SakhtHaelCount;
|
||||
$sum['SayerCount'] += $value->SakhtHaelCount;
|
||||
$sum['countAll'] += $value->countAll;
|
||||
$sum['TarizRahAvg'] += $value->TarizRahAvg;
|
||||
$sum['EslahGhosAvg'] += $value->EslahGhosAvg;
|
||||
$sum['TaransheBardariAvg'] += $value->TaransheBardariAvg;
|
||||
$sum['EhdasMeydanAvg'] += $value->EhdasMeydanAvg;
|
||||
$sum['EhdasTaghatoAvg'] += $value->EhdasTaghatoAvg;
|
||||
$sum['ImenSaziAvg'] += $value->ImenSaziAvg;
|
||||
$sum['EslahVoroodiAvg'] += $value->EslahVoroodiAvg;
|
||||
$sum['EhdasToonelAvg'] += $value->EhdasToonelAvg;
|
||||
$sum['EhdasVariantAvg'] += $value->EhdasVariantAvg;
|
||||
$sum['TarizAbnieFaniAvg'] += $value->TarizAbnieFaniAvg;
|
||||
$sum['SakhtHaelAvg'] += $value->SakhtHaelAvg;
|
||||
$sum['SayerAvg'] += $value->SakhtHaelAvg;
|
||||
|
||||
}
|
||||
|
||||
// dd($data);
|
||||
return view('excel.RoadDanger.CompareProgramAndFunction', [
|
||||
'roads' => $array,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'sum' => $sum,
|
||||
'province_count' => $provinces->count(),
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
34
app/Exports/RoadDanger/allSheet.php
Normal file
34
app/Exports/RoadDanger/allSheet.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadDanger;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
use App\Exports\RoadDanger\AccidentHotspotProjectsSheet;
|
||||
use App\Exports\RoadDanger\summaryAccidentPerformanceProvince;
|
||||
use App\Exports\RoadDanger\summaryAccidentPerformanceCity;
|
||||
use App\Exports\RoadDanger\summaryAccidentPerformanceProject;
|
||||
use App\Exports\RoadDanger\CompareProgramAndFunction;
|
||||
|
||||
|
||||
class allSheet implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new AccidentHotspotProjectsSheet($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
1 => new summaryAccidentPerformanceProvince($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
2 => new summaryAccidentPerformanceCity($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
3 => new summaryAccidentPerformanceProject($this->fromDate, $this->toDate, $this->province, $this->last_status_id),
|
||||
4 => new CompareProgramAndFunction($this->fromDate, $this->toDate, $this->province, $this->last_status_id)
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
141
app/Exports/RoadDanger/summaryAccidentPerformanceCity.php
Normal file
141
app/Exports/RoadDanger/summaryAccidentPerformanceCity.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadDanger;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class summaryAccidentPerformanceCity implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = $this->province;
|
||||
$last_status_id = $this->last_status_id;
|
||||
|
||||
$cities = \App\Models\City::join('provinces', 'cities.province_id', '=', 'provinces.id')
|
||||
->select(
|
||||
'provinces.name_fa as province_fa',
|
||||
'provinces.id as province_id',
|
||||
'cities.name_fa as city_fa',
|
||||
'cities.id as city_id',
|
||||
)
|
||||
->when($province, function($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->orderBy('cities.province_id', 'ASC')
|
||||
->get();
|
||||
$array = [];
|
||||
|
||||
foreach ($cities as $key => $value) {
|
||||
$array[$value->city_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
'city_fa' => $value->city_fa,
|
||||
'avg' => '-',
|
||||
'count' => '-'
|
||||
];
|
||||
}
|
||||
|
||||
$data = ContractSubItems::where('project_type_id', 2)
|
||||
->when($this->fromDate, function ($query) use ($fromDate, $toDate) {
|
||||
return $query->whereBetween('created_at', [$fromDate, $toDate]);
|
||||
})
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->when($this->last_status_id, function ($query, $last_status_id) {
|
||||
return $query->where('last_status_id', $last_status_id);
|
||||
})
|
||||
->orderBy('province_id', 'ASC')
|
||||
->select('province_fa', 'city_fa', 'city_id')
|
||||
->selectRaw("avg(progress_project) as avg")
|
||||
->selectRaw('count(*) as count')
|
||||
->groupBy('city_id')
|
||||
->get();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$array[$value->city_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
'city_fa' => $value->city_fa,
|
||||
'avg' => $value->avg,
|
||||
'count' => $value->count
|
||||
];
|
||||
}
|
||||
return view('excel.RoadDanger.summaryAccidentPerformanceCity', [
|
||||
'roads' => $array,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
106
app/Exports/RoadDanger/summaryAccidentPerformanceProject.php
Normal file
106
app/Exports/RoadDanger/summaryAccidentPerformanceProject.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadDanger;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class summaryAccidentPerformanceProject implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = $this->province;
|
||||
$last_status_id = $this->last_status_id;
|
||||
|
||||
$data = ContractSubItems::where('project_type_id', 2)
|
||||
->when($this->fromDate, function ($query) use ($fromDate, $toDate) {
|
||||
return $query->whereBetween('created_at', [$fromDate, $toDate]);
|
||||
})
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->when($this->last_status_id, function ($query, $last_status_id) {
|
||||
return $query->where('last_status_id', $last_status_id);
|
||||
})
|
||||
->orderBy('province_id', 'ASC')
|
||||
|
||||
->select('province_fa', 'city_fa', 'unique_code', 'axis_type_fa', 'axis_name_fa', 'project_title', 'progress_project')
|
||||
->get();
|
||||
|
||||
return view('excel.RoadDanger.summaryAccidentPerformanceProject', [
|
||||
'roads' => $data,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
139
app/Exports/RoadDanger/summaryAccidentPerformanceProvince.php
Normal file
139
app/Exports/RoadDanger/summaryAccidentPerformanceProvince.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadDanger;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class summaryAccidentPerformanceProvince implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = $this->province;
|
||||
$last_status_id = $this->last_status_id;
|
||||
|
||||
|
||||
$array = [];
|
||||
|
||||
$provinces = \App\Models\Province::select('id', 'name_fa')
|
||||
->when($province, function($query, $province) {
|
||||
return $query->where('id', $province);
|
||||
})
|
||||
->get();
|
||||
foreach ($provinces as $key => $value) {
|
||||
$array[$value->id] = [
|
||||
'province_fa' => $value->name_fa,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
$data = ContractSubItems::where('project_type_id', 2)
|
||||
// ->whereNotNull('progress_project')
|
||||
->when($this->fromDate, function ($query) use ($fromDate, $toDate) {
|
||||
return $query->whereBetween('created_at', [$fromDate, $toDate]);
|
||||
})
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->when($this->last_status_id, function ($query, $last_status_id) {
|
||||
return $query->where('last_status_id', $last_status_id);
|
||||
})
|
||||
->orderBy('province_id', 'ASC')
|
||||
|
||||
->select('province_fa', 'province_id')
|
||||
->selectRaw("avg(progress_project) as avg")
|
||||
->selectRaw('count(*) as count')
|
||||
->groupBy('province_id')
|
||||
->get();
|
||||
|
||||
$sum = [
|
||||
'avg' => 0,
|
||||
'count' => 0,
|
||||
];
|
||||
foreach ($data as $key => $value) {
|
||||
$array[$value->province_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
'avg' => round($value->avg, 1),
|
||||
'count' => $value->count,
|
||||
];
|
||||
$sum['avg'] += $value->avg;
|
||||
$sum['count'] += $value->count;
|
||||
}
|
||||
|
||||
|
||||
return view('excel.RoadDanger.summaryAccidentPerformanceProvince', [
|
||||
'roads' => $array,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'sum' => $sum,
|
||||
'province_count' => $provinces->count(),
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
22
app/Exports/RoadItems/AllSheets.php
Normal file
22
app/Exports/RoadItems/AllSheets.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadItems;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
// use App\Exports\RoadItems\RoadItems;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new RoadItems($this->fromDate, $this->toDate, $this->province),
|
||||
];
|
||||
}
|
||||
}
|
||||
99
app/Exports/RoadItems/RoadItems.php
Normal file
99
app/Exports/RoadItems/RoadItems.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadItems;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
|
||||
class RoadItems implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? null;
|
||||
$toDate = $this->toDate ?? null;
|
||||
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province ?? null;
|
||||
|
||||
$data = RoadItemsProject::where('status', 1)
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->whereBetween('activity_date_time', [$fromDate, $toDate])
|
||||
->get();
|
||||
|
||||
return view('excel.RoadItem.RoadItemsList', [
|
||||
'data' => $data,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
21
app/Exports/RoadPatrol/AllSheets.php
Normal file
21
app/Exports/RoadPatrol/AllSheets.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadPatrol;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class AllSheets implements WithMultipleSheets
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
public function sheets(): array
|
||||
{
|
||||
return [
|
||||
0 => new RoadPatrol($this->fromDate, $this->toDate, $this->province),
|
||||
];
|
||||
}
|
||||
}
|
||||
96
app/Exports/RoadPatrol/RoadPatrol.php
Normal file
96
app/Exports/RoadPatrol/RoadPatrol.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadPatrol;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\RoadPatrol as RoadPatrolModel;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
class RoadPatrol implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate ?? null;
|
||||
$toDate = $this->toDate ?? null;
|
||||
|
||||
$fromDate = $this->fromDate ?? '2021-03-21';
|
||||
$toDate = $this->toDate ?? \Carbon\Carbon::now();
|
||||
$province = $this->province ?? null;
|
||||
|
||||
$data = RoadPatrolModel::where('status', 1)
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->whereBetween('created_at', [$fromDate, $toDate])
|
||||
->get();
|
||||
|
||||
return view('excel.RoadPatrol.RoadPatrolList', [
|
||||
'data' => $data,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
294
app/Exports/RoadUpgrade/CompareProgramAndFunction.php
Normal file
294
app/Exports/RoadUpgrade/CompareProgramAndFunction.php
Normal file
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadUpgrade;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use App\Models\Province;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class CompareProgramAndFunction implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
public function view(): View
|
||||
{
|
||||
|
||||
$array = [];
|
||||
$province = $this->province;
|
||||
|
||||
foreach (Province::when($province, function ($query, $province) {
|
||||
return $query->where('id', $province);
|
||||
})->get() as $item) {
|
||||
$array[$item->id] = [
|
||||
'province_fa' => $item->name_fa,
|
||||
|
||||
'BotoniDoing' => 0,
|
||||
'BotoniDone' => 0,
|
||||
|
||||
'FeleziDoing' => 0,
|
||||
'FeleziDone' => 0,
|
||||
|
||||
'TooliLightingDoing' => 0,
|
||||
'TooliLightingDone' => 0,
|
||||
|
||||
'NoghteyiLightingDoing' => 0,
|
||||
'NoghteyiLightingDone' => 0,
|
||||
|
||||
'AlaemImeniDoing' => 0,
|
||||
'AlaemImeniDone' => 0,
|
||||
|
||||
'KhatkeshiDoing' => 0,
|
||||
'KhatkeshiDone' => 0,
|
||||
|
||||
'ShirvaniDoing' => 0,
|
||||
'ShirvaniDone' => 0,
|
||||
|
||||
'SayerDoing' => 0,
|
||||
'SayerDone' => 0,
|
||||
|
||||
'countAll' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$query = "SELECT
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 301 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 301 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 301 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 301 THEN operation_type_amount4
|
||||
END)) AS BotoniDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 301 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 301 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 301 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 301 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS BotoniDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 302 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 302 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 302 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 302 THEN operation_type_amount4
|
||||
END)) AS FeleziDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 302 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 302 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 302 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 302 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS FeleziDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 303 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 303 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 303 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 303 THEN operation_type_amount4
|
||||
END)) AS TooliLightingDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 303 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 303 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 303 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 303 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS TooliLightingDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 304 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 304 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 304 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 304 THEN operation_type_amount4
|
||||
END)) AS NoghteyiLightingDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 304 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 304 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 304 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 304 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS NoghteyiLightingDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 305 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 305 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 305 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 305 THEN operation_type_amount4
|
||||
END)) AS AlaemImeniDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 305 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 305 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 305 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 305 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS AlaemImeniDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 306 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 306 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 306 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 306 THEN operation_type_amount4
|
||||
END)) AS KhatkeshiDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 306 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 306 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 306 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 306 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS KhatkeshiDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 307 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 307 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 307 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 307 THEN operation_type_amount4
|
||||
END)) AS ShirvaniDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 307 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 307 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 307 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 307 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS ShirvaniDone,
|
||||
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 308 THEN operation_type_amount1
|
||||
WHEN operation_type_id2 = 308 THEN operation_type_amount2
|
||||
WHEN operation_type_id3 = 308 THEN operation_type_amount3
|
||||
WHEN operation_type_id4 = 308 THEN operation_type_amount4
|
||||
END)) AS SayerDoing,
|
||||
ROUND(SUM(CASE WHEN operation_type_id1 = 308 THEN (operation_type_amount1 * operation_type_progress1)/100
|
||||
WHEN operation_type_id2 = 308 THEN (operation_type_amount2 * operation_type_progress2)/100
|
||||
WHEN operation_type_id3 = 308 THEN (operation_type_amount3 * operation_type_progress3)/100
|
||||
WHEN operation_type_id4 = 308 THEN (operation_type_amount4 * operation_type_progress4)/100
|
||||
END)) AS SayerDone,
|
||||
|
||||
COUNT(*) AS countAll,
|
||||
province_fa,
|
||||
province_id
|
||||
FROM contract_subitems
|
||||
WHERE project_type_id = 3
|
||||
";
|
||||
|
||||
if ($this->province) {
|
||||
$query .= " AND province_id = {$province}\n";
|
||||
}
|
||||
|
||||
$query .= " GROUP BY province_id
|
||||
ORDER BY province_id ASC;";
|
||||
|
||||
$data = DB::select(DB::raw($query));
|
||||
|
||||
$sum = [
|
||||
'BotoniDoing' => 0,
|
||||
'BotoniDone' => 0,
|
||||
'FeleziDoing' => 0,
|
||||
'FeleziDone' => 0,
|
||||
'TooliLightingDoing' => 0,
|
||||
'TooliLightingDone' => 0,
|
||||
'NoghteyiLightingDoing' => 0,
|
||||
'NoghteyiLightingDone' => 0,
|
||||
'AlaemImeniDoing' => 0,
|
||||
'AlaemImeniDone' => 0,
|
||||
'KhatkeshiDoing' => 0,
|
||||
'KhatkeshiDone' => 0,
|
||||
'ShirvaniDoing' => 0,
|
||||
'ShirvaniDone' => 0,
|
||||
'SayerDoing' => 0,
|
||||
'SayerDone' => 0,
|
||||
|
||||
'countAll' => 0,
|
||||
];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$array[$value->province_id] = [
|
||||
'province_fa' => $value->province_fa,
|
||||
|
||||
'BotoniDoing' => $value->BotoniDoing,
|
||||
'BotoniDone' => $value->BotoniDone,
|
||||
'FeleziDoing' => $value->FeleziDoing,
|
||||
'FeleziDone' => $value->FeleziDone,
|
||||
'TooliLightingDoing' => $value->TooliLightingDoing,
|
||||
'TooliLightingDone' => $value->TooliLightingDone,
|
||||
'NoghteyiLightingDoing' => $value->NoghteyiLightingDoing,
|
||||
'NoghteyiLightingDone' => $value->NoghteyiLightingDone,
|
||||
'AlaemImeniDoing' => $value->AlaemImeniDoing,
|
||||
'AlaemImeniDone' => $value->AlaemImeniDone,
|
||||
'KhatkeshiDoing' => $value->KhatkeshiDoing,
|
||||
'KhatkeshiDone' => $value->KhatkeshiDone,
|
||||
'ShirvaniDoing' => $value->ShirvaniDoing,
|
||||
'ShirvaniDone' => $value->ShirvaniDone,
|
||||
'SayerDoing' => $value->SayerDoing,
|
||||
'SayerDone' => $value->SayerDone,
|
||||
|
||||
'countAll' => $value->countAll,
|
||||
];
|
||||
|
||||
$sum['BotoniDoing'] += $value->BotoniDoing;
|
||||
$sum['BotoniDone'] += $value->BotoniDone;
|
||||
$sum['FeleziDoing'] += $value->FeleziDoing;
|
||||
$sum['FeleziDone'] += $value->FeleziDone;
|
||||
$sum['TooliLightingDoing'] += $value->TooliLightingDoing;
|
||||
$sum['TooliLightingDone'] += $value->TooliLightingDone;
|
||||
$sum['NoghteyiLightingDoing'] += $value->NoghteyiLightingDoing;
|
||||
$sum['NoghteyiLightingDone'] += $value->NoghteyiLightingDone;
|
||||
$sum['AlaemImeniDoing'] += $value->AlaemImeniDoing;
|
||||
$sum['AlaemImeniDone'] += $value->AlaemImeniDone;
|
||||
$sum['KhatkeshiDoing'] += $value->KhatkeshiDoing;
|
||||
$sum['KhatkeshiDone'] += $value->KhatkeshiDone;
|
||||
$sum['ShirvaniDoing'] += $value->ShirvaniDoing;
|
||||
$sum['ShirvaniDone'] += $value->ShirvaniDone;
|
||||
$sum['SayerDoing'] += $value->SayerDoing;
|
||||
$sum['SayerDone'] += $value->SayerDone;
|
||||
|
||||
$sum['countAll'] += $value->countAll;
|
||||
}
|
||||
|
||||
return view('excel.Upgrade.CompareProgramAndFunction', [
|
||||
'array' => $array,
|
||||
'sum' => $sum,
|
||||
'sumShow' => $this->province ? 0 :1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
193
app/Exports/RoadUpgrade/RoadUpgradeSafeties.php
Normal file
193
app/Exports/RoadUpgrade/RoadUpgradeSafeties.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\RoadUpgrade;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use App\Models\ContractSubItems;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
|
||||
|
||||
class RoadUpgradeSafeties implements FromView, ShouldAutoSize, WithEvents, WithDrawings, WithStyles
|
||||
{
|
||||
public function __construct($fromDate = null, $toDate = null, $province = null, $last_status_id = null)
|
||||
{
|
||||
$this->fromDate = $fromDate ?? null;
|
||||
$this->toDate = $toDate ?? null;
|
||||
$this->province = $province ?? null;
|
||||
$this->last_status_id = $last_status_id ?? null;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$fromDate = $this->fromDate;
|
||||
$toDate = $this->toDate;
|
||||
$province = $this->province;
|
||||
$last_status_id = $this->last_status_id;
|
||||
|
||||
$data = ContractSubItems::where('project_type_id', 3)
|
||||
->when($this->province, function ($query, $province) {
|
||||
return $query->where('province_id', $province);
|
||||
})
|
||||
->when($this->last_status_id, function ($query, $last_status_id) {
|
||||
return $query->where('last_status_id', $last_status_id);
|
||||
})
|
||||
->with('Contracts:id,contract_peymankar')
|
||||
->orderBy('province_id', 'ASC')
|
||||
->get();
|
||||
|
||||
$array = [];
|
||||
foreach ($data as $road) {
|
||||
|
||||
$array[] = [
|
||||
'province' => $road->province_fa,
|
||||
'city' => $road->city_fa,
|
||||
'axis_type_fa' => $road->axis_type_fa,
|
||||
'axis_name_fa' => $road->axis_name_fa,
|
||||
'project_title' => $road->project_title,
|
||||
|
||||
'isDefined' => [
|
||||
'hefazBotoni' => $road->operation_type_id1 == '301' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '301' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '301' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '301' ? $road->operation_type_amount4 : "-"))),
|
||||
'hefazFelezi' => $road->operation_type_id1 == '302' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '302' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '302' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '302' ? $road->operation_type_amount4 : "-"))),
|
||||
'RoshanayiTooli' => $road->operation_type_id1 == '303' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '303' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '303' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '303' ? $road->operation_type_amount4 : "-"))),
|
||||
'RoshanayiNoghteyi' => $road->operation_type_id1 == '304' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '304' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '304' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '304' ? $road->operation_type_amount4 : "-"))),
|
||||
'AlaemImeni' => $road->operation_type_id1 == '305' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '305' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '305' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '305' ? $road->operation_type_amount4 : "-"))),
|
||||
'Khatkeshi' => $road->operation_type_id1 == '306' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '306' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '306' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '306' ? $road->operation_type_amount4 : "-"))),
|
||||
'TaransheBardari' => $road->operation_type_id1 == '307' ? $road->operation_type_amount1 :
|
||||
($road->operation_type_id2 == '307' ? $road->operation_type_amount2 :
|
||||
($road->operation_type_id3 == '307' ? $road->operation_type_amount3 :
|
||||
($road->operation_type_id4 == '307' ? $road->operation_type_amount4 : "-"))),
|
||||
|
||||
],
|
||||
|
||||
'isDone' => [
|
||||
'hefazBotoni' => $road->operation_type_id1 == '301' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '301' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '301' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '301' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'hefazFelezi' => $road->operation_type_id1 == '302' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '302' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '302' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '302' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'RoshanayiTooli' => $road->operation_type_id1 == '303' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '303' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '303' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '303' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 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_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 : "-"))),
|
||||
'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_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 : "-"))),
|
||||
'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_id3 == '306' ? $road->operation_type_amount3 * $road->operation_type_progress3 / 100 :
|
||||
($road->operation_type_id4 == '306' ? $road->operation_type_amount4 * $road->operation_type_progress4 / 100 : "-"))),
|
||||
'TaransheBardari' => $road->operation_type_id1 == '307' ? $road->operation_type_amount1 * $road->operation_type_progress1 / 100 :
|
||||
($road->operation_type_id2 == '307' ? $road->operation_type_amount2 * $road->operation_type_progress2 / 100 :
|
||||
($road->operation_type_id3 == '307' ? $road->operation_type_amount3 * $road->operation_type_progress3 :
|
||||
($road->operation_type_id4 == '307' ? $road->operation_type_amount4 * $road->operation_type_progress4 : "-"))),
|
||||
],
|
||||
'contract_date_from_parent_contract' => verta($road->contract_date_from_parent_contract)->format('Y/n/j'),
|
||||
'last_status_fa' => $road->last_status_fa,
|
||||
'progress_project' => $road->progress_project,
|
||||
'last_digit_project' => $road->last_digit_project,
|
||||
'last_function_operator' => $road->last_function_operator,
|
||||
'last_payable_operator' => $road->last_payable_operator,
|
||||
'complete_payable' => $road->complete_payable,
|
||||
'contract_peymankar' => $road->contracts->contract_peymankar,
|
||||
'contract_moshaver_tarahi' => $road->contract_moshaver_tarahi,
|
||||
'contract_moshaver_nezarat' => $road->contract_moshaver_nezarat,
|
||||
'operator_name' => $road->operator_name,
|
||||
'priority_project' => $road->priority_project_fa,
|
||||
'followup_priority_project' => $road->followup_priority_project,
|
||||
'operator_phone' => $road->operator_phone,
|
||||
'unique_code' => $road->unique_code,
|
||||
'updated_at_fa' => verta($road->last_date_update)->format('Y/n/j'),
|
||||
];
|
||||
}
|
||||
|
||||
return view('excel.Upgrade.RoadUpgradeSafeties', [
|
||||
'roads' => $array,
|
||||
'fromFa' => $fromDate ?? null,
|
||||
'toFa' => $toDate ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('B1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
|
||||
return [
|
||||
// Style the first row as bold text.
|
||||
'A:BA' => [
|
||||
'font' => [
|
||||
'name' => 'B Nazanin'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user