public function recentAlarmsAck() { if (($id = Request::get('fldModJackAlertID')) == '' || ($alert = Alerts::get($id)) === false) { return $this->index() . Widget::popupWrapper('Invalid Alert ID'); } $alert->status = Alerts::STATUS_SEEN; $alert->save(); return $this->index() . Widget::popupWrapper("Acknowledged Alert {$alert->id} - {$alert->desc}"); }
public function resetSave() { if (($confirm = Request::get('fldConfirm')) == '' || $confirm != 'RESET CONFIG') { return Widget::popupWrapper('Invalid response, Reset cancelled', -1, 'Action Cancelled') . $this->index(); } else { DB::exec(DB::DEF, 'DELETE FROM tblConfig'); return Widget::popupWrapper('All configuration data has been erased', -1, 'Reset Complete') . $this->index(); } }
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; }
public function sendPW() { $sql = 'SELECT fldUserID FROM tblUser WHERE fldUser=?'; if (($id = DB::oneValue(DB::DEF, $sql, Request::get('fldEmail'))) === false) { $msg = 'This email does not exist on this system.<br>' . 'Either choose a new email address or register as new customer.' . $this->forgotPassword(); } else { $pw = Password::passGen(10, Password::MEDIUM); if (DB::driver() == DB::MYSQL) { $sql = 'UPDATE tblUser SET fldPassword=PASSWORD(?) WHERE fldUserID=?'; DB::exec(DB::DEF, $sql, [$pw, $id]); } else { $sql = 'UPDATE tblUser SET fldPassword=? WHERE fldUserID=?'; DB::exec(DB::DEF, $sql, [hash('md5', $pw), $id]); } // Update the Database with the new Password combo $boss = Cfg::get('boss'); $desc = Cfg::get('desc'); // create the email message to notify about a password request $body = '<h3>User requested password<br>Email: <b>%s</b></h3><br>From %s'; Mailer::envelope()->format(Mailer::HTML_TEXT)->from(Request::get('fldEmail'))->to($boss)->subject('User requested password')->body(sprintf($body, Request::get('fldEmail'), $desc))->send(); $body = <<<TXT Message from %s Here are your login details Password: %s Regards %s TXT; // create the email message to notify the user of his/her login details Mailer::envelope()->from($boss)->to(Request::get('fldEmail'))->subject('Login Request ' . $desc)->body(sprintf($body, $desc, $pw, $desc))->send(); $msg = 'Soon you will receive an email that will contain your login details.'; } return Widget::popupWrapper($msg, -1); }
public static function hRefButton($url, $name, $attribs = []) { if (is_string($attribs)) { $attribs = [$attribs]; } if (!isset($attribs['id'])) { $attribs['id'] = 'linkButton_' . Invocation::next(); } return Widget::button("#{$attribs['id']}") . self::hRef($url, $name, $attribs); }
public function reload() { Config::clearCache(); Widget::popupWrapper('Sucessfully reloaded the config', 1000, 'Reload') . $this->index(); }
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(); }
public function newItem() { $defaults = ['cmd' => __CLASS__ . '::hello();', 'start' => strftime('%Y-%m-%d %H:%M'), 'cron' => '* * * * *', 'active' => 'No', 'lastRun' => '']; Scheduler::factory($defaults)->save(); return Widget::popupWrapper('New Item Created') . $this->index(); }