/wp-content/plugins/aqgeChart/AqgeChartOptionForm.php
PHP | 402 lines | 322 code | 66 blank | 14 comment | 24 complexity | d6a18f309700808c707a7b361e52b021 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1
- <?php
- require_once 'AqgeChartQuery.php';
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of AqgeChartOptionForm
- *
- * @author aqge
- */
- class AqgeChartOptionForm {
- //put your code here
-
- function updateLink($id){
- return get_admin_url(1, 'admin.php?page='. get_admin_page_parent().'&update='.$id ) ;
- }
- function saveLink(){
- return get_admin_url(1, 'admin.php?page='. get_admin_page_parent() ) ;
- }
- function deleteLink(){
- return get_admin_url(1, 'admin.php?page='. get_admin_page_parent().'&delete=true' ) ;
- }
- function getAttributes(){
- $pageOption=array(
- 0=>array(
- 'title'=>'Pengaturan Widget Distribusi Pangan',
- 'jenis'=>'widget',
- ),
- 1=>array(
- 'title'=>'Pengaturan Table distribusi Pangan',
- 'jenis'=>'Table'
- ),
- 'dateformat'=>array('full')
- );
- return $pageOption;
- }
- function aqge_chart_form($view){
- $model = new AqgeChartQuery;
- $pageOption = $this->getAttributes();
-
- if(isset($_POST['aqge-chart-submit'])) {
- $name = $_POST['aqge-chart-name'];
- $desc = $_POST['aqge-chart-desc'];
- $title = $_POST['aqge-chart-title'];
- $tipe = $_POST['aqge-chart-datatype']; //pibc harga
- $start = explode('/', $_POST['aqge-chart-start'] );
- $end = explode('/', $_POST['aqge-chart-end']);
- $group = $_POST['aqge-chart-group']; //harian mingguan
- $select = isset( $_POST['aqge-chart-data-select'])? $_POST['aqge-chart-data-select']:array(0);
- $select_group = isset( $_POST['aqge-chart-data-home'])? $_POST['aqge-chart-data-home']:0;
- $id = isset($_POST['aqge-chart-id'])?$_POST['aqge-chart-id']:0;
- $data = implode(',', $select);
- $kelompok = explode('-', $tipe);
- $option = $model->getOption($kelompok[0]);
- $mulai = date('Y-m-d', strtotime($start[2].'-'.$start[1].'-'.$start[0]));
- $selesai = date('Y-m-d', strtotime($end[2].'-'.$end[1].'-'.$end[0]));
- $model->_criteria = array(
- 'start'=>$mulai,
- 'end'=>$selesai,
- 'option'=>$kelompok[1],
- 'home'=>$select_group,
- 'data'=>$data,
- 'group'=>$option['group'][$group] ,
- 'order'=>$option['order'][$group] ,
- );
- //khusus untuk BPS
- if($tipe=='bps-1' || $tipe=='bps-2' ){
- $model->_criteria['start']=$start[2];
- $model->_criteria['end']=$end[2];
- }
-
-
-
- $sql = $model->getSQL($kelompok[0] );
-
- //special sql
- //if($tipe=='pibc-5')
- // $sql = $model->getSQL('pibcC');
- $model->saveQuery($name, $desc, $sql, $tipe, $title,$view, $group, $data,$mulai, $selesai, $id, $select_group );
- }
- $updatemodel = false;
- if(isset($_GET['update'])){
- $updatemodel = $model->getQueryByPk($_GET['update']);
- }
- ?>
- <div class="wrap">
- <?php echo screen_icon(); ?>
- <h2><?php echo $pageOption[$view]['title']; ?></h2>
- <p>selamat datang dipengaturan <?php echo $pageOption[$view]['jenis']; ?> distribusi pangan</p>
-
- <form action="<?php echo $this->saveLink(); ?>" method="post" id="aqge-chart-widget" class="aqge-form">
- <div class="aqge-chart-left">
- <!--Nama Pengenal-->
- <h4><label for="nama widget" >Nama pengenal <?php echo $pageOption[$view]['jenis']; ?> : </label>
- <input type="text" id="aqge-chart-widget-name" value="<?php echo ($updatemodel)?$updatemodel['name']:null; ?>" name="aqge-chart-name"/></h4>
-
- <!--Keterangan Singkat-->
- <h4><label for="Deskripsi widget">Ketarangan singkat <?php echo $pageOption[$view]['jenis']; ?> : </label>
- <textarea id="aqge-chart-widget-desc" name="aqge-chart-desc"><?php echo ($updatemodel)?$updatemodel['desc']:null; ?></textarea></h4>
-
- <!--Judul-->
- <h4><label for="judul widget">Judul yang tampil pada <?php echo $pageOption[$view]['jenis']; ?> : </label>
- <input type="text" id="aqge-chart-widget-title" value="<?php echo ($updatemodel)?$updatemodel['title']:null; ?>" name="aqge-chart-title" /> </h4>
-
- <!--Pohon Pilihan Data-->
- <h4><label for="jenis data">Jenis Data <i>(pilih satu)</i></label>
- <div class="aqge-chart-tree-node-container">
- <?php $treemodel = $model->getOptionTree(); ?>
-
- <ul class="aqge-chart-tree-node">
- <?php foreach($treemodel as $ikey=>$item) : ?>
- <li>
-
- <a href="#data" class="j-aqge-chart-tree-items">
- <span class="aqge-chart-tree-collapsed"></span>
- <?php echo $item['desc']; ?>
- </a>
- <ul style="display:<?php
- if(!$updatemodel){
- echo ($item['desc']=='pibc')?'block':'none' ;
- } else {
- $g = explode('-', $updatemodel['tipe']);
- echo ($g[0]==$ikey)?'block':'none' ;
- }
- ?>" >
- <?php foreach($item['items'] as $key=>$subitem) : ?>
- <li>
- <label>
- <input type="radio" id="aqge-chart-widget-datatype<?php echo $ikey.'-'.$key ;?>"
- value="<?php echo $ikey.'-'.$key ;?>"
- name="aqge-chart-datatype"
- <?php if($updatemodel && $updatemodel['tipe']==$ikey.'-'.$key) : ?>
- checked="checked"
- <?php endif; ?>
- class="aqge-chart-option-item j-aqge-chart-option-item" />
- <?php echo $subitem; ?>
-
- </label>
- <div class="clear"></div>
- </li>
- <?php endforeach; ?>
- </ul>
- </li>
- <?php endforeach; ?>
- </ul>
- </div>
- </h4>
-
-
- <!--Periode Tanggal/ bulan/ tahun-->
- <h4><label for="tanggal laporan">Periode Laporan</label>
- <h3>
- <?php
- if(!$updatemodel){
- $fmulai= date('d/m/Y', strtotime('-1 week'));
- $fend = date('d/m/Y');
- $fmulaih= date('Y-m-d', strtotime('-1 week'));
- $fendh = date('Y-m-d');
- } else {
- $fmulai= date('d/m/Y', strtotime( $updatemodel['start']));
- $fend = date('d/m/Y', strtotime( $updatemodel['end']));
- $fmulaih= date('Y-m-d', strtotime( $updatemodel['start']));
- $fendh = date('Y-m-d', strtotime( $updatemodel['end']));
- }
-
- for($i=date('Y'); $i>=1990; $i--)
- $tahun[$i]=$i;
-
- for($j=1; $j<=12; $j++)
- $bulan[$j]=date('F', strtotime("1990-$j-1"));
- ?>
-
- <input type="hidden" id="aqge-chart-widget-start-hidden" name="aqge-chart-start-hidden"
- value="<?php echo $fmulaih ?>"/>
-
- <span class="j-aqge-periode j-ap-pibc-1 j-ap-pibc-2 j-ap-pibc-3 j-ap-pibc-4 j-ap-pibc-5
- j-ap-daerah-0 j-ap-kemdag-0 j-ap-keramatjati-1 j-ap-keramatjati-2">
- <input type="text" id="aqge-chart-widget-start" name="aqge-chart-start"
- value="<?php echo $fmulai ?>"/>
- </span>
- <!--other format-->
- <span class="j-aqge-periode j-ap-bps-3 j-ap-bps-4 j-ap-bps-5 ">
- <!--bulan -->
- <select id="aqge-chart-widget-start-bulan" name="aqge-chart-start-bulan" >
- <?php foreach($bulan as $key=>$item): ?>
- <?php $selectbulan = (date('m', strtotime($fmulaih))==$key) ?'selected=selected':null; ?>
- <option value="<?php echo $key; ?>" <?php echo $selectbulan; ?> ><?php echo $item; ?></option>
- <?php endforeach; ?>
- </select>
- </span>
-
- <span class="j-aqge-periode j-ap-bps-1 j-ap-bps-2 j-ap-bps-3 j-ap-bps-4 j-ap-bps-5 ">
- <!--tahun saja-->
- <select id="aqge-chart-widget-start-tahun" name="aqge-chart-start-tahun" >
- <?php foreach($tahun as $key=>$item): ?>
- <?php $selectahun = (date('Y', strtotime($fmulaih))==$key) ?'selected=selected':null; ?>
- <option value="<?php echo $key; ?>" <?php echo $selectahun; ?> ><?php echo $item; ?></option>
- <?php endforeach; ?>
- </select>
- </span>
-
- s/d
- <input type="hidden" id="aqge-chart-widget-end-hidden" name="aqge-chart-end-hidden"
- value="<?php echo $fendh ?>"/>
-
- <span class="j-aqge-periode j-ap-pibc-1 j-ap-pibc-2 j-ap-pibc-3 j-ap-pibc-4 j-ap-pibc-5
- j-ap-daerah-0 j-ap-kemdag-0 j-ap-keramatjati-1 j-ap-keramatjati-2">
- <input type="text" id="aqge-chart-widget-end" name="aqge-chart-end"
- value="<?php echo $fend ?>"/>
- </span>
-
- <!--other format-->
- <span class="j-aqge-periode j-ap-bps-3 j-ap-bps-4 j-ap-bps-5 ">
- <!--bulan -->
- <select id="aqge-chart-widget-end-bulan" name="aqge-chart-end-bulan" >
- <?php foreach($bulan as $key=>$item): ?>
- <?php $selectbulan = (date('m', strtotime($fendh))==$key) ?'selected=selected':null; ?>
- <option value="<?php echo $key; ?>" <?php echo $selectbulan; ?> ><?php echo $item; ?></option>
- <?php endforeach; ?>
- </select>
- </span>
-
- <span class="j-aqge-periode j-ap-bps-1 j-ap-bps-2 j-ap-bps-3 j-ap-bps-4 j-ap-bps-5 ">
- <!--tahun saja-->
- <select id="aqge-chart-widget-end-tahun" name="aqge-chart-end-tahun" >
- <?php foreach($tahun as $key=>$item): ?>
- <?php $selectahun = (date('Y', strtotime($fendh))==$key) ?'selected=selected':null; ?>
- <option value="<?php echo $key; ?>" <?php echo $selectahun; ?> ><?php echo $item; ?></option>
- <?php endforeach; ?>
- </select>
- </span>
-
- </h3>
- </h4>
-
-
- <!--Pilihan group by-->
- <h4><label for="tanggal laporan">Jenis Laporan</label>
-
- <?php $periode=array('Harian','Mingguan','Bulanan','Tahunan'); ?>
- <select id="aqge-chart-widget-group" name="aqge-chart-group" >
- <?php foreach($periode as $key=>$item): ?>
- <option value="<?php echo $key+1; ?>"
- <?php echo ($updatemodel && $updatemodel['grup']==($key+1))?'selected=selected':null; ?>
- > <?php echo $item; ?></option>
- <?php endforeach; ?>
- </select>
-
- </h4>
- </div>
-
-
- <!--Pilihan data Kanan-->
- <div class="aqge-chart-right">
- <h4><label for="pilihan data" style="width:150px;">Pilihan data</label>
- <div class="aqge-chart-data-container">
- <?php $data=($updatemodel)?explode(',', $updatemodel['data']):array(0); ?>
- <?php $datagroup = array('pibc','kemdag','keramatjati','bps','daerah'); ?>
- <?php foreach($datagroup as $itemgroup):?>
- <ul class="aqge-chart-datagroup j-aqge-chart-datagroup j-aqge-chart-datagroup<?php echo $itemgroup; ?>">
- <?php $datamodel = $model->getDataItems($itemgroup); ?>
-
- <?php if($itemgroup=='kemdag'): ?>
- <?php $kemdagoption = $model->getDataItems('kemdagoption');?>
-
- <div class="j-aqge-chart-data-item j-aqge-chart-data-item-kemdag-0">
- <select class="j-aqge-chart-option-item-kemdag" name="aqge-chart-data-home">
- <option value="0">-pilih propinsi-</option>
- <?php foreach($kemdagoption as $optionitem): ?>
- <option value="<?php echo $optionitem['id'];?>"
- <?php if($optionitem['id']==$updatemodel['home']): ?>
- selected="selected"
- <?php endif; ?>
- ><?php echo $optionitem['desc'];?></option>
- <?php endforeach; ?>
- </select>
- </div>
- <?php endif; ?>
-
- <?php if($itemgroup=='daerah'): ?>
- <?php $daerahoption = $model->getDataItems('daerahoption');?>
-
- <div class="j-aqge-chart-data-item j-aqge-chart-data-item-daerah-0">
- <select class="j-aqge-chart-option-item-daerah" name="aqge-chart-data-home">
- <option value="0">-pilih propinsi-</option>
- <?php foreach($daerahoption as $optionitem): ?>
- <option value="<?php echo $optionitem['id'];?>"
- <?php if($optionitem['id']==$updatemodel['home']): ?>
- selected="selected"
- <?php endif; ?>
- ><?php echo $optionitem['desc'];?></option>
- <?php endforeach; ?>
- </select>
- </div>
- <?php endif; ?>
-
- <?php foreach($datamodel as $key=>$dataitem) : //penjualan, harga, kemdag-N ?>
- <li class="aqge-chart-data-item j-aqge-chart-data-item j-aqge-chart-data-item-<?php echo $itemgroup.'-'.$key; ?>"
- >
-
- <h4><?php echo $dataitem['title']; ?> </h4>
- <ul >
- <?php foreach($dataitem['items'] as $datasub):?>
- <li>
- <?php if(isset($datasub['add-title'])): ?>
- <label class="aqge-item-add-title"><?php echo $datasub['add-title']; ?> </label>
- <?php endif; ?>
-
- <label class="<?php echo isset($datasub['class'])?$datasub['class']:null; ?>" >
- <input type="checkbox" name="aqge-chart-data-select[]"
- value="<?php echo $datasub['id']; ?>"
- <?php //arti: sedang diupdate, group menu sama pibc-1 atau kemdag-0 dan hasil eplode id ada ?>
- <?php if($updatemodel && ($itemgroup.'-'.$key==$updatemodel['tipe'] ||
- ($itemgroup.'-0'==$updatemodel['tipe'] && $key==$updatemodel['home'] ) )
- && in_array($datasub['id'],$data) ) : ?>
- checked="checked"
- <?php endif; ?>
- />
- <?php echo $datasub['desc']; ?>
- </label>
-
- </li>
- <?php endforeach; ?>
- </ul>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php endforeach; ?>
- <div class="clear"></div>
- </div>
- </h4>
- </div>
-
-
- <!--Tombol submit-->
- <div>
- <input type="hidden" name="aqge-chart-id" value="<?php echo ($updatemodel && $updatemodel['id']?$updatemodel['id']:null); ?>" />
- <input type="submit" name="aqge-chart-submit" value="save" class="button-primary"/>
- </div>
-
-
- </form>
- <hr/>
-
-
- <!--Daftar record database-->
- <div>
- <h2>Daftar <?php echo $pageOption[$view]['jenis']; ?> tersimpan</h2>
- <?php $listmodel = $model->listQuery($view); //widget ?>
- <table class="wp-list-table widefat plugins" cellpadding="1" cellspacing="1">
- <thead>
- <tr>
- <th>Nama <?php echo $pageOption[$view]['jenis']; ?></th>
- <th>Info <?php echo $pageOption[$view]['jenis']; ?></th>
-
- </tr>
- </thead>
- <tbody>
- <?php foreach($listmodel as $item): ?>
- <tr>
- <td><?php echo $item['name']; ?></td>
- <td><?php echo $item['desc']; ?>
- <br/>
-
- <a href="#delete" class="j-aqge-chart-query-deleted aqge-chart-query-deleted aqge-chart-tool-link"
- url="<?php echo $this->deleteLink(); ?>" data-id="<?php echo $item['id']; ?>">
- delete</a> |
- <a href="<?php echo $this->updateLink($item['id'] ) ; ?>" class="aqge-chart-query-updated aqge-chart-tool-link" >
- update</a> |
- <a href="#view" class="j-aqge-chart-query-view aqge-chart-query-view aqge-chart-tool-link" data-id="<?php echo $item['id']; ?>">
- view</a>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
-
- </div>
- </div>
-
- <?php
- }
- }
- ?>