/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // security check if (TSession::getValue('logged') !== TRUE) { throw new Exception(_t('Not logged')); } // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'CUSTOMER') { throw new Exception(_t('Permission denied')); } TTransaction::close(); $table = new TTable(); // creates the form $this->form = new TForm('form_Issue'); $this->form->add($table); $table->width = '100%'; $this->form->style = 'width: 750px'; $this->form->class = 'tform'; $table->addRowSet(new TLabel(_t('Issue')), '')->class = 'tformtitle'; $table1 = new TTable(); $table2 = new TTable(); // create the form fields $id = new TEntry('id'); $id_user = new TDBCombo('id_user', 'changeman', 'Member', 'id', 'name'); $id_status = new TDBCombo('id_status', 'changeman', 'Status', 'id', 'complete_description'); $id_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description'); $id_priority = new TDBCombo('id_priority', 'changeman', 'Priority', 'id', 'description_translated'); $id_category = new TDBCombo('id_category', 'changeman', 'Category', 'id', 'description_translated'); $id_release = new TDBCombo('id_release', 'changeman', 'Release', 'id', 'name'); $id_member = new TDBCombo('id_member', 'changeman', 'Member', 'id', 'name'); $register_date = new TDate('register_date'); $close_date = new TDate('close_date'); $time = new TEntry('issue_time'); $title = new TEntry('title'); $description = new THtmlEditor('description'); $solution = new THtmlEditor('solution'); $id_user->addValidation(_t('User'), new TRequiredValidator()); $id_status->addValidation(_t('Status'), new TRequiredValidator()); $id_project->addValidation(_t('Project'), new TRequiredValidator()); $id_priority->addValidation(_t('Priority'), new TRequiredValidator()); $id_category->addValidation(_t('Category'), new TRequiredValidator()); $register_date->addValidation(_t('Start date'), new TRequiredValidator()); $title->addValidation(_t('Title'), new TRequiredValidator()); $description->addValidation(_t('Description'), new TRequiredValidator()); // define the sizes $id->setSize(100); $id_user->setSize(200); $id_status->setSize(200); $id_project->setSize(200); $id_priority->setSize(200); $id_category->setSize(200); $id_release->setSize(200); $id_member->setSize(200); $register_date->setSize(100); $close_date->setSize(100); $time->setSize(200); $title->setSize(200, 40); $description->setSize(680, 300); $solution->setSize(680, 300); $register_date->setMask('yyyy-mm-dd'); $close_date->setMask('yyyy-mm-dd'); $id->setEditable(FALSE); // add a row for the field id $table1->addRowSet(new TLabel('ID:'), $id); $table1->addRowSet(new TLabel(_t('User') . ': '), $id_user); $table1->addRowSet(new TLabel(_t('Status') . ': '), $id_status); $table1->addRowSet(new TLabel(_t('Project') . ': '), $id_project); $table1->addRowSet(new TLabel(_t('Priority') . ': '), $id_priority); $table1->addRowSet(new TLabel(_t('Category') . ': '), $id_category); $table2->addRowSet(new TLabel(_t('Release') . ': '), $id_release); $table2->addRowSet(new TLabel(_t('Assigned to')), $id_member); $table2->addRowSet(new TLabel(_t('Start date') . ':'), $register_date); $table2->addRowSet(new TLabel(_t('Due date') . ':'), $close_date); $table2->addRowSet(new TLabel(_t('Time') . ':'), $time); $table2->addRowSet(new TLabel(_t('Title') . ':'), $title); $row = $table->addRow(); $row->addCell($table1); $row->addCell($table2); $subnotebook = new TNotebook(); $subnotebook->setSize(710, 320); $subnotebook->style = 'padding: 50px'; $subnotebook->appendPage(_t('Description'), $description); $subnotebook->appendPage(_t('Solution'), $solution); $hbox = new THBox(); $hbox->add($subnotebook); $hbox->style = 'margin: 10px'; $row = $table->addRow(); $cell = $row->addCell($hbox); $cell->colspan = 3; // create an action button (save) $save_button = new TButton('save'); // define the button action $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save')); $save_button->setImage('ico_save.png'); $table->addRowSet($save_button, '')->class = 'tformaction'; // define wich are the form fields $this->form->setFields(array($id, $id_user, $id_status, $id_project, $id_priority, $id_category, $id_release, $id_member, $register_date, $close_date, $time, $title, $description, $solution, $save_button)); // add the form to the page parent::add($this->form); }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // security check if (TSession::getValue('logged') !== TRUE) { throw new Exception(_t('Not logged')); } // creates a table $table = new TTable(); $table1 = new TTable(); $table2 = new TTable(); // creates the form $this->form = new TForm('form_Issue'); $this->form->class = 'tform'; $this->form->style = 'width: 750px'; $table->width = '100%'; $this->form->add($table); $table->addRowSet(new TLabel(_t('Issue')), '')->class = 'tformtitle'; // add the table inside the form $this->form->add($table); // create the form fields $id_project = new TCombo('id_project'); $id_priority = new TDBCombo('id_priority', 'changeman', 'Priority', 'id', 'description_translated'); $id_category = new TDBCombo('id_category', 'changeman', 'Category', 'id', 'description_translated'); $register_date = new TDate('register_date'); $time = new TEntry('issue_time'); $title = new TEntry('title'); $description = new THtmlEditor('description'); $file = new TFile('file'); $register_date->setValue(date('Y-m-d')); $register_date->setMask('yyyy-mm-dd'); $time->setValue(date('H:i')); $id_priority->setValue(2); // default $description->style = 'margin: 10px'; TTransaction::open('changeman'); $member = Member::newFromLogin(TSession::getValue('login')); $member_projects = $member->getProjectsList(); $id_project->addItems($member_projects); // if just one project, its the default if (count($member_projects) == 1) { $project_keys = array_keys($member_projects); $id_project->setValue($project_keys[0]); } TTransaction::close(); $id_project->addValidation(_t('Project'), new TRequiredValidator()); $id_priority->addValidation(_t('Priority'), new TRequiredValidator()); $id_category->addValidation(_t('Category'), new TRequiredValidator()); $register_date->addValidation(_t('Start date'), new TRequiredValidator()); $title->addValidation(_t('Title'), new TRequiredValidator()); $description->addValidation(_t('Description'), new TRequiredValidator()); // define the sizes $id_project->setSize(200); $id_priority->setSize(200); $id_category->setSize(200); $register_date->setSize(100); $file->setSize(250); $time->setSize(50); $time->setMask('99:99'); $title->setSize(200, 40); $description->setSize(680, 300); $table1->addRowSet(new TLabel(_t('Project') . ': '), $id_project); $table1->addRowSet(new TLabel(_t('Priority') . ': '), $id_priority); $table1->addRowSet(new TLabel(_t('Category') . ': '), $id_category); $table2->addRowSet(new TLabel(_t('Start date') . ':'), array($register_date, $time)); $table2->addRowSet(new TLabel(_t('Title') . ':'), $title); $table2->addRowSet(new TLabel(_t('File') . ':'), $file); $row = $table->addRow(); $row->addCell($table1); $row->addCell($table2); $label_description = new TLabel(_t('Description')); $label_description->setFontStyle('b'); $row = $table->addRow(); $row->addCell($label_description); $row = $table->addRow(); $cell = $row->addCell($description); $cell->colspan = 3; // create an action button (save) $save_button = new TButton('save'); // define the button action $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save')); $save_button->setImage('ico_save.png'); $table->addRowSet($save_button, '')->class = 'tformaction'; // define wich are the form fields $this->form->setFields(array($id_project, $id_priority, $id_category, $register_date, $time, $title, $file, $description, $save_button)); // add the form to the page parent::add($this->form); }