hallo , i want tosk about datepicker
how to get value from date picker to query ,
i have code date picker , if i select date and data show as date selected from date picker
<?php
use app\common\helpers\Timeanddate;
use app\models\DeviceLog;
use yii\helpers\Html;
use yii\widgets\DetailView;
use dosamigos\chartjs\ChartJs;
use yii\helpers\ArrayHelper;
use dosamigos\datepicker\DatePicker;
/ @var $this yii\web\View /
/ @var $model app\models\Device /
$logs = DeviceLog::find()
->where([‘id_device’ => $model->id_device])
->andWhere([‘log_date’=> ‘tanggal’])
->orderBy(‘log_time DESC’)
->all();
$sumbu_x_data = array();
$sumbu_y_data = array();
foreach($logs as $log){
//Label Sumbu X
$sumbu_x_data[] = Timeanddate::getTimeOnly($log->log_time);
$sumbu_y_data[] = $log->value1;
}
$this->title = $model->device_name;
$this->params[‘breadcrumbs’][] = [‘label’ => ‘Devices’, ‘url’ => [‘index’]];
$this->params[‘breadcrumbs’][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class=“device-view box box-primary”>
<?php /<h1><?= Html::encode($this->title) ?></h1>/ ?>
<?= DetailView::widget([
‘model’ => $model,
‘attributes’ => [
//‘id_device’,
‘device_name’,
‘device_id’,
‘address’,
‘param1’,
//‘param2’,
// ‘param3’,
// ‘last_value1’,
// ‘last_value2’,
// ‘last_value3’,
// ‘last_update’,
// ‘last_value4’,
],
]) ?>
</div>
<div class=“row”>
<div class=“col-md-6”>
<div class=“box”>
<div class=“box-header with-border”>
<h3 class=“box-title”>Grafik Harian <?= $this->title = $model->device_name; ?></h3>
</div>
<!-- /.box-header -->
<div class=“box-body”>
<div class=“row”>
<div class=“col-md-12”>
<?= DatePicker::widget([
‘name’ => ‘Test’,
// ‘value’ => ‘2019-Jul-26’,
‘value’ => ArrayHelper::getValue($_GET, “tanggal”),
‘template’ => ‘{addon}{input}’,
‘clientOptions’ => [
‘autoclose’ => true,
‘format’ => ‘yyyy-mm-dd’
]
]);?>
<?php //[
// ‘attribute’=>‘log_date’,
// ‘value’=>‘log_date’,
// ‘format’=>‘raw’,
// ‘filter’=> DatePicker::widget([
// ‘model’ => $model,
// ‘attribute’ => $logs,
// ‘clientOptions’ => [
// ‘autoclose’ => true,
// ‘format’ => ‘yyyy-m-dd’,
// ‘style’ => ‘width: 200px;’, ‘class’ => ‘text-center’
// ]
// ])
// ]
?>
</div>
</div>
</div>
</div>
</div>
</div>