@php use Illuminate\Support\Facades\DB; $a = DB::table('tstktmatstockcard') ->groupBy('xvmatcode') ->selectRaw('SUM(xistkqtyleft) AS somme, xvmatcode'); $b = DB::table('tstktmatstockincoming') ->groupBy('xvmatcode') ->selectRaw('SUM(xistkqty) AS bsomme, xvmatcode'); $Material = DB::table('tmstmmaterial') ->select('tmstmmaterial.*', 'a.somme', 'b.bsomme') ->leftJoin(DB::raw("({$a->toSql()}) AS a"), 'a.xvmatcode', '=', 'tmstmmaterial.xvmatcode') ->leftJoin(DB::raw("({$b->toSql()}) AS b"), 'b.xvmatcode', '=', 'tmstmmaterial.xvmatcode') ->whereRaw('IFNULL(a.somme,0) + IFNULL(b.bsomme,0) > 0') ->where('xvmtycode', 'MatType-003') ->where('xbisactive', '1'); $Select = false; $Material = $Material ->orderBy('xvmatcode', 'desc') ->get() ->toArray(); foreach ($Material as $item) { $item->unit = DB::table('tmstmmat_unit') ->where('xvmatcode', '=', $item->xvmatcode) ->join('tmstmunit', 'tmstmmat_unit.xvuntcode', 'tmstmunit.xvuntcode') ->get() ->toArray(); } $supplier = DB::table('tmstmsupplier') ->orderBy('XVSplCode', 'desc') ->get(); $group = DB::table('TMstMMatGroup') ->orderBy('xvmgpcode', 'desc') ->get() ->toArray(); @endphp

วัสดุผ้า

ตัวเลือกการค้นหา
{{--
--}}