public static function sendLog($message)
 {
     return;
     if ($_SERVER["SERVER_NAME"] != "localhost") {
     }
     Yii::import('ext.ElephantIO.Client');
     if (!is_string($message)) {
         $message = NodeLogger::renderJSON($message);
     }
     //$elephant = new Client('http://pukul.in:10001', 'socket.io', 1, false, true, true);
     $elephant = new Client('http://localhost:8000', 'socket.io', 1, false, true, true);
     $elephant->init();
     $elephant->emit('newmessage', date("Y-m-d H:i:s") . "\n" . $message);
     $elephant->close();
     //echo "SEND MESSAGE ".$message;
 }
Пример #2
0
 public static function sendLog($message)
 {
     $fields_string = "";
     if (!is_string($message)) {
         $message = NodeLogger::renderJSON($message);
     }
     $fields = array('message' => $message);
     foreach ($fields as $key => $value) {
         $fields_string .= $key . '=' . $value . '&';
     }
     rtrim($fields_string, '&');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "http://localhost:1337/ws");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
     $output = curl_exec($ch);
     curl_close($ch);
 }
 private function process($year, $departemen_id)
 {
     $reportName = "laporan_kunjungan_loket";
     $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
     if (substr("" . $departemen_id, 0, 4) == "wil_") {
         $puskesmas = Puskesmas::model()->findByPk(substr("" . $departemen_id, 4));
         $departemen = NULL;
         $activeSheet->getCell("B3")->setValue("UPT Puskesmas: " . $puskesmas->nama . " Tahun " . $year);
     } else {
         $departemen = Departemen::model()->findByPk($departemen_id);
         $puskesmas = Puskesmas::model()->findByPk($departemen->puskesmas_id);
         $activeSheet->getCell("B3")->setValue($departemen->nama . " Tahun " . $year);
     }
     //header
     $col = 2;
     $poliPuskesmases = PoliPuskesmas::model()->findAllByAttributes(array("puskesmas_id" => $puskesmas->id));
     foreach ($poliPuskesmases as $poliPuskesmas) {
         $poli = Poli::model()->findByPk($poliPuskesmas->poli_id);
         $activeSheet->getCellByColumnAndRow($col, 7)->setValue($poli->nama);
         $col++;
     }
     $activeSheet->getCellByColumnAndRow($col, 7)->setValue("Total");
     $activeSheet->mergeCellsByColumnAndRow(2, 6, $col, 6);
     //konten
     $baris = 8;
     for ($bulan = 1; $bulan <= 12; $bulan++) {
         $col = 2;
         $total = 0;
         foreach ($poliPuskesmases as $poliPuskesmas) {
             //NodeLogger::sendLog("Poli ".$poliPuskesmas->poli_id);
             $poli_id = $poliPuskesmas->poli_id;
             if ($departemen == NULL) {
                 NodeLogger::sendLog("All");
                 $kunjungans = TransaksiKunjungan::model()->findAll("month(waktu) = '{$bulan}' AND year(waktu) = '{$year}' AND puskesmas_id = '" . $puskesmas->id . "'");
             } else {
                 NodeLogger::sendLog("Dept " . $departemen->id);
                 $kunjungans = TransaksiKunjungan::model()->findAll("departemen_id = '" . $departemen->id . "' AND month(waktu) = '{$bulan}' AND year(waktu) = '{$year}' AND puskesmas_id = '" . $puskesmas->id . "'");
             }
             //NodeLogger::sendLog("Jml Kunjungan Poli ".$poli_id." : ".count($kunjungans));
             $jml = 0;
             foreach ($kunjungans as $kunjungan) {
                 $jmlAntrian = TransaksiAntrian::model()->countByAttributes(array("poli_tujuan" => $poli_id, "kunjungan_id" => $kunjungan->id));
                 $jml += $jmlAntrian;
                 /*$antrians = TransaksiAntrian::model()->findAllByAttributes(array("poli_tujuan"=> $poli_id, "kunjungan_id"=>$kunjungan->id));
                   if($departemen == NULL){
                       //semua
                       $jml += count($antrians);
                   }else if($departemen->id == $kunjungan->departemen_id){
                       $jml += count($antrians);
                   }*/
             }
             $activeSheet->getCellByColumnAndRow($col, $baris)->setValue("" . $jml);
             $total += $jml;
             $col++;
             //break;
         }
         $activeSheet->getCellByColumnAndRow($col, $baris)->setValue($total);
         $baris++;
     }
     $col = 2;
     foreach ($poliPuskesmases as $poliPuskesmas) {
         $col++;
     }
     $activeSheet->getStyle("B20:" . $this->getHuruf($col) . "20")->getFill()->applyFromArray(array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => "C7F2FF")));
     //header
     $activeSheet->getStyle("B6:" . $this->getHuruf($col) . "7")->getFill()->applyFromArray(array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => "C7F2FF")));
     $activeSheet->getStyle("B6:" . $this->getHuruf($col) . "20")->applyFromArray(array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
     return array("phpexcel" => $objPHPExcel, "name" => $reportName . "_" . $year);
 }