public function importshoplists() { $ext = Input::file('file')->getClientOriginalExtension(); $validator = Validator::make(array('ext' => $ext), array('ext' => 'in:xls,xlsx')); if ($validator->fails()) { Session::flash('error', 'File format tidak di dukung'); return Redirect::to('/admin/import/shoplists'); } else { if ($ext == 'xls') { Input::file('file')->move(public_path(), 'sl.xls'); if (Input::get('replace') == 'on') { DB::table('shoplist')->delete(); } else { } try { Excel::load('public/sl.xls', function ($r) { $res = $r->all()->toArray(); foreach ($res as $data) { $d = new Shoplist(); $d->kode = $data['kode_sl']; $d->deskripsi = $data['deskripsi_pekerjaan']; $d->satuan = $data['satuan']; $d->harga = $data['harga']; $d->save(); } }); } catch (Exception $e) { Session::flash('error', 'File tidak sesuai format'); return Redirect::to('/admin/import/shoplists'); } } elseif ($ext == 'xlsx') { Input::file('file')->move(public_path(), 'sl.xlsx'); if (Input::get('replace') == 'on') { DB::table('shoplist')->delete(); } else { } try { Excel::load('public/sl.xlsx', function ($r) { $res = $r->all()->toArray(); foreach ($res as $data) { $d = new Shoplist(); $d->kode = $data['kode_sl']; $d->deskripsi = $data['deskripsi_pekerjaan']; $d->satuan = $data['satuan']; $d->harga = $data['harga']; $d->save(); } }); } catch (Exception $e) { Session::flash('error', 'File tidak sesuai format'); return Redirect::to('/admin/import/shoplists'); } } else { } Session::flash('success', 'Data telah dibuat.'); return Redirect::to('/admin/import/shoplists'); } }
public function storefromajax() { $shoplist = new Shoplist(); $shoplist->kode = Input::get('kode'); $shoplist->deskripsi = Input::get('deskripsi'); $shoplist->satuan = Input::get('satuan'); $shoplist->harga = Input::get('harga'); $shoplist->save(); return Response::json($shoplist); }
} } else { echo 'asc'; } ?> ">Quantity to order</a> </th> <th> Comment </th> </tr> </thead> <tbody> <?php include 'include/include_shoplist.php'; $ShoplistList = new Shoplist(); $ShoplistList->ShoplistList(); ?> </tbody> </table> <div class="totalSumWrapper"> <?php include 'include/include_shoplist_sum.php'; $ShoplistPriceSum = new ShoplistPrice(); $ShoplistPriceSum->ShoplistPriceSum(); ?> </div> </div> <!-- END --> <!-- Text outside the main content --> <?php
public function updatespj($id) { $oss = OSS::find($id); $oss->oss_type = "spj"; $oss->tanggal = Carbon::parse(Input::get('tanggal')); $oss->bantek = Input::get('bantek'); $oss->permasalahan = Input::get('permasalahan'); $oss->action = Input::get('action'); $oss->mulai = Carbon::parse(Input::get('mulai')); $oss->selesai = Carbon::parse(Input::get('selesai')); $oss->kode_rks = Input::get('kode_rks'); $oss->deskripsi_rks = Input::get('deskripsi_rks'); $oss->transport = Input::get('transport'); $oss->user_mengerjakan = Input::get('mengerjakan'); $oss->user_mengetahui = Input::get('mengetahui'); $oss->save(); $list_site = Input::get('namasite'); $oldsites = OSSBantekSite::where('oss_id', '=', $oss->id)->delete(); for ($si = 0; $si < count($list_site); $si++) { $ns = new OSSBantekSite(); $ns->oss_id = $oss->id; $ns->site_id = $list_site[$si]; $ns->save(); } $transport = ''; foreach ($oss->shoplists as $sl) { if ($sl->type == 'transport') { $transport = $sl; } } OSShop::where('oss_id', '=', $id)->delete(); $shopping_list = Input::get('shoplist'); $harga = 0; for ($i = 0; $i < count($shopping_list); $i++) { $ss = new OSShop(); $ss->oss_id = $oss->id; $ss->shoplist_id = $shopping_list[$i]; $ss->save(); $sl = Shoplist::find($shopping_list[$i]); $harga += $sl->harga; } $oss->harga = $harga; $oss->save(); $menyetujui = Input::get('menyetujui'); MenyetujuiOSS::where('oss_id', '=', $id)->delete(); for ($j = 0; $j < count($menyetujui); $j++) { $stj = new MenyetujuiOSS(); $stj->oss_id = $oss->id; $stj->user_id = $menyetujui[$j]; $stj->save(); } //perhitungan RKS $biaya_rks = 0; $st = new Carbon(Input::get('mulai')); $nd = new Carbon(Input::get('selesai')); $diff = $nd->diff($st)->days; if ($diff > 1) { $biaya_rks += 350000 * ($diff - 1); $biaya_rks += 150000; } else { if ($diff == 1) { $biaya_rks = 350000; } else { $biaya_rks = 150000; } } $oss->harga_rks = $biaya_rks; //biaya perjalanan $biayafee = 0; if (Input::get('transport') == 'no') { $oss->harga += $biaya_rks; } else { if ($transport == '') { $shopl = new Shoplist(); } else { $shopl = $transport; } $shopl->kode = Input::get('kode_sl_trans'); $shopl->deskripsi = Input::get('deskripsi_sl_trans'); $shopl->satuan = Input::get('satuan_sl_trans'); $shopl->harga = Input::get('harga_sl_trans'); $shopl->type = 'transport'; $shopl->save(); $ss = new OSShop(); $ss->oss_id = $oss->id; $ss->shoplist_id = $shopl->id; $ss->save(); if ($shopl->harga <= 500000) { $biayafee = 15 / 100 * $shopl->harga; } else { $biayafee = 10 / 100 * $shopl->harga; } $oss->harga += $biaya_rks + $biayafee + $shopl->harga; } $oss->save(); Session::flash('success', 'Data telah diubah.'); return Redirect::to('/admin/oss/spj'); }