Exemple #1
0
			<thead>
				<th>No.</th>
				<th>Nama Perawatan</th>
				<th>Biaya</th>
				<th>Diskon</th>
				<th>Komisi Dokter</th>
				<th>Komisi Perawat</th>
				<th>Obat Dalam</th>
				<th></th>
			</thead>
			<tbody>
				<tr ng-repeat="perawatan in perawatanCollection" ng-init="indexPerawatan=$index">
					<td>{{$index+1}}</td>
					<td width="30%">
						<?php 
$perawatan = Perawatan::model()->findAll();
?>
						<select ng-change="updatePerawatan(perawatan.id, isMember, $index)" ng-model="perawatan.id">
							<?php 
for ($i = 0; $i < count($perawatan); $i++) {
    echo '<option value="' . $perawatan[$i]['id_perawatan'] . '">' . $perawatan[$i]['nama_perawatan'] . ' - Rp. ' . number_format($perawatan[$i]['harga'], 2, ',', '.') . '</option>';
}
?>
						</select>
					</td>
					<td>
						{{perawatan.harga}}
					</td>
					<td>
						{{perawatan.diskon}}
					</td>
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['MasterTransaksi'])) {
         $model->attributes = $_POST['MasterTransaksi'];
         $model->updated_at = date('Y-m-d H:i:s');
         if ($model->save()) {
             //delete dokter
             $this->loadModelDeleteDokter($id);
             //save dokter
             $model_dokter = json_decode($_POST['MasterTransaksi']['dokter'], true);
             for ($a = 0; $a < count($model_dokter); $a++) {
                 $m_dokter = new TransaksiDokter();
                 $m_dokter->id_master_transaksi = $model->id_master_transaksi;
                 $m_dokter->id_dokter = $model_dokter[$a]['id_dokter'];
                 $m_dokter->created_at = date('Y-m-d H:i:s');
                 $m_dokter->save();
             }
             //delete perawat
             $this->loadModelDeletePerawat($id);
             //save perawat
             $model_perawat = json_decode($_POST['MasterTransaksi']['perawat'], true);
             for ($a = 0; $a < count($model_perawat); $a++) {
                 $m_perawat = new TransaksiPerawat();
                 $m_perawat->id_master_transaksi = $model->id_master_transaksi;
                 $m_perawat->id_perawat = $model_perawat[$a]['id_perawat'];
                 $m_perawat->created_at = date('Y-m-d H:i:s');
                 $m_perawat->save();
             }
             //delete obat
             $this->loadModelDeleteObat($id);
             //save obat
             $model_obat = json_decode($_POST['MasterTransaksi']['obat'], true);
             for ($a = 0; $a < count($model_obat); $a++) {
                 $m_obat = new TransaksiObat();
                 $m_obat->id_master_transaksi = $model->id_master_transaksi;
                 $m_obat->id_obat = $model_obat[$a]['id_obat'];
                 $m_obat->jumlah = $model_obat[$a]['jumlah'];
                 $m_obat->created_at = date('Y-m-d H:i:s');
                 $m_obat->save();
                 //update stok barang
                 Yii::app()->db->createCommand("update tbl_barang set stok=stok-" . $m_obat->jumlah . " where id_barang='" . $m_obat->id_obat . "'")->execute();
             }
             //delete perawatan
             $this->loadModelDeletePerawatan($id);
             //save perawatan
             $model_perawatan = json_decode($_POST['MasterTransaksi']['perawatan'], true);
             for ($a = 0; $a < count($model_perawatan); $a++) {
                 $m_perawatan = new TransaksiPerawatan();
                 $m_perawatan->id_master_transaksi = $model->id_master_transaksi;
                 $m_perawatan->id_perawatan = $model_perawatan[$a]['id'];
                 $m_perawatan->created_at = date('Y-m-d H:i:s');
                 $m_perawatan->save();
                 $model_obat_perawatan = $model_perawatan[$a]['obat'];
                 for ($b = 0; $b < count($model_obat_perawatan); $b++) {
                     $m_obat_perawatan = new TransaksiObatDalam();
                     $m_obat_perawatan->id_transaksi_perawatan = $m_perawatan->id_transaksi_perawatan;
                     $m_obat_perawatan->id_obat = $model_obat_perawatan[$b]['id_obat'];
                     $m_obat_perawatan->jumlah = $model_obat_perawatan[$b]['jumlah'];
                     $m_obat_perawatan->created_at = date('Y-m-d H:i:s');
                     $m_obat_perawatan->save();
                     //update stok barang
                     Yii::app()->db->createCommand("update tbl_barang_dalam set stok=stok-" . $m_obat_perawatan->jumlah . " where id_barang_dalam='" . $m_obat_perawatan->id_obat . "'")->execute();
                 }
             }
             $this->redirect(array('view', 'id' => $model->id_master_transaksi));
         }
     }
     $m_dokter = $this->loadModelDetailDokter($id);
     $arr_dokter = array();
     foreach ($m_dokter as $md) {
         $d['id_dokter'] = $md->id_dokter;
         array_push($arr_dokter, $d);
     }
     $m_perawat = $this->loadModelDetailPerawat($id);
     $arr_perawat = array();
     foreach ($m_perawat as $mp) {
         $d['id_perawat'] = $mp->id_perawat;
         array_push($arr_perawat, $d);
     }
     $m_obat = $this->loadModelDetailObat($id);
     $arr_obat = array();
     foreach ($m_obat as $mo) {
         $d['id_obat'] = $mo->id_obat;
         $d['harga'] = $mo->Barang->harga_jual - $mo->Barang->harga_jual * $mo->Barang->diskon / 100;
         $d['diskon'] = $mo->Barang->diskon . '%';
         $d['jumlah'] = $mo->jumlah;
         array_push($arr_obat, $d);
     }
     $m_perawatan = $this->loadModelDetailPerawatan($id);
     $arr_perawatan = array();
     $member = $model->Pasien->member;
     $diskon = 0;
     foreach ($m_perawatan as $mp) {
         $perawatan = Perawatan::model()->findByPk($mp->id_perawatan);
         if ($member === 'Tidak') {
             $diskon = $perawatan->diskon_umum;
         } else {
             if ($perawatan->diskon_umum > $perawatan->diskon_member) {
                 $diskon = $perawatan->diskon_umum;
             } else {
                 $diskon = $perawatan->diskon_member;
             }
         }
         $d['id'] = $mp->id_perawatan;
         $d['diskon'] = $diskon;
         $d['harga'] = $perawatan->harga - $perawatan->harga / 100 * $diskon;
         $d['komisi_dokter'] = $mp->Perawatan->komisi_dokter;
         $d['komisi_perawat'] = $mp->Perawatan->komisi_perawat;
         $d['obat'] = array();
         $criteria = new CDbCriteria();
         $criteria->condition = "id_perawatan = '" . $mp->id_perawatan . "'";
         $m_obat_perawatan = ObatPerawatan::model()->findAll($criteria);
         foreach ($m_obat_perawatan as $key => $op) {
             $d_op['id_obat'] = $op->id_obat;
             $d_op['jumlah'] = $op->jumlah;
             $d_op['nama_barang'] = $op->BarangDalam->nama_barang;
             $d_op['harga'] = ($op->BarangDalam->harga_jual - $op->BarangDalam->harga_jual * $op->BarangDalam->diskon / 100) * $op->jumlah;
             array_push($d['obat'], $d_op);
         }
         array_push($arr_perawatan, $d);
     }
     $fetch_detail['biaya'] = $model->biaya;
     $fetch_detail['hutang'] = $model->hutang;
     $fetch_detail['total'] = $model->total;
     $fetch_detail['total_bayar'] = $model->total_bayar;
     $fetch_detail['id_pasien'] = $model->id_pasien;
     $this->render('update', array('model' => $model, 'arr_dokter' => $arr_dokter, 'arr_perawat' => $arr_perawat, 'arr_obat' => $arr_obat, 'arr_perawatan' => $arr_perawatan, 'm_array' => $fetch_detail));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Perawatan the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Perawatan::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #4
0
}
?>
</table>
<br>
<table class="table table-bordered">
	<tr>
		<td style="width:10%">No.</td>
		<td>Nama Perawatan</td>
		<td>Biaya</td>
		<td>Diskon</td>
		<td>Obat Dalam</td>
	</tr>
	<?php 
$no = 1;
foreach ($perawatan as $o) {
    $m_perawatan = Perawatan::model()->findByPk($o->id_perawatan);
    $member = $model->Pasien->member;
    if ($member === 'Ya') {
        $data['diskon'] = $m_perawatan->diskon_umum;
    } else {
        if ($m_perawatan->diskon_umum > $m_perawatan->diskon_member) {
            $data['diskon'] = $m_perawatan->diskon_umum;
        } else {
            $data['diskon'] = $m_perawatan->diskon_member;
        }
    }
    echo "<tr>";
    echo "<td>" . $no . "</td>";
    echo "<td>" . $o->Perawatan->nama_perawatan . "</td>";
    echo "<td>" . ($m_perawatan->harga - $m_perawatan->harga / 100 * $data['diskon']) . "</td>";
    echo "<td>" . $data['diskon'] . "</td>";