/** * Execute the job. * * @return void */ public function handle() { try { //dd($this->req); \DB::begintransaction(); $me = \Me::data()->id_karyawan; // Create PO $po = data_po::create(['id_sph' => $this->req['id'], 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => $me, 'id_acc' => 0, 'adjustment' => $this->req['adjustment'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'keterangan' => $this->req['ket'], 'titipan' => $this->req['titipan']]); foreach ($this->req['id_barang'] as $i => $id_barang) { data_po_item::create(['id_po' => $po->id_po, 'id_item' => $id_barang, 'req_qty' => $this->req['qty'][$i], 'qty' => $this->req['qty'][$i], 'harga' => $this->req['harga'][$i], 'diskon' => $this->req['diskon'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i], 'id_prq' => $this->req['id_prq'][$i]]); data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]); // update Harga data_barang::find($id_barang)->update(['harga_beli' => $this->req['harga'][$i]]); // Update Log harga data_harga::create(['id_barang' => $id_barang, 'harga' => $this->req['harga'][$i], 'keterangan' => 'Update berdasarkan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me, 'tipe' => 1]); data_prq_item::find($this->req['id_prq_item'][$i])->update(['status' => 2]); } $format = 'PO-'; $po->no_po = $format . \Format::code($po->id_po); $po->save(); \Loguser::create('Membuat PO dengan No. PO ' . $po->no_po); \DB::commit(); return ['result' => true, 'err' => 'PO berhasil dibuat dengan No. ' . $po->no_po]; } catch (\Exception $e) { \DB::rollback(); return ['result' => false, 'err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { //dd($this->req); try { \DB::begintransaction(); $gr = data_spbm::create(['no_surat_jalan' => $this->req['sj'], 'tgl_terima_barang' => $this->req['tgl_terima'], 'tgl_periksa_barang' => $this->req['tgl_periksa'], 'id_kirim' => $this->req['pengiriman'], 'keterangan' => $this->req['keterangan'], 'id_po' => $this->req['id_po'], 'pemeriksa1' => $this->req['pemeriksa1'], 'pemeriksa2' => $this->req['pemeriksa2'], 'nm_pengirim' => $this->req['nm_pengirim'], 'titipan' => $this->req['titipan'], 'id_karyawan' => \Me::data()->id_karyawan]); $statuspo = []; foreach ($this->req['id_po_item'] as $i => $id_po_item) { if (!empty($this->req['qty_lg'])) { $qty = \Format::convertSatuan($this->req['id_barang'][$i], $this->req['id_satuan'][$i], $this->req['id_satuan_default'][$i]) * $this->req['qty_lg'][$i]; data_spbm_item::create(['id_spbm' => $gr->id_spbm, 'id_barang' => $this->req['id_barang'][$i], 'bonus' => $this->req['bonus'][$i], 'id_satuan' => $this->req['id_satuan'][$i], 'qty_lg' => $this->req['qty_lg'][$i], 'qty' => $qty, 'merek' => $this->req['merek'][$i], 'barang_sesuai' => $this->req['barang_sesuai'][$i], 'keterangan' => $this->req['kets'][$i], 'tgl_exp' => $this->req['tgl_exp'][$i], 'sisa' => $qty]); // Perubahan Status Item PO if ($this->req['bonus'][$i] == 0) { $itempo = data_po_item::find($this->req['id_po_item'][$i]); if ($this->req['qty_lg'][$i] >= $this->req['req_qty'][$i]) { $itempo->status = 3; $itempo->qty = $itempo->qty - $this->req['qty_lg'][$i]; $itempo->save(); // Perubahan status PRQ $count = data_prq_item::where('id_prq', $itempo->id_prq)->where('status', 1)->count(); if ($count == 0) { data_prq::find($itempo->id_prq)->update(['status' => 3]); } } else { $statuspo[] = 1; $itempo->status = 2; $itempo->qty = $itempo->qty - $this->req['qty_lg'][$i]; $itempo->save(); } } // Log Stok data_log_barang::create(['id_barang' => $this->req['id_barang'][$i], 'qty' => $qty, 'keterangan' => 'Good Receive', 'id_gudang' => 0, 'kondisi' => 1, 'tipe' => 2, 'id_parent' => $gr->id_spbm, 'id_karyawan' => \Me::data()->id_karyawan]); // Udate Stok ke data barang $b = data_barang::find($this->req['id_barang'][$i]); $b->in = $b->in + $qty; $b->save(); } } // Merubah Status PO $po = data_po::find($this->req['id_po']); if (count($statuspo) > 0) { $po->update(['status' => 2]); } else { $po->update(['status' => 3]); } $format = 'GR-'; $gr->no_spbm = $format . \Format::code($gr->id_spbm); $gr->save(); \Loguser::create('Membuat Permohonan Barang Masuk dengan No. ' . $gr->no_spbm); \DB::commit(); return ['label' => 'seccess', 'err' => 'PO berhasil diproses! dengan No. ' . $gr->no_spbm]; } catch (\Exception $e) { \DB::rollback(); return ['label' => 'danger', 'err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { foreach ($this->req['id_barang'] as $i => $id_barang) { if (!empty($this->req['qty'][$i])) { $item = data_prq_item::firstOrCreate(['id_prq' => $this->req['id_prq'], 'id_barang' => $id_barang]); $item->update(['qty' => $this->req['qty'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]); } } $prq = data_prq::find($this->req['id_prq']); \Loguser::create('Menambahkan item tambahan terhadap PRQ No. ' . $prq->no_prq); return $this->req; }
/** * Execute the job. * * @return void */ public function handle() { $titipan = !empty($this->req['titipan']) ? $this->req['vendor'] : 0; $prq = data_prq::find($this->req['id_prq']); $prq->update(['target' => date('Y-m-d', strtotime($this->req['deadline'])), 'keterangan' => $this->req['ket'], 'titipan' => $titipan]); data_prq_item::whereId_prq($this->req['id_prq'])->delete(); foreach ($this->req['id_barang'] as $i => $id_barang) { if (!empty($this->req['qty'][$i])) { data_prq_item::create(['id_prq' => $this->req['id_prq'], 'id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]); } } \Loguser::create('Melakukan perubahan data PRQ No. ' . $prq->no_prq); return $prq; }
/** * Execute the job. * * @return void */ public function handle() { $titipan = !empty($this->req['titipan']) ? $this->req['vendor'] : 0; $prq = data_prq::create(['target' => date('Y-m-d', strtotime($this->req['deadline'])), 'id_pemohon' => \Me::data()->id_karyawan, 'keterangan' => $this->req['ket'], 'tipe' => $this->req['tipe'], 'id_acc' => 0, 'titipan' => $titipan]); foreach ($this->req['id_barang'] as $i => $id_barang) { if (!empty($this->req['qty'][$i])) { data_prq_item::create(['id_prq' => $prq->id_prq, 'id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]); } } $kode = 'PRQ-'; $prq->no_prq = $kode . \Format::code($prq->id_prq); $prq->save(); \Loguser::create('Membuat PRQ No. ' . $prq->no_prq); return $prq; }
/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $me = \Me::data()->id_karyawan; $sph = data_sph::find($this->req['id_sph']); $grup = data_sph_grup::whereId_sph_grup($sph->id_sph_grup)->select('status')->first(); if ($grup->status == 2) { throw new \Exception("Maaf SPH No. " . $sph->no_sph_item . " sudah kadaluarsa!", 1); } // Create PO $po = data_po::create(['id_sph' => $this->req['id_sph'], 'id_vendor' => $sph->id_vendor, 'deadline' => $sph->deadline, 'id_pembuat' => $me, 'id_acc' => 0, 'adjustment' => $sph->adjustment, 'diskon' => $sph->diskon, 'ppn' => $sph->ppn, 'keterangan' => $sph->keterangan]); $items = data_sph_item::whereId_sph($this->req['id_sph'])->get(); foreach ($items as $item) { data_po_item::create(['id_po' => $po->id_po, 'id_item' => $item->id_item, 'req_qty' => $item->qty, 'qty' => $item->qty, 'harga' => $item->harga, 'diskon' => $item->diskon, 'ppn' => $item->ppn, 'pph' => $item->pph, 'keterangan' => $item->keterangan, 'id_satuan' => $item->id_satuan, 'id_prq' => $item->id_prq]); // update Harga data_barang::find($item->id_item)->update(['harga_beli' => $item->harga]); // Update Log harga data_harga::create(['id_barang' => $item->id_item, 'harga' => $item->harga, 'keterangan' => 'Update berdasarkan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me, 'tipe' => 1]); data_prq_item::whereId_prq($item->id_prq)->whereId_barang($item->id_item)->update(['status' => 2]); } $format = 'PO-'; $po->no_po = $format . \Format::code($po->id_po); $po->save(); // Update data SPH Grup data_sph_grup::find($this->req['id_sph_grup'])->update(['status' => 2]); // Update data sph $sph->status = 2; $sph->save(); \Loguser::create('Menjadikan SPH denga No. ' . $sph->no_sph . ' menjadi PO dengan No. ' . $po->no_po); \DB::commit(); return ['err' => 'Po Berhail di buat dengan No. ' . $po->no_po]; } catch (\Exception $e) { \DB::rollback(); return ['err' => $e->getMessage()]; } }
public function getEdit($id) { $prq = data_prq::join('data_karyawan AS a', 'a.id_karyawan', '=', 'data_prq.id_pemohon')->leftJoin('data_karyawan AS b', 'b.id_karyawan', '=', 'data_prq.id_acc')->where('data_prq.id_prq', $id)->select('data_prq.*', 'a.nm_depan', 'a.nm_belakang', 'b.nm_depan AS acc_depan', 'b.nm_belakang AS acc_belakang')->first(); $items = data_prq_item::join('data_barang', 'data_barang.id_barang', '=', 'data_prq_item.id_barang')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_prq_item.id_prq', $id)->select('data_barang.kode', 'data_barang.nm_barang', 'data_barang.in', 'data_barang.out', 'data_prq_item.*', 'ref_satuan.nm_satuan')->get(); $ids = []; $sels = []; foreach ($items as $id) { $ids[] = $id->id_barang; $sels[$id->id_barang] = $id->id_satuan; } $param['ids'] = $ids; $param['tipe'] = $prq->tipe; $param['sels'] = $sels; $param = json_encode($param); return view('Pengadaan.PRQ.EditPRQ', ['prq' => $prq, 'items' => $items, 'param' => $param, 'tipe' => $prq->tipe]); }
public function getCreate($id = 0) { $items = data_prq_item::join('data_prq', 'data_prq.id_prq', '=', 'data_prq_item.id_prq')->join('data_barang', 'data_barang.id_barang', '=', 'data_prq_item.id_barang')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_prq_item.id_satuan')->join('ref_satuan AS b', 'b.id_satuan', '=', 'data_barang.id_satuan')->whereIn('data_prq_item.id_prq_item', $this->ids)->select('data_prq.no_prq', 'data_prq.id_prq', 'data_barang.nm_barang', 'data_barang.kode', 'data_barang.in', 'data_barang.out', 'data_prq_item.*', 'ref_satuan.nm_satuan', 'b.nm_satuan AS default_satuan', 'b.id_satuan AS default_id_satuan')->get(); if (count($items) < 1) { return redirect('/sph/select')->withNotif(['label' => 'danger', 'err' => 'Anda belum memilih item barang untuk dijadikan SPH']); } //$vendors = data_vendor::whereStatus(1)->get(); if ($id > 0) { $sph = data_sph_grup::whereId_sph_grup($id); if ($sph->count() < 1) { return redirect('/sph')->withNotif(['label' => 'danger', 'err' => 'SPH tidak ditemukan!']); } $sp = $sph->first(); $no_sph = $sp->no_sph; } else { $no_sph = 0; } $ids = []; foreach ($items as $i) { $ids[] = $i->id_barang; } $ids = json_encode($ids); return view('Pembelian.SPH.CreateSPH', ['items' => $items, 'id' => $id, 'no_sph' => $no_sph, 'ids' => $ids]); }
public function getCreate() { $items = data_prq_item::join('data_prq', 'data_prq.id_prq', '=', 'data_prq_item.id_prq')->join('data_barang', 'data_barang.id_barang', '=', 'data_prq_item.id_barang')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_prq_item.id_satuan')->join('ref_satuan AS b', 'b.id_satuan', '=', 'data_barang.id_satuan')->whereIn('data_prq_item.id_prq_item', $this->ids)->select('data_prq.no_prq', 'data_prq.id_prq', 'data_barang.nm_barang', 'data_barang.kode', 'data_barang.in', 'data_barang.out', 'data_prq_item.*', 'ref_satuan.nm_satuan', 'b.nm_satuan AS default_satuan', 'b.id_satuan AS default_id_satuan')->get(); if (count($items) < 1) { return redirect('/po/select')->withNotif(['label' => 'danger', 'err' => 'Anda belum memilih item barang untuk dijadikan SPH']); } $vendors = data_vendor::whereStatus(1)->get(); $ids = []; foreach ($items as $i) { $ids[] = $i->id_barang; } $ids = json_encode($ids); return view('Pembelian.PO.Create', ['items' => $items, 'vendors' => $vendors, 'id' => 0, 'no_sph' => 0, 'ids' => $ids]); }