/** * Class Constructor * @param $title_msg Dialog Title * @param $form Dialog form body * @param $action Action to be processed when closing the dialog * @param $caption Button caption */ public function __construct($title_msg, TForm $form, TAction $action = NULL, $caption = '') { $this->id = uniqid(); $modal_wrapper = new TElement('div'); $modal_wrapper->{'class'} = 'modal'; $modal_wrapper->{'id'} = $this->id; $modal_wrapper->{'style'} = 'padding-top: 10%; z-index:4000'; $modal_wrapper->{'tabindex'} = '-1'; $modal_dialog = new TElement('div'); $modal_dialog->{'class'} = 'modal-dialog'; $modal_content = new TElement('div'); $modal_content->{'class'} = 'modal-content'; $modal_header = new TElement('div'); $modal_header->{'class'} = 'modal-header'; $close = new TElement('button'); $close->{'type'} = 'button'; $close->{'class'} = 'close'; $close->{'data-dismiss'} = 'modal'; $close->{'aria-hidden'} = 'true'; $close->add('×'); $title = new TElement('h4'); $title->{'class'} = 'modal-title'; $title->{'style'} = 'display:inline'; $title->add($title_msg ? $title_msg : AdiantiCoreTranslator::translate('Input')); $form_name = $form->getName(); $wait_message = AdiantiCoreTranslator::translate('Loading'); if ($form instanceof TQuickForm) { $form->delActions(); $actionButtons = $form->getActionButtons(); if ($actionButtons) { foreach ($actionButtons as $key => $button) { $button->{'data-toggle'} = "modal"; $button->{'data-dismiss'} = 'modal'; $button->addFunction("\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');"); $buttons[] = $button; } } } else { $button = new TButton(strtolower(str_replace(' ', '_', $caption))); $button->{'data-toggle'} = "modal"; $button->{'data-dismiss'} = 'modal'; $button->addFunction("\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');"); $button->setAction($action); $button->setLabel($caption); $buttons[] = $button; $form->addField($button); } $footer = new TElement('div'); $footer->{'class'} = 'modal-footer'; $modal_wrapper->add($modal_dialog); $modal_dialog->add($modal_content); $modal_content->add($modal_header); $modal_header->add($close); $modal_header->add($title); $modal_content->add($form); $modal_content->add($footer); if (isset($buttons) and $buttons) { foreach ($buttons as $button) { $footer->add($button); } } $modal_wrapper->show(); TScript::create("tdialog_start( '#{$this->id}' );"); }
/** * Show the widget at the screen */ public function show() { // define the tag properties $this->tag->name = $this->name; // tag name $this->tag->value = $this->value; // tag value $this->tag->type = 'password'; // input type if (strstr($this->size, '%') !== FALSE) { $this->setProperty('style', "width:{$this->size};", FALSE); //aggregate style info } else { $this->setProperty('style', "width:{$this->size}px;", FALSE); //aggregate style info } // verify if the field is not editable if (parent::getEditable()) { if (isset($this->exitAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->exitAction->serialize(FALSE); $this->setProperty('onBlur', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)"); } } else { // make the field read-only $this->tag->readonly = "1"; $this->tag->{'class'} = 'tfield_disabled'; // CSS } // show the tag $this->tag->show(); }
/** * Class Constructor * @param $caption Button caption * @param $form Dialog form body * @param $action Action to be processed when closing the dialog * @param $title_msg Dialog Title */ public function __construct($title_msg, TForm $form, TAction $action = NULL, $caption = '') { parent::__construct('', NULL, Gtk::DIALOG_MODAL); parent::set_position(Gtk::WIN_POS_CENTER); parent::set_title($title_msg ? $title_msg : AdiantiCoreTranslator::translate('Input')); $actions = array(); $action_counter = 0; if ($form instanceof TQuickForm) { $form->delActions(); $actionButtons = $form->getActionButtons(); foreach ($actionButtons as $key => $button) { parent::add_button($button->getLabel(), $action_counter); $actions[] = $button->getAction(); $action_counter++; } } else { parent::add_button($caption, $action_counter); $actions[] = $action; } $this->vbox->pack_start($form); $form->show(); $this->show_all(); parent::connect('key_press_event', array($this, 'onClose')); $result = parent::run(); foreach ($actions as $actionIndex => $buttonAction) { if ($result == $actionIndex) { if ($buttonAction) { $parameters = $buttonAction->getParameters(); $data = $form->getData(); foreach ($data as $key => $value) { $parameters[$key] = $value; } parent::destroy(); call_user_func_array($buttonAction->getAction(), array($parameters)); return; } } } parent::destroy(); }
/** * Show the widget at the screen */ public function show() { // define the tag properties $this->tag->id = $this->id; $this->tag->name = 'file_' . $this->name . '[]'; // tag name $this->tag->receiver = $this->name; // tag name $this->tag->value = $this->value; // tag value $this->tag->type = 'file'; // input type $this->tag->style = "width:{$this->size}px;height:{$this->height}px"; // size $this->tag->multiple = '1'; $complete_action = "'undefined'"; // verify if the widget is editable if (parent::getEditable()) { if (isset($this->completeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->completeAction->serialize(FALSE); $complete_action = "function() { __adianti_post_lookup('{$this->formName}', '{$string_action}', this); }"; } } else { // make the field read-only $this->tag->readonly = "1"; $this->tag->type = 'text'; $this->tag->{'class'} = 'tfield_disabled'; // CSS } $id_div = mt_rand(1000000000, 1999999999); $div = new TElement('div'); $div->style = "width:{$this->size}px;"; $div->id = 'div_file_' . $id_div; $divParciais = new TElement('div'); $divParciais->style = 'width:100%;'; $divParciais->id = 'div_parciais_' . $id_div; foreach ((array) $this->value as $val) { $hdFileName = new THidden($this->name . '[]'); $hdFileName->setValue($val); $div->add($hdFileName); } $div->add($this->tag); $div->add($divParciais); $div->show(); $action = "engine.php?class={$this->uploaderClass}"; TScript::create(" tmultifile_start( '{$this->tag->id}', '{$action}', '{$divParciais->id}', {$complete_action});"); }
/** * Show the widget */ public function show() { // check if it's not editable if (parent::getEditable()) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $serialized_action = ''; if ($this->action) { // get the action class name if (is_array($callback = $this->action->getAction())) { if (is_object($callback[0])) { $rc = new ReflectionClass($callback[0]); $classname = $rc->getShortName(); } else { $classname = $callback[0]; } $inst = new $classname(); $ajaxAction = new TAction(array($inst, 'onSelect')); if (in_array($classname, array('TStandardSeek2'))) { $ajaxAction->setParameter('parent', $this->action->getParameter('parent')); $ajaxAction->setParameter('database', $this->action->getParameter('database')); $ajaxAction->setParameter('model', $this->action->getParameter('model')); $ajaxAction->setParameter('display_field', $this->action->getParameter('display_field')); $ajaxAction->setParameter('receive_key', $this->action->getParameter('receive_key')); $ajaxAction->setParameter('receive_field', $this->action->getParameter('receive_field')); $ajaxAction->setParameter('criteria', $this->action->getParameter('criteria')); $ajaxAction->setParameter('display_field2', $this->action->getParameter('display_field2')); } else { if ($actionParameters = $this->action->getParameters()) { foreach ($actionParameters as $key => $value) { $ajaxAction->setParameter($key, $value); } } } $ajaxAction->setParameter('form_name', $this->formName); $string_action = $ajaxAction->serialize(FALSE); if ($this->useOutEvent) { $this->setProperty('seekaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', document.{$this->formName}.{$this->name})"); $this->setProperty('onBlur', $this->getProperty('seekaction'), FALSE); } } $this->action->setParameter('form_name', $this->formName); $serialized_action = $this->action->serialize(FALSE); } parent::show(); $this->button->onclick = "javascript:serialform=(\$('#{$this->formName}').serialize());\n __adianti_append_page('engine.php?{$serialized_action}&'+serialform)"; $this->button->show(); if ($this->auxiliar) { echo ' '; $this->auxiliar->show(); } } else { parent::show(); } }
/** * Show the widget at the screen */ public function show() { if ($this->items) { // iterate the RadioButton options $i = 0; foreach ($this->items as $index => $label) { $button = $this->buttons[$index]; $button->setName($this->name); // check if contains any value if ($this->value == $index) { // mark as checked $button->setProperty('checked', '1'); } // create the label for the button $obj = $this->labels[$index]; $obj->{'class'} = 'tcheckgroup_label'; if ($this->getSize() and isset($this->breakItems)) { $obj->setSize($this->getSize()); } // check whether the widget is non-editable if (parent::getEditable()) { if (isset($this->changeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->changeAction->serialize(FALSE); $button->setProperty('onChange', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)"); } } else { $button->setEditable(FALSE); $obj->setFontColor('gray'); } $obj->add($button); $obj->show(); $i++; if ($this->layout == 'vertical' or $this->breakItems == $i) { // shows a line break $br = new TElement('br'); $br->show(); $i = 0; } echo "\n"; } } }
/** * Shows the widget */ public function show() { // define the tag properties $this->tag->name = $this->name; // tag name $this->tag->id = $this->id; // tag name $this->setProperty('style', "width:{$this->size}px", FALSE); //aggregate style info $multiple = $this->maxSize == 1 ? 'false' : 'true'; $load_items = 'undefined'; if ($this->initialItems) { $new_items = array(); foreach ($this->initialItems as $key => $item) { $new_item = array('id' => $key, 'text' => $item); $new_items[] = $new_item; } if ($multiple == 'true') { $load_items = json_encode($new_items); } else { $load_items = json_encode($new_item); } } $preitems_json = 'undefined'; if ($this->items) { $preitems = array(); foreach ($this->items as $key => $item) { $new_item = array('id' => $key, 'text' => $item); $preitems[] = $new_item; } $preitems_json = json_encode($preitems); } $search_word = AdiantiCoreTranslator::translate('Search'); if ($this->editable) { $this->tag->show(); $change_action = 'function() {}'; if (isset($this->changeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->changeAction->serialize(FALSE); $change_action = "function() { serialform=tmultisearch_get_form_data('{$this->formName}', '{$this->name}');\n __adianti_ajax_lookup('{$string_action}&'+serialform, this); }"; } TScript::create(" tmultisearch_start( '{$this->id}', '{$this->minLength}', '{$this->maxSize}', '{$search_word}', {$multiple}, {$preitems_json}, '{$this->size}px', '{$this->height}px', {$load_items}, {$change_action} ); "); } else { $this->tag->{'readonly'} = "1"; $this->tag->{'class'} = 'tfield_disabled'; // CSS $this->tag->{'onmouseover'} = "style.cursor='default'"; $this->tag->{'type'} = 'text'; $this->tag->{'value'} = $this->encodeData($this->value); $this->tag->show(); } }
/** * Shows the widget at the screen */ public function show() { // define the tag properties $this->tag->name = $this->name; // TAG name $this->tag->value = $this->value; // TAG value $this->tag->type = 'text'; // input type //$this->setProperty('style', "width:{$this->size}px", FALSE); //aggregate style info if (is_string($this->size)) { $this->setProperty('style', "width:{$this->size}", FALSE); } else { $this->setProperty('style', "width:{$this->size}px", FALSE); } //aggregate style info if ($this->id) { $this->tag->{'id'} = $this->id; } // verify if the widget is non-editable if (parent::getEditable()) { if (isset($this->exitAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->exitAction->serialize(FALSE); $this->setProperty('exitaction', "serialform=(\$('#{$this->formName}').serialize());\n __adianti_ajax_lookup('{$string_action}&'+serialform, document.{$this->formName}.{$this->name})", FALSE); $this->setProperty('onBlur', $this->getProperty('exitaction'), FALSE); } if ($this->mask) { $this->tag->onKeyPress = "return tentry_mask(this,event,'{$this->mask}')"; } } else { $this->tag->readonly = "1"; $this->tag->{'class'} = 'tfield_disabled'; // CSS $this->tag->onmouseover = "style.cursor='default'"; } // shows the tag $this->tag->show(); if (isset($this->completion)) { $options = json_encode($this->completion); TScript::create(" tentry_autocomplete( '{$this->name}', {$options}); "); } if ($this->numericMask) { TScript::create("tentry_numeric_mask( '{$this->name}', {$this->decimals}, '{$this->decimalsSeparator}', '{$this->thousandSeparator}'); "); } }
/** * Shows the widget at the screen */ public function show() { // define the tag properties $this->tag->name = $this->name; // TAG name $this->tag->value = $this->value; // TAG value $this->tag->type = 'text'; // input type $this->tag->style = "width:{$this->size}px"; // size if ($this->id) { $this->tag->{'id'} = $this->id; } // verify if the widget is non-editable if (parent::getEditable()) { $exit_action = 'function() {}'; if (isset($this->exitAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->exitAction->serialize(FALSE); $exit_action = "function() { __adianti_post_lookup('{$this->formName}', '{$string_action}', document.{$this->formName}.{$this->name}) }"; } TScript::create(" tspinner_start( '#{$this->id}', '{$this->value}', '{$this->min}', '{$this->max}', '{$this->step}', {$exit_action}); "); } else { $this->tag->readonly = "1"; $this->tag->{'class'} = 'tfield_disabled'; // CSS $this->tag->style = "width:{$this->size}px;" . "-moz-user-select:none;"; $this->tag->onmouseover = "style.cursor='default'"; } // shows the tag $this->tag->show(); }
/** * Show the widget */ public function show() { $this->tag->name = $this->name; // tag name if ($this->size) { $this->setProperty('style', "width:{$this->size}px; resize:none", FALSE); //aggregate style info } if ($this->height) { $this->setProperty('style', "height:{$this->height}px; resize:none", FALSE); //aggregate style info } // check if the field is not editable if (!parent::getEditable()) { // make the widget read-only $this->tag->readonly = "1"; $this->tag->{'class'} = 'tfield_disabled'; // CSS } if (isset($this->exitAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->exitAction->serialize(FALSE); $this->setProperty('onBlur', "serialform=(\$('#{$this->formName}').serialize());\n __adianti_ajax_lookup('{$string_action}&'+serialform, this)"); } // add the content to the textarea $this->tag->add(htmlspecialchars($this->value)); // show the tag $this->tag->show(); }
/** * Select the register by ID and return the information to the main form * When using onblur signal, AJAX passes all needed parameters via GET * instead of calling onSetup before. */ public static function onSelect($param) { $key = $param['key']; $database = isset($param['database']) ? $param['database'] : TSession::getValue('standard_seek_database'); $receive_key = isset($param['receive_key']) ? $param['receive_key'] : TSession::getValue('standard_seek_receive_key'); $receive_field = isset($param['receive_field']) ? $param['receive_field'] : TSession::getValue('standard_seek_receive_field'); $display_field = isset($param['display_field']) ? $param['display_field'] : TSession::getValue('standard_seek_display_field'); $parent = isset($param['parent']) ? $param['parent'] : TSession::getValue('standard_seek_parent'); try { TTransaction::open($database); // load the active record $model = isset($param['model']) ? $param['model'] : TSession::getValue('standard_seek_model'); $activeRecord = new $model($key); $pk = constant("{$model}::PRIMARYKEY"); $object = new StdClass(); $object->{$receive_key} = isset($activeRecord->{$pk}) ? $activeRecord->{$pk} : ''; $object->{$receive_field} = isset($activeRecord->{$display_field}) ? $activeRecord->{$display_field} : ''; TTransaction::close(); TForm::sendData($parent, $object); parent::closeWindow(); // closes the window } catch (Exception $e) { // clear fields $object = new StdClass(); $object->{$receive_key} = ''; $object->{$receive_field} = ''; TForm::sendData($parent, $object); // undo all pending operations TTransaction::rollback(); } }
public function onEdit($param) { if (isset($param) && isset($param['key'])) { $key = $param['key']; } if (!isset($key)) { $form_requisicao = new stdClass(); $form_requisicao->numeroSRP = ''; $form_requisicao->numeroProcessoOrigem = ''; $form_requisicao->numeroProcesso = ''; $form_requisicao->validade = ''; $form_requisicao->nome = ''; $form_requisicao->uasg = ''; $form_requisicao->emissao = date('d/m/Y'); TSession::delValue('requisicao_itens'); TSession::delValue('requisicao_itens_o'); TSession::delValue('form_requisicao'); TSession::delValue('SRP_id'); TForm::sendData('form_requisicao', $form_requisicao); $this->onReload(); return; } try { TTransaction::open('saciq'); $requisicao = new Requisicao($key); $form_requisicao = new stdClass(); $form_requisicao->id = $key; $form_requisicao->numeroSRP = $requisicao->srp->numeroSRP; $form_requisicao->numeroProcessoOrigem = $requisicao->srp->numeroProcesso; $form_requisicao->numeroProcesso = $requisicao->numeroProcesso; $form_requisicao->validade = TDate::date2br($requisicao->srp->validade); $form_requisicao->nome = $requisicao->srp->nome; $form_requisicao->uasg = $requisicao->srp->uasg; $form_requisicao->emissao = TDate::date2br($requisicao->emissao); TSession::delValue('requisicao_itens'); TSession::delValue('requisicao_itens_o'); TSession::setValue('SRP_id', $requisicao->srp->id); TSeekButton::disableField('form_requisicao', 'numeroSRP'); foreach ($requisicao->getItems() as $item_requisicao) { $item = new stdClass(); $item->item_id = $item_requisicao->id; $item->numeroItem = $item_requisicao->numeroItem; $item->descricaoSumaria = $item_requisicao->descricaoSumaria; $item->quantidade = $item_requisicao->quantidade; $item->valorUnitario = $item_requisicao->valorUnitario; $item->justificativa = $item_requisicao->justificativa; $item->prazoEntrega = $item_requisicao->prazoEntrega; $item->total = $item_requisicao->total; $itens[$item->numeroItem] = $item; } TSession::setValue('requisicao_itens', $itens); TSession::setValue('requisicao_itens_o', $itens); TSession::setValue('form_requisicao', $form_requisicao); TForm::sendData('form_requisicao', $form_requisicao); $this->onReload(); TTransaction::close(); } catch (Exception $e) { if ($e->getCode() == 23000) { new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente'); } else { if ($e->getCode() == 0) { new TMessage('error', '<b>Error</b> <br>' . $e->getMessage()); } else { new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode()); } } // desfazer todas as operacoes pendentes TTransaction::rollback(); } }
/** * Execute the exit action */ public function onExecuteExitAction() { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->wname, 'TForm::setFields()')); } if (isset($this->exitAction) and $this->exitAction instanceof TAction) { $callback = $this->exitAction->getAction(); $param = (array) TForm::retrieveData($this->formName); call_user_func($callback, $param); } }
/** * Clear the field * @param $form_name Form name * @param $field Field name */ public static function clearField($form_name, $field) { $form = TForm::getFormByName($form_name); if ($form instanceof TForm) { $field = $form->getField($field); if ($field instanceof AdiantiWidgetInterface) { $field->setValue(NULL); } } }
/** * Shows the widget */ public function show() { // define the tag properties $this->tag->name = $this->name; // tag name if ($this->id) { $this->tag->id = $this->id; } if (strstr($this->size, '%') !== FALSE) { $this->setProperty('style', "width:{$this->size};", false); //aggregate style info } else { $this->setProperty('style', "width:{$this->size}px;", false); //aggregate style info } if ($this->defaultOption !== FALSE) { // creates an empty <option> tag $option = new TElement('option'); $option->add($this->defaultOption); $option->value = ''; // tag value // add the option tag to the combo $this->tag->add($option); } if ($this->items) { // iterate the combobox items foreach ($this->items as $chave => $item) { if (substr($chave, 0, 3) == '>>>') { $optgroup = new TElement('optgroup'); $optgroup->label = $item; // add the option to the combo $this->tag->add($optgroup); } else { // creates an <option> tag $option = new TElement('option'); $option->value = $chave; // define the index $option->add($item); // add the item label // verify if this option is selected if ($chave == $this->value and $this->value !== NULL) { // mark as selected $option->selected = 1; } if (isset($optgroup)) { $optgroup->add($option); } else { $this->tag->add($option); } } } } // verify whether the widget is editable if (parent::getEditable()) { if (isset($this->changeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->changeAction->serialize(FALSE); $this->setProperty('changeaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)"); $this->setProperty('onChange', $this->getProperty('changeaction')); } } else { // make the widget read-only //$this->tag-> disabled = "1"; // the value don't post $this->tag->{'onclick'} = "return false;"; $this->tag->{'style'} .= ';pointer-events:none'; $this->tag->{'class'} = 'tfield_disabled'; // CSS } // shows the combobox $this->tag->show(); }
/** * Add a form action * @param $label Action Label * @param $action TAction Object * @param $icon Action Icon */ public function addQuickAction($label, TAction $action, $icon = 'ico_save.png') { $name = strtolower(str_replace(' ', '_', $label)); $button = new TButton($name); parent::addField($button); // define the button action $button->setAction($action, $label); $button->setImage($icon); if (!$this->has_action) { // creates the action table $actions = new TTable(); $this->action_row = $actions->addRow(); $row = $this->table->addRow(); $row->{'class'} = 'tformaction'; $cell = $row->addCell($actions); $cell->colspan = 2; } // add cell for button $this->action_row->addCell($button); $this->has_action = TRUE; $this->actionButtons[] = $button; return $button; }
/** * Shows the widget at the screen */ public function show() { $this->tag->{'id'} = $this->id; if ($this->items) { $i = 1; // iterate the checkgroup options foreach ($this->items as $index => $label) { // control to reduce available options when they are present // in another connected list as a post value if ($this->connectedTo and is_array($this->connectedTo)) { foreach ($this->connectedTo as $connectedList) { if (isset($connectedList->items[$index]) and $connectedList->valueSet) { continue 2; } } } // instantiates a new Item $item = new TElement('li'); if ($this->itemIcon) { $item->add($this->itemIcon); } $item->add(new TLabel($label)); $item->{'class'} = 'tsortlist_item btn btn-default'; $item->{'style'} = 'display:block;'; $item->{'id'} = "tsortlist_{$this->name}_item_{$i}_li"; $item->{'title'} = $this->tag->title; $input = new TElement('input'); $input->{'id'} = "tsortlist_{$this->name}_item_{$i}_li_input"; $input->{'type'} = 'hidden'; $input->{'name'} = $this->name . '[]'; $input->{'value'} = $index; $item->add($input); $this->tag->add($item); $i++; } } if (parent::getEditable()) { $change_action = 'function() {}'; if (isset($this->changeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->changeAction->serialize(FALSE); $change_action = "function() { __adianti_post_lookup('{$this->formName}', '{$string_action}', this); }"; } $connect = 'false'; if ($this->connectedTo and is_array($this->connectedTo)) { foreach ($this->connectedTo as $connectedList) { $connectIds[] = '#' . $connectedList->getId(); } $connect = implode(', ', $connectIds); } TScript::create(" tsortlist_start( '#{$this->id}', '{$connect}', {$change_action} ) "); } $this->tag->show(); }
public function onSelect($param) { try { //var_dump($param); $key = $param['key']; if (!$key) { return; } TTransaction::open('saciq'); //$srp = new Srp($key); $repository = new TRepository('Srp'); $criteria = new TCriteria(); $criteria->add(new TFilter('numeroSRP', '=', $key)); $srps = $repository->load($criteria); if (count($srps) > 0) { $srp = $srps[0]; } if ($srp->estaVencida()) { new TMessage('error', 'SRP Vencida!'); return; } $oldSRP = NULL; if ($oldSRP != TSession::getValue('SRP_id')) { $oldSRP = TSession::getValue('SRP_id'); } if ($oldSRP != $srp->id) { if (TSession::getValue('cessao_itens')) { $reloadForm = true; } TSession::delValue('cessao_itens'); $obj = new stdClass(); $obj->numeroItem = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; $obj->quantidade = ''; //$obj->prazoEntrega = '60 Dias'; //$obj->justificativa = ''; TForm::sendData('form_itens', $obj); } TSession::setValue('SRP_id', $srp->id); $obj = new stdClass(); $obj->numeroSRP = $srp->numeroSRP; $obj->nome = $srp->nome; $obj->numeroProcessoOrigem = $srp->numeroProcesso; $obj->uasg = $srp->uasg; $obj->validade = TDate::date2br($srp->validade); TForm::sendData('form_cessao', $obj); TSession::setValue('form_cessao', $obj); if (isset($reloadForm) && $reloadForm) { TScript::create("__adianti_load_page2('engine.php?class=CessaoForm');"); //new TScript("__adianti_load_page('engine?class=CessaoForm');"); } //AdiantiCoreApplication::executeMethod('CessaoForm','onReload'); TTransaction::close(); parent::closeWindow(); } catch (Exception $e) { $obj = new stdClass(); $obj->numeroSRP = ''; $obj->nome = ''; $obj->numeroProcesso = ''; $obj->uasg = ''; $obj->validade = ''; TForm::sendData('cessao_form', $obj); TTransaction::rollback(); } }
function onReload($param = null) { $this->datagrid->clear(); $key = $param['key']; if (!isset($key)) { $value = TSession::getValue('srp_form_view_key'); if (!isset($value)) { return; } $key = $value; } try { TTransaction::open('saciq'); $srp = new Srp($key); if (!isset($srp)) { TTransaction::close(); return; } $object = new stdClass(); $object->id = $srp->id; $object->numeroSRP = $srp->numeroSRP; $object->numeroIRP = $srp->numeroIRP; $object->numeroProcesso = $srp->numeroProcesso; $object->uasg = $srp->uasg; $object->validade = TDate::date2br($srp->validade); $object->nome = $srp->nome; $object->natureza = $srp->natureza->descricao; foreach ($srp->getItems() as $item) { $row = $this->datagrid->addItem($item); } TForm::sendData('SrpFormView', $object); TTransaction::close(); } catch (Exception $e) { if ($e->getCode() == 23000) { new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente'); } else { if ($e->getCode() == 0) { new TMessage('error', '<b>Error</b> <br>' . $e->getMessage()); } else { new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode()); } } // desfazer todas as operacoes pendentes TTransaction::rollback(); } }
/** * Clear actions row */ public function delActions() { if ($this->actionsContainer) { foreach ($this->actionButtons as $key => $button) { parent::delField($button); unset($this->actionButtons[$key]); } $this->actionsContainer->clearChildren(); } }
/** * Shows the widget */ public function show() { // define the tag properties $this->tag->name = $this->name; // tag name $this->tag->id = $this->id; // tag name $this->setProperty('style', "width:{$this->size}px", FALSE); //aggregate style info $multiple = $this->maxSize == 1 ? 'false' : 'true'; $load_items = 'undefined'; if ($this->initialItems) { $new_items = array(); foreach ($this->initialItems as $key => $item) { $new_item = array('id' => $key, 'text' => $item); $new_items[] = $new_item; } if ($multiple == 'true') { $load_items = json_encode($new_items); } else { $load_items = json_encode($new_item); } } $orderColumn = isset($this->orderColumn) ? $this->orderColumn : $this->column; $criteria = ''; if ($this->criteria) { $criteria = str_replace(array('+', '/'), array('-', '_'), base64_encode(serialize($this->criteria))); } $hash = md5("{$this->seed}{$this->database}{$this->key}{$this->column}{$this->model}"); $length = $this->minLength; $class = $this->service; $callback = array($class, 'onSearch'); $method = $callback[1]; $search_word = AdiantiCoreTranslator::translate('Search'); $url = "engine.php?class={$class}&method={$method}&static=1&database={$this->database}&key={$this->key}&column={$this->column}&model={$this->model}&orderColumn={$orderColumn}&criteria={$criteria}&operator={$this->operator}&mask={$this->mask}"; $change_action = 'function() {}'; if (isset($this->changeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->changeAction->serialize(FALSE); $change_action = "function() { serialform=tmultisearch_get_form_data('{$this->formName}', '{$this->name}');\n __adianti_ajax_lookup('{$string_action}&'+serialform, this); }"; } TScript::create(" tdbmultisearch_start( '{$this->id}', '{$length}', '{$this->maxSize}', '{$search_word}', {$multiple}, '{$url}', '{$this->size}px', '{$this->height}px', {$load_items}, '{$hash}', {$change_action} ); "); // shows the component $this->tag->show(); }
public function onSelect($param) { try { if (!$param['key']) { return; } if (!TSession::getValue('SRP_id') && !$this->continue) { $this->closeWindow(); new TMessage('error', 'Número SRP Inválido'); $this->message = false; return; } $key = $param['key']; TTransaction::open('saciq'); //TTransaction::setLogger(new TLoggerTXT('c:\array\file.txt')); $repository = new TRepository('Item'); $criteria = new TCriteria(); $criteria->add(new TFilter('numeroItem', '=', $key)); if (TSession::getValue('SRP_id')) { $criteria->add(new TFilter('srp_id', '=', TSession::getValue('SRP_id'))); } $itens = $repository->load($criteria); if (count($itens) > 0) { $item = $itens[0]; $itens_o = TSession::getValue('cessao_itens_o'); if (isset($itens_o) && isset($itens_o[$item->numeroItem])) { $item->estoqueDisponivel += $itens_o[$item->numeroItem]->quantidade; } if ($item->estoqueDisponivel == 0) { $obj = new stdClass(); $obj->numeroItem = ''; $obj->item_id = ''; $obj->numeroItem = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; //$obj->quantidade = ''; $obj->prazoEntrega = '60 Dias'; $obj->justificativa = ''; TForm::sendData('form_itens', $obj); $this->closeWindow(); new TMessage('error', 'Item sem quantidade disponível'); $this->message = false; return; } $obj = new stdClass(); $obj->item_id = $item->id; if (strpos($item->descricaoSumaria, '–')) { $item->descricaoSumaria = str_replace('–', '-', $item->descricaoSumaria); $item->store(); } $obj->numeroItem = $item->numeroItem; $obj->descricaoSumaria = $item->descricaoSumaria; $obj->valorUnitario = $item->valorUnitario; TForm::sendData('form_itens', $obj); parent::closeWindow(); } else { $obj = new stdClass(); $obj->item_id = ''; $obj->numeroItem = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; //$obj->quantidade = ''; $obj->prazoEntrega = '60 Dias'; $obj->justificativa = ''; TForm::sendData('form_itens', $obj); parent::closeWindow(); } TTransaction::close(); } catch (Exception $e) { $obj = new stdClass(); $obj->item_id = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; $obj->quantidade = ''; $obj->prazoEntrega = '60 Dias'; $obj->justificativa = ''; TForm::sendData('form_itens', $obj); TTransaction::rollback(); } }
/** * Executed when the user chooses the record */ public function onSelect($param) { try { $key = $param['key']; TTransaction::open('sobcontrole'); // load the active record $tipocontato = new tipocontato($key); //var_dump($tipocontato); // closes the transaction TTransaction::close(); $object = new StdClass(); $object->tipocontato_idtipocontato = $tipocontato->idtipocontato; $object->tipocontato_descricao = $tipocontato->descricao; TForm::sendData('form_seek_sample', $object); parent::closeWindow(); // closes the window } catch (Exception $e) { // clear fields $object = new StdClass(); $object->tipocontato_idtipocontato = ''; $object->tipocontato_descricao = ''; TForm::sendData('form_seek_sample', $object); // undo pending operations TTransaction::rollback(); } }
/** * Reload combobox items after it is already shown * @param $formname form name (used in gtk version) * @param $name field name * @param $items array with items */ public static function reload($formname, $name, $items) { $form = TForm::getFormByName($formname); $combo = $form->getField($name); $combo->clear(); $combo->addItems($items); }
/** * Shows the widget at the screen */ public function show() { if ($this->items) { // iterate the checkgroup options $i = 0; foreach ($this->items as $index => $label) { $button = $this->buttons[$index]; // verify if the checkbutton is checked if (@in_array($index, $this->value)) { $button->setValue($index); // value=indexvalue (checked) } // create the label for the button $obj = $this->labels[$index]; $obj->{'class'} = 'tcheckgroup_label'; $obj->setTip($this->tag->title); if ($this->getSize() and isset($this->breakItems)) { $obj->setSize($this->getSize()); } // check whether the widget is non-editable if (parent::getEditable()) { if (isset($this->changeAction)) { if (!TForm::getFormByName($this->formName) instanceof TForm) { throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()')); } $string_action = $this->changeAction->serialize(FALSE); $button->setProperty('onChange', "serialform=(\$('#{$this->formName}').serialize());\n __adianti_ajax_lookup('{$string_action}&'+serialform, this)"); } } else { $button->setEditable(FALSE); $obj->setFontColor('gray'); } $obj->add($button); $obj->show(); $i++; if ($this->layout == 'vertical' or $this->breakItems == $i) { // shows a line break $br = new TElement('br'); $br->show(); $i = 0; } echo "\n"; } } }