public function actionEntry() { $model = new EntryForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { // valid data received in $model // do something meaningful here about $model ... return $this->render('entry-confirm', ['model' => $model]); } else { // either the page is initially displayed or there is some validation error return $this->render('entry', ['model' => $model]); } }
public function actionEntry() { $model = new EntryForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { // данные в $model удачно проверены // делаем что-то полезное с $model ... return $this->render('entry-confirm', ['model' => $model]); } else { // либо страница отображается первый раз, либо есть ошибка в данных return $this->render('entry', ['model' => $model]); } }
static function renderImportFromDirectory() { $html = '<div id="entryform">'; $html .= '<h1>' . translate('Import all .ics files of a directory') . '</h1>'; $html .= '<p>' . translate('This process will import each file in a directory named "username.ics" and create a user and calendar for each file to import.') . '</p>'; $data = (object) array('directory_path' => '/path/to/your/ics/files', 'calendar_path' => 'calendar'); $ef = new EntryForm($_SERVER['REQUEST_URI'], $data, true, true); $html .= "<table width=\"100%\" class=\"data\">\n"; $html .= $ef->StartForm(array("autocomplete" => "off")); $html .= $ef->DataEntryLine(translate("path to store your ics"), "%s", "text", "calendar_path", array("size" => 20, "title" => translate("Set the path to store your ics e.g. 'calendar' will be referenced as /caldav.php/username/calendar/"), "help" => translate("<b>WARNING: all events in this path will be deleted before inserting allof the ics file</b>")), ''); $html .= $ef->DataEntryLine(translate("Directory on the server"), "%s", "text", "directory_path", array("size" => 20, "title" => translate("The path on the server where your .ics files are."))); $html .= "</table>\n"; $html .= $ef->SubmitButton("import_from_directory", translate('Submit')); $html .= $ef->EndForm(); $html .= "</div>"; return $html; }
/** * Render the form / viewer as HTML to show the userclient * @return string An HTML fragment to display in the page. */ function Render() { global $c, $session; $html = ""; $session->Dbg("OrganisationPlus", "Render: type=insert"); $ef = new EntryForm($REQUEST_URI, $this->Values, $this->EditMode); $ef->NoHelp(); // Prefer this style, for the moment $onsubmit = $this->validation->func_name; // retrieve the name of the onsubmit javascript function $html .= $ef->StartForm(array("autocomplete" => "off", "onsubmit" => "return {$onsubmit}(this)")); $html .= "<table class=\"data\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n"; $html .= $this->RenderOrganisationDetails($ef); $html .= $this->RenderDefaultSystem($ef); $html .= $this->RenderPrimaryUser($ef); // Render the Javascript validation rules for the form $html .= $this->validation->RenderJavascript(); $html .= "</table>\n"; $html .= '<div id="footer">'; $html .= $ef->SubmitButton("submit", "insert" == $this->WriteType ? "Create" : "Update"); $html .= '</div>'; $html .= $ef->EndForm(); if ($this->new_record) { // We have a small script here to toggle enablement of the password fields vs. invite field. $html .= <<<EOSCRIPT <script language="JavaScript"> function InviteChanged(invite) { invite.form.new_password.disabled = invite.checked; invite.form.confirm_password.disabled = invite.form.new_password.disabled; return true; } InviteChanged(document.getElementById('id_invite')); </script> EOSCRIPT; } return $html; }
$s .= "itself is provided here:<br>"; $href = $URL_PREFIX . "/qams-step-detail.php?project_id={$qastep->project_id}&step_id={$qastep->qa_step_id}"; $stlink = "<a href=\"{$href}\">{$href}</a>"; $s .= " " . $stlink . "</p>"; $project->QAMSNotifyEmail("QAMS Activity Notice", $s, $subject, $recipients); } } } // null assignment } // assignment changed } } // Main content.. $s = ""; $ef = new EntryForm($RESPONSE->requested, $project, $have_admin ? 1 : 0); $ef->NoHelp(); if ($ef->editmode) { $s .= $ef->StartForm(); $s .= $ef->HiddenField("qa_action", "{$qa_action}"); if ($project->request_id > 0) { $s .= $ef->HiddenField("project_id", $project->request_id); $s .= $ef->HiddenField("step_id", "{$qastep->qa_step_id}"); } } // Start main table.. $s .= "<table width=\"100%\" class=\"data\" cellspacing=\"0\" cellpadding=\"0\">\n"; $s .= $ef->BreakLine("Quality Assurance Step"); $s .= "<tr><td height=\"15\" colspan=\"2\"> </td></tr>"; if ($this->project_manager_fullname != "") { $href = "/user.php?user_no={$this->project_manager}";
/** * Render the form / viewer as HTML to show the user * @return string An HTML fragment to display in the page. */ function Render() { $html = ""; dbg_error_log("User", ":Render: type={$this->WriteType}, edit_mode={$this->EditMode}"); $ef = new EntryForm($REQUEST_URI, $this->Values, $this->EditMode); $ef->NoHelp(); // Prefer this style, for the moment if ($ef->EditMode) { $html .= $ef->StartForm(array("autocomplete" => "off")); if ($this->user_no > 0) { $html .= $ef->HiddenField("user_no", $this->user_no); } } $html .= "<table width=\"100%\" class=\"data\" cellspacing=\"0\" cellpadding=\"0\">\n"; $html .= $this->RenderFields($ef); $html .= $this->RenderRoles($ef); $html .= "</table>\n"; if ($ef->EditMode) { $html .= '<div id="footer">'; $html .= $ef->SubmitButton("submit", "insert" == $this->WriteType ? translate("Create") : translate("Update")); $html .= '</div>'; $html .= $ef->EndForm(); } return $html; }
/** * Return project QA Plan. If editable return as form fields with * the form tags, encapsulated in a nice table with all of the fields we * need to edit a project's QA plan. * @param integer $edit Flag, if 1 then editable fields in a form */ function RenderQAPlan($edit = 1) { global $qa_action; $s = ""; $ef = new EntryForm($REQUEST_URI, $this, $edit); $ef->NoHelp(); if ($ef->editmode) { $s .= $ef->StartForm(); if ($this->request_id > 0) { $s .= $ef->HiddenField("request_id", $this->request_id); $s .= $ef->HiddenField("post_action", "config_update"); $s .= $ef->HiddenField("qa_action", "qaplan"); $s .= $ef->HiddenField("edit", "1"); } } // Just the things we want created/updated in QAMS.. $s .= "<table width=\"100%\" class=\"data\" cellspacing=\"0\" cellpadding=\"0\">\n"; if (isset($this->qa_process)) { $s .= $ef->BreakLine("Quality Assurance Plan"); $s .= "<tr><td height=\"15\" colspan=\"2\"> </td></tr>\n"; // Project info.. $s .= "<tr><td colspan=\"2\"><b>Project:</b> " . $this->brief . "</td></tr>\n"; if ($this->project_manager_fullname != "") { $pmlink = "<a href=\"/user.php?user_no={$this->project_manager}\">"; $pmlink .= $this->project_manager_fullname; $pmlink .= "</a>"; $s .= "<tr><td colspan=\"2\"><b>Project Manager:</b> " . $pmlink . "</td></tr>"; } if ($this->qa_mentor_fullname != "") { $qalink = "<a href=\"/user.php?user_no={$this->qa_mentor}\">"; $qalink .= $this->qa_mentor_fullname; $qalink .= "</a>"; $s .= "<tr><td colspan=\"2\"><b>QA Mentor:</b> " . $qalink . "</td></tr>"; } $s .= "<tr><td height=\"15\" colspan=\"2\"> </td></tr>"; $s .= "<tr><td colspan=\"2\">" . $this->qa_process->QAPlan() . "</td></tr>"; } $s .= "<tr><td height=\"15\" colspan=\"2\"> </td></tr>"; $s .= "</table>\n"; $qaplan_status = $this->qa_process->overall_approval_status(STEP_ID_QAPLAN); if ($ef->editmode && $qaplan_status != "y" && $qaplan_status != "p") { $s .= $ef->SubmitButton("submit", "Update"); $s .= $ef->EndForm(); } return $s; }
public function actionDetail($n, $confirmation = 0) { if (Yii::app()->user->getState('siteVersion') == 'mobile') { Yii::app()->clientScript->registerCssFile('/css/mobile/blocs.css'); $this->layout = '//mobileLayouts/column1'; } if (!($contest = Contest::model()->with(array('fields' => array('order' => 'fields.rank ASC'), 'fields.multi' => array('order' => 'multi.rank ASC')))->find('i18nContest.l_title_url=:n', array('n' => $n)))) { throw new CHttpException(404, 'The requested page does not exist.'); } $currentDate = date('Y-m-d H:i:s'); $contestMultilang = Contest::model()->multilang()->find('i18nContest.l_title_url=:n', array('n' => $n)); Yii::app()->languageManager->translatedGetVars['n'] = array(); foreach (array_keys(Yii::app()->languageManager->languages) as $language) { Yii::app()->languageManager->translatedGetVars['n'][$language] = $contestMultilang->{'title_url_' . $language}; } // In case detail page is accessed directly and contest is inactive. if ($contest->status == "inactive") { $this->redirect($this->createUrl('index')); } if ($confirmation) { $this->render('confirmation', array('contest' => $contest)); } elseif ($contest->end_date !== null && $contest->end_date < $currentDate || $contest->status == "archived") { $this->render('conclusion', array('contest' => $contest)); } else { $entry = new EntryForm(); $validators = $entry->getValidatorList(); $required = 'verify_code, '; $files = ''; $length = ''; $email = ''; $entry->verify_code = null; $entry->attributeLabels['verify_code'] = Yii::t('contestModule.common', 'Code de sécurité'); $validators->add(CValidator::createValidator('captcha', $this, 'verify_code', array('message' => Yii::t('contestModule.common', 'Le code saisi est invalide. Veuillez entrer le code à nouveau.'), 'allowEmpty' => !CCaptcha::checkRequirements(), 'captchaAction' => '/site/captcha'))); foreach ($contest->fields as $field) { $entry->{$field->id} = null; $entry->attributeLabels[$field->id] = CHtml::encode($field->title); if ($field->required) { $required .= $field->id . ', '; } $length .= $field->id . ', '; if ($field->type == 'email') { $email .= $field->id . ', '; } if ($field->type == 'file') { $files = $field->id . ', '; $behaviors = array('class' => 'application.models.behaviors.UploadingBehavior.ModelUploadingBehavior', 'attribute' => $field->id, 'dir' => 'files/_user/contest_entries', 'tempDir' => 'files/_user/contest_entries/_temp', 'cacheTime' => 10 * 24 * 60 * 60, 'uploadcare' => null, 'allowDelete' => false); $entry->{$field->id . 'Handler'} = $entry->attachBehavior($field->id . 'Handler', $behaviors); $entry->behaviors = array($behaviors); } } if ($required != '') { $validators->add(CValidator::createValidator('required', $this, substr($required, 0, -2))); } if ($length != '') { $validators->add(CValidator::createValidator('length', $this, substr($length, 0, -2), array('max' => 1000))); } if ($email != '') { $validators->add(CValidator::createValidator('email', $this, substr($email, 0, -2))); } if ($files != '') { $validators->add(CValidator::createValidator('file', $this, substr($files, 0, -2), array('allowEmpty' => true))); } if (isset($_POST['EntryForm'])) { foreach ($_POST['EntryForm'] as $id => $attribute) { if (is_array($attribute)) { $entry->{$id} = serialize($attribute); } else { $entry->{$id} = $attribute; } } if ($entry->validate()) { $entryModel = new ContestEntry(); $entryModel->contest_id = $contest->id; $entryModel->ip = $_SERVER['REMOTE_ADDR']; $entryModel->save(); foreach ($contest->fields as $field) { if ($field->type == 'checkbox') { $entry->{$field->id} = unserialize($entry->{$field->id}); } if (is_array($entry->{$field->id})) { foreach ($entry->{$field->id} as $entryValue) { $model = new ContestEntryItem(); $model->contest_entry_id = $entryModel->id; $model->contest_field_id = $field->id; $model->content = $entryValue; $model->save(); } } else { $model = new ContestEntryItem(); $model->contest_entry_id = $entryModel->id; $model->contest_field_id = $field->id; $model->content = $entry->{$field->id}; $model->save(); } } if ($contest->send_notification_email == 1) { $message = $this->renderPartial('_notificationEmail', array('entry' => $entryModel, 'contest' => $contest), true); Helper::sendMail($this->module->notificationEmail, 'Nouvelle participation à "' . CHtml::encode($contest->title) . '"', $message); } $this->redirect(array('detail', 'n' => $n, 'confirmation' => 1)); } foreach ($contest->fields as $field) { if ($field->type == 'checkbox') { $entry->{$field->id} = unserialize($entry->{$field->id}); } } } $this->render('detail', array('contest' => $contest, 'currentDate' => $currentDate, 'entry' => $entry)); } }
function RenderSearchForm($target_url) { global $session, $theme, $search_record; $html = ""; $search_record = (object) array(); $org_code = intval($GLOBALS['org_code']); if ($org_code > 0) { $search_record->org_code = $org_code; } // $session->Log( 'DBG: isset($_POST[submit])=%s isset($_GET[saved_query])=%s', isset($_POST[submit]), isset($_GET['saved_query'] ) ); if (!isset($_POST['submit']) && isset($_GET['saved_query'])) { $qry = new PgQuery("SELECT query_params FROM saved_queries WHERE (user_no = ? OR public ) AND lower(query_name) = lower(?);", $session->user_no, $_GET['saved_query']); if ($qry->Exec('RenderSearchForm') && $qry->rows == 1 && ($row = $qry->Fetch())) { $_POST = unserialize($row->query_params); } } $ef = new EntryForm($REQUEST_URI, $search_record, true); // We do the formatting fairly carefully here... $ef->SimpleForm('<span style="white-space: nowrap"><span class="srchp">%s:</span><span class="srchf">%s</span></span> '); $html .= $ef->StartForm(array("autocomplete" => "off", "onsubmit" => "return CheckSearchForm();")); $html .= "<table border=0 cellspacing=2 cellpadding=0 align=center class=row0 width=100% style=\"border: 1px dashed #aaaaaa;\">\n"; $html .= "<tr><td width=100%><table border=0 cellspacing=0 cellpadding=0 width=100%><tr valign=middle><td width=100%>\n"; if (isset($_GET['search_for']) && !isset($_POST['search_for'])) { $_POST['search_for'] = $_GET['search_for']; } $html .= $ef->DataEntryLine("Find", "%s", "text", "search_for", array("size" => 10, "class" => "srchf", "title" => "Search for free text in the request or notes. Regular expressions are OK too.")); // Organisation drop-down if ($session->AllowedTo("Admin") || $session->AllowedTo("Support") || $session->AllowedTo("Contractor")) { $html .= $ef->DataEntryLine("Organisation", "", "lookup", "org_code", array("_sql" => SqlSelectOrganisations($org_code), "_null" => "-- All Organisations --", "onchange" => "OrganisationChanged();", "title" => "The organisation that this work will be done for.", "class" => "srchf", "style" => "width: 18em")); } // System (within Organisation) drop-down $html .= $ef->DataEntryLine("System", "", "lookup", "system_id", array("_sql" => SqlSelectSystems($org_code), "_null" => "-- All Systems --", "onchange" => "SystemChanged();", "title" => "The business system that this request applies to.", "class" => "srchf", "style" => "width: 18em")); $html .= $ef->DataEntryLine("Requester", "", "lookup", "requested_by", array("_sql" => SqlSelectRequesters($org_code), "_null" => "-- Any Requester --", "onchange" => "PersonChanged();", "title" => "The client who is requesting this, or who is in charge of ensuring it happens.", "class" => "srchf", "style" => "width: 12em")); $html .= $ef->DataEntryLine("Watching", "", "lookup", "interested_in", array("_sql" => SqlSelectSubscribers($org_code), "_null" => "-- Any Interested User --", "title" => "The client who is requesting this, or who is in charge of ensuring it happens.", "class" => "srchf", "style" => "width: 12em")); // Person Assigned to W/R $html .= $ef->DataEntryLine("ToDo", "", "lookup", "allocated_to", array("_sql" => SqlSelectSubscribers($org_code), "_null" => "-- Any Assigned User --", "_nobody" => "-- Not Yet Allocated --", "class" => "srchf", "title" => "A person who has been assigned to work on requests.", "style" => "width: 12em")); // Date range $html .= $ef->DataEntryLine("Last Action", "%s", "date", "from_date", array("size" => 10, "class" => "srchf", "title" => "Only show requests with action after this date.")); $html .= "<a href=\"javascript:show_calendar('forms.form.from_date');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\">" . $theme->Image("date-picker.gif") . "</a> \n"; $html .= $ef->DataEntryLine("To", "%s", "date", "to_date", array("size" => 10, "class" => "srchf", "title" => "Only show requests with action before this date.")); $html .= "<a href=\"javascript:show_calendar('forms.form.to_date');\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\">" . $theme->Image("date-picker.gif") . "</a> \n"; // Type of Request $html .= $ef->DataEntryLine("Type", "%s", "lookup", "type_code", array("_type" => "request|request_type", "_null" => "-- All Types --", "class" => "srchf", "style" => "width: 8em", "title" => "Only show this type of request")); if ($session->AllowedTo("Admin")) { // $html .= "<div id=\"whereclause\">"; $html .= $ef->DataEntryLine("Where", "%s", "text", "where_clause", array("size" => 60, "class" => "srchf", "title" => "Add an SQL 'WHERE' clause to further refine the search - you will need to know what you are doing...")); // $html .= "</div>"; } $html .= "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr>"; $html .= "<td style=\"vertical-align: top; padding-top: 0.3em; white-space:wrap;\"><span class=\"srchp\">Status:</span></td><td valign='top'>\n"; $sql = "SELECT * FROM lookup_code WHERE source_table='request' "; $sql .= " AND source_field='status_code' "; $sql .= " ORDER BY source_table, source_field, lookup_seq, lookup_code "; $qry = new PgQuery($sql); if ($qry->Exec("RenderSearchForm") && $qry->rows > 0) { $i = 0; while ($status = $qry->Fetch()) { $ef->record->incstat[$status->lookup_code] = strpos($GLOBALS['default_search_statuses'], $status->lookup_code) != false ? 1 : ''; if ($i++ > 0) { $html .= " "; } $html .= $ef->DataEntryField("%s", "checkbox", "incstat[{$status->lookup_code}]", array("_label" => $status->lookup_desc, "class" => "srchf", "value" => 1)); // if ( $i++ == round($qry->rows / 2) ) $html .= "<br />"; } $html .= $ef->DataEntryField("%s", "checkbox", "inactive", array("_label" => "inactive", "class" => "srchf", "value" => 1)); $html .= "</td>\n"; } $html .= "</tr></table>\n"; $html .= RenderTagsPanel($ef); $html .= RenderColumnSelections($ef); // style="display: block; float:right; clear: left;" $html .= '<div id="savesearch">'; $html .= $ef->DataEntryLine("Save as", "%s", "text", "savelist", array("size" => 20, "class" => "srchf", "title" => "A name to use to refer to this query in the future.")); $html .= $ef->DataEntryField("%s", "checkbox", "save_query_order", array("_label" => "With Order?", "class" => "srchf", "value" => 1)); $html .= $ef->DataEntryField("%s", "checkbox", "save_public", array("_label" => "Public?", "class" => "srchf", "value" => 1)); $search_record->save_hotlist = 't'; $html .= $ef->DataEntryField("%s", "checkbox", "save_hotlist", array("_label" => "In my menu?", "class" => "srchf", "value" => 1)); $html .= $ef->SubmitButton("submit", "Save Query", array("title" => "Save this query so you can run it again.")); $html .= "</div>"; $html .= $ef->DataEntryLine("Max results", "%s", "text", "maxresults", array("size" => 6, "class" => "srchf", "title" => "The maximum number of rows to show in the listing")); $html .= $ef->SubmitButton("submit", "Run Query", array("title" => "Run a query with these settings")); $html .= "</td></tr></table>\n"; $html .= "</td></tr></table>\n"; $html .= $ef->EndForm(); return $html; }
$sql .= "AND organisation.active "; } $sql .= "AND ( EXISTS(SELECT 1 FROM org_system WHERE organisation.org_code = org_system.org_code AND org_system.system_id = " . qpg($system_id) . ") "; if ($session->AllowedTo("Admin") || $session->AllowedTo("Support")) { $sql .= "OR organisation.org_type = 1 "; /** Primary Support Organisation */ } $sql .= ") "; if (!($session->AllowedTo("Admin") || $session->AllowedTo("Support"))) { $sql .= "AND usr.org_code='{$session->org_code}' "; } $sql .= " ORDER BY (1000 - lookup_seq), LOWER(fullname);"; $q = new PgQuery($sql, $system_id); // echo "<p>$q->querystring</p>"; $search_record = (object) array(); $ef = new EntryForm($REQUEST_URI, $search_record, true); $ef->NoHelp(); // Prefer this style, for the moment echo $ef->StartForm(array("autocomplete" => "off")); if ($q->Exec("SystemUsers::Users") && $q->rows) { // Build table of usrs found echo <<<TABLEHEADINGS <table border="0" cellpadding="2" cellspacing="1" align="center" width="100%"> <tr> <th class="cols">Full Name</th> <th class="cols">Organisation</th> <th class="cols">User Role</th> </tr> TABLEHEADINGS; $line_format = <<<LINEFORMAT <tr class="row%1d" title="%s">
$stlink = "<a href=\"{$href}\">{$href}</a>"; $s .= " " . $stlink . "</p>"; // Covering notes.. if ($approval_covernotes != "") { $s .= "<p><b>The approver also noted:</b><br>"; $s .= $approval_covernotes . "</p>"; } $project->QAMSNotifyEmail("Approval Post Advice", $s, $subject); // Now re-direct them where they can see the project summary.. header("Location: /qams-project.php?request_id={$project->request_id}"); exit; } } // Main content.. $s = ""; $ef = new EntryForm($REQUEST_URI, $project, $have_admin ? 1 : 0); $ef->NoHelp(); $s .= $ef->StartForm(); $s .= $ef->HiddenField("qa_action", "{$qa_action}"); if ($project->request_id > 0) { $s .= $ef->HiddenField("project_id", $project->request_id); $s .= $ef->HiddenField("step_id", "{$qastep->qa_step_id}"); $s .= $ef->HiddenField("ap_type_id", "{$ap_type_id}"); } // Start main table.. $s .= "<table width=\"100%\" class=\"data\" cellspacing=\"0\" cellpadding=\"0\">\n"; $s .= $ef->BreakLine("Quality Assurance Approval"); $s .= "<tr><td height=\"15\" colspan=\"2\"> </td></tr>"; $s .= "<tr><td colspan=\"2\">" . ContentForm($project, $qastep, $ap_type_id) . "</td></tr>"; $s .= "<tr><td height=\"15\" colspan=\"2\"> </td></tr>"; $s .= "</table>\n";