示例#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
 public function __toString()
 {
     $id = 'DBTable_' . Invocation::next();
     $msg = '<table id="' . $id . '">';
     if ($this->getRowCount() == 0) {
         $msg .= '<tr><td>No Rows</td></tr>';
     } else {
         $firstTime = true;
         foreach ($this->table as &$row) {
             if ($firstTime) {
                 $msg .= '  <tr>';
                 foreach ($row as $key => &$value) {
                     $msg .= '<th>' . $key . '</th>';
                 }
                 $msg .= '  </tr>' . "\n";
                 $firstTime = false;
             }
             $msg .= '  <tr>';
             foreach ($row as &$value) {
                 $msg .= '<td>' . $value . '</td>';
             }
             $msg .= '  </tr>' . "\n";
         }
     }
     $msg .= '</table>' . "\n";
     return Widget::styleTable('#' . $id) . $msg;
 }
示例#3
0
 public function index()
 {
     if (!$this->ok) {
         return 'Invalid table: ' . $this->tableName;
     }
     $html = $this->controller();
     $paginationHtml = $this->paginator->toHtml();
     $html .= Tag::form(['action' => $this->formAction, 'onSubmit' => "if (!checkIfADelete('{$this->delTag}')) return false; return true;"]) . Tag::table(array_merge(['id' => 'CRUD' . $this->suffix], $this->styles[self::TABLE_C])) . Tag::tr();
     if ($this->canDelete) {
         $js = "\$().ready(function() { \$('input[type=checkbox][name^={$this->delTag}]').shiftClick(); });";
         $html .= JS::library('jquery.shiftclick.js') . JS::javaScript($js) . Tag::th() . Tag::hTag('span', ['title' => 'Click here to Toggle all the Delete checkboxes']) . 'D' . Tag::_hTag('span') . Tag::br() . Tag::checkBox('_dcheck', 'Y', false, ['onClick' => "toggleAll(this,'{$this->delTag}','{$this->submitId}')", 'title' => 'Toggle all the Delete checkboxes.']) . Tag::_th();
     }
     if ($this->canUpdate) {
         $js = "\$().ready(function() { \$('input[type=checkbox][name^={$this->updTag}]').shiftClick(); });";
         $html .= JS::library('jquery.shiftclick.js') . JS::javaScript($js) . Tag::th() . Tag::hTag('span', ['title' => 'Click here to Toggle all the Update checkboxes']) . 'U' . Tag::_hTag('span') . Tag::br() . Tag::checkBox('_ucheck', 'Y', false, ['onClick' => "toggleAll(this,'{$this->updTag}','{$this->submitId}')", 'title' => 'Toggle all the Update checkboxes.']) . Tag::_th();
     }
     foreach ($this->columnTitles as $colName => $title) {
         if (isset($this->displayType[$colName])) {
             if (is_string($this->displayType[$colName])) {
                 $type = $this->displayType[$colName];
             } else {
                 $type = $this->displayType[$colName][0];
             }
         } else {
             $type = self::DISPLAY;
         }
         if (!in_array($type, [self::HIDDEN, self::NONE])) {
             $html .= Tag::th() . $this->columnator->toHtml($colName, $title) . Tag::_th();
         }
     }
     foreach ($this->extraCols as $title => $col) {
         $html .= Tag::th();
         if (isset($this->columnTitles[$title])) {
             $html .= $this->columnator->toHtml($title, $this->columnTitles[$title]);
         } else {
             $html .= $title;
         }
         $html .= Tag::_th();
     }
     $html .= Tag::_tr() . "\n";
     $tab = $this->createSQLResult();
     $this->calculateColumnWidths($tab);
     foreach ($tab as $idx => $row) {
         $html .= Tag::tr();
         if ($this->canDelete) {
             $html .= Tag::td(['align' => 'center']) . Tag::checkBox("{$this->delTag}[{$idx}]", $row[$this->primaryKey], false, ['id' => "{$this->delTag}_{$idx}", 'onClick' => "showSubmit('{$this->submitId}')", 'title' => 'Toggle to delete this row.']) . Tag::_td();
         }
         if ($this->canUpdate) {
             $html .= Tag::td(['align' => 'center']) . Tag::checkBox("{$this->updTag}[{$idx}]", $row[$this->primaryKey], false, ['id' => "{$this->updTag}_{$idx}", 'onClick' => "showSubmit('{$this->submitId}')", 'title' => 'Toggle to update this row.']) . Tag::_td();
         }
         foreach ($row as $key => $value) {
             $html .= $this->renderValue($idx, $key, $value);
         }
         foreach ($this->extraCols as $col) {
             $html .= Tag::td() . call_user_func_array($col, [$idx, $row[$this->primaryKey]]) . Tag::_td();
         }
         $html .= Tag::_tr() . "\n";
     }
     $this->resp->set($this->action, 'applyChanges');
     $html .= Tag::_table() . $this->resp->toHidden() . Tag::submit('Apply Changes', ['style' => 'display: none', 'id' => $this->submitId, 'title' => 'Click here to apply the changes to this table']) . Tag::_form();
     return self::header() . Widget::styleTable('#CRUD' . $this->suffix) . ($this->topPage ? $paginationHtml : '') . $html . ($this->bottomPage ? $paginationHtml : '') . $this->insertForm();
 }