88 lines
3.5 KiB
PHP
88 lines
3.5 KiB
PHP
<?php
|
|
if(!session_id()) {
|
|
session_start();
|
|
}
|
|
if(!empty($_POST)){
|
|
require_once ('../core/main.php');
|
|
require_once (_DOCROOT_.'vendor/autoload.php');
|
|
|
|
// save to rest api farmasi
|
|
$arr_store = ['input'=>$_POST['input'],'arr_input'=>$_POST['arr_input']];
|
|
|
|
$client = new GuzzleHttp\Client();
|
|
$res = $client->request('POST', $_SESSION['FARMASI_WEBADDRESS'].'/api/penjualan', [
|
|
'form_params'=> $arr_store,
|
|
'headers' => [
|
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
|
'x-token' => $_SESSION['farmasi_x_token']
|
|
],
|
|
]);
|
|
|
|
$jsonp = ($res->getStatusCode() == 201) ? $res->getBody()->getContents() : [];
|
|
$data_jual = (!empty($jsonp)) ? json_decode($jsonp) : null;
|
|
$log_jual = (array) $data_jual->main;
|
|
$log_jualdetil = (array) $data_jual->detil;
|
|
$log_mutasi = (array) $data_jual->mutasi;
|
|
|
|
// echo '<div style="text-align:left">
|
|
// <pre>',print_r($data_jual),'</pre>
|
|
// <pre>',print_r($log_jual),'</pre>';
|
|
// echo '<pre>',print_r($log_jualdetil),'</pre></div>';
|
|
// exit;
|
|
$insert_main = "INSERT INTO ttlogjual ".bind_sql($log_jual);
|
|
|
|
execute($insert_main);
|
|
|
|
foreach($log_jualdetil as $detil) {
|
|
$insert_detil = "INSERT INTO ttlogjuald ".bind_sql($detil);
|
|
|
|
$update_mutasi = "UPDATE ttlogmutasi set Keluar = (Keluar+".$detil['Jumlah']."), StockAkhir = (StockAkhir-".$detil['Jumlah'].") WHERE KodePeriode = '".date('Ym')."' and KodeDepo = '".$detil['KodeDepo']."' AND KodeBarang = '".$detil['KodeBarang']."' AND StStock = ".$detil['StStock'];
|
|
|
|
execute($insert_detil);
|
|
execute($update_mutasi);
|
|
}
|
|
|
|
$insert_obat = "INSERT INTO t_pemberianobat(IDXRANAP,NOMR,TANGGAL,DOKTER,KodeTransaksi) VALUES('$_POST[id_admission]','$_POST[nomr]','".date('Y-m-d H:i:s')."','$_POST[kddokter]','$log_jual[Kode]')";
|
|
execute($insert_obat);
|
|
|
|
}
|
|
$id_admission = (isset($id_admission)) ? $id_admission : $_POST['id_admission'];
|
|
|
|
$query_view = "SELECT t_pemberianobat.TANGGAL,ttlogjuald.*,tmlogbarang.Nama FROM t_pemberianobat JOIN ttlogjual ON t_pemberianobat.KodeTransaksi = ttlogjual.Kode
|
|
JOIN ttlogjuald on ttlogjual.Kode = ttlogjuald.KodeJual
|
|
JOIN tmlogbarang on ttlogjuald.KodeBarang = tmlogbarang.Kode
|
|
WHERE IDXRANAP = '$id_admission'";
|
|
// var_dump($query_view);
|
|
?>
|
|
<div id="valid_spo">
|
|
<div id="head_report_spo" style="display:none" align="center">
|
|
<div align="center" style="clear:both; padding:20px">
|
|
<div style="letter-spacing:-1px; font-size:16px; font:bold;"><?=$header1?></div>
|
|
<div style="letter-spacing:-2px; font-size:24px; color:#666; font:bold;"><?=$header2?></div>
|
|
<div><?=$header3?><br /><?=$header4?></div>
|
|
<hr style="margin:5px;" />
|
|
</div>
|
|
</div>
|
|
|
|
<table class="table table-hover table-bordered table-striped table-sm">
|
|
<tr align="center" class="bg-success text-light">
|
|
<th>No</th>
|
|
<th>Tanggal</th>
|
|
<th>Nama Obat</th>
|
|
<th>Waktu</th>
|
|
<th>Keterangan</th>
|
|
</tr>
|
|
<?php
|
|
$qry = $db->query($query_view);
|
|
$no = 1;
|
|
foreach($qry->fetchAll() as $data){
|
|
echo '<tr><td>'.$no.'</td>
|
|
<td>'.$data['TANGGAL'].'</td>
|
|
<td>'.$data['Nama'].'</td>
|
|
<td>Pagi : '.(($data['SP'] == 1) ? 'Ya' : '-').', Siang : '.(($data['SS'] == 1) ? 'Ya' : '-').', Sore : '.(($data['SSR'] == 1) ? 'Ya' : '-').', Malam : '.(($data['SM'] == 1) ? 'Ya' : '-').'</td>
|
|
<td>'.$data['Frek'].' x '.$data['Jfrek'].' '.$data['Signa'].'</td></tr>';
|
|
} ?>
|
|
</table>
|
|
</div>
|
|
<input type="button" class="btn btn-success text" value="PRINT" onclick="printIt('valid_spo','head_report_spo')" />
|