/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); // get the form data into an active record Issue $object = $this->form->getData(); // form validation $this->form->validate(); $member = Member::newFromLogin(TSession::getValue('login')); if ($member->password !== md5($object->current_password)) { throw new Exception(_t('Current password does not match')); } if ($object->new_password1 !== $object->new_password2) { throw new Exception(_t('New password does not match the confirm password')); } // stores the object $member->password = md5($object->new_password1); $member->store(); // fill the form with the active record data $this->form->setData($object); // close the transaction TTransaction::close(); // shows the success message new TMessage('info', _t('Password changed successfully')); // reload the listing } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); // get the form data into an active record Note $object = $this->form->getData('Note'); $logged = Member::newFromLogin(TSession::getValue('login')); $object->id_user = $logged->id; $object->register_date = date('Y-m-d'); $object->register_time = date('H:i'); // form validation $this->form->validate(); // stores the object $object->store(); $issue = new Issue($object->id_issue); $project = new Project($issue->id_project); $member = new Member($issue->id_user); // who has opened the issue // read email configuration file $ini = parse_ini_file('app/config/email.ini'); $members = $project->getMembers(array('MEMBER', 'MANAGER')); $members = array_merge($members, array($member)); // merge the logged user $mail_template = file_get_contents('app/resources/note.html'); $mail_template = str_replace('{DESCRIPTION}', $issue->description, $mail_template); $mail_template = str_replace('{OPENER}', $member->name . ' ' . $issue->register_date . ' ' . $issue->issue_time, $mail_template); $mail_template = str_replace('{NOTE}', $object->note, $mail_template); $mail_template = str_replace('{MEMBER}', $logged->name . ' ' . $object->register_date . ' ' . $object->register_time, $mail_template); $mail = new TMail(); $mail->setFrom($ini['from'], $ini['name']); $mail->setSubject(_t('Note') . ' #' . $issue->id . ': ' . $issue->title); $mail->setHtmlBody($mail_template); foreach ($members as $member) { $emails = explode(',', $member->email); foreach ($emails as $email) { $mail->addAddress(trim($email), $member->name); // echo "{$email}, {$member-> name} <br>"; } } $mail->SetUseSmtp(); $mail->SetSmtpHost($ini['host'], $ini['port']); $mail->SetSmtpUser($ini['user'], $ini['pass']); $mail->setReplyTo($ini['repl']); $mail->send(); // fill the form with the active record data $this->form->setData($object); // close the transaction TTransaction::close(); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); // reload the listing } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * 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 !== 'ADMINISTRATOR' and Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'MANAGER') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // creates a table $table = new TTable(); // creates the form $this->form = new TForm('form_Document'); $this->form->add($this->notebook); $this->form->class = 'tform'; $this->form->add($table); $table->addRowSet(new TLabel(_t('Document')), '')->class = 'tformtitle'; // create the form fields $id = new TEntry('id'); $id_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description'); $title = new TEntry('title'); $content = new THtmlEditor('content'); $id->setEditable(FALSE); // define the sizes $id->setSize(100); $id_project->setSize(200); $title->setSize(200, 40); $content->setSize(680, 350); $table->addRowSet(new TLabel('ID:'), $id); $table->addRowSet(new TLabel(_t('Project') . ': '), $id_project); $table->addRowSet(new TLabel(_t('Title') . ': '), $title); $hbox = new THBox(); $hbox->style = 'margin: 10px'; $hbox->add($content); $row = $table->addRow(); $row->addCell($lbl = new TLabel(_t('Content') . ': ')); $lbl->setFontStyle('b'); $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'); // define wich are the form fields $this->form->setFields(array($id, $id_project, $title, $content, $save_button)); $table->addRowSet($save_button, '')->class = 'tformaction'; $container = new TTable(); $container->addRow()->addCell($this->form); // add the form to the page parent::add($container); }
/** * 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 !== 'ADMINISTRATOR') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // defines the database parent::setDatabase('changeman'); // defines the active record parent::setActiveRecord('Category'); // creates the form $this->form = new TQuickForm('form_Category'); $this->form->setFormTitle(_t('Category')); $this->form->class = 'tform'; $this->form->style = 'width: 640px'; // create the form fields $id = new TEntry('id'); $description = new TEntry('description'); // define the sizes $this->form->addQuickField('ID', $id, 100); $this->form->addQuickField(_t('Description') . ': ', $description, 200); $id->setEditable(FALSE); // define the form action $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png'); // creates a DataGrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $this->datagrid->addQuickColumn('ID', 'id', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'id')); $this->datagrid->addQuickColumn(_t('Description'), 'description', 'left', 480, new TAction(array($this, 'onReload')), array('order', 'description')); // add the actions to the datagrid $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png'); $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png'); // create the datagrid model $this->datagrid->createModel(); // creates the page navigation $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // creates the page structure using a vbox $container = new TVBox(); $container->add($this->form); $container->add($this->datagrid); $container->add($this->pageNavigation); // add the container inside the page parent::add($container); }
/** * Class constructor * Creates the page, and the listing */ public 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 !== 'ADMINISTRATOR') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // defines the database parent::setDatabase('changeman'); // defines the active record parent::setActiveRecord('Role'); // defines the filter field parent::setFilterField('description'); // creates a DataGrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $this->datagrid->addQuickColumn('ID', 'id', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'id')); $this->datagrid->addQuickColumn(_t('Description'), 'description', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'description')); $this->datagrid->addQuickColumn(_t('Mnemonic'), 'mnemonic', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'mnemonic')); // create the datagrid model $this->datagrid->createModel(); // creates the page navigation $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // creates the page structure using a table $table = new TTable(); // add a row to the datagrid $row = $table->addRow(); $row->addCell($this->datagrid); // add a row for page navigation $row = $table->addRow(); $row->addCell($this->pageNavigation); // add the table inside the page parent::add($table); }
/** * 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 !== 'ADMINISTRATOR') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // defines the database parent::setDatabase('changeman'); // defines the active record parent::setActiveRecord('Project'); // creates the form $this->form = new TQuickForm('form_Project'); $this->form->class = 'tform'; $this->form->style = 'width:600px'; $this->form->setFormTitle(_t('Projects')); // create the form fields $id = new TEntry('id'); $description = new TEntry('description'); $page = new TEntry('page'); $id->setEditable(FALSE); // define the sizes $this->form->addQuickField('ID:', $id, 100); $this->form->addQuickField(_t('Description') . ':', $description, 200); $this->form->addQuickField(_t('Address') . ':', $page, 200); // define the form action $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); $vbox = new TVBox(); $vbox->add($this->form); // add the form to the page parent::add($vbox); }
/** * method Delete() * Delete a record */ function Delete($param) { try { // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'ADMINISTRATOR') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // get the parameter $key $key = $param['key']; // open a transaction with database 'changeman' TTransaction::open('changeman'); // instantiates object Issue $object = new Issue($key); // deletes the object from the database $object->delete(); // close the transaction TTransaction::close(); // reload the listing $this->onReload(); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record deleted')); } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * Class constructor * Creates the page, the form and the listing */ public 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 !== 'ADMINISTRATOR' and Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'MANAGER') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // defines the database parent::setDatabase('changeman'); // defines the active record parent::setActiveRecord('Member'); // defines the filter field parent::setFilterField('name'); parent::setLimit(50); // creates the form $this->form = new TForm('form_search_Member'); // creates a table $table = new TTable(); $table->width = '100%'; // add the table inside the form $this->form->add($table); $this->form->class = 'tform'; $table->addRowSet(new TLabel(_t('Members')), '')->class = 'tformtitle'; // create the form fields $filter = new TEntry('name'); $filter->setSize(400); $filter->setValue(TSession::getValue('Member_name')); // add a row for the filter field $row = $table->addRow(); $row->addCell(new TLabel(_t('Name') . ': ')); $row->addCell($filter); // create two action buttons to the form $find_button = new TButton('find'); $new_button = new TButton('new'); // define the button actions $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find')); $find_button->setImage('ico_find.png'); $class = 'MemberForm'; $new_button->setAction(new TAction(array($class, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); $buttons = new THBox(); $buttons->add($find_button); $buttons->add($new_button); $row = $table->addRow(); $row->class = 'tformaction'; $cell = $row->addCell($buttons); $cell->colspan = 2; // define wich are the form fields $this->form->setFields(array($filter, $find_button, $new_button)); // creates a DataGrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $this->datagrid->addQuickColumn('ID', 'id', 'right', 50, new TAction(array($this, 'onReload')), array('order', 'id')); $this->datagrid->addQuickColumn(_t('Name'), 'name', 'left', 160, new TAction(array($this, 'onReload')), array('order', 'name')); $this->datagrid->addQuickColumn(_t('Role'), 'role_description', 'left', 140, new TAction(array($this, 'onReload')), array('order', 'id_role')); $this->datagrid->addQuickColumn('Login', 'login', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'login')); $this->datagrid->addQuickColumn('Email', 'email', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'email')); $this->datagrid->addQuickColumn(_t('Active'), 'is_active', 'left', 70, new TAction(array($this, 'onReload')), array('order', 'active')); // add the actions to the datagrid $class = 'MemberForm'; $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($class, 'onEdit')), 'id', 'ico_edit.png'); $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png'); // create the datagrid model $this->datagrid->createModel(); // creates the page navigation $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // creates the page structure using a vbox $container = new TVBox(); $container->add($this->form); $container->add($this->datagrid); $container->add($this->pageNavigation); // add the vbox inside the page parent::add($container); }
/** * method onReload() * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); $member = Member::newFromLogin(TSession::getValue('login')); // creates a repository for Release $repository = new TRepository('Release'); $limit = 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('Release_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('Release_filter')); } // customer may only view its projects if ($member->role_mnemonic == 'CUSTOMER') { $member_projects_ids = array_keys($member->getProjectsList()); $criteria->add(new TFilter('id_project', 'IN', $member_projects_ids)); } // load the objects according to criteria $objects = $repository->load($criteria); $this->datagrid->clear(); if ($objects) { // iterate the collection of active records foreach ($objects as $object) { // add the object inside the datagrid $this->datagrid->addItem($object); } } // reset the criteria for record count $criteria->resetProperties(); $count = $repository->count($criteria); $this->pageNavigation->setCount($count); // count of records $this->pageNavigation->setProperties($param); // order, page $this->pageNavigation->setLimit($limit); // limit // close the transaction TTransaction::close(); $this->loaded = true; } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
<?php require_once 'init.php'; $template = 'theme1'; $uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; new TSession(); $lang = TSession::getValue('language') ? TSession::getValue('language') : 'en'; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); if (TSession::getValue('logged')) { TTransaction::open('changeman'); $member = Member::newFromLogin(TSession::getValue('login')); if ($member->role_mnemonic == 'CUSTOMER') { $content = file_get_contents("app/templates/{$template}/customer.html"); } else { if ($member->role_mnemonic == 'MEMBER') { $content = file_get_contents("app/templates/{$template}/member.html"); } else { if ($member->role_mnemonic == 'MANAGER') { $content = file_get_contents("app/templates/{$template}/manager.html"); } else { if ($member->role_mnemonic == 'ADMINISTRATOR') { $content = file_get_contents("app/templates/{$template}/admin.html"); } } } } TTransaction::close(); } else { $content = file_get_contents("app/templates/{$template}/login.html"); }
/** * 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 !== 'ADMINISTRATOR' and Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'MANAGER') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // creates a table $table = new TTable(); $table1 = new TTable(); $table2 = new TTable(); // creates the form $this->form = new TForm('form_Member'); $this->form->class = 'tform'; $this->form->style = 'width: 640px'; $this->form->add($table); $table->width = '100%'; $table->addRowSet(new TLabel(_t('Members')), '')->class = 'tformtitle'; $row = $table->addRow(); $row->addCell($table1); $cell = $row->addCell($table2); $cell->valign = 'top'; $options = array('Y' => _t('Yes'), 'N' => _t('No')); // create the form fields $id = new TEntry('id'); $name = new TEntry('name'); $id_role = new TDBCombo('id_role', 'changeman', 'Role', 'id', 'description'); $login = new TEntry('login'); $password = new TPassword('password'); $email = new TEntry('email'); $active = new TCombo('active'); $projects = new TDBCheckGroup('project_ids', 'changeman', 'Project', 'id', 'description'); $id->setEditable(FALSE); $active->addItems($options); // define the sizes $id->setSize(100); $name->setSize(200, 40); $id_role->setSize(160); $login->setSize(200, 40); $password->setSize(200, 40); $email->setSize(200, 40); $active->setSize(200); // add a row for the field id $row = $table1->addRow(); $cell = $row->addCell(new TLabel('ID:')); $cell->width = '100px'; $row->addCell($id); // add a row for the field name $row = $table1->addRow(); $row->addCell(new TLabel(_t('Name') . ': ')); $row->addCell($name); // add a row for the field id_role $row = $table1->addRow(); $row->addCell(new TLabel(_t('Role') . ': ')); $row->addCell($id_role); // add a row for the field login $row = $table1->addRow(); $row->addCell(new TLabel('Login:'******'Password') . ': ')); $row->addCell($password); // add a row for the field email $row = $table1->addRow(); $row->addCell(new TLabel('Email:')); $row->addCell($email); // add a row for the field active $row = $table1->addRow(); $row->addCell(new TLabel(_t('Active') . ': ')); $row->addCell($active); // add a row for the field projects $row = $table2->addRow(); $cell = $row->addCell($lbl_pro = new TLabel(_t('Projects') . ': ')); $row = $table2->addRow(); $row->addCell($projects); $lbl_pro->setFontStyle('b'); // create an action button (save) $save_button = new TButton('save'); $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save')); $save_button->setImage('ico_save.png'); $row = $table->addRow(); $row->class = 'tformaction'; $row->addCell($save_button)->colspan = 2; // define wich are the form fields $this->form->setFields(array($id, $name, $id_role, $login, $password, $email, $active, $projects, $save_button)); $container = new TVBox(); $container->add($this->form); parent::add($container); }
/** * 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 !== 'ADMINISTRATOR' and Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'MANAGER') { throw new Exception(_t('Permission denied')); } TTransaction::close(); // creates a table $table = new TTable(); // creates the form $this->form = new TForm('form_Release'); $this->form->class = 'tform'; $this->form->style = 'width: 640px'; $this->form->add($table); $table->width = '100%'; $table->addRowSet(new TLabel(_t('Release')), '')->class = 'tformtitle'; $options = array('Y' => _t('Yes'), 'N' => _t('No')); // create the form fields $id = new TEntry('id'); $id_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description'); $name = new TEntry('name'); $sendmail = new TRadioGroup('sendmail'); $description = new THtmlEditor('description'); $id_project->addValidation(_t('Project'), new TRequiredValidator()); $name->addValidation(_t('Name'), new TRequiredValidator()); $id->setEditable(FALSE); // define the sizes $id->setSize(100); $id_project->setSize(200); $name->setSize(200, 40); $description->setSize(530, 200); $sendmail->addItems($options); $sendmail->setLayout('horizontal'); $sendmail->setValue('N'); $table->addRowSet(new TLabel('ID:'), $id); $table->addRowSet(new TLabel(_t('Project') . ': '), $id_project); $table->addRowSet(new TLabel(_t('Name') . ': '), $name); $table->addRowSet(new TLabel(_t('Send e-mail') . ': '), $sendmail); $hbox = new THBox(); $hbox->style = 'margin: 10px'; $hbox->add($description); // add a row for the field description $row = $table->addRow(); $row->addCell($lbl = new TLabel(_t('Description') . ': ')); $lbl->setFontStyle('b'); $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_project, $name, $description, $sendmail, $save_button)); // add the form to the page parent::add($this->form); }
/** * method onEdit() * Executed whenever the user clicks at the edit button da datagrid */ function onEdit($param) { try { // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'CUSTOMER') { throw new Exception(_t('Permission denied')); } TTransaction::close(); if (isset($param['key'])) { // get the parameter $key $key = $param['key']; // open a transaction with database 'changeman' TTransaction::open('changeman'); // instantiates object Issue $object = new Issue($key); // fill the form with the active record data $this->form->setData($object); // close the transaction TTransaction::close(); } else { $this->form->clear(); } } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); // get the form data into an active record Issue $object = $this->form->getData('Issue'); $member = Member::newFromLogin(TSession::getValue('login')); // standard values $object->id_user = $member->id; $object->id_status = 1; // NEW // form validation $this->form->validate(); // stores the object $object->store(); // have attachments if ($object->file) { $target_folder = 'attach/' . $object->id; $target_file = $target_folder . '/' . $object->file; @mkdir($target_folder); rename('tmp/' . $object->file, $target_file); } $project = new Project($object->id_project); // read email configuration file $ini = parse_ini_file('app/config/email.ini'); $members = $project->getMembers(array('MEMBER', 'MANAGER')); $members = array_merge($members, array($member)); // merge the logged user $mail_template = file_get_contents('app/resources/ticket_open.html'); $mail_template = str_replace('{DESCRIPTION}', $object->description, $mail_template); $mail_template = str_replace('{OPENER}', $member->name . ' ' . $object->register_date . ' ' . $object->issue_time, $mail_template); $mail = new TMail(); $mail->setFrom($ini['from'], $ini['name']); $mail->setSubject(_t('Issue') . ' #' . $object->id . ': ' . $object->title . ' (' . $object->status . ')'); $mail->setHtmlBody($mail_template); foreach ($members as $member) { $emails = explode(',', $member->email); foreach ($emails as $email) { $mail->addAddress(trim($email), $member->name); // echo "{$email}, {$member-> name} <br>"; } } if (isset($target_file)) { $mail->addAttach($target_file); } $mail->SetUseSmtp(); $mail->SetSmtpHost($ini['host'], $ini['port']); $mail->SetSmtpUser($ini['user'], $ini['pass']); $mail->setReplyTo($ini['repl']); $mail->send(); // fill the form with the active record data $this->form->setData($object); // close the transaction TTransaction::close(); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); // reload the listing } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage() . '<br>' . _t('Try again')); // undo all pending operations TTransaction::rollback(); } }