Files
citrus-cms/resources/views/admin-ajax/weld-line-comparator.blade.php
2026-04-28 21:15:09 +03:00

36 lines
1009 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* @api-readonly
* Compares weld lines with line lists
*/
use Illuminate\Support\Facades\DB;
// Güvenlik için kullanıcı kontrolleri
$u = Auth::user();
if(!$u) {
echo json_encode(['error' => 'İzin hatası']);
exit();
}
// weld_logs tablosunda olup line_lists tablosunda olmayan kayıtları bulalım
$query = DB::table('weld_logs')
->select(
'weld_logs.id',
DB::raw('COALESCE(weld_logs.line_number, \'\') as line_number'),
DB::raw('COALESCE(weld_logs.design_area, \'\') as design_area')
)
->whereNotExists(function ($query) {
$query->select(DB::raw(1))
->from('line_lists')
->whereRaw('line_lists.line_no = weld_logs.line_number AND line_lists.unit = weld_logs.design_area');
});
// Tüm verileri getir
$result = $query->groupBy('line_number', 'design_area')->get();
$totalCount = count($result);
// Sonucu JSON olarak döndür
echo json_encode([
'data' => $result,
'totalCount' => $totalCount
]);