/** * Execute the job. * * @return void */ public function handle() { try { \DB::begintransaction(); $id_karyawan = \Me::data()->id_karyawan; $barang = data_barang::find($this->req['id']); $barang->update(['nm_barang' => $this->req['nm_barang'], 'id_kategori' => $this->req['id_kategori'], 'id_satuan' => $this->req['id_satuan'], 'stok_minimal' => $this->req['stok_minimal'], 'keterangan' => $this->req['keterangan'], 'tipe' => $this->req['tipe'], 'ppn' => $this->req['ppn'], 'harga_beli' => $this->req['harga_beli'], 'harga_jual' => $this->req['harga_jual'], 'id_klasifikasi' => $this->req['id_klasifikasi']]); data_barang_detail::where('id_barang', $this->req['id'])->delete(); if (isset($this->req['labels']) && count($this->req['labels']) > 0) { foreach ($this->req['labels'] as $i => $val) { if (strlen($val) > 0 && strlen($this->req['values'][$i]) > 0) { data_barang_detail::create(['id_barang' => $this->req['id'], 'label' => ucwords($val), 'nm_detail' => $this->req['values'][$i]]); } } } ref_konversi_satuan::where('id_barang', $this->req['id'])->delete(); ref_konversi_satuan::create(['id_barang' => $barang->id_barang, 'id_satuan_max' => $this->req['id_satuan'], 'id_satuan_min' => $this->req['id_satuan'], 'qty' => 1]); if (isset($this->req['koversi_satuan']) && count($this->req['koversi_satuan']) > 0) { foreach ($this->req['koversi_satuan'] as $i => $id_satuan) { if ($id_satuan > 0) { ref_konversi_satuan::create(['id_barang' => $barang->id_barang, 'id_satuan_max' => $id_satuan, 'id_satuan_min' => $this->req['id_satuan'], 'qty' => $this->req['koversi_qty'][$i]]); } } } if ($this->req['harga_beli'] != $this->req['last_harga']) { data_harga::create(['id_barang' => $barang->id_barang, 'harga' => $this->req['harga_beli'], 'keterangan' => 'Update harga dari ' . number_format($this->req['last_harga'], 0, ',', '.'), 'id_karyawan' => $id_karyawan, 'tipe' => 1]); } if ($this->req['harga_jual'] != $this->req['last_harga_jual']) { data_harga::create(['id_barang' => $barang->id_barang, 'harga' => $this->req['harga_jual'], 'keterangan' => 'Update harga dari ' . number_format($this->req['last_harga_jual'], 0, ',', '.'), 'id_karyawan' => $id_karyawan, 'tipe' => 2]); } // Pengkodean $tipe = $this->req['tipe'] == 1 ? 'O-' : 'B-'; $kat = ref_kategori::find($this->req['id_kategori']); $kats = $kat->alias . '-'; $urut = \Format::code($barang->id_barang); $jj = ''; if ($this->req['tipe'] == 1) { $kls = ref_klasifikasi::find($this->req['id_klasifikasi']); $jj = '-' . $kls->kode; } $kode = $tipe . $kats . $urut . $jj; $barang->kode = $kode; $barang->save(); \Loguser::create('Melakukan perubahan terhada data master gudang Kode. ' . $barang->kode); \DB::commit(); return ['label' => 'success', 'err' => $this->req['nm_barang'] . ' Berhasil diperbaharui']; } catch (\Exception $e) { \DB::rollback(); return ['label' => 'danger', 'err' => $e->getMessage()]; } }
public function getSelect($tipe = 0) { $akses = \Me::accessGudang(); $status = \Me::statusGudang(); if (empty($tipe) || $tipe > 2 || !is_numeric($tipe)) { return redirect('/stockadj')->withNotif(['label' => 'danger', 'err' => 'Kesalahan, Silahkan buat pengajuan baru!']); } if ($status == 0) { return redirect('/stockadj')->withNotif(['label' => 'danger', 'err' => 'Maaf, Anda belum memiliki Akses. Silahkan untuk menghubungu atasan Anda!']); } if (!in_array($tipe, $akses)) { return redirect('/stockadj')->withNotif(['label' => 'danger', 'err' => 'Maaf Bukan domain Anda!']); } $items = data_barang::srcprq([], $this->ids, $tipe)->paginate(10); $kats = ref_kategori::all(); if ($tipe == 1) { $title = 'Semua daftar Obat'; } elseif ($tipe == 2) { $title = 'Semua daftar Barang'; } return view('Pengadaan.StockAdjustment.Select', ['items' => $items, 'kats' => $kats, 'tipe' => $tipe, 'title' => $title]); }
public function postDestroy(Request $req) { ref_kategori::find($req->id)->delete(); return json_encode(['result' => true]); }
/** * Menampilkan data LIMIT */ public function getLimit() { $src = null; $kat = 0; $order = 'asc'; $limit = 10; $tipe = 0; if (isset($_GET['src'])) { $src = $_GET['src']; $kat = is_numeric($_GET['kat']) ? $_GET['kat'] : 0; $order = $_GET['orderby']; $limit = is_numeric($_GET['limit']) ? $_GET['limit'] : 10; $tipe = empty($_GET['tipe']) ? 0 : $_GET['tipe']; } $fileds = isset($_GET['sort']) ? $_GET['sort'] : null; switch ($fileds) { case "barang": $filed = 'data_barang.nm_barang'; break; case "kode": $filed = 'data_barang.kode'; break; case "kategori": $filed = 'ref_kategori.nm_kategori'; break; case "waktu": $filed = 'data_barang.created_at'; break; default: $filed = 'data_barang.nm_barang'; } $items = data_barang::detailslimit($src, $kat, $filed, $order, $tipe)->paginate($limit); $tipes = [1 => 'Obat', 2 => 'Barang']; return view('Pengadaan.LimitStok', ['items' => $items, 'kategoris' => ref_kategori::all(), 'src' => $src, 'kat' => $kat, 'filed' => $fileds, 'order' => $order, 'limit' => $limit, 'tipes' => $tipes, 'tipe' => $tipe]); }
public function getSelectitemspmb() { //session()->forget($this->MySession); $items = data_barang::join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_barang.status', 1)->where('data_barang.tipe', 2)->select('data_barang.*', 'ref_satuan.nm_satuan')->whereNotIn('data_barang.id_barang', $this->ids)->paginate(10); $kats = ref_kategori::all(); return view('Pengadaan.SPB.SelectItems', ['items' => $items, 'kats' => $kats, 'tipe' => 2]); }
public function getLaporanstok() { $klasifikasis = ref_klasifikasi::all(); $kategoris = ref_kategori::all(); return view('Laporan.Logistik.LaporanStok', ['klasifikasis' => $klasifikasis, 'kategoris' => $kategoris]); }
public function getSelect() { $me = \Me::subgudang(); if (!$me->access) { return redirect('/subgudang/adjustment')->withNotif(['label' => 'warning', 'err' => 'Penyesuaian stok hanya bisa dilakukan oleh user yang memiliki akses terhadap sub gudang']); } $items = data_item_gudang::adj([], $this->ids)->paginate(10); $kats = ref_kategori::all(); return view('Pengadaan.SubGudang.SelectAdjustment', ['items' => $items, 'kats' => $kats, 'tipe' => 0, 'title' => '']); }