first commit
This commit is contained in:
No files matched your search
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\Barang;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class BarangController extends Controller
|
||||
{
|
||||
|
||||
public function showAllBarangs()
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarang')->get());
|
||||
}
|
||||
|
||||
public function showOneBarang($id)
|
||||
{
|
||||
return response()->json(Barang::find($id));
|
||||
}
|
||||
|
||||
public function showStockAll()
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('m.StStock,TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,TMLogBarang.StFornas,TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['TMLogBarang.Aktif','=',1]
|
||||
])
|
||||
->groupBy('s.Kode','TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','m.StStock','TMLogBarang.StFornas','TMLogBarang.StRes')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showStockByDepo($depo, $stStok)
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock,TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['m.KodeDepo','=',$depo],
|
||||
['bs.StStock','=',$stStok],
|
||||
['TMLogBarang.Aktif','=',1]
|
||||
])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock','TMLogBarang.StRes')
|
||||
->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showAllStockByDepo($depo)
|
||||
{
|
||||
$tmp_all_stok = DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock,TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['m.KodeDepo','=',$depo],
|
||||
['TMLogBarang.Aktif','=',1]
|
||||
])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock','TMLogBarang.StRes')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get();
|
||||
$arr_all_stok = [];
|
||||
foreach($tmp_all_stok as $row) {
|
||||
$arr_all_stok[$row->Kode.';'.$row->StStock] = [
|
||||
'Kode'=>$row->Kode,
|
||||
'Nama'=>$row->Nama,
|
||||
'satuan'=>$row->satuan,
|
||||
'jenis'=>$row->jenis,
|
||||
'jmlStok'=>$row->jmlStok,
|
||||
'HJual'=>$row->HJual,
|
||||
'HPP'=>$row->HPP,
|
||||
'StStock'=>$row->StStock
|
||||
];
|
||||
}
|
||||
return response()->json($arr_all_stok);
|
||||
}
|
||||
|
||||
public function showAllStockByDepoByName($depo,$nama)
|
||||
{
|
||||
$nama = urldecode($nama);
|
||||
$query = DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock as kodeStok,TMLogBarang.KodeJenis,TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['m.KodeDepo','=',$depo],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
['TMLogBarang.Nama','like','%'.$nama.'%']
|
||||
])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock','TMLogBarang.KodeJenis','TMLogBarang.StRes')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get();
|
||||
|
||||
return response()->json($query);
|
||||
}
|
||||
|
||||
public function showAllStockAskesByName($nama)
|
||||
{
|
||||
$nama = urldecode($nama);
|
||||
$query = DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->join('TMOrgDepo as d','m.KodeDepo','=','d.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock as kodeStok,TMLogBarang.KodeJenis,TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['d.statusPasien','=','ASKES'],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
['TMLogBarang.Nama','like','%'.$nama.'%']
|
||||
])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock','TMLogBarang.KodeJenis','TMLogBarang.StRes')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get();
|
||||
|
||||
return response()->json($query);
|
||||
}
|
||||
|
||||
public function showAllStockHibah()
|
||||
{
|
||||
$query = DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->join('TMOrgDepo as d','m.KodeDepo','=','d.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock as kodeStok,TMLogBarang.KodeJenis,TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['s.Kode','=','6'],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock','TMLogBarang.KodeJenis','TMLogBarang.StRes')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get();
|
||||
|
||||
return response()->json($query);
|
||||
}
|
||||
|
||||
public function showAlkesAll()
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock,'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['TMLogBarang.Aktif','=',1]
|
||||
])
|
||||
->whereIn('TMLogBarang.KodeKelompok',['ALK','ALKES','ALKDOK','ALKHUS'])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showAlkes($id)
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('s.Kode as kodeStok,TMLogBarang.Kode,TMLogBarang.Nama,TMLogBarang.StFornas, r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
['TMLogBarang.Nama','like','%'.$id.'%']
|
||||
])
|
||||
->whereIn('TMLogBarang.KodeKelompok',['ALK','ALKES','ALKDOK','ALKHUS'])
|
||||
->groupBy('s.Kode','TMLogBarang.Kode','TMLogBarang.Nama','TMLogBarang.StFornas','r1.Nama','s.Nama','bs.HPP','bs.HJual','m.StStock')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showAlkesDepo($depo)
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['m.KodeDepo','=',$depo],
|
||||
['TMLogBarang.Aktif','=',1]
|
||||
])
|
||||
->whereIn('TMLogBarang.KodeKelompok',['ALK','ALKES','ALKDOK','ALKHUS'])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showAlkesJknByName($nama)
|
||||
{
|
||||
$nama = urldecode($nama);
|
||||
return response()->json(DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->join('TMOrgDepo as d','m.KodeDepo','=','d.Kode')
|
||||
->select(DB::raw('TMLogBarang.Kode,TMLogBarang.Nama,r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,bs.StStock'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['d.statusPasien','=','ASKES'],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
['TMLogBarang.Nama','like','%'.$nama.'%']
|
||||
])
|
||||
->whereIn('TMLogBarang.KodeKelompok',['ALK','ALKES','ALKDOK','ALKHUS'])
|
||||
->groupBy('TMLogBarang.Kode','TMLogBarang.Nama','r1.Nama','s.Nama','bs.HPP','bs.HJual','bs.StStock')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
// ->having(DB::raw('sum(m.StockAkhir)'),'>',0)
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showStock($id)
|
||||
{
|
||||
$query = DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('s.Kode as kodeStok,TMLogBarang.Kode,TMLogBarang.Nama,TMLogBarang.StFornas, r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,TMLogBarang.KodeJenis, TMLogBarang.StRes'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
['TMLogBarang.Nama','like','%'.$id.'%']
|
||||
])
|
||||
->groupBy('s.Kode','TMLogBarang.Kode','TMLogBarang.Nama','TMLogBarang.StFornas','r1.Nama','s.Nama','bs.HPP','bs.HJual','m.StStock','TMLogBarang.KodeJenis','TMLogBarang.StRes')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
->get();
|
||||
$result = response()->json($query);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function showStockAdv($depo, $kode, $ststock)
|
||||
{
|
||||
$query = DB::table('TMLogBarang')
|
||||
->leftJoin('TMLogReference as r1','TMLogBarang.KodeSatuan','=','r1.Kode')
|
||||
->join('TTLogMutasiBarang as m','TMLogBarang.Kode','=','m.KodeBarang')
|
||||
->join('TMLogBarangStock as bs','TMLogBarang.Kode','=','bs.KodeBarang')
|
||||
->join('TMStock as s','m.StStock','=','s.Kode')
|
||||
->select(DB::raw('s.Kode as kodeStok,TMLogBarang.Kode,TMLogBarang.Nama,TMLogBarang.StFornas, r1.Nama as satuan,s.Nama as jenis,sum(m.StockAkhir) as jmlStok,bs.HJual,bs.HPP,TMLogBarang.KodeJenis'))
|
||||
->where([
|
||||
['m.KodePeriode','=',date('Ym')],
|
||||
['bs.StStock','=',DB::raw('cast(m.StStock as int)')],
|
||||
['TMLogBarang.Aktif','=',1],
|
||||
['m.KodeDepo','=',$depo],
|
||||
['bs.StStock','=',$ststock],
|
||||
['TMLogBarang.Kode','=',$kode]
|
||||
])
|
||||
->groupBy('s.Kode','TMLogBarang.Kode','TMLogBarang.Nama','TMLogBarang.StFornas','r1.Nama','s.Nama','bs.HPP','bs.HJual','m.StStock','TMLogBarang.KodeJenis')
|
||||
->orderBy(DB::raw('sum(m.StockAkhir)'),'desc')
|
||||
->get();
|
||||
$result = response()->json($query);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function showStatusStok()
|
||||
{
|
||||
return response()->json(DB::table('TMStock')->where('aktif',1)->get());
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = Barang::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = Barang::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Barang::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\BarangStock;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class BarangStockController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(DB::table('TMLogBarangStock')->get());
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = BarangStock::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = BarangStock::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
BarangStock::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Laravel\Lumen\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Depo;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DepoController extends Controller
|
||||
{
|
||||
|
||||
public function showAllDepos()
|
||||
{
|
||||
return response()->json(Depo::all());
|
||||
}
|
||||
|
||||
public function showOneDepo($id)
|
||||
{
|
||||
return response()->json(Depo::find($id));
|
||||
}
|
||||
|
||||
public function showSubDepo()
|
||||
{
|
||||
return response()->json(Depo::where('StJual',1)->get());
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = Depo::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = Depo::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Depo::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class ExampleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Barang;
|
||||
use App\Mail\DrugRestriction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class IjinObatController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send email the given item.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $kodeobat
|
||||
* @return Response
|
||||
*/
|
||||
public function sendNotif($kodeobat, Request $request)
|
||||
{
|
||||
$barang = Barang::find($kodeobat);
|
||||
// dd($barang);
|
||||
|
||||
// return (new DrugRestriction($barang,$request))->render();
|
||||
// Send notification
|
||||
// return response()->json($request->all());
|
||||
if(preg_match("/,/", $request->input('emailto')))
|
||||
{
|
||||
$arr_recipient = explode(",",$request->input('emailto'));
|
||||
array_walk($arr_recipient,'trim');
|
||||
foreach($arr_recipient as $recipient) {
|
||||
Mail::to($recipient)->send(new DrugRestriction($barang,$request));
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mail::to($request->input('emailto'))->send(new DrugRestriction($barang,$request));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\MutasiBarang;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class MutasiBarangController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(DB::table('TTLogMutasiBarang')->whereRaw("LEFT(KodePeriode,4) in ('".date('Y')."')")->paginate(10000));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = MutasiBarang::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$mutasi = MutasiBarang::findOrFail($id);
|
||||
$mutasi->update($request->input);
|
||||
|
||||
return response()->json($mutasi, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
MutasiBarang::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\Otorisasi;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class OtorisasiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send email the given item.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function sendOtorisasi(Request $request)
|
||||
{
|
||||
// Send notification
|
||||
// return response()->json($request->all());
|
||||
if(preg_match("/,/", $request->input('emailto')))
|
||||
{
|
||||
$arr_recipient = explode(",",$request->input('emailto'));
|
||||
array_walk($arr_recipient,'trim');
|
||||
foreach($arr_recipient as $recipient) {
|
||||
Mail::to($recipient)->send(new Otorisasi($request));
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mail::to($request->input('emailto'))->send(new Otorisasi($request));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\Depo;
|
||||
use App\LogJual;
|
||||
use App\LogJualDetil;
|
||||
use App\LogMutasiBarang;
|
||||
use App\TMPasien;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class PenjualanController extends Controller
|
||||
{
|
||||
|
||||
public function showJual()
|
||||
{
|
||||
return response()->json(LogJual::select('NoJual','TglJual','TMOrgDepo.Nama as nama_upf','NamaPx','AlamatPx')
|
||||
->join('TMOrgDepo','TMOrgDepo.Kode','TTLogJual.KodeDepo')
|
||||
->whereRaw('CONVERT(VARCHAR(10), TglJual, 103) = \''.date('d/m/Y').'\'')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showJualDetil($nojual)
|
||||
{
|
||||
if(preg_match("/-/", $nojual))
|
||||
{
|
||||
$nojual = preg_replace("/-/", ' ', $nojual);
|
||||
}
|
||||
$obj_query = LogJual::select('NoJual','TMOrgDepo.Nama as nama_upf','NoRMPx','NoBilling','NamaPx','AlamatPx','TMLogBarang.Nama as namaBarang','TTLogJualD.Jumlah','TTLogJualD.Harga','TMPetugas.Nama as nama_petugas','jaminan.Nama as nama_penjamin','TotJual')
|
||||
->selectRaw('CONCAT(CONVERT(VARCHAR(10), TglJual, 103),\' \',CONVERT(VARCHAR(10), TglJual, 108)) as TglJual')
|
||||
->selectRaw('(SELECT SUM(Harga*Jumlah) from TTLogJualD as d2 where d2.KodeJual = TTLogJual.Kode GROUP BY d2.KodeJual) as TotDetil')
|
||||
->selectRaw('(TotJual-(SELECT SUM(Harga*Jumlah) from TTLogJualD as d2 where d2.KodeJual = TTLogJual.Kode GROUP BY d2.KodeJual)) as Pembulatan')
|
||||
->join('TMOrgDepo','TMOrgDepo.Kode','TTLogJual.KodeDepo')
|
||||
->join('TTLogJualD','TTLogJual.Kode','TTLogJualD.KodeJual')
|
||||
->join('TMLogBarang','TTLogJualD.KodeBarang','TMLogBarang.Kode')
|
||||
->join('TMPetugas','TTLogJual.IdPetugas','TMPetugas.Kode')
|
||||
->leftJoin('TMLogReference as jaminan','TTLogJual.KodeJamin','jaminan.Kode')
|
||||
->where('NoJual','=',$nojual)
|
||||
->get();
|
||||
|
||||
return response()->json($obj_query);
|
||||
}
|
||||
|
||||
public function showJualFiltered($search)
|
||||
{
|
||||
return response()->json(LogJual::select('NoJual','TglJual','TMOrgDepo.Nama as nama_upf','NamaPx','AlamatPx')
|
||||
->join('TMOrgDepo','TMOrgDepo.Kode','TTLogJual.KodeDepo')
|
||||
->whereRaw('CONVERT(VARCHAR(10), TglJual, 103) = \''.date('d/m/Y').'\' AND (TMOrgDepo.Nama like \'%'.$search.'%\' OR NamaPx like \'%'.$search.'%\' OR AlamatPx like \'%'.$search.'%\')')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showJualFilteredDate($tgl)
|
||||
{
|
||||
$tgl = preg_replace("/-/","/",$tgl);
|
||||
return response()->json(LogJual::select('NoJual','TglJual','TMOrgDepo.Nama as nama_upf','NamaPx','AlamatPx')
|
||||
->join('TMOrgDepo','TMOrgDepo.Kode','TTLogJual.KodeDepo')
|
||||
->whereRaw('CONVERT(VARCHAR(10), TglJual, 103) = \''.$tgl.'\'')
|
||||
->get());
|
||||
}
|
||||
|
||||
|
||||
public function showTotalJual()
|
||||
{
|
||||
return response()->json(LogJual::selectRaw('count(NoJual) as jumlah')
|
||||
->join('TMOrgDepo','TMOrgDepo.Kode','TTLogJual.KodeDepo')
|
||||
->whereRaw('CONVERT(VARCHAR(10), TglJual, 103) = \''.date('d/m/Y').'\'')
|
||||
->get());
|
||||
}
|
||||
|
||||
public function showDetil($id)
|
||||
{
|
||||
return response()->json(LogJualDetil::where('KodeJual',$id)->get());
|
||||
}
|
||||
|
||||
private function insert_loop(Request $request)
|
||||
{
|
||||
$arr_input = (array) $request->input('arr_input');
|
||||
$totalJual = 0;
|
||||
foreach($arr_input as $detil){
|
||||
if($detil['Jumlah'] == '' ) { continue; }
|
||||
$totalJual += ($detil['Harga']*$detil['Jumlah']);
|
||||
}
|
||||
|
||||
if($totalJual == 0)
|
||||
{
|
||||
return response()->json(['status'=>'error','message'=>'Data barang kosong.'],200);
|
||||
}
|
||||
|
||||
$input = (array) $request->input('input');
|
||||
// get kode jual
|
||||
$tmp_jual = LogJual::where('Kode','like',$input['KodeDepo'].date('Ym').'%')->orderBy('Kode','desc')->first();
|
||||
if(!empty($tmp_jual)){
|
||||
$kd_jual = str_replace($input['KodeDepo'], "", $tmp_jual->Kode);
|
||||
$kd_jual = substr($kd_jual,6);
|
||||
$kd_jual += 1;
|
||||
$kd_jual = date('Ym').str_pad($kd_jual, 6, "0", STR_PAD_LEFT);
|
||||
}
|
||||
else {
|
||||
$kd_jual = date('Ym').'000001';
|
||||
}
|
||||
|
||||
// get no jual depo
|
||||
$findDepo = Depo::find($input['KodeDepo']);
|
||||
$tmp_jual2 = LogJual::where('NoJual','like',$findDepo->Inisial.date('Ym').'%')->orderBy('NoJual','desc')->first();
|
||||
if(!empty($tmp_jual2)){
|
||||
$no_jual = str_replace($findDepo->Inisial, "", $tmp_jual2->NoJual);
|
||||
$no_jual = substr($no_jual,6);
|
||||
$no_jual += 1;
|
||||
$no_jual = date('Ym').str_pad($no_jual, 6, "0", STR_PAD_LEFT);
|
||||
}
|
||||
else {
|
||||
$no_jual = date('Ym').'000001';
|
||||
}
|
||||
|
||||
$input['Kode'] = $input['KodeDepo'].$kd_jual;
|
||||
$input['NoJual'] = $findDepo->Inisial.$no_jual;
|
||||
$input['TglJual'] = date('Y-m-d H:i:s');
|
||||
$input['NoMinta'] = $input['KodeDepo'].$kd_jual;
|
||||
$input['Aktif'] = 1;
|
||||
$input['StCetak'] = 1;
|
||||
$input['StJual'] = 1;
|
||||
$input['TotJual'] = $totalJual;
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$inputvar = (array) $request->input('input');
|
||||
$arr_input = (array) $request->input('arr_input');
|
||||
// generate data to insert with 3 times trying
|
||||
|
||||
// DB::enableQueryLog();
|
||||
$is_success = 0;
|
||||
for( $i = 0; $i < 3; $i++) {
|
||||
if($is_success == 0) {
|
||||
$input = $this->insert_loop($request);
|
||||
|
||||
$LogJual = LogJual::firstOrNew($input);
|
||||
|
||||
if(!$LogJual->save()) {
|
||||
$is_success = 0;
|
||||
}
|
||||
else {
|
||||
$is_success = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// return response()->json(DB::getQueryLog());exit;
|
||||
|
||||
$LogJualD = $LogMutasi = [];
|
||||
if($is_success)
|
||||
{
|
||||
$i = 1;
|
||||
foreach($arr_input as $detil)
|
||||
{
|
||||
if($detil['Jumlah'] == '') continue;
|
||||
$detil['Kode'] = $input['Kode'].date('Ym').str_pad($i, 4, '0', STR_PAD_LEFT);
|
||||
$detil['KodeJual'] = $input['Kode'];
|
||||
$detil['StStock'] = $detil['StStock']*1;
|
||||
$detil['StRacik'] = $detil['StRacik']*1;
|
||||
$detil['Frek'] = $detil['Frek']*1;
|
||||
$detil['JFrek'] = $detil['JFrek']*1;
|
||||
$detil['Jumlah'] = $detil['Jumlah']*1;
|
||||
$detil['Harga'] = $detil['Harga']*1;
|
||||
$detil['HargaRetur'] = $detil['Harga'];
|
||||
$detil['HPP'] = $detil['HPP']*1;
|
||||
$detil['SP'] = $detil['SP']*1;
|
||||
$detil['SS'] = $detil['SS']*1;
|
||||
$detil['SSR'] = $detil['SSR']*1;
|
||||
$detil['SM'] = $detil['SM']*1;
|
||||
$detil['PenG'] = $detil['PenG']*1;
|
||||
$detil['PenF'] = $detil['PenF']*1;
|
||||
unset($detil['subtotal']);
|
||||
|
||||
$LogJualDetil = LogJualDetil::create($detil);
|
||||
|
||||
$LogMutasiBarang = LogMutasiBarang::where([
|
||||
['KodePeriode',date('Ym')],
|
||||
['KodeDepo',$input['KodeDepo']],
|
||||
['KodeBarang',$detil['KodeBarang']],
|
||||
['StStock',$detil['StStock']]
|
||||
])
|
||||
->update([
|
||||
'Keluar' => DB::raw('(Keluar+'.$detil['Jumlah'].')'),
|
||||
'StockAkhir' => DB::raw('(StockAkhir-'.$detil['Jumlah'].')')
|
||||
]);
|
||||
|
||||
$LogJualD[] = $LogJualDetil;
|
||||
$LogMutasi[] = $LogMutasiBarang;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// return response()->json(DB::getQueryLog());exit;
|
||||
|
||||
if($is_success) {
|
||||
// create pasien
|
||||
$arr_pasien['NoRM'] = $inputvar['NoRMPx'];
|
||||
$arr_pasien['Nama'] = $inputvar['NamaPx'];
|
||||
$arr_pasien['JKL'] = NULL;
|
||||
$arr_pasien['Alamat'] = '';
|
||||
$arr_pasien['TglLahir'] = $inputvar['TglLahir'];
|
||||
|
||||
$savePasien = TMPasien::updateOrCreate($arr_pasien);
|
||||
|
||||
return response()->json([
|
||||
'status'=>'sukses',
|
||||
'message'=>'Data penjualan obat telah disimpan.',
|
||||
'main'=>$LogJual,
|
||||
'detil'=>$LogJualD,
|
||||
'mutasi'=>$LogMutasi
|
||||
], 201);
|
||||
}
|
||||
else {
|
||||
return response()->json([
|
||||
'status'=>'error',
|
||||
'message'=>'Data penjualan obat gagal disimpan.'
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = Barang::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Barang::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class PetugasController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(DB::table('TMPetugas')->get());
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = Reference::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = Reference::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Reference::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\MasterProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class ProviderController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(MasterProvider::all());
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = MasterProvider::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = MasterProvider::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
MasterProvider::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\Reference;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class ReferenceController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(DB::table('TMLogReference')->get());
|
||||
}
|
||||
|
||||
public function showJenis()
|
||||
{
|
||||
return response()->json(DB::table('TMLogReference')
|
||||
->select('Kode','Nama')
|
||||
->where([['Tipe','=',1],['aktif','=',1]])
|
||||
->get()
|
||||
);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = Reference::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = Reference::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Reference::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use App\MasterStok;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class StokController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(DB::table('TMStock')->get());
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = MasterStok::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = MasterStok::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
MasterStok::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
class TempatController extends Controller
|
||||
{
|
||||
|
||||
public function showAll()
|
||||
{
|
||||
return response()->json(DB::table('TMLogReference')->get());
|
||||
}
|
||||
|
||||
public function showBy($jenis)
|
||||
{
|
||||
if($jenis == 1)
|
||||
{
|
||||
return response()->json(DB::table('TMOrgTL')->join('TMOrgJL as j','TMOrgTL.KodeJL','=','j.Kode')->where('TMOrgTL.Aktif',1)->select(DB::raw('TMOrgTL.Kode,TMOrgTL.KodeJL,j.Nama as NamaJL,TMOrgTL.Nama,TMOrgTL.StInap'))->get());
|
||||
}
|
||||
elseif($jenis == 2){
|
||||
return response()->json(DB::table('TMOrgJL')->where('Aktif',1)->get());
|
||||
}
|
||||
else {
|
||||
return response(500);
|
||||
}
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$author = Reference::create($request->all());
|
||||
|
||||
return response()->json($author, 201);
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
$author = Reference::findOrFail($id);
|
||||
$author->update($request->all());
|
||||
|
||||
return response()->json($author, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Reference::findOrFail($id)->delete();
|
||||
return response('Deleted Successfully', 200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use App\User;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('auth:api');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'email' => 'required',
|
||||
'password' => 'required'
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->input('email'))->first();
|
||||
$decrypt = base64_decode($request->input('password'));
|
||||
$hash = substr(substr($decrypt, 2),0,-2);
|
||||
if($user != NULL && Hash::check($hash, $user->password)){
|
||||
$apikey = base64_encode(str_random(40));
|
||||
$time = date('Y-m-d H:i:s');
|
||||
User::where('email', $request->input('email'))->update(['api_key' => "$apikey"]);;
|
||||
return response()->json(['status' => 'success','api_key' => $apikey,'api_timestamp' => $time]);
|
||||
}else{
|
||||
return response()->json(['status' => 'fail'],401);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user