예제 #1
0
    public function index()
    {
        $schedulerList = Scheduler::getList(true);
        $formName = 'SchedulerManager_index';
        $id = 'SchedulerManager_table';
        $js = "\$().ready ( function () {\n";
        $valid = Validator::factory($formName);
        $html = Tag::table(['id' => $id]) . Tag::tr() . Tag::th() . 'Upd' . Tag::_th() . Tag::th() . 'Del' . Tag::_th() . Tag::th() . 'Command' . Tag::_th() . Tag::th() . 'Start Date' . Tag::_th() . Tag::th() . 'Cron' . Tag::_th() . Tag::th() . 'Active' . Tag::_th() . Tag::th() . 'Last Run' . Tag::_th() . Tag::_tr();
        if (count($schedulerList) == 0) {
            $html .= Tag::tr() . Tag::td(['colspan' => 20]) . 'No Scheduled Tasks' . Tag::_td() . Tag::_tr();
        } else {
            $js .= <<<JS
                \$('input[type=checkbox][name^=fldUpd]').shiftClick();

JS;
            $rowIdx = 0;
            foreach ($schedulerList as $idx => $schedulerItem) {
                $row = '_' . $idx;
                $valid->addExists('fldCommand' . $row, 'Command must exist')->addExists('fldCron' . $row, 'Interval must exist');
                $js .= <<<JS
                    \$( '#fldStartDate{$row}' ).datetimepicker({
                        dateFormat: 'yy-mm-dd',
                        timeFormat: 'HH:mm'
                    });
JS;
                $lastRun = $schedulerItem->lastRun == '' ? '*Never*' : $schedulerItem->lastRun;
                $html .= Tag::tr() . Tag::td() . Tag::checkBox('fldUpd[]', $idx, false, ['id' => 'U' . $rowIdx]) . Tag::_td() . Tag::td() . Tag::linkButton('?' . Response::factory()->set('fldID', $idx)->action(__CLASS__ . '->deleteItem()'), 'Delete', ['onClick' => "confirm('Are you sure?')"]) . Tag::_td() . Tag::td(['width' => '100%', 'nowrap' => 'nowrap']) . Tag::text('fldCommand' . $row, $schedulerItem->cmd, ['style' => 'width:100%;', 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Tag::text('fldStartDate' . $row, $schedulerItem->start, ['id' => 'fldStartDate' . $row, 'size' => '18', 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Tag::text('fldCron' . $row, $schedulerItem->cron, ['onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . Lists::select('fldActive' . $row, ['Yes', 'No'], ['default' => $schedulerItem->active, 'onChange' => "\$('#U{$rowIdx}').attr('checked',true)"]) . Tag::_td() . Tag::td(['nowrap' => 'nowrap']) . $lastRun . Tag::_td() . Tag::_tr();
                $rowIdx++;
            }
        }
        $html .= Tag::_table();
        $js .= '});';
        return JS::libraryWithDependancies(JS::JQUERY_UI_DATETIME) . JS::library('jquery.shiftclick.js') . JS::javaScript($js) . $valid->toHtml() . Widget::styleTable('#' . $id) . Tag::form(['name' => $formName, 'onSubmit' => $valid->onSubmit()]) . $html . Response::factory()->action(__CLASS__ . '->save()')->toHidden() . Tag::submit('Save') . Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->newItem()'), 'New Item') . Tag::_form();
    }
예제 #2
0
파일: CRUD.php 프로젝트: raxisau/JackBooted
 private function renderValue($rowIdx, $colName, $value)
 {
     $html = '';
     $name = $this->gridTag . '[' . $rowIdx . '][' . $colName . ']';
     $autoUpdateJS = "autoUpdate({$rowIdx},'{$this->updTag}','{$this->delTag}','{$this->submitId}');";
     $id = $this->gridTag . '_' . $rowIdx . '_' . $colName;
     $updClickAttrib = ['onClick' => $autoUpdateJS, 'id' => $id];
     $updCheckAttrib = ['onChange' => $autoUpdateJS, 'id' => $id];
     $type = $this->getColumnType($colName);
     switch ($type) {
         case self::NONE:
             break;
         case self::DISPLAY:
             $html .= $value == '' ? '&nbsp;' : Tag::e($value);
             break;
         case self::HIDDEN:
             $this->resp->set($name, $value);
             break;
         case self::RADIO:
             $dispList = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : null;
             $updCheckAttrib['default'] = $value;
             $html .= Tag::table() . Tag::tr() . Tag::td(['nowrap' => 'nowrap']) . implode(Tag::_td() . Tag::td(['nowrap' => 'nowrap']), Lists::radio($name, $dispList, $updCheckAttrib)) . Tag::_td() . Tag::_tr() . Tag::_table();
             break;
         case self::SELECT:
             $dispList = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : null;
             $blankLine = isset($this->displayType[$colName][2]) ? $this->displayType[$colName][2] : false;
             $updCheckAttrib['default'] = $value;
             $updCheckAttrib['hasBlank'] = $blankLine;
             $html .= Lists::select($name, $dispList, $updCheckAttrib);
             break;
         case self::CHECKBOX:
             $checkValue = isset($this->displayType[$colName][1]) ? $this->displayType[$colName][1] : 'YES';
             $html .= Tag::checkBox($name, $checkValue, $value == $checkValue, $updClickAttrib);
             break;
         case self::TIMESTAMP:
             $attribs = array_merge($updCheckAttrib, $this->cellAttributes[$colName]);
             $attribs['value'] = strftime('%Y-%m-%d %H:%M:%S', (int) $value);
             $attribs['size'] = strlen($attribs['value']) + 1;
             $html .= Tag::text($name, $attribs);
             break;
         case self::ENCTEXT:
             $value = Cryptography::de((string) $value);
             // Fall through to output text field
         // Fall through to output text field
         case self::TEXT:
         default:
             $updCheckAttrib['value'] = (string) $value;
             $html .= Tag::text($name, array_merge($updCheckAttrib, $this->cellAttributes[$colName]));
             break;
     }
     if (!in_array($type, [self::HIDDEN, self::NONE])) {
         $html = Tag::td() . $html . Tag::_td();
     }
     return $html;
 }