Author kumkum

Yii2: How to Create Editable Row in Gridview

Setup 1 – View Put the following code inside gridview: [ ‘class’=>’kartik\grid\EditableColumn’, ‘attribute’ => ‘nilai_tugas’, ‘value’ => function ($model) { return $model->nilai_tugas; }, ‘editableOptions’=> function ($model, $key, $index) { return [ ‘header’=>’Name’, ‘size’=>’md’, ‘formOptions’=>[‘action’ => [‘krs-detail/editNilai’]], ‘inputType’=>\kartik\editable\Editable::INPUT_TEXT, ]; } ], Setup 2 – Controller Put the following code into controller file: use kartik\grid\EditableColumnAction; use yii\helpers\ArrayHelper;…

PHP Tutorial: How to Check Date is Today Date

Use the following code to check a date whether it is today date. $timestamp = “2022-06-27”; $today = new DateTime(“today”); $match_date = DateTime::createFromFormat( “Y-m-d”, $timestamp ); $match_date->setTime( 0, 0, 0 ); $diff = $today->diff( $match_date ); $diffDays = (integer)$diff->format( “%R%a” ); // Extract days count in interval if ($diffDays != 0) { echo “not today”;…

How to Fix Let’s Encrypt ACME v1 Disabled

Let’s Encrypt is popular free SSL service. My VPS which is using Virtualmin was unable to use Let’s Encrypt and throw an error “ACME v1 disabled”. To fix this problem, execute the following line in terminal: apt-get install socat certbot certbot register After that, complete the register with a valid e-mail address and try to…

Yii2 Custom Action Button

Use the following format code to make custom action button in Gridview: [ ‘class’ => ‘yii\grid\ActionColumn’, ‘header’ => ‘Actions’, ‘headerOptions’ => [‘style’ => ‘color:#337ab7’], ‘template’ => “{update} {print} {delete}”, ‘buttons’ => [ ‘view’ => function ($url, $model) { return Html::a(‘<span class=”glyphicon glyphicon-eye-open”></span>’, $url, [ ‘title’ => Yii::t(‘app’, ‘lead-view’), ]); }, ‘update’ => function ($url, $model) { return…

How to Create Bandwidth Usage Script on Linux

Using a tool called iftop we can monitor bandwidth usage via command line on Linux. But here we will create our own shell script to monitor bandwidth usage. The idea is to read rx_bytes and tx_bytes files inside /sys/class/net/[interface]/statistics/ folder. Create netspeed script in /usr/local/bin/ and copy and paste below script. Script content: Exit nano…