Skip to content

Instantly share code, notes, and snippets.

@virbo
Last active May 25, 2016 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virbo/ad08c362c4ff294e791fab07490a9f5d to your computer and use it in GitHub Desktop.
Save virbo/ad08c362c4ff294e791fab07490a9f5d to your computer and use it in GitHub Desktop.
<?php
use yii\helpers\Url;
/**
* List table View
*
* @author Yusuf Ayuba
* @copyright 2016
* @link http://dutainformasi.net
* @location app\views\site
*/
$this->title = $temp['error_desc']!==''?'Error '.$temp['error_code'].': '.$temp['error_desc']:'List Table';
$this->params['breadcrumbs'][] = 'List Table';
?>
<div class="page-header" style="margin-top: 0px;" >
<div class="row">
<div class="col-md-12">
<h4>List Tabel</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>#</td>
<th width="20%">Nama Table</th>
<th width="10%">Jenis</th>
<th>Keterangan</th>
<th width="20%">Aksi</th>
</tr>
</thead>
<tbody>
<?php
if ($temp['error_desc']!=='') {
echo "<tr><td colspan=\"5\" align=\"center\">Error ".$temp['error_code'].": ".$temp['error_desc']."</td></tr>";
} else {
$i=0;
foreach ($temp['result'] as $row) {
echo "<tr>
<td>".++$i."</td>
<td>".$row['table']."</td>
<td>".$row['jenis']."</td>
<td>".$row['keterangan']."</td>
<td>
<a href=\"".Url::to(['site/struktur?table='.$row['table']])."\">
<span class=\"glyphicon glyphicon-tasks\" aria-hidden=\"true\"></span> Struktur
</a> |
<a href=\"".Url::to(['site/view?table='.$row['table']])."\">
<span class=\"glyphicon glyphicon-search\" aria-hidden=\"true\"></span> View Data
</a>
</td>
</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Soapmodel;
/**
* Site Controller
*
* @author Yusuf Ayuba
* @copyright 2016
* @link http://dutainformasi.net
* @location app\controllers
*/
class SiteController extends Controller
{
const WSDL_USER = 'username feeder';
const WSDL_PASS = 'password feeder';
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
public function actionIndex()
{
return $this->render('index');
}
public function actionList()
{
$wsdl = new Soapmodel();
$token = $wsdl->token(self::WSDL_USER,self::WSDL_PASS);
return $this->render('listtable',[
'temp' => $wsdl->listtable($token),
]);
}
public function actionStruktur($table)
{
$tables = $table==''?'mahasiswa':$table;
$wsdl = new Soapmodel();
$token = $wsdl->token(self::WSDL_USER,self::WSDL_PASS);
return $this->render('struktur',[
'temp' => $wsdl->dictionary($token,$tables),
'table' => $tables
]);
}
public function actionView($table)
{
$tables = $table==''?'mahasiswa':$table;
$filter = '';
$order = '';
$limit = 10;
$offset = 0;
$wsdl = new Soapmodel();
$token = $wsdl->token(self::WSDL_USER,self::WSDL_PASS);
return $this->render('view',[
'dictionary' => $wsdl->dictionary($token,$tables),
'total' => $wsdl->count_all($token,$tables,$filter),
'temp' => $wsdl->recordset($token,$tables,$filter,$order,$limit,$offset),
'table' => $tables
]);
}
}
<?php
namespace app\models;
use Yii;
use yii\base\Model;
use Esyst\Nusoap\NusoapClient;
/**
* Soap Module
*
* @author Yusuf Ayuba
* @copyright 2016
* @link http://dutainformasi.net
* @location app\models
*/
class Soapmodel extends Model
{
protected $wsdl;
public function __construct()
{
parent::__construct();
$this->wsdl = new NusoapClient("http://localhost:8082/ws/live.php?wsdl", true);
}
public function token($username,$password)
{
return $this->wsdl->call('GetToken',[
'username' => $username,
'password' => $password
]);
}
public function listtable($token)
{
return $this->wsdl->call('ListTable',[
'token' => $token
]);
}
public function dictionary($token,$tabel)
{
return $this->wsdl->call('GetDictionary', [
'token' => $token,
'table' => $tabel
]);
}
public function recordset($token, $table, $filter, $order, $limit, $offset) {
return $this->wsdl->call('GetRecordset',[
'token' => $token,
'table' => $table,
'filter' => $filter,
'order' => $order,
'limit' => $limit,
'offset' => $offset
]);
}
public function record($token, $table, $filter) {
return $this->wsdl->call('GetRecord', [
'token' => $token,
'table' => $table,
'filter' => $filter
]);
}
public function insertrset($token, $table, $records) {
return $this->wsdl->call('InsertRecordset',[
'token' => $token,
'table' => $table,
'data' => json_encode($records)
]);
}
public function insertrecord($token, $table, $records) {
return $this->wsdl->call('InsertRecord',[
'token' => $token,
'table' => $table,
'data' => json_encode($records)
]);
}
public function update($token,$table,$records) {
return $this->wsdl->call('UpdateRecord',[
'token' => $token,
'table' => $table,
'data' => $records
]);
}
public function updaterset($token,$table,$records) {
return $this->wsdl->call('UpdateRecordset',[
'token' => $token,
'table' => $table,
'data' => $records
]);
}
public function count_all($token,$table,$filter) {
return $this->wsdl->call('GetCountRecordset',[
'token' => $token,
'table' => $table,
'filter' => $filter
]);
}
}
<?php
/**
* struktur view
*
* @author Yusuf Ayuba
* @copyright 2016
* @link http://dutainformasi.net
* @location app\views\site
*/
$this->title = $temp['error_desc']!==''?'Error '.$temp['error_code'].': '.$temp['error_desc']:'List Table';
$this->params['breadcrumbs'][] = ['label' => 'List Table', 'url' => ['list']];
$this->params['breadcrumbs'][] = 'Struktur Table';
?>
<div class="page-header" style="margin-top: 0px;" >
<div class="row">
<div class="col-md-12">
<h4>Struktur Table {{<?php echo $table;?>}}</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
if ($temp['error_desc']!=='') {
echo "<div class=\"alert alert-danger\">
<h4>Error ".$temp['error_code']."</h4>
<p>".$temp['error_desc']."</p>
</div>";
} else {
echo "<table class=\"table table-hover table-striped table-bordered\">
<thead>
<tr>
<th>#</th>
<th>Nama Kolom</th>
<th>Primary Key</th>
<th>Tipe</th>
<th>Not Null</th>
<th>Keterangan</th>
</tr>
</thead>
<tbody>";
$i=0;
foreach ($temp['result'] as $value) {
isset($value['pk'])?$pk='PK':$pk='';
isset($value['not_null'])?$nl='not_null':$nl='null';
echo "<tr>
<td>".++$i."</td>
<td>".$value['column_name']."</td>
<td>".$pk."</td>
<td>".$value['type']."</td>
<td>".$nl."</td>
<td>".$value['desc']."</td>
</tr>";
}
echo "</tbody>
</table>";
}
?>
</div>
</div>
<?php
/**
* Views view
*
* @author Yusuf Ayuba
* @copyright 2016
* @link http://dutainformasi.net
* @location app\views\site
*/
$this->title = $temp['error_desc']!==''?'Error '.$temp['error_code'].': '.$temp['error_desc']:'List Table';
$this->params['breadcrumbs'][] = ['label' => 'List Table', 'url' => ['list']];
$this->params['breadcrumbs'][] = 'View Table';
?>
<div class="page-header" style="margin-top: 0px;" >
<div class="row">
<div class="col-md-12">
<h4>View Table {{<?php echo $table;?>}}. Jumlah data: <?php echo $total['result']; ?></h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
if ($temp['error_desc']!=='') {
echo "<div class=\"alert alert-danger\">
<h4>Error ".$temp['error_code']."</h4>
<p>".$temp['error_desc']."</p>
</div>";
} else {
?>
<table class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<?php
foreach ($dictionary['result'] as $value) {
echo "<th>".$value['column_name']."</th>";
}
?>
</tr>
</thead>
<tbody>
<?php
$i=0;
foreach ($temp['result'] as $value) {
echo "<tr>
<td>".++$i."</td>";
foreach ($dictionary['result'] as $dict) {
if (isset($value[$dict['column_name']])) {
$temp_isi = $value[$dict['column_name']];
} else {
$temp_isi = "";
}
echo "<td>".$temp_isi."</td>";
}
echo "</tr>";
}
?>
</tbody>
</table>
<?php } ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment