function getForm($form_id) { $form = DynamicForm::lookup($form_id); if (!$form) { return; } foreach ($form->getFields() as $field) { $field->render(); } }
function getForm() { if (!isset($this->form)) { // Look for the entry first if ($this->form = DynamicFormEntry::lookup(array('object_type' => 'C'))) { return $this->form; } elseif (!($this->form = DynamicForm::lookup(array('type' => 'C')))) { $this->__loadDefaultForm(); return $this->getForm(); } // Create an entry to be saved later $this->form = $this->form->instanciate(); $this->form->object_type = 'C'; } return $this->form; }
function getConfigurationForm() { if (!$this->_form) { $this->_form = DynamicForm::lookup(array('type' => 'L' . $this->get('list_id'))); } return $this->_form; }
$errors[$f] = sprintf('%s is required', mb_convert_case($f, MB_CASE_TITLE)); } elseif (isset($_POST[$f])) { $form->set($f, $_POST[$f]); } } break; case 'mass_process': if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { $errors['err'] = sprintf(__('You must select at least %s'), __('one custom form')); } else { $count = count($_POST['ids']); switch (strtolower($_POST['a'])) { case 'delete': $i = 0; foreach ($_POST['ids'] as $k => $v) { if (($t = DynamicForm::lookup($v)) && $t->delete()) { $i++; } } if ($i && $i == $count) { $msg = sprintf(__('Successfully deleted %s'), _N('selected custom form', 'selected custom forms', $count)); } elseif ($i > 0) { $warn = sprintf(__('%1$d of %1$d %3$s deleted'), $i, $count, _N('selected custom form', 'selected custom forms', $count)); } elseif (!$errors['err']) { $errors['err'] = sprintf(__('Unable to delete %s'), _N('selected custom form', 'selected custom forms', $count)); } break; } } break; }
function getForm() { $id = $this->getFormId(); if ($id == self::FORM_USE_PARENT && ($p = $this->getParent())) { $this->form = $p->getForm(); } elseif ($id && !$this->form) { $this->form = DynamicForm::lookup($id); } return $this->form; }
function getForm() { if (!$this->_form && $this->_list) { $this->_form = DynamicForm::lookup(array('type' => 'L' . $this->_list->getId())); } return $this->_form; }
function updateForms($user_id) { global $thisstaff; if (!$thisstaff) { Http::response(403, "Login required"); } elseif (!($user = User::lookup($user_id))) { Http::response(404, "No such customer"); } elseif (!isset($_POST['forms'])) { Http::response(422, "Send updated forms list"); } // Add new forms $forms = DynamicFormEntry::forUser($user_id); foreach ($_POST['forms'] as $sort => $id) { $found = false; foreach ($forms as $e) { if ($e->get('form_id') == $id) { $e->set('sort', $sort); $e->save(); $found = true; break; } } // New form added if (!$found && ($new = DynamicForm::lookup($id))) { $user->addForm($new, $sort); } } // Deleted forms foreach ($forms as $idx => $e) { if (!in_array($e->get('form_id'), $_POST['forms'])) { $e->delete(); } } Http::response(201, 'Successfully managed'); }
function updateForms($ticket_id) { global $thisstaff; if (!$thisstaff) { Http::response(403, "Login required"); } elseif (!($ticket = Ticket::lookup($ticket_id))) { Http::response(404, "No such ticket"); } elseif (!$ticket->checkStaffAccess($thisstaff)) { Http::response(403, "Access Denied"); } elseif (!isset($_POST['forms'])) { Http::response(422, "Send updated forms list"); } // Add new forms $forms = DynamicFormEntry::forTicket($ticket_id); foreach ($_POST['forms'] as $sort => $id) { $found = false; foreach ($forms as $e) { if ($e->get('form_id') == $id) { $e->set('sort', $sort); $e->save(); $found = true; break; } } // New form added if (!$found && ($new = DynamicForm::lookup($id))) { $f = $new->instanciate(); $f->set('sort', $sort); $f->setTicketId($ticket_id); $f->save(); } } // Deleted forms foreach ($forms as $idx => $e) { if (!in_array($e->get('form_id'), $_POST['forms'])) { $e->delete(); } } Http::response(201, 'Successfully managed'); }
function getForm() { if (!isset($this->_form)) { $this->_form = DynamicForm::lookup($this->get('form_id')); if ($this->_form && isset($this->id)) { $this->_form->data($this); } } return $this->_form; }
function getForm() { $form = DynamicForm::lookup($this->get('form_id')); if ($form) { if (isset($this->id)) { $form->data($this); } if ($this->errors()) { $form->addErrors($this->errors(), true); } } return $form; }
public function openNewTicketAction() { $id = $_POST['id']; if (isset($id)) { $item = new \model\Equipment($id); if (isset($item)) { $form_id = $item->getTicketFormId(); $form = \DynamicForm::lookup($form_id); if (isset($form)) { $data_id = $form->getField('asset_id')->getWidget()->name; $_SESSION[':form-data'] = array($data_id => $item->getAsset_id()); header("Location: " . OST_WEB_ROOT . "scp/tickets.php?a=open"); die; } } } }
public static function saveDynamicData($form_id, $id, $data) { if (intval($id) > 0) { $form = \DynamicForm::lookup($form_id); if (isset($form)) { $form_entry = static::getDynamicData($id); $one = $form_entry->one(); if (isset($one)) { $one->getSaved(); } else { $one = $form->instanciate(); $one->set('object_type', 'E'); $one->setObjectId($id); } $one->setSource($data); $one->save(); } } }