Exemplo n.º 1
0
 public function actionIndex()
 {
     // total semua pemasukan
     $criteria = new CDbCriteria();
     $criteria->addBetweenCondition('TANGGAL_ORDER', date('Y-m-01', strtotime('this month')), date('Y-m-t', strtotime('this month')));
     $kredit = Order::model()->findAll($criteria);
     $total = 0;
     foreach ($kredit as $k) {
         $total += $k->TOTAL;
     }
     // menghitung total order
     $order_c = Order::model()->count();
     // menghitung total pasien
     $pelanggan_c = Pasien::model()->count();
     // get data order hari ini
     $criteria2 = new CDbCriteria();
     $criteria2->condition = 'date(TANGGAL_ORDER) = date(NOW())';
     $hariini = Order::model()->count($criteria2);
     // get barang yang tanggal expired
     $expired = Item::getExpired();
     // data obat habis
     $criteria = new CDbCriteria();
     $criteria->order = 'TANGGAL_ORDER DESC';
     $criteria->limit = '5';
     $dataProvider = new CActiveDataProvider('Pasien', array('pagination' => false, 'criteria' => $criteria));
     $this->render('index', array('total' => $total, 'order' => $order_c, 'pelanggan' => $pelanggan_c, 'hariini' => $hariini, 'expired' => $expired));
 }
Exemplo n.º 2
0
 public function detail($NoRegLab)
 {
     $rujukan = ViewRujukandetail::where('NoRegLab', '=', $NoRegLab)->first();
     $pasien = Pasien::where('NoRegLab', '=', $NoRegLab)->first();
     $hargatotal = Pemeriksaan::where('NoRegLab', '=', $NoRegLab)->sum('Harga');
     $pemeriksaan = Pemeriksaan::where('NoRegLab', '=', $NoRegLab)->orderBy('NoRegLab', 'asc')->get();
     return View::make('billing.detail_billing', compact('pemeriksaan', 'hargatotal', 'pasien', 'rujukan'));
 }
Exemplo n.º 3
0
 public function edit($NmrSpesimen)
 {
     $rujukan = Rujukan::find($NmrSpesimen);
     $lab = Lab::get();
     $pasien = Pasien::get();
     $jnskategori = Jnskategori::get();
     //$reglab = Reglab::all();
     return View::make('rujukan.edit_rujukan')->with('rujukan', $rujukan)->with('lab', $lab)->with('pasien', $pasien)->with('jnskategori', $jnskategori);
     //->with('reglab',$reglab);
 }
Exemplo n.º 4
0
 public function siapaAku($id)
 {
     if ($id != 0) {
         $pelanggan = Pasien::model()->findByPk($id);
         if (count($pelanggan) > 0) {
             return $pelanggan->NAMA_PASIEN;
         } else {
             return "-";
         }
     } else {
         return "-";
     }
 }
 private function processKTP($tanggal, $tanggal2, $departemen_id)
 {
     $reportName = "laporan_pembayaran_ktp";
     $objPHPExcel = $this->loadPHPExcelLib($reportName);
     $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet = $objPHPExcel->getActiveSheet();
     $filter = "";
     if (substr("" . $departemen_id, 0, 4) == "wil_") {
         $puskesmas = Puskesmas::model()->findByPk(substr("" . $departemen_id, 4));
         $departemen = NULL;
         $activeSheet->setCellValue("A2", "Wilayah Puskesmas " . ucwords(strtolower($puskesmas->nama)));
     } else {
         $departemen = Departemen::model()->findByPk($departemen_id);
         $puskesmas = Puskesmas::model()->findByPk($departemen->puskesmas_id);
         $activeSheet->setCellValue("A2", $departemen->nama);
         $filter = " AND departemen_id = '" . $departemen->id . "'";
     }
     //judul
     $activeSheet->setCellValue("A4", "Tanggal " . $tanggal . " s/d " . $tanggal2);
     $tanggal = $this->reverseDate($tanggal);
     $tanggal2 = $this->reverseDate($tanggal2);
     $baris = 10;
     $trs = TransaksiKunjungan::model()->findAll("waktu between '{$tanggal} 00:00:00' AND '{$tanggal2} 23:59:00' AND puskesmas_id = '" . $puskesmas->id . "'" . $filter);
     foreach ($trs as $t) {
         if ($t->jenis_pembayaran_id == 1) {
             //UMUM
             $pasien = Pasien::model()->findByPk($t->pasien_id);
             if ($pasien->dalam_wilayah == 1) {
                 $wilayah[0] += 1;
             } else {
                 if ($pasien->dalam_wilayah == 2) {
                     $wilayah[1] += 1;
                 } else {
                     $wilayah[2] += 1;
                 }
             }
             $umur = date_diff(date_create($pasien->tanggal_lahir), date_create(date("Y-m-d", strtotime($t->waktu))))->y;
             if ($umur > 200) {
                 $umur = 0;
             }
             $activeSheet->setCellValue("A" . $baris, $baris - 9);
             $activeSheet->setCellValueExplicit("B" . $baris, $pasien->kode, PHPExcel_Cell_DataType::TYPE_STRING);
             $activeSheet->setCellValue("C" . $baris, $pasien->nama);
             $activeSheet->setCellValue("D" . $baris, $umur);
             $activeSheet->setCellValue("E" . $baris, $t->jenis_kunjungan == "B" ? "1" : "0");
             $activeSheet->setCellValue("F" . $baris, $t->jenis_kunjungan == "L" ? "1" : "0");
             $activeSheet->setCellValue("G" . $baris, $pasien->jenis_kelamin == "L" ? "1" : "0");
             $activeSheet->setCellValue("H" . $baris, $pasien->jenis_kelamin == "P" ? "1" : "0");
             $activeSheet->setCellValue("I" . $baris, $pasien->dalam_wilayah == "1" ? "1" : "0");
             $activeSheet->setCellValue("J" . $baris, $pasien->dalam_wilayah == "2" ? "1" : "0");
             $activeSheet->setCellValue("K" . $baris, $pasien->dalam_wilayah == "3" ? "1" : "0");
             $activeSheet->setCellValue("L" . $baris, date("d-m-Y", strtotime($t->waktu)));
             $activeSheet->setCellValue("M" . $baris, $pasien->alamat);
             $activeSheet->setCellValueExplicit("N" . $baris, $pasien->no_ktp . "", PHPExcel_Cell_DataType::TYPE_STRING);
             $activeSheet->setCellValue("O" . $baris, "10000");
             $antrian = TransaksiAntrian::model()->findByAttributes(array("kunjungan_id" => $t->id));
             //BP
             if ($antrian->poli_tujuan == 1) {
                 $activeSheet->setCellValue("P" . $baris, $t->jenis_kunjungan == "B" ? "1" : "0");
                 $activeSheet->setCellValue("Q" . $baris, $t->jenis_kunjungan == "L" ? "1" : "0");
             }
             if ($antrian->poli_tujuan == 3) {
                 $activeSheet->setCellValue("R" . $baris, $t->jenis_kunjungan == "B" ? "1" : "0");
                 $activeSheet->setCellValue("S" . $baris, $t->jenis_kunjungan == "L" ? "1" : "0");
             }
             if ($antrian->poli_tujuan == 4) {
                 $activeSheet->setCellValue("T" . $baris, $t->jenis_kunjungan == "B" ? "1" : "0");
                 $activeSheet->setCellValue("U" . $baris, $t->jenis_kunjungan == "L" ? "1" : "0");
             }
             $baris++;
         }
     }
     $activeSheet->getStyle("A10:S" . $baris)->applyFromArray($this->getNormalStyle());
     $activeSheet->setCellValue("E" . $baris, "=SUM(E10:E" . ($baris - 1) . ")");
     /*$activeSheet->setCellValue("F".$baris, "=SUM(F10:F".($baris-1).")");
       $activeSheet->setCellValue("G".$baris, "=SUM(G10:G".($baris-1).")");
       $activeSheet->setCellValue("H".$baris, "=SUM(H10:H".($baris-1).")");
       $activeSheet->setCellValue("I".$baris, "=SUM(I10:I".($baris-1).")");
       
       $activeSheet->setCellValue("N".$baris, "=SUM(N10:N".($baris-1).")");
       $activeSheet->setCellValue("O".$baris, "=SUM(O10:O".($baris-1).")");
       $activeSheet->setCellValue("P".$baris, "=SUM(P10:P".($baris-1).")");
       $activeSheet->setCellValue("Q".$baris, "=SUM(Q10:Q".($baris-1).")");
       $activeSheet->setCellValue("R".$baris, "=SUM(R10:R".($baris-1).")");
       $activeSheet->setCellValue("S".$baris, "=SUM(S10:S".($baris-1).")");*/
     return array("phpexcel" => $objPHPExcel, "name" => $reportName . "_" . $tanggal . "_" . $tanggal2);
 }
