Skip to content

Instantly share code, notes, and snippets.

View mdmunir's full-sized avatar

Misbahul D Munir mdmunir

View GitHub Profile
<?php
/* @var $this \yii\web\View */
?>
<div>
Event:
<ul id="response">
</ul>
</div>
<?php
$url = \yii\helpers\Url::to(['/site/message'],true);
@mdmunir
mdmunir / Chat.php
Created May 26, 2015 03:40
Simple Chat Application (Models). Put at folder `app/models`
<?php
namespace app\models;
/**
* Description of Chat
*
* @author Misbahul D Munir <[email protected]>
* @since 1.0
*/
@mdmunir
mdmunir / ChatController.php
Created May 26, 2015 03:46
Put at folder `@app/controllers`
<?php
namespace app\controllers;
use Yii;
use app\models\Chat;
use app\models\ChatAccount;
use yii\helpers\Url;
use app\components\SSE;
@mdmunir
mdmunir / index.php
Last active August 29, 2015 14:21
Put in folder `@app/views/chat`
<?php
use yii\web\View;
use yii\helpers\Url;
/* @var $this View */
$this->title = 'Simple Chat';
$this->registerJs($this->render('script.js'), View::POS_END);
$this->registerCss($this->render('style.css'));
@mdmunir
mdmunir / Action.php
Created June 23, 2015 22:41
Menghitung waktu shalat
public function actionImsakiyah()
{
$model = new \app\models\Imsakiyah();
$jadwal = null;
if ($model->load(\Yii::$app->request->get(), '') && $model->validate()) {
$jadwal = $model->getImsakiyah();
}
return $this->render('imsakiyah', ['model' => $model, 'jadwal' => $jadwal]);
}
@mdmunir
mdmunir / _form.php
Created March 20, 2016 09:51
Contoh Tabular Input
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use mdm\widgets\GridInput;
/* @var $this yii\web\View */
/* @var $model app\models\Order */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
define('APP_PATH', __DIR__);
define('SYS_GLOBAL_VAR', '_d326_fw');
session_start();
function set($name, $value)
{
$GLOBALS[SYS_GLOBAL_VAR][$name] = $value;
}
<!DOCTYPE html>
<html>
<head>
<title><?= get('title') ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<div class="wrap">
class Contact extends Model
{
public function rules()
{
return [
// name, email, subject and body are required
[['name', 'email', 'subject', 'body'], 'required'],
// email has to be a valid email address
['email', 'email'],
// verifyCode needs to be entered correctly
@mdmunir
mdmunir / subquery.php
Last active April 8, 2016 06:48
Sub Query
<?php
$queryGM = (new Query())
->select(['gmd.product_id', 'total' => 'sum(gmd.qty)'])
->from(['gm' => '{{%goods_movement}}'])
->innerJoin(['gmd' => '{{%goods_movement_dtl}}'], '[[gmd.movement_id]]=[[gm.id]]')
->where(['gm.status' => 20, 'gm.reff_type' => self::REFF_SELF, 'gm.reff_id' => $this->id])
->groupBy(['gmd.product_id']);
$queryItem = (new Query())
->select(['md.product_id', 'md.cogs', 'md.qty', 'md.uom_id', 'g.total'])