Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Detemiten::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['TGL' => $this->TGL, 'JMLLOT' => $this->JMLLOT, 'JMLSAHAM' => $this->JMLSAHAM, 'SALDO' => $this->SALDO, 'SALDOR1' => $this->SALDOR1, 'HARGA' => $this->HARGA, 'TGLAKHIR' => $this->TGLAKHIR, 'JMLLOTB' => $this->JMLLOTB, 'JMLSAHAMB' => $this->JMLSAHAMB, 'SALDOB' => $this->SALDOB]);
     $query->andFilterWhere(['like', 'EMITEN_KODE', $this->EMITEN_KODE]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function actionExportExcel()
 {
     //$searchModel = new SecuritasSearch();
     //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $session = Yii::$app->session;
     $dataProvider = $session->get('dataProvider');
     $lotshare = $this->getLotshare();
     $objReader = \PHPExcel_IOFactory::createReader('Excel2007');
     $template = Yii::getAlias('@app/views/' . $this->id) . '/_export.xlsx';
     $objPHPExcel = $objReader->load($template);
     //$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(\PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
     //$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(\PHPExcel_Worksheet_PageSetup::PAPERSIZE_FOLIO);
     $baseRow = 4;
     // line 2
     $activeSheet = $objPHPExcel->getActiveSheet();
     foreach ($dataProvider->getModels() as $row) {
         if ($baseRow != 4) {
             $activeSheet->insertNewRowBefore($baseRow, 1);
         }
         $activeSheet->setCellValue('A' . $baseRow, $baseRow - 3);
         $activeSheet->setCellValue('B' . $baseRow, $row->KODE);
         $activeSheet->setCellValue('C' . $baseRow, $row->JMLLOT);
         $activeSheet->setCellValue('D' . $baseRow, $row->JMLSAHAM);
         //-	Range Beli = saldob / (jmllotb * jmllbrsaham) -> Ket:  saldob, jmllotb dr detemiten; jmllbrsaham dr lotshare.
         $detemiten = Detemiten::find()->where(['EMITEN_KODE' => $row->KODE])->orderBy('TGL DESC')->one();
         $range_beli = (double) @($detemiten->SALDOB / ($detemiten->JMLLOTB * $lotshare));
         $activeSheet->setCellValue('E' . $baseRow, $range_beli);
         $range = @($row->SALDO / $row->JMLSAHAM);
         $activeSheet->setCellValue('F' . $baseRow, $range);
         $activeSheet->setCellValue('G' . $baseRow, $row->SALDO);
         $activeSheet->setCellValue('H' . $baseRow, $row->HARGA);
         $detemiten = Detemiten::find()->where(['EMITEN_KODE' => $row->KODE])->orderBy('TGL DESC')->one();
         if (substr($detemiten->TGLAKHIR, 0, 4) == '0000') {
             $tgl = '-';
         } else {
             $tgl = date('d-m-Y', strtotime($detemiten->TGLAKHIR));
         }
         $activeSheet->setCellValue('I' . $baseRow, $tgl);
         $saldo2 = @($row->HARGA / $row->JMLSAHAM);
         $activeSheet->setCellValue('J' . $baseRow, $saldo2);
         $laba_rugi = $row->JMLSAHAM * $row->HARGA - $row->SALDO;
         $activeSheet->setCellValue('K' . $baseRow, $laba_rugi);
         if ($baseRow % 2 == 0) {
             $activeSheet->getStyle('A' . $baseRow . ':' . 'K' . $baseRow)->applyFromArray(['fill' => ['type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => ['rgb' => 'efefef']]]);
         } else {
             $activeSheet->getStyle('A' . $baseRow . ':' . 'K' . $baseRow)->applyFromArray(['fill' => ['type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => ['rgb' => 'ffffff']]]);
         }
         $baseRow++;
     }
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="' . $this->id . '_' . date('YmdHis') . '.xlsx"');
     header('Cache-Control: max-age=0');
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
     $objWriter->save('php://output');
     exit;
 }
Exemplo n.º 3
0
 /**
  * Deletes an existing Emiten model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     try {
         $detemiten = Detemiten::find()->where(['EMITEN_KODE' => $model->KODE])->count();
         if ($detemiten == 0) {
             $model->delete();
             Yii::$app->session->setFlash('success', 'Data berhasil dihapus.');
         } else {
             Yii::$app->session->setFlash('warning', 'Emiten ini sudah punya Detail Emiten sehingga Tidak Dapat Dihapus');
         }
     } catch (Exception $e) {
         Yii::$app->session->setFlash('error', 'Data tidak dapat dihapus karena telah digunakan pada transaksi lain.');
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 4
0
                <th>No</th>
                <th>Kode</th>
                <th>Jml Lot</th>
                <th>Jml Saham</th>
                <th>Range Beli</th>
                <th>Range</th>
                <th>Saldo</th>
                <th>Harga *)</th>
                <th>Tgl Akhir</th>
                <th>Saldo **)</th>
                <th>Laba(+)/Rugi(-)</th>
        </tr>
        <?php 
$no = 1;
foreach ($dataProvider->getModels() as $row) {
    $detemiten = \app\models\Detemiten::find()->where(['EMITEN_KODE' => $row->KODE])->orderBy('TGL DESC')->one();
    if (substr($detemiten->TGLAKHIR, 0, 4) == '0000') {
        $tgl = '-';
    } else {
        $tgl = date('d-m-Y', strtotime($detemiten->TGLAKHIR));
    }
    ?>
        <tr>
                <td><?php 
    echo $no++;
    ?>
</td>
                <td><?php 
    echo $row->KODE;
    ?>
</td>
Exemplo n.º 5
0
                          timeout: 3000,
                          push: false,
                          replace: false
                        });
                    '], 'pluginOptions' => ['allowClear' => true, 'multiple' => true]]) . '</div>' . '</div>'], 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset Grid'])], ButtonExport::widget()], 'export' => ['fontAwesome' => true], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'KODE', 'label' => 'Kode', 'options' => ['width' => '100px'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['attribute' => 'JMLLOT', 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'filter' => false], ['attribute' => 'JMLSAHAM', 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'format' => ['decimal', 2], 'hAlign' => 'right', 'vAlign' => 'middle', 'filter' => false], ['header' => 'Range Beli', 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'value' => function ($data) use($lotshare) {
    //-	Range Beli = saldob / (jmllotb * jmllbrsaham) -> Ket:  saldob, jmllotb dr detemiten; jmllbrsaham dr lotshare.
    $detemiten = Detemiten::find()->where(['EMITEN_KODE' => $data->KODE])->orderBy('TGL DESC')->one();
    $range_beli = (double) @($detemiten->SALDOB / ($detemiten->JMLLOTB * $lotshare));
    return number_format($range_beli, 2);
    //-	Laba/Rugi = (jmlsaham * harga) - saldo
}], ['header' => 'Range', 'format' => ['decimal', 2], 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'value' => function ($data) {
    //- Range = Saldo / Jml Saham
    return @($data->SALDO / $data->JMLSAHAM);
}], ['attribute' => 'SALDO', 'format' => ['decimal', 2], 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'filter' => false], ['attribute' => 'HARGA', 'format' => ['decimal', 2], 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'filter' => false], ['header' => 'Tgl Akhir', 'format' => ['date', 'php:d/M/Y'], 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'value' => function ($data) {
    //-	Range Beli = saldob / (jmllotb * jmllbrsaham) -> Ket:  saldob, jmllotb dr detemiten; jmllbrsaham dr lotshare.
    $detemiten = Detemiten::find()->where(['EMITEN_KODE' => $data->KODE])->orderBy('TGL DESC')->one();
    if (substr($detemiten->TGLAKHIR, 0, 4) == '0000') {
        return '-';
    } else {
        return date('d-m-Y', strtotime($detemiten->TGLAKHIR));
    }
}], ['header' => 'Saldo **)', 'format' => ['decimal', 2], 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'value' => function ($data) {
    //- Range = Saldo / Jml Saham
    return @($data->HARGA / $data->JMLSAHAM);
}], ['header' => 'Laba/Rugi', 'format' => ['decimal', 2], 'options' => ['width' => '100px'], 'headerOptions' => ['style' => 'text-align:center'], 'hAlign' => 'right', 'vAlign' => 'middle', 'value' => function ($data) {
    return $data->JMLSAHAM * $data->HARGA - $data->SALDO;
}]]]);
?>

    <?php 
$this->registerJs('
Exemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDetemitens()
 {
     return $this->hasMany(Detemiten::className(), ['EMITEN_KODE' => 'KODE']);
 }
Exemplo n.º 7
0
 public function checkDetemitenByDate($date)
 {
     $date = date('Y-m-d', strtotime($date));
     $exists = Detemiten::find()->where(['TGL' => $date])->exists();
     return $exists;
 }