Exemplo n.º 6
0
?>
        </td>
    </tr>
</table>
<hr>
<center>
    <?php 
$form = $this->beginWidget('booster.widgets.TbActiveForm', array('id' => 'pasien-form', 'enableAjaxValidation' => false));
?>

    <?php 
echo $form->errorSummary($model);
?>

    <?php 
$nama = CHtml::listData(Pasien::model()->findAll(), 'nama', 'nama');
$this->widget('ext.select2.ESelect2', array('model' => $model, 'attribute' => 'nama', 'data' => $nama, 'htmlOptions' => array('style' => 'width:550px', 'prompt' => '-- Pilih Nama Pasien --')));
?>
 &nbsp;
    <?php 
$this->widget('booster.widgets.TbButton', array('buttonType' => 'submit', 'context' => 'primary', 'label' => $model->isNewRecord ? 'Search' : 'Save'));
?>
    <?php 
$this->endWidget();
?>
</center>
<hr>


<?php 
$this->widget('booster.widgets.TbGridView', array('id' => 'pasien-grid', 'dataProvider' => $dataProvider, 'filter' => $model, 'emptyText' => 'Tidak ada laporan :)', 'template' => "{summary}{items}{pager}", 'enablePagination' => true, 'columns' => array('nama', 'alamat', 'jenis_kelamin', 'tel', array('class' => 'booster.widgets.TbButtonColumn', 'template' => '{usg}', 'buttons' => array('usg' => array('label' => 'Lihat Profil', 'url' => "CHtml::normalizeUrl(array('pasien/view','id'=>\$data->id_pasien))"))), array('class' => 'booster.widgets.TbButtonColumn', 'template' => '{update},{delete}'))));
 private function process($tanggal, $tanggal2, $departemen_id, $jenis_kunjungan, $jenis_pembayaran_id, $jenis_kelamin, $jenis_laporan, $klinik, $wilayah)
 {
     $reportName = "laporan_kunjungan_loket_harian";
     $tanggal = $this->reverseDate($tanggal);
     $tanggal2 = $this->reverseDate($tanggal2);
     $objPHPExcel = $this->loadPHPExcelLib($reportName);
     $rekapArray = array();
     foreach (JenisPembayaran::model()->findAll("status = '1'") as $jp) {
         $rekapArray[$jp->nama] = array();
         foreach (Poli::model()->findAllByAttributes(array("jenis" => 1, "status" => 1)) as $poli) {
             $rekapArray[$jp->nama][$poli->nama] = array("L" => 0, "P" => 0);
         }
     }
     $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet = $objPHPExcel->getActiveSheet();
     //judul
     $activeSheet->getCell("B4")->setValue("Tanggal : " . $tanggal);
     $filter = "";
     if (substr("" . $departemen_id, 0, 4) == "wil_") {
         $puskesmas = Puskesmas::model()->findByPk(substr("" . $departemen_id, 4));
         $departemen = NULL;
         $activeSheet->getCell("B3")->setValue("Wilayah Puskesmas " . ucwords(strtolower($puskesmas->nama)));
     } else {
         $departemen = Departemen::model()->findByPk($departemen_id);
         $puskesmas = Puskesmas::model()->findByPk($departemen->puskesmas_id);
         $activeSheet->getCell("B3")->setValue($departemen->nama);
         $filter = " AND departemen_id = '" . $departemen->id . "'";
     }
     if ($jenis_kunjungan != "") {
         $filter .= " AND jenis_kunjungan = '" . $jenis_kunjungan . "' ";
     }
     if ($jenis_pembayaran_id != "") {
         $filter .= " AND jenis_pembayaran_id = '" . $jenis_pembayaran_id . "' ";
     }
     if ($jenis_laporan != "") {
         $arrayDiagnosaKhusus = array();
         foreach (Lb1JenisLaporanDetail::model()->findAllByAttributes(array("jenis_id" => $jenis_laporan)) as $data) {
             $arrayDiagnosaKhusus[] = $data->penyakit_id;
         }
     }
     //header
     $baris = 8;
     $no = 1;
     $transaksiArray = TransaksiKunjungan::model()->findAll("waktu between '{$tanggal} 00:00:00' AND '{$tanggal2} 23:59:00' AND puskesmas_id = '" . $puskesmas->id . "'" . $filter);
     foreach ($transaksiArray as $kunjungan) {
         $pasien = Pasien::model()->findByPk($kunjungan->pasien_id);
         if ($jenis_kelamin != "" && $pasien->jenis_kelamin != $jenis_kelamin) {
             continue;
         }
         if ($wilayah != "" && $pasien->dalam_wilayah != $wilayah) {
             continue;
         }
         $ada = FALSE;
         $kosong = TRUE;
         $jenis_pembayaran = JenisPembayaran::model()->findByPk($kunjungan->jenis_pembayaran_id);
         $poli = Poli::model()->findByPk($kunjungan->poli_tujuan);
         $diagnosaArray = array();
         $idDiagnosaArray = array();
         $meds = TransaksiMedicalRecord::model()->findAllByAttributes(array("kunjungan_id" => $kunjungan->id));
         foreach ($meds as $med) {
             $diags = TransaksiDiagnosa::model()->findAllByAttributes(array("medical_record_id" => $med->id));
             foreach ($diags as $diag) {
                 $kosong = FALSE;
                 $ada = TRUE;
                 /*
                                     if($jenis_laporan != "" && !in_array($diag->penyakit_id, $arrayDiagnosaKhusus)){
                                         
                                     }else{
                                         $ada = TRUE;
                                     }*/
                 $penyakit = Penyakit::model()->findByAttributes(array("id" => $diag->penyakit_id));
                 $diagnosaArray[] = "[" . $penyakit->kode . "/" . $diag->jenis_kasus . "] " . ($penyakit->nama_indonesia == "" ? $penyakit->nama : $penyakit->nama_indonesia);
             }
         }
         $ada2 = FALSE;
         $kosong2 = TRUE;
         $bpArray = array();
         $ants = TransaksiAntrian::model()->findAllByAttributes(array("kunjungan_id" => $kunjungan->id));
         foreach ($ants as $ant) {
             $kosong2 = FALSE;
             if ($klinik != "" && $ant->poli_tujuan != $klinik) {
             } else {
                 $ada2 = TRUE;
             }
             $polie = Poli::model()->findByPk($ant->poli_tujuan);
             $rekapArray[$jenis_pembayaran->nama][$polie->nama][$pasien->jenis_kelamin] += 1;
             $bpArray[] = $polie->nama;
         }
         if ($kosong || $kosong2 || $ada && $ada2) {
         } else {
             continue;
         }
         $activeSheet->getCellByColumnAndRow(1, $baris)->setValue($no . ".");
         $activeSheet->getCellByColumnAndRow(2, $baris)->setValue(date("d-m-Y", strtotime($kunjungan->waktu)));
         $activeSheet->getCellByColumnAndRow(3, $baris)->setValueExplicit($pasien->kode, PHPExcel_Cell_DataType::TYPE_STRING);
         $activeSheet->getCellByColumnAndRow(4, $baris)->setValue($pasien->nama);
         $age = date_diff(date_create($pasien->tanggal_lahir), date_create($kunjungan->waktu))->y;
         if ($age > 200) {
             $age = 0;
         }
         $activeSheet->getCellByColumnAndRow(5, $baris)->setValue($age);
         $activeSheet->getCellByColumnAndRow(6, $baris)->setValue($pasien->jenis_kelamin);
         $activeSheet->getCellByColumnAndRow(7, $baris)->setValue($pasien->alamat);
         $activeSheet->getCellByColumnAndRow(8, $baris)->setValue($pasien->nama_kepala_keluarga);
         $activeSheet->getCellByColumnAndRow(9, $baris)->setValueExplicit($pasien->no_ktp, PHPExcel_Cell_DataType::TYPE_STRING);
         $activeSheet->getCellByColumnAndRow(10, $baris)->setValue($jenis_pembayaran->nama);
         $activeSheet->getCellByColumnAndRow(11, $baris)->setValueExplicit($kunjungan->kode_asuransi, PHPExcel_Cell_DataType::TYPE_STRING);
         $activeSheet->getCellByColumnAndRow(12, $baris)->setValue($kunjungan->jenis_kunjungan == "B" ? "Baru" : "Lama");
         $activeSheet->getCellByColumnAndRow(13, $baris)->setValue(implode(", ", $diagnosaArray));
         //diagnosa
         $activeSheet->getCellByColumnAndRow(14, $baris)->setValue(implode(", ", $bpArray));
         //bp
         $tujuan = $poli->nama . " : " . ucwords(strtolower(Departemen::model()->findByPk($kunjungan->departemen_id)->nama));
         $activeSheet->getCellByColumnAndRow(15, $baris)->setValue($tujuan);
         $baris++;
         $no++;
     }
     $activeSheet->getStyle("B8:P" . ($baris - 1))->applyFromArray(array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
     //Pindah ke sheet 2
     $objPHPExcel->setActiveSheetIndex(1);
     $activeSheet = $objPHPExcel->getActiveSheet();
     $smbaris = 4;
     foreach ($rekapArray as $key => $rekap) {
         $num = 2;
         $activeSheet->getCellByColumnAndRow(1, $smbaris)->setValue($key);
         foreach (Poli::model()->findAllByAttributes(array("jenis" => 1, "status" => 1)) as $poli) {
             if ($smbaris == 4) {
                 //set judul
                 $activeSheet->getCellByColumnAndRow($num, 2)->setValue($poli->nama);
                 $activeSheet->getCellByColumnAndRow($num, 3)->setValue("Lk");
                 $activeSheet->getCellByColumnAndRow($num + 1, 3)->setValue("Pr");
                 $activeSheet->getCellByColumnAndRow($num + 2, 3)->setValue("Total");
                 $activeSheet->mergeCellsByColumnAndRow($num, 2, $num + 2, 2);
             }
             $activeSheet->getCellByColumnAndRow($num, $smbaris)->setValue($rekap[$poli->nama]["L"]);
             $activeSheet->getCellByColumnAndRow($num + 1, $smbaris)->setValue($rekap[$poli->nama]["P"]);
             $activeSheet->getCellByColumnAndRow($num + 2, $smbaris)->setValue($rekap[$poli->nama]["L"] + $rekap[$poli->nama]["P"]);
             $num += 3;
         }
         if ($smbaris == 4) {
             $activeSheet->getStyle("B2:" . $this->get_col_letter($num - 1) . "3")->applyFromArray(array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => '8B0000')), 'font' => array('color' => array('rgb' => 'FFFFFF'))));
         }
         $smbaris++;
     }
     $this->fillBorder($activeSheet, "B2:" . $this->get_col_letter($num - 1) . ($smbaris - 1));
     $activeSheet->getStyle("B4:" . $this->get_col_letter($num - 1) . ($smbaris - 1))->applyFromArray(array('font' => array('color' => array('rgb' => '000000'), 'size' => 13, 'name' => 'Calibri')));
     $activeSheet->getStyle("C4:" . $this->get_col_letter($num - 1) . ($smbaris - 1))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     return array("phpexcel" => $objPHPExcel, "name" => $reportName . "_" . $tanggal);
 }
