/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $spb = data_spb::find($this->req['id_spb']); $item = data_spb_item::whereId_spb($this->req['id_spb'])->select('id_gudang')->first(); $gudang = $item->id_gudang; foreach ($this->req['id_barang'] as $i => $id) { if (!empty($this->req['qty'][$i])) { $items = data_spb_item::firstOrCreate(['id_spb' => $this->req['id_spb'], 'id_item' => $id, 'status' => 1]); $qty = \Format::convertSatuan($id, $this->req['satuan'][$i], $this->req['id_satuan'][$i]) * $this->req['qty'][$i]; $items->update(['id_gudang' => $gudang, 'qty_awal' => $qty, 'qty' => $qty, 'qty_lg' => $this->req['qty'][$i], 'keterangan' => $this->req['kets'][$i], 'id_satuan' => $this->req['satuan'][$i]]); } } \Loguser::create('Menambahkan item tambahan terhadap PMB/PMO No. ' . $spb->no_spb); \DB::commit(); return ['res' => true, 'label' => 'success', 'err' => $spb->no_spb . ' berhasil ditambahkan!']; } catch (\Exception $e) { \DB::rollback(); return ['res' => false, 'label' => 'danger', 'err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $spb = data_spb::create(['id_departemen' => \Me::data()->id_departemen, 'id_pemohon' => \Me::data()->id_karyawan, 'keterangan' => $this->req['ket'], 'id_acc' => 0, 'deadline' => date('Y-m-d', strtotime($this->req['deadline'])), 'tipe' => $this->req['tipe']]); $gudang = empty($this->req['id_gudang']) ? 0 : $this->req['id_gudang']; foreach ($this->req['id_barang'] as $i => $id) { if (!empty($this->req['qty'][$i])) { $qty = \Format::convertSatuan($id, $this->req['satuan'][$i], $this->req['id_satuan'][$i]) * $this->req['qty'][$i]; data_spb_item::create(['id_spb' => $spb->id_spb, 'id_item' => $id, 'qty_awal' => $qty, 'qty' => $qty, 'qty_lg' => $this->req['qty'][$i], 'keterangan' => $this->req['kets'][$i], 'status' => 1, 'id_gudang' => $gudang, 'id_satuan' => $this->req['satuan'][$i]]); } } $kode = $this->req['tipe'] == 1 ? 'PMO-' : 'PMB-'; $spb->no_spb = $kode . \Format::code($spb->id_spb); $spb->save(); \Loguser::create('Membuat Pengajuan barang No. ' . $spb->no_spb); \DB::commit(); return ['res' => true, 'label' => 'success', 'err' => 'Permohonan Barang berhasil terkirim dengan Nomor ' . $spb->no_spb]; } catch (\Exception $e) { \DB::rollback(); return ['res' => false, 'label' => 'danger', 'err' => $e->getMessage()]; } }
/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $spb = data_spb::find($this->req['id_spb']); $spb->keterangan = $this->req['ket']; $spb->deadline = date('Y-m-d', strtotime($this->req['deadline'])); $spb->save(); data_spb_item::where('id_spb', $this->req['id_spb'])->delete(); $gudang = empty($this->req['id_gudang']) ? 0 : $this->req['id_gudang']; foreach ($this->req['id_barang'] as $i => $id) { if (!empty($this->req['qty'][$i])) { $qty = \Format::convertSatuan($id, $this->req['satuan'][$i], $this->req['id_satuan'][$i]) * $this->req['qty'][$i]; data_spb_item::create(['id_spb' => $spb->id_spb, 'id_item' => $id, 'qty_awal' => $qty, 'qty' => $qty, 'qty_lg' => $this->req['qty'][$i], 'keterangan' => $this->req['kets'][$i], 'status' => 1, 'id_gudang' => $gudang, 'id_satuan' => $this->req['satuan'][$i]]); } } \Loguser::create('Melakukan perubahan terhadap data PMB/PMO No. ' . $spb->no_spb); \DB::commit(); return ['label' => 'success', 'err' => 'Sukses, No ' . $spb->no_spb . ' berhasil diperbaharui.']; } catch (\Exception $e) { \DB::rollback(); return ['label' => 'danger', 'err' => $e->getMessage()]; } }
public function getProcess($id) { $spb = data_spb::join('data_karyawan AS a', 'a.id_karyawan', '=', 'data_spb.id_pemohon')->leftJoin('data_karyawan AS b', 'b.id_karyawan', '=', 'data_spb.id_acc')->join('data_departemen', 'data_departemen.id_departemen', '=', 'data_spb.id_departemen')->where('data_spb.id_spb', $id)->select('a.nm_depan', 'a.nm_belakang', 'b.nm_depan AS acc_depan', 'b.nm_belakang AS acc_belakang', 'data_departemen.nm_departemen', 'data_spb.*')->first(); $akses = \Me::accessGudang(); if (!in_array($spb->tipe, $akses)) { return redirect('/skb/spb')->withNotif(['label' => 'danger', 'err' => 'Maaf, Tidak ada akses untuk anda!']); } if ($spb->status > 2 || $spb->id_acc == 0) { return redirect('/skb/spb'); } $items = data_spb_item::byspb($id)->get(); return view('Pengadaan.SKB.ProcessSPB', ['spb' => $spb, 'items' => $items, 'satuan' => ref_satuan::all()]); }
public function getPrintspb($id) { $find = data_spb::join('data_karyawan', 'data_karyawan.id_karyawan', '=', 'data_spb.id_pemohon')->join('data_departemen', 'data_departemen.id_departemen', '=', 'data_spb.id_departemen')->where('data_spb.id_spb', $id)->where('data_spb.id_departemen', \Me::data()->id_departemen)->select('data_spb.*', 'data_karyawan.nm_depan', 'data_karyawan.nm_belakang', 'data_departemen.nm_departemen'); if ($find->count() == 0) { return redirect('/pmbumum'); } $spb = $find->first(); $items = data_spb_item::join('data_barang', 'data_barang.id_barang', '=', 'data_spb_item.id_item')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_spb_item.id_spb', $id)->select('data_spb_item.*', 'data_barang.id_barang', 'data_barang.in', 'data_barang.out', 'data_barang.nm_barang', 'data_barang.kode', 'ref_satuan.nm_satuan')->get(); return view('Print.Pengadaan.SPB', ['spb' => $spb, 'items' => $items]); }