Exemple #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()];
     }
 }
 /**
  * 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()];
     }
 }
Exemple #3
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()];
     }
 }
 public function getDatapembelian(Request $req)
 {
     if ($req->ajax()) {
         $res = [];
         $out = '';
         $kat = [];
         $seri = [];
         $items = data_po::grafikpembelian($req->tahun)->get();
         foreach ($items as $item) {
             $kat[] = \Format::indoDate2($item->tanggal);
             $seri[] = (int) $item->total;
         }
         $res['po'] = ['kategori' => $kat, 'data' => $seri];
         $kato = [];
         $serio = [];
         $obats = data_po_item::grafikpembelian(1, $req->tahun)->get();
         foreach ($obats as $o) {
             $kato[] = \Format::indoDate2($o->tanggal);
             $serio[] = (int) $o->total;
         }
         $res['obat'] = ['kategori' => $kato, 'data' => $serio];
         $katb = [];
         $serib = [];
         $barangs = data_po_item::grafikpembelian(2, $req->tahun)->get();
         foreach ($barangs as $b) {
             $katb[] = \Format::indoDate2($b->tanggal);
             $serib[] = (int) $b->total;
         }
         $res['barang'] = ['kategori' => $katb, 'data' => $serib];
         return json_encode($res);
     }
 }
 /**
  * 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()
 {
     //dd($this->req);
     try {
         \DB::begintransaction();
         if ($this->req['id'] < 1) {
             $group = data_sph_grup::create(['id_pembuat' => \Me::data()->id_karyawan]);
         } else {
             $group = data_sph_grup::find($this->req['id_sph_grup']);
             \Loguser::create('Melakukan Perubahan pada Pengajuan pada SPH No. ' . $group->no_sph);
         }
         $sph = data_sph::create(['id_sph_grup' => $group->id_sph_grup, 'id_vendor' => $this->req['vendor'], 'deadline' => $this->req['deadline'], 'id_pembuat' => \Me::data()->id_karyawan, 'id_acc' => 0, 'diskon' => $this->req['gdiskon'], 'ppn' => $this->req['gppn'], 'adjustment' => $this->req['adjustment'], 'keterangan' => $this->req['ket']]);
         foreach ($this->req['id_sph_item'] as $i => $id_sph_item) {
             data_sph_item::create(['id_sph' => $sph->id_sph, 'id_prq' => $this->req['id_prq'][$i], 'id_item' => $this->req['id_barang'][$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]]);
             data_prq::find($this->req['id_prq'][$i])->update(['status' => 2]);
         }
         if ($this->req['id'] < 1) {
             $format = 'G-SPH/';
             $group->no_sph = $format . \Format::code($group->id_sph_grup);
             $group->save();
             \Loguser::create('Membuat Surat Pengajuan Harga dengan No. ' . $group->no_sph);
         }
         $fo = 'SPH/';
         $sph->no_sph_item = $fo . \Format::code($sph->id_sph);
         $sph->save();
         // Update SPH ke status system
         $old = data_sph::find($this->req['id']);
         $old->update(['status' => 3]);
         // Update Status PO by system
         $po = data_po::whereId_sph($this->req['id'])->update(['status' => 5]);
         \DB::commit();
         return ['status' => true, 'data' => ['id_sph' => $sph->id_sph, 'id_sph_grup' => $sph->id_sph_grup]];
     } catch (\Exception $e) {
         \DB::rollback();
         return ['status' => false, 'label' => 'danger', 'err' => $e->getMessage()];
     }
 }
Exemple #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()];
     }
 }
    public function getAllpo(Request $req)
    {
        if ($req->ajax()) {
            $res = [];
            $out = '';
            $status = $req->status == 0 ? [1, 2, 3] : $req->status;
            $items = data_po::forvendor($req->id, $req->all(), $status)->paginate($req->limit);
            $total = $items->total();
            $status = [1 => 'Baru', 2 => 'Proses', 3 => 'Selesai'];
            if ($total > 0) {
                $no = $items->currentPage() == 1 ? 1 : $items->perPage() * $items->currentPage() - $items->perPage() + 1;
                foreach ($items as $item) {
                    $out .= '
						<tr>
							<td>' . $no . '</td>
							<td>
								' . $item->no_po . '
								<div class="link">
									<small>
										[<a href="' . url('/po/print/' . $item->id_po) . '" target="_balnk">Print</a>]
									</small>
								</div>	
							</td>
							<td>
								<span>' . \Format::indoDate($item->created_at) . '</span>
								<div><small class="text-muted">' . \Format::hari($item->created_at) . ', ' . \Format::jam($item->created_at) . '</small></div>
							</td>
							<td>
								<span>' . \Format::indoDate($item->deadline) . '</span>
							</td>
							<td>' . $status[$item->status] . '</td>
						</tr>
					';
                    $no++;
                }
            } else {
                $out = '
					<tr>
    					<td colspan="5">Tidak ditemukan</td>
    				</tr>
				';
            }
            $res['content'] = $out;
            $res['pagin'] = $items->render();
            return json_encode($res);
        }
    }
 public function getCreategr($id = 0)
 {
     if (empty($id) || !is_numeric($id)) {
         return redirect('/gr/po')->withNotif(['label' => 'danger', 'err' => 'PO tidak ditemukan !']);
     }
     $po = data_po::join('data_vendor', 'data_vendor.id_vendor', '=', 'data_po.id_vendor')->where('data_po.id_po', $id)->select('data_po.*', 'data_vendor.nm_vendor');
     if ($po->count() == 0) {
         return redirect('/gr/po')->withNotif(['label' => 'danger', 'err' => 'PO tidak ditemukan !']);
     }
     $po = $po->first();
     if ($po->status > 2) {
         return redirect('/gr/po')->withNotif(['label' => 'danger', 'err' => 'PO tidak ditemukan !']);
     }
     $items = data_po_item::forspbmbypo($id)->get();
     $status = [1 => 'Status baru', 2 => 'Dalam proses'];
     return view('Pembelian.SPBM.Creategr', ['po' => $po, 'items' => $items, 'status' => $status]);
 }
 public function getAdditempo(Request $req)
 {
     if ($req->ajax()) {
         $res = [];
         $out = [];
         $po = data_po::find($req->id);
         $items = data_po_item::allpo($req->id)->get();
         foreach ($items as $item) {
             /* MATEMATIKA */
             $diskon = $item->harga * $item->diskon / 100;
             $aftdiskon = $item->harga - $diskon;
             $ppn = $aftdiskon + $item->ppn;
             $pph = $aftdiskon + $item->pph;
             $harga = $aftdiskon + $ppn + $pph;
             $out[] = ['id_barang' => $item->id_item, 'kode' => $item->kode, 'nm_barang' => $item->nm_barang, 'id_satuan' => $item->id_satuan, 'nm_satuan' => $item->nm_satuan, 'qty' => $item->req_qty, 'diskon' => $item->diskon, 'ppn' => $item->ppn, 'pph' => $item->pph, 'harga' => $item->harga, 'total' => $harga * $item->req_qty];
         }
         $res['po'] = $po;
         $res['items'] = $out;
         return json_encode($res);
     }
 }
Exemple #11
0
 public function postDelpo(Request $req)
 {
     if ($req->ajax()) {
         $po = data_po::find($req->id);
         $po->update(['status' => 4]);
         \Loguser::create('Menghapus PO no. ' . $po->no_po);
         return json_encode(['id' => $req->id]);
     }
 }