model
model stokunknown
abap
2 years ago
2.5 kB
1
Indexable
Never
/** PROSES PENGURANGAN TOTAL STOK ROLL */ if ($jmlh_pakai_roll <= $stok_roll) { echo 'masuk'; foreach ($sqlpilihroll as $row) { $id_bb = $row['id_bb']; $jmlh_roll = $row['jmlh_roll']; if ($jmlh_pakai_roll > 0) { // buat var $temp sbg. pengurang $temp = $jmlh_pakai_roll; /** PROSES PENGURANGAN ROLL */ $jmlh_pakai_roll = $jmlh_pakai_roll - $jmlh_roll; $jmlh_roll - $temp; if ($jmlh_pakai_roll > 0) { $stok_update = 0; $stok_update1 = $jmlh_roll; } else { $stok_update = $jmlh_roll - $temp; $stok_update1 = $temp; } /** PROSES PENGURANGAN STOCK KG */ if ($jmlh_pakai_kg <= $stok_allkg) { echo 'masuk'; foreach ($sqlpilihkg as $roww) { $id_bb = $roww['id_bb']; $jmlh_kg = $roww['jmlh_kg']; } if ($jmlh_pakai_kg > 0) { // buat var $temp sbg. pengurang Jumlah KG $temp = $jmlh_pakai_kg; //proses pengurangan kg $jmlh_pakai_kg = $jmlh_pakai_kg - $jmlh_kg; $jmlh_kg - $temp; if ($jmlh_pakai_kg > 0) { $stok_updatekg = 0; $stok_updatekg1 = $jmlh_kg; } else { $stok_updatekg = $jmlh_kg - $temp; $stok_updatekg1 = $temp; } $this->db->set('jmlh_roll', $stok_update); $this->db->set('jmlh_kg', $stok_updatekg); $this->db->where('kode_bb', $bahan_pakai); $this->db->where('id_bb', $id_bb); $this->db->update('tb_bahanbaku'); var_dump($stok_update); var_dump($stok_updatekg); $data4 = array( 'no_konsep' => $no_konsep, 'tanggal' => date('d/m/Y'), 'bahan_pakai' => $bahan_pakai, 'jmlh_rollcutting' => $stok_update1, 'jmlh_kgcutting' => $stok_updatekg1, 'estimasi_hasil' => $estimasi_hasil, 'keterangan_cutting' => $keterangan_cutting, 'dibuat' => $dibuat, 'status' => 'OPEN' ); $this->db->insert('tb_subcutting', $data4); } } } } } else { echo 'gagal'; } return $this->db->affected_rows();