deptandashboard /wp-content/plugins/aqgeChart/AqgeChartOptionForm.php

Language PHP Lines 403
MD5 Hash d6a18f309700808c707a7b361e52b021 Estimated Cost $4,620 (why?)
Repository https://bitbucket.org/aqge/deptandashboard View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<?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
}
}

?>
Back to Top