Exemplo n.º 8
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     //inisialisasi model Order
     $order = new Order('search');
     $order->unsetAttributes();
     // clear any default values
     if (isset($_GET['Order'])) {
         $order->attributes = $_GET['Order'];
     }
     $orderbaru = new Order('baru');
     $orderbaru->RESEP = 1;
     $orderbaru->orderdetail = new OrderDetail('baru');
     //inisialisasi model OrderDetail
     $order_detail = new OrderDetail();
     //inisialisasi model Pelanggan
     $pelanggan = new Pasien('search');
     $pelanggan->unsetAttributes();
     // clear any default values
     if (isset($_GET['Pasien'])) {
         $pelanggan->attributes = $_GET['Pasien'];
     }
     $newpl = new Pasien('baru');
     $newpl->ID_LAYANAN = 1;
     if (isset($_POST['Pasien'])) {
         $newpl->attributes = $_POST['Pasien'];
         $newpl->BIAYA_REGISTRASI = 5000;
         $newpl->TANGGAL_REGISTRASI = date('Y-m-d H:i:s');
         if ($newpl->save()) {
             Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             $this->redirect(array('/site'));
         }
     }
     if (isset($_POST['Order'])) {
         $orderbaru->attributes = $_POST['Order'];
         $orderbaru->TANGGAL_ORDER = date('Y-m-d H:i:s');
         $orderbaru->USER_PEMBUAT = Yii::app()->user->nama;
         if ($orderbaru->validate()) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if (!$orderbaru->save()) {
                     throw new Exception();
                 }
                 $subtotal = 0;
                 foreach ($_POST['OrderDetail'] as $kd => $detail) {
                     if (!empty($detail['JUMLAH'])) {
                         $od = new OrderDetail('baru');
                         $od->ID_ITEM = $kd;
                         $od->KODE_ORDER = $orderbaru->KODE_ORDER;
                         //proses harga by resep
                         $od->HARGA = Item::getHargaByResep($kd, $orderbaru->RESEP);
                         $od->JUMLAH = $detail['JUMLAH'];
                         $od->DISKON = $detail['DISKON'];
                         //$od->DISKON = Barang::getDiskonById($kd);
                         //update stok barang
                         Item::updateStokItem($kd, $detail['JUMLAH']);
                         $subtotal += $od->JUMLAH * $od->HARGA;
                         if (!$od->save()) {
                             throw new Exception();
                         }
                     }
                 }
                 $transaction->commit();
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             } catch (Exception $ex) {
                 $transaction->rollback();
                 echo $ex->getMessage();
                 exit;
             }
         }
     }
     // $dataProvider=new CActiveDataProvider('Pasien',array(
     // 	'pagination'=>false,
     // ));
     $this->render('create', array('order' => $order, 'order_detail' => $order_detail, 'pelanggan' => $pelanggan, 'pelanggan_baru' => $newpl, 'orderbaru' => $orderbaru));
 }
