Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query_group_tipe="Select tipe,variant,nama FROM stok GROUP BY tipe,variant,nama"
- $output_tipe=[];
- foreach($query_group_tipe as $tipe_item)
- {
- $output_tipe[$tipe_item->tipe]=[
- 'nama_produk'=>$tipe_item->nama,
- 'variant'=>$tipe_item->variant,
- ];
- }
- $stok_gudang="Select tipe,SUM(stok) as stok_total FROM stok WHERE detail='Gudang'";
- $output_stok_gudang=[];
- foreach($stok_gudang as $gudang_item)
- {
- $output_stok_gudang[$gudang_item->tipe]=$gudang_item->stok_total;
- }
- $output=[];
- foreach($output_tipe as $ot)
- {
- $stok_gudang_total=isset($ot['tipe])?$ot['tipe]:0;
- $output[]=[
- 'nama'=>$ot['nama_produk'],
- 'variant'=>$ot['variant],
- 'tipe'=>$ot['tipe'],
- 'stok_gudang'=>$stok_gudang_total
- ];
- }
- unset($output_tipe);
- unset($output_stok_gudang);
Add Comment
Please, Sign In to add comment