Exemplo n.º 1
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.º 2
0
 public function getPrint($id = 0)
 {
     if (empty($id) || !is_numeric($id)) {
         return redirect('/gr')->withNotif(['label' => 'danger', 'err' => 'Maaf, tidak ditemukan !']);
     }
     $gr = data_spbm::byid($id)->first();
     if ($gr == null) {
         return redirect('/gr')->withNotif(['label' => 'danger', 'err' => 'Maaf, tidak ditemukan !']);
     }
     $items = data_spbm_item::bygr($id)->get();
     $kirim = [1 => 'Dikirim oleh Supplier', 2 => 'Dikirim Oleh Ekspedisi', 3 => 'Diambil Oleh Onkologi'];
     return view("Print.Pembelian.GR.printGR", ['items' => $items, 'gr' => $gr, 'kirim' => $kirim]);
 }
Exemplo n.º 3
0
    public function getListexpired(Request $req)
    {
        if ($req->ajax()) {
            $items = data_spbm_item::join('data_spbm', 'data_spbm.id_spbm', '=', 'data_spbm_item.id_spbm')->where('data_spbm_item.id_barang', $req->id_barang)->select('data_spbm_item.tgl_exp', 'data_spbm.no_spbm', 'data_spbm.id_spbm')->paginate(5);
            $res = [];
            $out = '';
            if ($items->total() > 0) {
                foreach ($items as $item) {
                    $out .= '
					<tr>
						<td>
							<a href="' . url('/gr/print/' . $item->id_spbm) . '" target="_blank">' . $item->no_spbm . '</a>
						</td>
						<td class="text-right">' . \Format::indoDate($item->tgl_exp) . '</td>
					</tr>
				';
                }
            } else {
                $out = '
					<tr>
						<td colspan="2">Tidak ditemukan</td>
					</tr>
				';
            }
            $res['content'] = $out;
            $res['pagin'] = $items->render();
            $res['id_barang'] = $req->id_barang;
            return json_encode($res);
        }
    }