Exemplo n.º 9
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'master-transaksi-form', 'enableAjaxValidation' => true));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'id_pasien');
?>
		<?php 
$this->widget('ext.chosen.Chosen', array('name' => 'MasterTransaksi[id_pasien]', 'value' => $model->id_pasien, 'data' => array('' => 'Semua') + CHtml::listData(Pasien::model()->findAll(), 'id_pasien', 'nama'), 'htmlOptions' => array('ng-change' => 'updatePasien(id_pasien)', 'ng-model' => 'id_pasien')));
?>
		<?php 
echo $form->error($model, 'id_pasien');
?>
	</div>
	<br>

	<div class="row">
		<label>Dokter</label>
		<table class="table table-bordered">
			<thead>
				<th>No.</th>
				<th colspan="2">Nama Dokter</th>
			</thead>
			<tbody>
Exemplo n.º 10
0
 public function loadModel($id)
 {
     $model = Pasien::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 11
0
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'sms-logs-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true, 'clientOptions' => array('validateOnChange' => false, 'validateOnSubmit' => true)));
echo @Yii::app()->user->getFlash('info');
?>

                <div class="form-body">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-group">
                                <?php 
echo $form->labelEx($model, 'TUJUAN', array('class' => 'control-label'));
?>
                                <?php 
echo $form->dropDownList($model, 'TUJUAN', Pasien::model()->ListPasienSMS(), array('class' => 'form-control', 'multiple' => "multiple"));
?>
                                <?php 
echo $form->error($model, 'TUJUAN');
?>
                            </div>
                        </div>
                        <div class="col-md-5">
                            <div class="form-group">
                            	<?php 
if ($model->PESAN == SmsLog::NAMAPERUSAHAAN || $model->PESAN == "") {
    $model->PESAN = SmsLog::NAMAPERUSAHAAN . " \n";
}
?>
                                <?php 
echo $form->labelEx($model, 'PESAN', array('class' => 'control-label'));
Exemplo n.º 12
0
 private function process($month, $year, $departemen_id, $kategori_penyakit)
 {
     $reportName = "laporan_lb1";
     $objPHPExcel = $this->loadPHPExcelLib($reportName);
     $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet = $objPHPExcel->getActiveSheet();
     $namaBulan = array("1" => "Januari", "2" => "Februari", "3" => "Maret", "4" => "April", "5" => "Mei", "6" => "Juni", "7" => "Juli", "8" => "Agustus", "9" => "September", "10" => "Oktober", "11" => "November", "12" => "Desember");
     //judul
     $activeSheet->getCell("B3")->setValue(": " . Setting::getNamaPuskesmas());
     $activeSheet->getCell("B4")->setValue(": " . Setting::getKodePuskesmas());
     $activeSheet->getCell("B5")->setValue(": " . CHtml::value(WilayahKabupaten::model()->findByPk(Setting::getKabupaten()), "nama"));
     $activeSheet->getCell("AW4")->setValue($namaBulan[$month]);
     $activeSheet->getCell("AW5")->setValue($year);
     $filter = "";
     if (substr("" . $departemen_id, 0, 4) == "wil_") {
         $puskesmas = Puskesmas::model()->findByPk(substr("" . $departemen_id, 4));
         $departemen = NULL;
     } else {
         $departemen = Departemen::model()->findByPk($departemen_id);
         $puskesmas = Puskesmas::model()->findByPk($departemen->puskesmas_id);
         $filter = " AND departemen_id = '" . $departemen->id . "'";
     }
     $kodePusk = Setting::getKodePuskesmas();
     //konten
     $globaldata = array();
     $baris = 11;
     $trs = array();
     if ($kategori_penyakit == "") {
         //$trs = Penyakit::model()->findAll("lb1_status = '1'");
         foreach (Penyakit::model()->findAll("lb1_status = '1'") as $p) {
             $trs[] = $p->id;
         }
     } else {
         foreach (Lb1JenisLaporanDetail::model()->findAllByAttributes(array("jenis_id" => $kategori_penyakit)) as $detail) {
             //$penyakit = Penyakit::model()->findByAttributes(array("id" => $detail->penyakit_id));
             $trs[] = $detail->penyakit_id;
         }
     }
     $jumlahData = 0;
     foreach ($trs as $p) {
         $activeSheet->getCellByColumnAndRow(0, $baris)->setValue($kodePusk);
         $activeSheet->getCellByColumnAndRow(1, $baris)->setValue($namaBulan[$month]);
         $activeSheet->getCellByColumnAndRow(2, $baris)->setValue($year);
         $activeSheet->getCellByColumnAndRow(3, $baris)->setValue($p->kode);
         $activeSheet->getCellByColumnAndRow(4, $baris)->setValue($p->nama_indonesia);
         //$activeSheet->getCell("CE".$baris)->setValue($p->id);
         $output = array();
         for ($i = 0; $i < 18; $i++) {
             $output[$i . "_L_B"] = 0;
             $output[$i . "_L_L"] = 0;
             $output[$i . "_P_B"] = 0;
             $output[$i . "_P_L"] = 0;
         }
         $globaldata[$p] = $output;
         $baris++;
         $jumlahData++;
     }
     $diags = TransaksiDiagnosa::model()->findAll("puskesmas_id = '" . $puskesmas->id . "' AND year(waktu) = '{$year}' AND month(waktu) = '{$month}'" . $filter);
     foreach ($diags as $diag) {
         $med = TransaksiMedicalRecord::model()->findByPk($diag->medical_record_id);
         $pasien = Pasien::model()->findByPk($med->pasien_id);
         $jenis_kelamin = $pasien->jenis_kelamin;
         $kategoriUmur = $this->getKategoriUmur($pasien);
         if (in_array($diag->penyakit_id, $trs)) {
             $globaldata[$diag->penyakit_id][$kategoriUmur . "_" . $jenis_kelamin . "_" . $diag->jenis_kasus] += 1;
         }
     }
     $jumlahIsi = 0;
     $baris = 11;
     foreach ($globaldata as $penyakit_id => $output) {
         /*
                       $kunjungans = TransaksiKunjungan::model()->findAll("puskesmas_id = '{$puskemas_id}' AND year(waktu) = '{$year}' AND month(waktu) = '{$month}'");
                       foreach($kunjungans as $kunjungan){
                       $pasien = Pasien::model()->findByPk($kunjungan->pasien_id);
                       $jenis_kelamin = $pasien->jenis_kelamin;
         
                       //get kategori umur
                       $kategoriUmur = $this->getKategoriUmur($pasien);
         
                       $medRecArray = array();
                       $antrians = TransaksiAntrian::model()->findAll("kunjungan_id = '{$kunjungan->id}'");
                       foreach($antrians as $antrian){
                       $medRecArray[$antrian->medical_record_id] = 1;
                       }
         
                       foreach($medRecArray as $key => $val){
                       $diags = TransaksiDiagnosa::model()->findAll("puskesmas_id = '{$puskemas_id}' AND medical_record_id = '{$key}' AND penyakit_id = '{$p->id}'");
                       foreach($diags as $diag){
                       $output[$kategoriUmur."_".$jenis_kelamin."_".$diag->jenis_kasus] += 1;
                       }
                       }
                       } */
         $jml = array();
         $jml["L_B"] = 0;
         $jml["L_L"] = 0;
         $jml["P_B"] = 0;
         $jml["P_L"] = 0;
         for ($kat = 0; $kat <= 17; $kat++) {
             $kolom = 10 + $kat * 4;
             $activeSheet->getCellByColumnAndRow($kolom, $baris)->setValue($output[$kat . "_L_B"]);
             $activeSheet->getCellByColumnAndRow($kolom + 1, $baris)->setValue($output[$kat . "_L_L"]);
             $activeSheet->getCellByColumnAndRow($kolom + 2, $baris)->setValue($output[$kat . "_P_B"]);
             $activeSheet->getCellByColumnAndRow($kolom + 3, $baris)->setValue($output[$kat . "_P_L"]);
             $jml["L_B"] += $output[$kat . "_L_B"];
             $jml["L_L"] += $output[$kat . "_L_L"];
             $jml["P_B"] += $output[$kat . "_P_B"];
             $jml["P_L"] += $output[$kat . "_P_L"];
         }
         $p = Penyakit::model()->findByAttributes(array("id" => $penyakit_id));
         $activeSheet->getCellByColumnAndRow(0, $baris)->setValue($kodePusk);
         $activeSheet->getCellByColumnAndRow(1, $baris)->setValue($namaBulan[$month]);
         $activeSheet->getCellByColumnAndRow(2, $baris)->setValue($year);
         $activeSheet->getCellByColumnAndRow(3, $baris)->setValue($p->kode);
         $nama = $p->nama_indonesia;
         if ($nama == "") {
             $nama = $p->nama;
         }
         $activeSheet->getCellByColumnAndRow(4, $baris)->setValue($nama);
         $activeSheet->getCellByColumnAndRow(5, $baris)->setValue("=SUM(G" . $baris . ":J" . $baris . ")");
         $activeSheet->getCellByColumnAndRow(6, $baris)->setValue($jml["L_B"]);
         $activeSheet->getCellByColumnAndRow(7, $baris)->setValue($jml["L_L"]);
         $activeSheet->getCellByColumnAndRow(8, $baris)->setValue($jml["P_B"]);
         $activeSheet->getCellByColumnAndRow(9, $baris)->setValue($jml["P_L"]);
         /*
                     if($jumlahIsi>$jumlahData){
                         $p = Penyakit::model()->findByAttributes(array("id"=>$penyakit_id));
                         $activeSheet->getCellByColumnAndRow(0, $baris)->setValue($kodePusk);
                         $activeSheet->getCellByColumnAndRow(1, $baris)->setValue($namaBulan[$month]);
                         $activeSheet->getCellByColumnAndRow(2, $baris)->setValue($year);
                         $activeSheet->getCellByColumnAndRow(3, $baris)->setValue($p->kode);
                         $nama = $p->nama_indonesia;
                         if($nama == ""){
                             $nama = $p->nama;
                         }
                         $activeSheet->getCellByColumnAndRow(4, $baris)->setValue($nama);
                         $this->fillBorder($activeSheet, "A".$baris.":CD".$baris);
                     }*/
         //$activeSheet->getCell("CF".$baris)->setValue($penyakit_id);
         $baris++;
         $jumlahIsi++;
     }
     $this->fillBorder($activeSheet, "A11:CD" . ($baris - 1));
     return array("phpexcel" => $objPHPExcel, "name" => $reportName . "_" . $namaBulan[$month] . "_" . $year);
 }
 private function process2($year, $departemen_id)
 {
     $reportName = "laporan_kunjungan_loket_lengkap";
     $objPHPExcel = $this->loadPHPExcelLib($reportName);
     $objPHPExcel->setActiveSheetIndex(0);
     $activeSheet = $objPHPExcel->getActiveSheet();
     $activeSheet->setCellValue("A1", "Tahun " . $year);
     $filter = "";
     if (substr("" . $departemen_id, 0, 4) == "wil_") {
         $puskesmas = Puskesmas::model()->findByPk(substr("" . $departemen_id, 4));
         $departemen = NULL;
         $activeSheet->getCell("C3")->setValue($puskesmas->nama);
     } else {
         $departemen = Departemen::model()->findByPk($departemen_id);
         $puskesmas = Puskesmas::model()->findByPk($departemen->puskesmas_id);
         $activeSheet->getCell("C3")->setValue($departemen->nama);
         $filter = "AND departemen_id = '" . $departemen_id . "' ";
     }
     $baris = 11;
     for ($bulan = 1; $bulan <= 12; $bulan++) {
         $baseQuery = "year(waktu) = '{$year}' AND month(waktu) = '{$bulan}' AND puskesmas_id = '" . $puskesmas->id . "'" . $filter;
         //kunjungan baru
         $kunjunganBaru = TransaksiKunjungan::model()->count($baseQuery . " AND jenis_kunjungan = 'B'");
         $activeSheet->setCellValue("C" . $baris, $kunjunganBaru);
         //kunjungan lama
         $kunjunganLama = TransaksiKunjungan::model()->count($baseQuery . " AND jenis_kunjungan = 'L'");
         $activeSheet->setCellValue("D" . $baris, $kunjunganLama);
         //BP
         $criteria = new CDbCriteria();
         $criteria->condition = $baseQuery . " AND poli_tujuan IN(1, 24)";
         $criteria->order = "id";
         $criteria->group = "kunjungan_id";
         $bp = TransaksiAntrian::model()->count($criteria);
         $activeSheet->setCellValue("F" . $baris, $bp);
         $criteria = new CDbCriteria();
         $criteria->condition = $baseQuery . " AND poli_tujuan = '3'";
         $criteria->order = "id";
         $criteria->group = "kunjungan_id";
         $bpg = TransaksiAntrian::model()->count($criteria);
         $activeSheet->setCellValue("G" . $baris, $bpg);
         $criteria = new CDbCriteria();
         $criteria->condition = $baseQuery . " AND poli_tujuan IN(4,5,6)";
         $criteria->order = "id";
         $criteria->group = "kunjungan_id";
         $kia = TransaksiAntrian::model()->count($criteria);
         $activeSheet->setCellValue("H" . $baris, $kia);
         $criteria = new CDbCriteria();
         $criteria->condition = $baseQuery . " AND poli_tujuan = '17'";
         $criteria->order = "id";
         $criteria->group = "kunjungan_id";
         $p2 = TransaksiAntrian::model()->count($criteria);
         $activeSheet->setCellValue("I" . $baris, $p2);
         $criteria = new CDbCriteria();
         $criteria->condition = $baseQuery . " AND poli_tujuan IN(2,12,13)";
         $criteria->order = "id";
         $criteria->group = "kunjungan_id";
         $ugd = TransaksiAntrian::model()->count($criteria);
         $activeSheet->setCellValue("J" . $baris, $ugd);
         //dalam luar wilayah
         $wilayah = array(0, 0, 0);
         //jenis pembayaran
         $jp = array(0, 0, 0, 0, 0, 0);
         $trs = TransaksiKunjungan::model()->findAll($baseQuery);
         foreach ($trs as $t) {
             if ($t->jenis_pembayaran_id == 1) {
                 //UMUM
                 $pasien = Pasien::model()->findByPk($t->pasien_id);
                 if ($pasien->dalam_wilayah == 1) {
                     $wilayah[0] += 1;
                 } else {
                     if ($pasien->dalam_wilayah == 2) {
                         $wilayah[1] += 1;
                     } else {
                         $wilayah[2] += 1;
                     }
                 }
             } else {
                 if ($t->jenis_pembayaran_id == 3) {
                     //PBI
                     $jp[0] += 1;
                 } else {
                     if ($t->jenis_pembayaran_id == 5) {
                         //NON PBI ASKES / TNI POLRI
                         $jp[1] += 1;
                     } else {
                         if ($t->jenis_pembayaran_id == 4) {
                             //NON MANDIRI
                             $jp[2] += 1;
                         } else {
                             if ($t->jenis_pembayaran_id == 6) {
                                 //JAMKESDA
                                 $jp[3] += 1;
                             } else {
                                 if ($t->jenis_pembayaran_id == 2) {
                                     //JAMKESDA
                                     $jp[4] += 1;
                                 } else {
                                     if (in_array($t->jenis_pembayaran_id, array(7, 8, 9, 10, 11))) {
                                         //GRATIS
                                         $jp[5] += 1;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $activeSheet->setCellValue("L" . $baris, $wilayah[0]);
         $activeSheet->setCellValue("M" . $baris, $wilayah[1]);
         $activeSheet->setCellValue("N" . $baris, $wilayah[2]);
         $activeSheet->setCellValue("O" . $baris, $jp[0]);
         $activeSheet->setCellValue("P" . $baris, $jp[1]);
         $activeSheet->setCellValue("Q" . $baris, $jp[2]);
         $activeSheet->setCellValue("R" . $baris, $jp[3]);
         $activeSheet->setCellValue("S" . $baris, $jp[4]);
         $activeSheet->setCellValue("T" . $baris, $jp[5]);
         //rujuk
         //dalam luar wilayah
         $wilayah = array(0, 0, 0);
         //jenis pembayaran
         $jp = array(0, 0, 0, 0, 0, 0);
         $baseQuery = "year(waktu_periksa) = '{$year}' AND month(waktu_periksa) = '{$bulan}' AND puskesmas_id = '" . $puskesmas->id . "'" . $filter;
         $trans = TransaksiMedicalRecord::model()->findAll($baseQuery . " AND keadaan_akhir_id = '9'");
         foreach ($trans as $meds) {
             $t = TransaksiKunjungan::model()->findByPk($meds->kunjungan_id);
             if ($t->jenis_pembayaran_id == 1) {
                 //UMUM
                 $pasien = Pasien::model()->findByPk($t->pasien_id);
                 if ($pasien->dalam_wilayah == 1) {
                     $wilayah[0] += 1;
                 } else {
                     if ($pasien->dalam_wilayah == 2) {
                         $wilayah[1] += 1;
                     } else {
                         $wilayah[2] += 1;
                     }
                 }
             } else {
                 if ($t->jenis_pembayaran_id == 3) {
                     //PBI
                     $jp[0] += 1;
                 } else {
                     if ($t->jenis_pembayaran_id == 5) {
                         //NON PBI ASKES / TNI POLRI
                         $jp[1] += 1;
                     } else {
                         if ($t->jenis_pembayaran_id == 4) {
                             //NON MANDIRI
                             $jp[2] += 1;
                         } else {
                             if ($t->jenis_pembayaran_id == 6) {
                                 //JAMKESDA
                                 $jp[3] += 1;
                             } else {
                                 if ($t->jenis_pembayaran_id == 2) {
                                     //JAMKESDA
                                     $jp[4] += 1;
                                 } else {
                                     if (in_array($t->jenis_pembayaran_id, array(7, 8, 9, 10, 11))) {
                                         //GRATIS
                                         $jp[5] += 1;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $activeSheet->setCellValue("V" . $baris, $wilayah[0]);
         $activeSheet->setCellValue("W" . $baris, $wilayah[1]);
         $activeSheet->setCellValue("X" . $baris, $wilayah[2]);
         $activeSheet->setCellValue("Y" . $baris, $jp[0]);
         $activeSheet->setCellValue("Z" . $baris, $jp[1]);
         $activeSheet->setCellValue("AA" . $baris, $jp[2]);
         $activeSheet->setCellValue("AB" . $baris, $jp[3]);
         $activeSheet->setCellValue("AC" . $baris, $jp[4]);
         $activeSheet->setCellValue("AD" . $baris, $jp[5]);
         $baris++;
     }
     return array("phpexcel" => $objPHPExcel, "name" => $reportName . "_" . $year);
 }
Exemplo n.º 14
0
function get_pasien()
{
    $pasien = new Pasien();
    return $pasien->get_pasien();
}
Exemplo n.º 15
0
 public function actionIndex()
 {
     if (!WebUser::isGuest() && WebUser::isAdmin()) {
         $this->render('index');
     } elseif (!WebUser::isGuest() && WebUser::isKasir()) {
         //inisialisasi model Order
         $order = new Order('search');
         $order->unsetAttributes();
         // clear any default values
         if (isset($_GET['Order'])) {
             $order->attributes = $_GET['Order'];
         }
         $orderbaru = new Order('baru');
         $orderbaru->RESEP = 1;
         $orderbaru->orderdetail = new OrderDetail('baru');
         //inisialisasi model OrderDetail
         $order_detail = new OrderDetail();
         //inisialisasi model Pelanggan
         $pelanggan = new Pasien('search');
         $pelanggan->unsetAttributes();
         // clear any default values
         if (isset($_GET['Pasien'])) {
             $pelanggan->attributes = $_GET['Pasien'];
         }
         $newpl = new Pasien('baru');
         // $newpl->ID_LAYANAN = 1;
         if (isset($_POST['Pasien'])) {
             $newpl->attributes = $_POST['Pasien'];
             //$newpl->BIAYA_REGISTRASI = 5000;
             $newpl->TANGGAL_REGISTRASI = date('Y-m-d H:i:s');
             if ($newpl->save()) {
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/site'));
             }
         }
         if (isset($_POST['Order'])) {
             //var_dump($_POST['Order']);
             //die();
             $orderbaru->attributes = $_POST['Order'];
             $orderbaru->TANGGAL_ORDER = date('Y-m-d H:i:s');
             $orderbaru->USER_PEMBUAT = Yii::app()->user->nama;
             if ($orderbaru->save()) {
                 $subtotal = 0;
                 foreach ($_POST['OrderDetail'] as $detail) {
                     //var_dump($_POST['OrderDetail']);
                     //die();
                     $od = new OrderDetail('baru');
                     $od->ID_ITEM = $detail['ID_ITEM'];
                     $od->KODE_ORDER = $orderbaru->KODE_ORDER;
                     //proses harga by resep
                     $od->HARGA = Item::getHargaByResep($detail['ID_ITEM'], $orderbaru->RESEP);
                     $od->JUMLAH = $detail['JUMLAH'];
                     $od->DISKON = $detail['DISKON'];
                     $od->save();
                     Item::updateStokItem($detail['ID_ITEM'], $detail['JUMLAH']);
                     $subtotal += $od->JUMLAH * $od->HARGA;
                 }
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             }
             // if ($orderbaru->validate()) {
             //     $transaction = Yii::app()->db->beginTransaction();
             //     try {
             //         if (!$orderbaru->save())
             //             throw new Exception;
             //         $subtotal = 0;
             //         foreach ($_POST['OrderDetail'] as $kd => $detail) {
             //             if (!empty($detail['JUMLAH'])) {
             //                 $od = new OrderDetail('baru');
             //              $od->ID_ITEM = $kd;
             //              $od->KODE_ORDER = $orderbaru->KODE_ORDER;
             //              //proses harga by resep
             //              $od->HARGA = Item::getHargaByResep($kd, $orderbaru->RESEP);
             //              $od->JUMLAH = $detail['JUMLAH'];
             //              //$od->DISKON = $detail['DISKON'];
             //              //$od->DISKON = Barang::getDiskonById($kd);
             //              //var_dump($_POST['OrderDetail']);
             // 	//die();
             //              //update stok barang
             //              Item::updateStokItem($kd, $detail['JUMLAH']);
             //              $subtotal += $od->JUMLAH * $od->HARGA;
             //                 if (!$od->save())
             //                     throw new Exception;
             //             }
             //         }
             //         $transaction->commit();
             //         Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             //         $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             //     } catch (Exception $ex) {
             //         $transaction->rollback();
             //         echo $ex->getMessage(); exit();
             //     }
             // }
         }
         $criteria = new CDbCriteria();
         $criteria->order = 'TANGGAL_REGISTRASI DESC';
         $dataProvider = new CActiveDataProvider('Pasien', array('criteria' => $criteria, 'pagination' => false));
         $pasien_today = Pasien::listRegisterToday();
         $this->render('index3', array('dataProvider' => $dataProvider, 'order' => $order, 'order_detail' => $order_detail, 'pelanggan' => $pelanggan, 'pelanggan_baru' => $newpl, 'orderbaru' => $orderbaru, 'pasien_today' => $pasien_today));
     } else {
         $this->redirect(array('login'));
     }
 }
Exemplo n.º 16
0
 public function actionCreateMultiple()
 {
     $model = new SmsLog();
     $smsBerhasil = count(SmsLog::model()->findALlByAttributes(array('STATUS' => 1)));
     $smsGagal = count(SmsLog::model()->findALlByAttributes(array('STATUS' => 0)));
     $smsTotal = $smsBerhasil + $smsGagal;
     $smsKuota = Sms::model()->findByPk(1);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['SmsLog'])) {
         Yii::import('ext.nasrulsms.SMSreguler');
         if ($_POST['SmsLog']['TUJUAN'] != "" && $_POST['SmsLog']['PESAN'] != "") {
             ob_start();
             $smsusername = "******";
             $smspassword = "******";
             $apikey = "4b15b9bb700fef70f11e143d09a3f3c9";
             $banyak = 0;
             $berhasil = 0;
             $gagal = 0;
             // cek curl aktif atau tidak
             if (!function_exists('curl_version')) {
                 Yii::app()->user->setFlash('info', "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'></button>Curl tidak aktif! aktifkan dulu mas bero! -_-</div>");
                 $this->redirect(array('createMultiple'));
             }
             // inisialisasi
             $nohp = $_POST['SmsLog']['TUJUAN'];
             $pesan = $_POST['SmsLog']['PESAN'];
             // filter karakter
             $replace = str_replace(" ", "", $nohp);
             $replace = str_replace("-", "", $replace);
             $replace = str_replace("(", "", $replace);
             $replace = str_replace(")", "", $replace);
             $replace = str_replace("+62", "0", $replace);
             // looping sesuai jumlah nomor yg diinput
             $pisahkoma = count($nohp);
             if (count($pisahkoma) < $smsKuota->SISA_KUOTA) {
                 if ($smsKuota->STATUS != 0 && $smsKuota->MASA_BERLAKU > date("Y-m-d H:i:s")) {
                     foreach ($nohp as $value) {
                         $pelanggan = Pasien::model()->findByPk($value);
                         if (count($pelanggan) > 0) {
                             // kirim sms
                             $sms = new SMSreguler();
                             $sms->setUsername($smsusername);
                             $sms->setPassword($smspassword);
                             $sms->setApi($apikey);
                             $sms->setTo($pelanggan->NO_TELP);
                             $sms->setText($pesan);
                             $sts = $sms->smssend();
                             $idreport = explode('|', $sts);
                             if (substr($sts, 0, 1) == '0') {
                                 $status = 1;
                                 $berhasil += 1;
                             } else {
                                 $status = 0;
                                 $gagal += 1;
                             }
                             // simpan sms ke db
                             $smsLog = new SmsLog();
                             $smsLog->ID_USER = Yii::app()->user->getState('nama');
                             $smsLog->ID_PASIEN = $pelanggan->ID_PASIEN;
                             $smsLog->PESAN = $pesan;
                             $smsLog->TUJUAN = $pelanggan->NO_TELP;
                             $smsLog->TANGGAL_KIRIM = date("Y-m-d H:i:s");
                             $smsLog->STATUS = $status;
                             $smsLog->save();
                             // catat record
                             $banyak += 1;
                         }
                     }
                     $error = false;
                 } else {
                     Yii::app()->user->setFlash('info', "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'></button><strong>GAGAL!</strong> Status SMS Broadcast Tidak Aktif, silahkan hubungi <strong>Admin Website</strong>.</div>");
                     // reset STATUS
                     $smsMaster = Sms::model()->findByPk(1);
                     $smsMaster->STATUS = 0;
                     $smsMaster->save();
                     $this->redirect(array('createMultiple'));
                 }
             } else {
                 $model->addError('TUJUAN', 'Jumlah Nomor Tujuan SMS melebihi sisa kuota.');
                 $model->PESAN = $pesan;
                 $error = true;
             }
             $smsMaster = Sms::model()->findByPk(1);
             $smsMaster->SISA_KUOTA = $smsMaster->SISA_KUOTA - $banyak;
             $smsMaster->save();
             if (!$error) {
                 $notifikasi = "Total SMS Terkirim adalah <strong>" . $banyak . " SMS</strong>, terdiri dari <strong>" . $berhasil . " Berhasil</strong> dan <strong>" . $gagal . " Gagal</strong>.";
                 Yii::app()->user->setFlash('info', "<div class='alert alert-success'><button type='button' class='close' data-dismiss='alert'></button>" . $notifikasi . "</div>");
                 $this->redirect(array('createMultiple'));
             }
         }
     }
     $this->render('create_multiple', array('model' => $model, 'smsBerhasil' => $smsBerhasil, 'smsGagal' => $smsGagal, 'smsTotal' => $smsTotal, 'smsKuota' => $smsKuota->SISA_KUOTA));
 }