Exemplo n.º 1
0
 /**
  * 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()];
     }
 }
Exemplo n.º 2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         //dd($this->req);
         \DB::begintransaction();
         $me = \Me::data()->id_karyawan;
         // Create PO
         $po = data_po::find($this->req['id']);
         $po->update(['id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'adjustment' => $this->req['adjustment'], 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'keterangan' => $this->req['ket']]);
         data_po_item::whereId_po($this->req['id'])->delete();
         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]]);
             // 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_beli' => $this->req['harga'][$i], 'keterangan' => 'Update berdasarkan pembaharuan PO', 'id_po' => $po->id_po, 'id_karyawan' => $me]);
         }
         \Loguser::create('Melakukan perubahan data PO No. ' . $po->no_po);
         \DB::commit();
         return ['result' => true, 'err' => 'PO berhasil diperbaharui'];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'err' => $e->getMessage()];
     }
 }
Exemplo n.º 3
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         $me = \Me::data()->id_karyawan;
         $retur = data_retur::create(['tipe' => 2, 'id_po' => $this->req['id_po'], 'id_vendor' => $this->req['id_vendor'], 'id_karyawan' => $me]);
         data_po::find($this->req['id_po'])->update(['status' => 2]);
         foreach ($this->req['id_barang'] as $i => $id_barang) {
             if (!empty($this->req['qty'][$i])) {
                 data_retur_item::create(['id_retur' => $retur->id_retur, 'id_barang' => $id_barang, 'id_satuan' => $this->req['id_satuan'][$i], 'qty' => $this->req['qty'][$i], 'qty_lg' => $this->req['qty'][$i]]);
                 // Log Stok
                 data_log_barang::create(['id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'id_gudang' => 0, 'kondisi' => 2, 'tipe' => 5, 'id_parent' => $retur->id_retur, 'id_karyawan' => $me]);
                 // Update stok
                 $barang = data_barang::find($id_barang);
                 $barang->out = $barang->out + $this->req['qty'][$i];
                 $barang->save();
                 // Update data PO items
                 $itm = data_po_item::where('id_po', $this->req['id_po'])->where('id_item', $id_barang)->first();
                 $qpo = $itm->qty + $this->req['qty'][$i];
                 data_po_item::where('id_po', $this->req['id_po'])->where('id_item', $id_barang)->update(['qty' => $qpo, 'status' => 1]);
             }
         }
         $format = 'EX-RTN-';
         $kode = $format . \Format::code($retur->id_retur);
         $retur->no_retur = $kode;
         $retur->save();
         \Loguser::create('Membuat Retur Pembelian dengan No. ' . $kode);
         \DB::commit();
         return ['result' => true, 'label' => 'success', 'err' => 'Return Pembelian berhasil dibuat dengan No. ' . $kode];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'label' => 'danger', 'err' => $e->getMessage()];
     }
 }
Exemplo n.º 4
0
 /**
  * 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()];
     }
 }
Exemplo n.º 5
0
 /**
  * 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()];
     }
 }
Exemplo n.º 6
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         $me = \Me::data()->id_karyawan;
         \DB::begintransaction();
         $stok = data_penyesuaian_stok::create(['tipe' => $this->req['tipe'], 'id_karyawan' => $me, 'keterangan' => $this->req['ket'], 'tanggal' => $this->req['tanggal']]);
         if (count($this->req['id_barang']) == 0) {
             throw new \Exception("Barang/Obat tidak ditemukan!", 1);
         }
         $notempty = [];
         foreach ($this->req['id_barang'] as $i => $id_barang) {
             if (!empty($this->req['qty'][$i])) {
                 $notempty[] = 1;
                 $qty = \Format::convertSatuan($id_barang, $this->req['satuan'][$i], $this->req['satuan_default'][$i]) * $this->req['qty'][$i];
                 data_penyesuaian_stok_item::create(['id_penyesuaian_stok' => $stok->id_penyesuaian_stok, 'id_barang' => $id_barang, 'id_satuan' => $this->req['satuan'][$i], 'qty_lg' => $this->req['qty'][$i], 'current_qty' => $this->req['current_qty'][$i], 'new_qty' => $qty, 'keterangan' => $this->req['kets'][$i]]);
             }
             if (count($notempty) == 0) {
                 throw new \Exception("Barang/Obat tidak ditemukan!", 1);
             }
             // Log Stok
             $kondisi = $qty >= $this->req['current_qty'][$i] ? 1 : 2;
             $stok_qty = $this->req['current_qty'][$i] - $qty;
             data_log_barang::create(['id_barang' => $id_barang, 'qty' => abs($stok_qty), 'keterangan' => 'Penyesuaian Stok', 'id_gudang' => 0, 'kondisi' => $kondisi, 'tipe' => 3, 'id_parent' => $stok->id_penyesuaian_stok, 'id_karyawan' => $me]);
             // Stok gudang
             $barang = data_barang::find($id_barang);
             if ($kondisi == 1) {
                 $barang->in = $barang->in + abs($stok_qty);
             } else {
                 $barang->out = $barang->out + abs($stok_qty);
             }
             $barang->save();
         }
         // Code
         $tipe = $this->req['tipe'] == 1 ? 'O-' : 'B-';
         $format = $tipe . 'ADJ-' . \Format::code($stok->id_penyesuaian_stok);
         $stok->no_penyesuaian_stok = $format;
         $stok->save();
         \Loguser::create('Melakukan penyesuaian Stok dengan No. ' . $stok->no_penyesuaian_stok);
         \DB::commit();
         return ['result' => true, 'label' => 'success', 'err' => 'Penyesuaian berhasil di buat dengan No. ' . $stok->no_penyesuaian_stok];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'label' => 'danger', 'err' => $e->getMessage()];
     }
 }
Exemplo n.º 7
0
 /**
  * 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()];
     }
 }
Exemplo n.º 8
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         \DB::begintransaction();
         $me = \Me::data()->id_karyawan;
         $retur = data_retur::create(['tipe' => 1, 'id_gudang_asal' => $this->req['id_gudang'], 'id_karyawan' => $me]);
         foreach ($this->req['id_barang'] as $i => $id_barang) {
             if (!empty($this->req['qty'][$i])) {
                 data_retur_item::create(['id_retur' => $retur->id_retur, 'id_barang' => $id_barang, 'id_satuan' => $this->req['id_satuan'][$i], 'qty' => $this->req['qty'][$i], 'qty_lg' => $this->req['qty'][$i]]);
                 // Log Stok
                 data_log_barang::create(['id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'id_gudang' => 0, 'kondisi' => 1, 'tipe' => 4, 'id_parent' => $retur->id_retur, 'id_karyawan' => $me]);
                 // Log Stok
                 data_log_barang::create(['id_barang' => $id_barang, 'qty' => $this->req['qty'][$i], 'id_gudang' => $this->req['id_gudang'], 'kondisi' => 2, 'tipe' => 4, 'id_parent' => $retur->id_retur, 'id_karyawan' => $me]);
                 // Update stok Gudang besat
                 $barang = data_barang::find($id_barang);
                 $barang->in = $barang->in + $this->req['qty'][$i];
                 $barang->save();
                 // Update Stok sub gudang
                 $gudang = data_item_gudang::where('id_barang', $id_barang)->where('id_gudang', $this->req['id_gudang'])->first();
                 $gd = data_item_gudang::find($gudang->id_item_gudang);
                 $gd->out = $gudang->out + $this->req['qty'][$i];
                 $gd->save();
             }
         }
         $format = 'IN-RTN-';
         $kode = $format . \Format::code($retur->id_retur);
         $retur->no_retur = $kode;
         $retur->save();
         \Loguser::create('Membuat Retur Gudang dengan No. ' . $kode);
         \DB::commit();
         return ['result' => true, 'label' => 'success', 'err' => 'Return Gudang berhasil dibuat dengan No. ' . $kode];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['result' => false, 'label' => 'danger', 'err' => $e->getMessage()];
     }
 }
 public function getPrintexcel(Request $req)
 {
     $kd_barang = data_barang::where('id_barang', $req->barang)->select('kode')->first();
     $gudang = ref_gudang::find($req->gudang);
     \Excel::create('Kartu_Stok_' . str_replace('-', '_', str_slug($gudang->nm_gudang)) . '_' . $kd_barang->kode . '_' . date('d_F_Y'), function ($excel) use($req) {
         if ($req->barang == 0) {
             return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Item tidak ditemukan!']);
         }
         $items = [];
         // Data Barang
         $barang = data_item_gudang::join('data_barang', 'data_barang.id_barang', '=', 'data_item_gudang.id_barang')->join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_item_gudang.status', 1)->where('data_item_gudang.id_gudang', $req->gudang)->where('data_item_gudang.id_barang', $req->barang)->where('data_barang.tipe', $req->tipe)->select('data_barang.nm_barang', 'data_barang.kode', 'data_item_gudang.in', 'data_item_gudang.out', 'ref_satuan.nm_satuan')->first();
         if ($barang == null) {
             return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Item tidak ditemukan!']);
         }
         //Sisa per priode
         $sisapriode = data_log_barang::sisapriode($req->all())->get();
         //dd($sisapriode);
         $sisa = 0;
         foreach ($sisapriode as $sp) {
             if ($sp->kondisi == 1) {
                 $sisa += $sp->qty;
             } else {
                 $sisa -= $sp->qty;
             }
         }
         $lastsisa = $sisa;
         // Log stok
         $logs = data_log_barang::kartostokbyitem($req->all())->get();
         foreach ($logs as $item) {
             if ($item->tipe == 1) {
                 $parent = data_skb::find($item->id_parent);
             } else {
                 if ($item->tipe == 2) {
                     //$parent = data_spbm::find($item->id_parent);
                     $parent = data_spbm::join('data_spbm_item', 'data_spbm_item.id_spbm', '=', 'data_spbm.id_spbm')->where('data_spbm_item.id_barang', $req->barang)->where('data_spbm.id_spbm', $item->id_parent)->select('data_spbm.*', 'data_spbm_item.tgl_exp')->first();
                 } else {
                     if ($item->tipe == 3) {
                         $parent = data_penyesuaian_stok::find($item->id_parent);
                     } else {
                         if ($item->tipe == 4) {
                             $parent = data_retur::find($item->id_parent);
                         } else {
                             if ($item->tipe == 5) {
                                 $parent = data_retur::find($item->id_parent);
                             }
                         }
                     }
                 }
             }
             if ($item->kondisi == 1) {
                 $lastsisa += $item->qty;
             } else {
                 $lastsisa -= $item->qty;
             }
             $items[] = ['tipe' => $item->tipe, 'parent' => $parent, 'kondisi' => $item->kondisi, 'qty' => $item->qty, 'sisa' => $lastsisa, 'oleh' => $item->nm_depan . ' ' . $item->nm_belakang];
         }
         $jenis = [1 => 'SKB', 2 => 'Good Receive', 3 => 'Penyesuaian', 4 => 'Retur Gudang', 5 => 'Retur Pembelian'];
         // Parameters
         $params = '';
         foreach ($req->all() as $par => $val) {
             if ($par != '_token') {
                 $params .= $par . '=' . $val . '&';
             }
         }
         $param = rtrim($params, '&');
         $gudang = ref_gudang::find($req->gudang);
         $data = ['barang' => $barang, 'items' => $items, 'req' => $req, 'jenis' => $jenis, 'param' => $params, 'gudang' => $gudang];
         $excel->sheet('New sheet', function ($sheet) use($data) {
             $sheet->loadView('Print.Pengadaan.SubGudang.Excel', $data);
         });
     })->export('xlsx');
 }
Exemplo n.º 10
0
 public function getAdditemprq($tipe = 0)
 {
     $akses = \Me::accessGudang();
     if (empty($tipe) || $tipe > 2 || !is_numeric($tipe)) {
         return redirect('/prq')->withNotif(['label' => 'danger', 'err' => 'Kesalahan, Silahkan buat pengajuan baru!']);
     }
     if (!in_array($tipe, $akses)) {
         return redirect('/prq')->withNotif(['label' => 'danger', 'err' => 'Maaf Bukan domain Anda!']);
     }
     if (count($this->ids) < 1) {
         return redirect('/prq/select')->withNotif(['label' => 'warning', 'err' => 'Maaf, Anda belum menentukan item Barang yang akan diproses.<br /> Silahkan pilih beberapa item di bawah ini']);
     }
     $items = data_barang::join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->whereIn('id_barang', $this->ids)->where('data_barang.tipe', $tipe)->select('data_barang.*', 'ref_satuan.nm_satuan')->get();
     if (count($items) == 0) {
         return redirect('/prq')->withNotif(['label' => 'danger', 'err' => 'Kesalahan, Silahkan buat pengajuan baru!']);
     }
     $prqs = data_prq::where('status', 1)->where('tipe', $tipe)->get();
     $ids = [];
     foreach ($items as $id) {
         $ids[] = $id->id_barang;
     }
     $ids = json_encode($ids);
     return view('Pengadaan.PRQ.AddItemPRQ', ['items' => $items, 'prqs' => $prqs, 'ids' => $ids, 'tipe' => $tipe]);
 }
 public function getAdditem(Request $req)
 {
     if ($req->ajax()) {
         $item = data_barang::join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_barang.id_barang', $req->id)->select('data_barang.id_barang', 'data_barang.id_satuan', 'data_barang.kode', 'data_barang.nm_barang', 'data_barang.harga_beli', 'ref_satuan.nm_satuan')->first();
         return json_encode($item);
     }
 }
Exemplo n.º 12
0
 /**
  * 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]);
 }
Exemplo n.º 13
0
 public function getAdditemspb($tipe = 0)
 {
     if (count($this->ids) < 1) {
         return redirect('/pmbumum')->withNotif(['label' => 'warning', 'err' => 'Maaf, Anda belum menentukan item Barang yang akan diproses.<br /> Silahkan pilih beberapa item dib  bawah ini']);
     }
     if (empty($tipe) || $tipe > 2 || !is_numeric($tipe)) {
         return redirect('/pmbumum')->withNotif(['label' => 'warning', 'err' => 'Kesalahan, Silahkan tentukan kembali permintaan anda!']);
     }
     $items = data_barang::join('ref_satuan', 'ref_satuan.id_satuan', '=', 'data_barang.id_satuan')->where('data_barang.tipe', $tipe)->whereIn('id_barang', $this->ids)->select('data_barang.*', 'ref_satuan.nm_satuan')->get();
     if (count($items) < 1) {
         return redirect('/pmbumum')->withNotif(['label' => 'warning', 'err' => 'Maaf, Anda belum menentukan item Barang yang akan diproses.<br /> Silahkan pilih beberapa item dib  bawah ini']);
     }
     $spb = data_spb::where('id_departemen', \Me::data()->id_departemen)->where('tipe', $tipe)->where('status', 1)->get();
     $ids = [];
     foreach ($items as $id) {
         $ids[] = $id->id_barang;
     }
     $ids = json_encode($ids);
     return view('Pengadaan.SPB.AdditemSPB', ['items' => $items, 'spball' => $spb, 'tipe' => $tipe, 'satuan' => ref_satuan::all(), 'ids' => $ids]);
 }
 public function getLaporanstokprint(Request $req)
 {
     //dd($req->all());
     if ($req->tipe == 'klasifikasi' && $req->id_klasifikasi == '') {
         return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Anda belum menenetukan Klasifikasi']);
     }
     if ($req->tipe == 'kategori' && $req->id_kategori == '') {
         return redirect()->back()->withNotif(['label' => 'danger', 'err' => 'Anda belum menenetukan Kategori']);
     }
     $items = data_barang::laporanstok($req->all())->get();
     $tipe = [1 => 'Obat', 2 => 'Barang'];
     return view('Laporan.Logistik.LaporanStokPrint', ['items' => $items, 'req' => $req, 'tipe' => $tipe]);
 }
Exemplo n.º 15
0
    public function getLogharga(Request $req)
    {
        if ($req->ajax()) {
            $res = [];
            $items = data_po_item::join('data_po', 'data_po.id_po', '=', 'data_po_item.id_po')->where('data_po.id_vendor', $req->vendor)->whereIn('data_po.status', [1, 2, 3])->where('data_po_item.id_item', $req->id_barang)->orderby('data_po_item.id_po_item', 'desc')->select('data_po.no_po', 'data_po.id_po', 'data_po.created_at', 'data_po.status', 'data_po_item.harga')->paginate(10);
            $status = [1 => 'Baru', 2 => 'Proses', 3 => 'Selesai'];
            $out = '<table class="table table-striped" >
				<thead>
					<tr>
						<th>PO</th>
						<th>Tanggal</th>
						<th>Status</th>
						<th class="text-right">Harga</th>
					</tr>
				</thead>
				<tbody>
			';
            if ($items->total() > 0) {
                foreach ($items as $item) {
                    $out .= '<tr>
						<td>
							<a href="' . url('/po/print/' . $item->id_po) . '" target="_blank">' . $item->no_po . '</a>
						</td>
						<td>
							' . \Format::indoDate($item->created_at) . '<br />
							<div><small class="text-muted">' . \Format::hari($item->created_at) . ', ' . \Format::jam($item->created_at) . '</small></div>
						</td>
						<td>' . $status[$item->status] . '</td>
						<td class="text-right">' . number_format($item->harga, 0, ',', '.') . '</td>
					</tr>';
                }
            } else {
                $out .= '<tr>
					<td colspan="4">Tidak ditemukan</td>
				<tr>';
            }
            $out .= '</tbody></table>';
            $vendor = data_vendor::find($req->vendor);
            $barang = data_barang::find($req->id_barang);
            $res['vendor'] = $vendor->nm_vendor;
            $res['kode'] = $barang->kode;
            $res['content'] = $out;
            $res['pagin'] = $items->render();
            return json_encode($res);
        }
    }
Exemplo n.º 16
0
 public function postAdditem(Request $req)
 {
     if ($req->ajax()) {
         $item = data_barang::find($req->id);
         $new = [['kode' => $item->kode, 'id_barang' => $item->id_barang, 'nm_barang' => $item->nm_barang, 'sisa' => $item->in - $item->out, 'tipe' => $item->tipe]];
         $items = [];
         $find = false;
         if (!empty($req->session()->get($this->MySession))) {
             foreach ($req->session()->get($this->MySession) as $val) {
                 if ($val['id_barang'] == $req->id) {
                     $items[] = ['kode' => $val['kode'], 'id_barang' => $val['id_barang'], 'nm_barang' => $val['nm_barang'], 'sisa' => $val['sisa'], 'tipe' => $val['tipe']];
                     $find = true;
                 } else {
                     $items[] = ['kode' => $val['kode'], 'id_barang' => $val['id_barang'], 'nm_barang' => $val['nm_barang'], 'sisa' => $val['sisa'], 'tipe' => $val['tipe']];
                 }
             }
         }
         if ($find) {
             $value = $items;
         } else {
             $value = array_merge($new, $items);
         }
         $req->session()->put($this->MySession, $value);
         return json_encode(['id' => $req->id]);
     }
 }