示例#1
0
 /**
  * Store a newly created resource in storage.
  * POST /invoice
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::to('invoice')->withErrors($validator)->withInput(Input::all());
     } else {
         $invoice = new Invoice();
         $invoice->no_inv = Input::get('no_inv');
         $invoice->tgl_inv = Input::get('tgl_inv');
         $invoice->no_PO = Input::get('no_PO');
         $invoice->ship_by = Input::get('ship_by');
         $invoice->pay_method = Input::get('pay_method');
         $invoice->no_rek = Input::get('no_rek');
         $invoice->pelabuhan = Input::get('pelabuhan');
         $invoice->carrier = Input::get('carrier');
         $invoice->save();
         $SPPB = Barang::join('detil_SPPB', 'barang.kode_barang', '=', 'detil_SPPB.kode_barang')->join('SPPB', 'detil_SPPB.no_SPPB', '=', 'SPPB.no_SPPB')->join('PO', 'SPPB.no_SPPB', '=', 'PO.no_SPPB')->where('no_PO', Input::get('no_PO'))->selectRaw('barang.kode_barang as barang, jml_pesan as pesan')->get();
         foreach ($SPPB as $key => $value) {
             $barang = Barang::find($value->barang);
             $barang->jml_barang = $barang->jml_barang - $value->pesan;
             $barang->save();
         }
         Session::flash('message', 'Successfully created invoice!');
         return Redirect::to('invoice');
     }
 }
示例#2
0
 public static function stok($id)
 {
     $barang = DB::table('bahan')->where('id', $id)->first();
     if (!$barang) {
         $barang = Barang::find($id);
         return $barang->stok;
     }
     return $barang->stok;
 }
 /**
  * Show the form for editing the specified barang.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $barang = Barang::find($id);
     $categories = [];
     foreach (Category::all() as $category) {
         $categories[$category->id] = $category->nama;
     }
     $aroma = [];
     foreach (Parfum::orderBy('nama')->get() as $p) {
         $aroma[$p->id] = $p->nama;
     }
     return View::make('admin.barangs.edit', compact('barang', 'categories', 'aroma'));
 }
示例#4
0
 public function simpan2()
 {
     $detilSTTB = new DetilSTTB();
     $detilSTTB->no_STTB = Input::get('noSTTB');
     $detilSTTB->kode_barang = Input::get('kd_brg');
     $detilSTTB->jml_beli = Input::get('jml_beli');
     $detilSTTB->ket = Input::get('ket');
     $detilSTTB->save();
     $barang = Barang::find(Input::get('kd_brg'));
     $barang->jml_barang = $barang->jml_barang + Input::get('jml_beli');
     $barang->save();
     $brg = array('confirm' => 'succes');
     Session::flash('message', 'Successfully created STTB!');
 }
 /**
  * actionBrgkat() select2 barang mendapatkan unit barang
  * @author ptrnov  <*****@*****.**>
  * @since 1.1
  */
 public function actionBrgunit()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $ids = $_POST['depdrop_parents'];
         $kat_id = empty($ids[0]) ? null : $ids[0];
         $brg_id = empty($ids[1]) ? null : $ids[1];
         if ($brg_id != null) {
             $brgu = new Barang();
             $model = Barang::find()->where("KD_BARANG='" . $brg_id . "'")->one();
             $brgUnit = $model->unit;
             //foreach ($brgUnit as $value) {
             //$out[] = ['id'=>$value['UNIT'],'name'=> $value['NM_UNIT']];
             $out[] = ['id' => $brgUnit->KD_UNIT, 'name' => $brgUnit->NM_UNIT];
             //$out[] = ['id'=>'E07','name'=> $value->NM_UNIT];
             // }
             echo json_encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
 public function show($id)
 {
     $barang = Barang::find($id)->formula;
     $formula = Formula::select('formula', 'qty')->where('barang_id', $id)->get();
     return View::make('admin.formulas.show', compact('formula', 'barang'));
 }
示例#7
0
 public static function tipe($id)
 {
     $barang = Barang::find($id);
     if (!$barang) {
         return false;
     }
     return $barang->kategori_id;
 }
示例#8
0
 public function addToCart($id)
 {
     $barang = Barang::find($id);
     $tipe = Auth::user()->tipe;
     $qty = $_GET['qty'];
     if ($tipe == 1 || $tipe == 2) {
         $harga = $barang->harga_agenresmi;
     } elseif ($tipe == 3) {
         $harga = $barang->harga_agenlepas;
     } else {
         $harga = $barang->harga;
     }
     $data = ['id' => $barang->id, 'name' => $barang->nama, 'qty' => $qty, 'price' => $harga, 'options' => ['image' => $barang->gambar, 'berat' => $barang->berat]];
     if (isset($_GET['aroma'])) {
         $data['options']['aroma'] = $_GET['aroma'];
         if (isset($_GET['aromaKedua'])) {
             $data['options']['aroma'] = $_GET['aromaKedua'];
         }
     }
     // dd($data['options']['aroma']);
     Cart::associate('Barang')->add($data);
     $cartContent = Cart::content();
     // return View::make('store.cart', compact('cartContent'));
     return Cart::count(false);
 }
示例#9
0
@extends('_layouts.admin')

@section('content')

@foreach($detail as $d)
  <h4>{{$d->barang_id}} - {{$d->jumlah}} -- {{$d->keterangan}}</h4>
  @if(Barang::find($d->barang_id)->formula)
    @if($d->keterangan)
    <?php 
$needed[] = ['bahan' => Barang::aroma($d->keterangan), 'qty' => $d->jumlah];
?>
    @endif
    <?php 
$formulas = Barang::find($d->barang_id)->formula;
?>
    @foreach($formulas as $f)
      <li>{{$f->formula}} - {{$f->qty}}</li>
      @if(!array_search($f->formula, array_column($needed,'bahan')))
        <?php 
$needed[] = ['bahan' => $f->formula, 'qty' => $f->qty * $d->jumlah];
?>
      @else
        @foreach($needed as $key => $n)
          @if($n['bahan']==$f->formula)
            <?php 
$needed[$key]['qty'] += $f->qty * $d->jumlah;
?>
          @endif
        @endforeach
      @endif
    @endforeach
示例#10
0
 /**
  * Remove the specified resource from storage.
  * DELETE /barang/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $barang = Barang::find($id);
     $barang->delete();
     // redirect
     Session::flash('message', 'Successfully deleted barang!');
     return Redirect::to('barang');
     //
 }