ikinci temizlik tamamlandı

This commit is contained in:
Ümit Tunç
2026-04-28 21:15:09 +03:00
parent f80443aec0
commit 37e7296527
8313 changed files with 2400677 additions and 0 deletions
@@ -0,0 +1,101 @@
<?php
$projects = active_projects();
$projects[] = "General";
foreach($projects AS $project) {
$id = str_slug($project);
$appr = setting("$id-approximate-planned-wdi");
$totalNps = apply_welded_filter(db("weld_logs"))->where("no_of_the_joint_as_per_as_built_survey", "not like", "%R%");
$currentNps = apply_welded_filter(db("weld_logs"))->where("no_of_the_joint_as_per_as_built_survey", "not like", "%R%")->whereNotNull("welding_date");
$countNps = apply_welded_filter(db("weld_logs"))->where("no_of_the_joint_as_per_as_built_survey", "not like", "%R%");
$max = 80000;
if($project != "General") {
$totalNps = $totalNps->where("project", $project);
$currentNps = $currentNps->where("project", $project);
$countNps = $countNps->where("project", $project);
$max = 20000;
}
$currentNps = $currentNps->sum("nps_1");
$totalNps = $totalNps->sum("nps_1");
$countNps = $countNps->sum("nps_1");
try {
$npsPercent = round($currentNps * 100 / $totalNps, 2);
$apprPercent = round($appr * 100 / $totalNps, 2);
} catch (\Throwable $th) {
$apprPercent = 0;
$npsPercent = 0;
}
?>
<script>
$(() => {
$('#gauge{{$id}}').dxLinearGauge({
// geometry: { orientation: 'vertical' },
scale: {
majorTick: {
visible: true,
length: 10 // Specify the length of the major tick lines
},
line: {
visible: true,
width: 5 // Set the line thickness here
},
startValue: 0,
endValue: 100,
// customTicks: [0, {{$appr}}],
},
title: {
text: '{{strtoupper($project)}}',
font: { size: 28 },
},
export: {
enabled: true,
},
tooltip: {
enabled: true,
customizeTooltip: function (info) {
console.log(info);
// Customize the tooltip text based on your logic
var text = "";
if(info.type == 'subvalue-indicator') {
if(info.index == 0) {
text = "Real Total Value: %";
} else {
text = "Approximate Value: %";
}
}
info.valueText = text + info.valueText;
}
},
value: {{$npsPercent}},
subvalues: [{{$npsPercent}}, {{$apprPercent}}],
subvalueIndicator: {
type: 'triangleMarker',
color: 'red',
tooltip: {
enabled: true,
},
},
});
});
</script>
<div id="gauge{{$id}}"></div>
<?php } ?>
@@ -0,0 +1,179 @@
<?php
$baseQuery = apply_welded_filter(db("weld_logs"));
$subcontractors = clone $baseQuery;
$subcontractors = $subcontractors
->select("ste_subcontractor")
->whereNotNull("ste_subcontractor")
->distinct()
->pluck("ste_subcontractor")
->toArray();
$monthly = apply_welded_filter(db("weld_logs"))
->select(DB::raw('(SUM(CASE WHEN type_of_joint = "S" THEN nps_1 ELSE 0 END) + 0) as sum_S'),
DB::raw('(SUM(CASE WHEN type_of_joint = "F" THEN nps_1 ELSE 0 END) + 0) as sum_F'))
->selectRaw("(SUM(nps_1) + 0) AS total_nps");
foreach ($subcontractors as $subcontractor) {
$safeSubcontractor = addslashes($subcontractor);
$monthly->selectRaw(
"(SUM(CASE WHEN ste_subcontractor = '{$safeSubcontractor}' THEN nps_1 ELSE 0 END) + 0) as " . str_slug($subcontractor, "_")
);
}
$monthly = $monthly
->selectRaw('DATE_FORMAT(welding_date, "%m.%y") as month')
->whereNotNull("welding_date")
->groupByRaw('DATE_FORMAT(welding_date, "%m.%y")')
->orderByRaw('MIN(welding_date) ASC')
->get();
// String değerleri float'a dönüştür ve null değerleri 0 yap
foreach ($monthly as $item) {
$item->sum_S = (float) ($item->sum_S ?? 0);
$item->sum_F = (float) ($item->sum_F ?? 0);
$item->total_nps = (float) ($item->total_nps ?? 0);
foreach ($subcontractors as $subcontractor) {
$fieldName = str_slug($subcontractor, "_");
if (isset($item->$fieldName)) {
$item->$fieldName = (float) ($item->$fieldName ?? 0);
} else {
$item->$fieldName = 0.0;
}
}
}
// Debug için veriyi kontrol et
// dd($monthly->toArray());
?>
<script>
const dataSource = <?php echo json_encode_tr($monthly) ?>;
$(() => {
$('#monthlyProgress').dxChart({
palette: 'colored',
dataSource: dataSource,
commonSeriesSettings: {
argumentField: 'month',
},
series: [{
valueField: 'sum_F',
name: 'Field',
type: 'bar',
color: '#008fd8',
visible: true,
}, {
valueField: 'sum_S',
name: 'Shop',
type: 'bar',
color: '#ff6b6b',
visible: true,
}, {
type: 'spline',
valueField: 'total_nps',
name: 'TOTAL',
color: '#00d084',
point: {
visible: true,
size: 6,
},
visible: true,
},
@foreach($subcontractors AS $subcontractor)
{
type: 'spline',
valueField: '{{str_slug($subcontractor, "_")}}',
name: '{{$subcontractor}}',
point: {
visible: true,
size: 6,
},
visible: true,
},
@endforeach
],
valueAxis: {
grid: {
visible: true,
},
title: {
text: 'NPS Values',
},
min: 0,
max: function() {
// En yüksek değeri bul ve %20 margin ekle
let maxValue = 0;
dataSource.forEach(function(item) {
maxValue = Math.max(maxValue, item.sum_F || 0, item.sum_S || 0, item.total_nps || 0);
@foreach($subcontractors AS $subcontractor)
maxValue = Math.max(maxValue, item.{{str_slug($subcontractor, "_")}} || 0);
@endforeach
});
return Math.ceil(maxValue * 1.2);
}(),
tickInterval: function() {
// Tick aralığını otomatik hesapla
let maxValue = 0;
dataSource.forEach(function(item) {
maxValue = Math.max(maxValue, item.sum_F || 0, item.sum_S || 0, item.total_nps || 0);
@foreach($subcontractors AS $subcontractor)
maxValue = Math.max(maxValue, item.{{str_slug($subcontractor, "_")}} || 0);
@endforeach
});
return Math.ceil(maxValue / 10);
}(),
},
argumentAxis: {
grid: {
visible: true,
},
},
tooltip: {
enabled: true,
shared: true,
format: {
type: 'largeNumber',
precision: 2,
},
},
legend: {
verticalAlignment: 'bottom',
horizontalAlignment: 'center',
},
export: {
enabled: true,
},
title: {
text: '{{e2("Monthly Progress")}}',
},
onContentReady: function(e) {
// Chart yüklendiğinde veri kontrolü
console.log('Chart data:', e.component.option('dataSource'));
// Y ekseni değerlerini düzenle
let valueAxis = e.component.getArgumentAxis();
let maxValue = 0;
dataSource.forEach(function(item) {
maxValue = Math.max(maxValue, item.sum_F || 0, item.sum_S || 0, item.total_nps || 0);
@foreach($subcontractors AS $subcontractor)
maxValue = Math.max(maxValue, item.{{str_slug($subcontractor, "_")}} || 0);
@endforeach
});
// Y ekseni maksimum değerini ayarla
e.component.option('valueAxis.max', Math.ceil(maxValue * 1.2));
e.component.option('valueAxis.tickInterval', Math.ceil(maxValue / 8));
},
onSeriesClick: function(e) {
// Series tıklandığında detay bilgisi
console.log('Series clicked:', e.seriesName, 'Value:', e.value);
}
});
});
</script>
<div id="monthlyProgress"></div>
@@ -0,0 +1,161 @@
<?php
$data = j(setting("ndtCalculation"));
$stats = [];
$statsData = [];
foreach($data AS $d) {
foreach($d AS $field => $value) {
if(strpos($field, "backlog") !== false) {
$field = str_replace("_backlog", "", $field);
$field = strtoupper($field);
if(!isset($stats[$field])) {
$stats[$field] = 0;
}
if($value>0) {
$stats[$field] += $value;
}
}
}
}
foreach($stats AS $log => $value) {
$statsData[] = [
'log_name' => $log,
'val' => $value,
];
}
$labels = implode("','",array_keys($stats));
$datas = implode(",",array_values($stats));
$totalCount = array_sum(array_values($stats));
?>
<div class="row">
<div class="col-md-6">
<canvas class="d-none" id="ndtBacklogStats"></canvas>
<div id="ndtBacklogChart"></div>
</div>
<div class="col-md-6">
<table class="table table-sm table-bordered table-striped">
<tr>
<th>{{e2("Status")}}</th>
<th>{{e2("Count")}}</th>
<th>{{e2("%")}}</th>
</tr>
<?php foreach($stats AS $label => $stat) {
?>
<tr>
<td>{{$label}}</td>
<td>{{$stat}}</td>
<td>%{{round($stat * 100 / $totalCount, 0)}}</td>
</tr>
<?php
} ?>
<tr>
<th>{{e2("Total")}}</th>
<th>{{$totalCount}}</th>
<th>%100</th>
</tr>
</table>
</div>
</div>
<script>
$(() => {
const ndtBacklogData = <?php echo json_encode_tr($statsData) ?>;
$('#ndtBacklogChart').dxPieChart({
type: 'doughnut',
// palette: 'Pastel',
dataSource: ndtBacklogData,
// title: '{{e2("Spool List")}}',
tooltip: {
enabled: true,
// format: 'millions',
customizeTooltip(arg) {
console.log(arg);
return {
text: `${arg.valueText} - ${(arg.percent * 100).toFixed(2)}%`,
};
},
},
legend: {
horizontalAlignment: 'center',
verticalAlignment: 'top',
margin: 0,
visible: true
},
export: {
enabled: true,
},
series: [{
argumentField: 'log_name',
label: {
visible: true,
connector: {
visible: true,
},
customizeText: function (arg) {
return arg.percentText;
}
},
}],
});
});
</script>
<script>
const ctx2 = document.getElementById('ndtBacklogStats');
var options = {
tooltips: {
enabled: true
},
plugins: {
datalabels: {
formatter: (value, ctx) => {
let sum = ctx.dataset._meta[0].total;
let percentage = (value * 100 / sum).toFixed(2) + "%";
return percentage;
},
color: '#fff',
}
}
};
new Chart(ctx2, {
type: 'doughnut',
data: {
labels: ['<?php echo $labels ?>'],
datasets: [{
label: '# {{e2("Count")}}',
data: [<?php echo $datas ?>],
borderWidth: 1
}]
},
options: options
});
</script>
@@ -0,0 +1,55 @@
<?php $punchLists = db("punch_lists")
->select("status")
->selectRaw("count(*) val")
->groupBy("status")
->get();
?>
<div id="punchStatusChart"></div>
<script>
$(() => {
const punchStatusData = <?php echo json_encode_tr($punchLists) ?>;
$('#punchStatusChart').dxPieChart({
type: 'doughnut',
// palette: 'Bright',
dataSource: punchStatusData,
title: '{{e2("Punch Status Percents")}}',
tooltip: {
enabled: true,
format: 'millions',
customizeTooltip(arg) {
return {
text: `${arg.valueText} - ${(arg.percent * 100).toFixed(2)}%`,
};
},
},
legend: {
horizontalAlignment: 'center',
verticalAlignment: 'top',
margin: 0,
visible: true
},
export: {
enabled: true,
},
series: [{
argumentField: 'status',
label: {
visible: true,
//format: 'percent',
connector: {
visible: true,
},
customizeText: function (arg) {
return arg.percentText;
}
},
}],
});
});
</script>
@@ -0,0 +1,54 @@
<?php $testPackages = db("test_packages")
->select("tp_general_status AS status")
->selectRaw("count(*) val")
->groupBy("tp_general_status")
->get();
?>
<div id="testStatusChart"></div>
<script>
$(() => {
const testStatusData = <?php echo json_encode_tr($testPackages) ?>;
$('#testStatusChart').dxPieChart({
type: 'doughnut',
// palette: 'Soft Pastel',
dataSource: testStatusData,
title: '{{e2("Test Status Percents")}}',
tooltip: {
enabled: true,
customizeTooltip(arg) {
return {
text: `${arg.valueText} - ${(arg.percent * 100).toFixed(2)}%`,
};
},
},
legend: {
horizontalAlignment: 'center',
verticalAlignment: 'top',
margin: 0,
},
export: {
enabled: true,
},
series: [{
argumentField: 'status',
label: {
visible: true,
//format: 'percent',
connector: {
visible: true,
},
customizeText: function (arg) {
return arg.percentText;
}
},
}],
});
});
</script>