Пример #1
0
 /**
  * Submit excel file to database.
  *
  * @return Response
  */
 public function upload()
 {
     $all = Request::all();
     $file = $all['file'];
     $data['data'] = $file;
     $table = ExcelHelper::import($file);
     foreach ($table as $key => $value) {
         foreach ($value as $j => $k) {
             if ($k === null) {
                 $value[$j] = '';
             }
         }
         $value['nama'] = ucwords(strtolower($value['nama']));
         $tipeakun = TipeAkun::firstOrCreate(['nama' => $value['nama']]);
     }
     return redirect('tipeakun');
 }
Пример #2
0
 /**
  * Submit excel file to database.
  *
  * @return Response
  */
 public function upload()
 {
     $all = Request::all();
     $file = $all['file'];
     $table = ExcelHelper::import($file);
     foreach ($table as $key => $value) {
         foreach ($value as $j => $k) {
             if ($k === null) {
                 $value[$j] = '';
             }
         }
         $barang = Barang::find($value['id'])->first();
         if ($barang == null) {
             $barang = new Barang();
             /* fill tipe barang MASIH HARUS DIBENERIN*/
             $tipebarang = $value['tipebarang'];
             // $tipebarang = TipeBarang::find($tipebarang);
             // if ($tipebarang == null) {
             // 	$tipebarang = ucwords(strtolower($tipebarang));
             // 	$tipebarang = TipeBarang::firstOrCreate(['nama' => $tipebarang]);
             // 	$tipebarang = $tipebarang->id;
             // }
             $value['tipebarang'] = $tipebarang;
             /* fill numeric awal */
             if (!is_numeric($value['nilai_persediaan_awal'])) {
                 $value['nilai_persediaan_awal'] = 0;
             }
             if (!is_numeric($value['harga_jual1'])) {
                 $value['harga_jual1'] = 0;
             }
             if (!is_numeric($value['harga_jual2'])) {
                 $value['harga_jual2'] = 0;
             }
             if (!is_numeric($value['harga_jual3'])) {
                 $value['harga_jual3'] = 0;
             }
             if (!is_numeric($value['harga_jual4'])) {
                 $value['harga_jual4'] = 0;
             }
             if (!is_numeric($value['harga_jual5'])) {
                 $value['harga_jual5'] = 0;
             }
             if (!is_numeric($value['saldo_minimum'])) {
                 $value['saldo_minimum'] = 0;
             }
             /* correct status */
             $status = strtolower($value['status']);
             if ($status != 'aktif' && $status != 'non aktif') {
                 $status = 'aktif';
             }
             $value['status'] = $status;
             /* finally */
             $barang->fill($value);
             $barang->save();
             // dd($barang);
         }
     }
     return redirect('barang');
 }
Пример #3
0
 /**
  * Submit excel file to database.
  *
  * @return Response
  */
 public function upload()
 {
     $all = Request::all();
     $file = $all['file'];
     $table = ExcelHelper::import($file);
     foreach ($table as $key => $value) {
         foreach ($value as $j => $k) {
             if ($k === null) {
                 $value[$j] = '';
             }
         }
         $akun = Akun::find(['no_akun' => $value['no_akun']])->first();
         if ($akun == null) {
             $akun = new Akun();
             /* fill mata_uang */
             $mata_uang = Currency::find($value['mata_uang']);
             if ($mata_uang == null) {
                 continue;
             }
             $value['mata_uang'] = $mata_uang->simbol;
             /* fill tipe akun */
             $id_tipeakun = $value['id_tipeakun'];
             $tipeakun = TipeAkun::find($id_tipeakun);
             if ($tipeakun == null) {
                 $id_tipeakun = ucwords(strtolower($id_tipeakun));
                 $tipeakun = TipeAkun::firstOrCreate(['nama' => $id_tipeakun]);
                 $id_tipeakun = $tipeakun->id;
             }
             $value['id_tipeakun'] = $id_tipeakun;
             /* fill saldo awal */
             if (!is_numeric($value['saldo_awal'])) {
                 $value['saldo_awal'] = 0;
             }
             /* fill tanggal */
             if ($value['tanggal'] == null) {
                 $value['tanggal'] = date('Y-m-d');
             } else {
                 $tanggal = $value['tanggal'];
                 $tanggal = date('Y-m-d', strtotime($tanggal));
                 $value['tanggal'] = $tanggal;
             }
             /* finally */
             $akun->fill($value);
             $akun->save();
             // dd($akun);
         }
         //dd($akun);
         // $akun = Akun::firstOrCreate(['no_akun' => $value['no_akun']]);
         //$akun
     }
     return redirect('akun');
 }