Exemplo n.º 1
1
 /**
  * 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}' );");
 }
Exemplo n.º 2
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to be processed when closing the dialog
  * @param $title_msg  Dialog Title
  */
 public function __construct($type, $message, TAction $action = NULL, $title_msg = '')
 {
     $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';
     $image = new TImage("lib/adianti/images/{$type}.png");
     $image->{'style'} = 'float:left';
     $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 : ($type == 'info' ? AdiantiCoreTranslator::translate('Information') : AdiantiCoreTranslator::translate('Error')));
     $body = new TElement('div');
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->{'style'} = 'margin-left:20px;float:left; display:inline-block';
     $span->add($message);
     $body->add($span);
     $button = new TElement('button');
     $button->{'class'} = 'btn btn-default';
     $button->{'data-dismiss'} = 'modal';
     $button->{'onclick'} = "\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');";
     $button->add('OK');
     if ($action) {
         $button->{'onclick'} .= "__adianti_load_page('{$action->serialize()}');";
         $button->{'data-toggle'} = "modal";
     }
     $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($body);
     $modal_content->add($footer);
     $footer->add($button);
     $modal_wrapper->show();
     $callback = 'function () {' . $button->{'onclick'} . '}';
     TScript::create("tdialog_start( '#{$this->id}', {$callback} );");
 }
Exemplo n.º 3
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $wrapper = new TElement('div');
     $wrapper->{'class'} = 'input-group color-div';
     $span = new TElement('span');
     $span->{'class'} = 'input-group-addon tcolor';
     $i = new TElement('i');
     $i->{'class'} = 'tcolor-icon';
     $span->add($i);
     ob_start();
     parent::show();
     $child = ob_get_contents();
     ob_end_clean();
     $wrapper->add($child);
     $wrapper->add($span);
     $wrapper->show();
     if (parent::getEditable()) {
         TScript::create(" tcolor_start(); ");
     }
 }
Exemplo n.º 4
0
 /**
  * Shows the DataGrid
  */
 function show()
 {
     // shows the datagrid
     parent::show();
     $params = $_REQUEST;
     unset($params['class']);
     unset($params['method']);
     // to keep browsing parameters (order, page, first_page, ...)
     $urlparams = '&' . http_build_query($params);
     // inline editing treatment
     TScript::create(" tdatagrid_inlineedit( '{$urlparams}' );");
     TScript::create(" tdatagrid_enable_groups();");
 }
Exemplo n.º 5
0
 /**
  * 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}'); ");
     }
 }
Exemplo n.º 6
0
 /**
  * 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();
 }
Exemplo n.º 7
0
 /**
  * Show the widget
  */
 public function show()
 {
     $this->tag->{'id'} = $this->id;
     $this->tag->{'class'} = 'thtmleditor';
     // CSS
     $this->tag->name = $this->name;
     // tag name
     // add the content to the textarea
     $this->tag->add(htmlspecialchars($this->value));
     TScript::create(" thtmleditor_start( '{$this->tag->{'id'}}', '{$this->size}', '{$this->height}' ); ");
     // check if the field is not editable
     if (!parent::getEditable()) {
         TScript::create(" thtmleditor_disable_field('{$this->formName}', '{$this->name}'); ");
     }
     // show the tag
     $this->tag->show();
 }
Exemplo n.º 8
0
 /**
  * Open a File Dialog
  * @param $file File Name
  */
 public static function openFile($file)
 {
     TScript::create("__adianti_download_file('{$file}')");
 }
Exemplo n.º 9
0
 /**
  * Send data for a form located in the parent window
  * @param $form_name  Form Name
  * @param $object     An Object containing the form data
  */
 public static function sendData($form_name, $object, $aggregate = FALSE, $fireEvents = TRUE)
 {
     $fire_param = $fireEvents ? 'true' : 'false';
     // iterate the object properties
     if ($object) {
         foreach ($object as $field => $value) {
             if (is_object($value)) {
                 foreach ($value as $property => $data) {
                     // if inside ajax request, then utf8_encode if isn't utf8
                     if (utf8_encode(utf8_decode($data)) !== $data) {
                         $data = utf8_encode(addslashes($data));
                     } else {
                         $data = addslashes($data);
                     }
                     $data = str_replace(array("\n", "\r"), array(' ', ' '), $data);
                     // send the property value to the form
                     TScript::create(" tform_send_data('{$form_name}', '{$field}_{$property}', '{$data}', {$fire_param}); ");
                 }
             } else {
                 // if inside ajax request, then utf8_encode if isn't utf8
                 if (utf8_encode(utf8_decode($value)) !== $value) {
                     $value = utf8_encode(addslashes($value));
                 } else {
                     $value = addslashes($value);
                 }
                 $value = str_replace(array("\n", "\r"), array(' ', ' '), $value);
                 // send the property value to the form
                 if ($aggregate) {
                     TScript::create(" tform_send_data_aggregate('{$form_name}', '{$field}', '{$value}', {$fire_param}); ");
                 } else {
                     TScript::create(" tform_send_data('{$form_name}', '{$field}', '{$value}', {$fire_param}); ");
                     TScript::create(" tform_send_data_by_id('{$form_name}', '{$field}', '{$value}', {$fire_param}); ");
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Show
  */
 public function show()
 {
     TScript::create('tmenubar_start()');
     parent::show();
 }
Exemplo n.º 11
0
 /**
  * Close all TJQueryDialog
  */
 public static function closeAll()
 {
     // it has to be inline (not external function call)
     TScript::create(' $(\'[widget="TWindow"]\').remove() ');
 }
Exemplo n.º 12
0
 /**
  * Shows the widget at the screen
  */
 public function show()
 {
     $js_mask = str_replace('yyyy', 'yy', $this->mask);
     $language = strtolower(LANG);
     if (parent::getEditable()) {
         TScript::create("tdate_start( '#{$this->id}', '{$this->mask}', '{$language}');");
     }
     parent::show();
 }
Exemplo n.º 13
0
 /**
  * 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()) {
         $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}' ) ");
     }
     $this->tag->show();
 }
Exemplo n.º 14
0
 /**
  * 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 editable
     if (parent::getEditable()) {
         $this->tag->readonly = "1";
         $this->tag->style = "width:40px;-moz-user-select:none;border:0;text-align:center";
         $div = new TElement('div');
         $div->id = $this->id . '_div';
         $div->style = "width:{$this->size}px";
         $main_div = new TElement('div');
         $main_div->style = "text-align:center;width:{$this->size}px";
         TScript::create(" tslider_start( '#{$this->id}', {$this->value}, {$this->min}, {$this->max}, {$this->step}); ");
         $main_div->add($this->tag);
         $main_div->add($div);
         $main_div->show();
     } else {
         $this->tag->readonly = "1";
         $this->tag->{'class'} = 'tfield_disabled';
         // CSS
         $this->tag->style = "width:40px;-moz-user-select:none;";
         $this->tag->onmouseover = "style.cursor='default'";
         $this->tag->show();
     }
 }
Exemplo n.º 15
0
 /**
  * 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();
 }
Exemplo n.º 16
0
 /**
  * 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();
 }
 /**
  * Register URL
  *
  * @param $page URL to be registered
  */
 public static function registerPage($page)
 {
     TScript::create("__adianti_register_state('{$page}', 'user');");
 }
Exemplo n.º 18
0
 /**
  * Shows the expander
  */
 public function show()
 {
     parent::show();
     TScript::create('texpander_start();');
 }
Exemplo n.º 19
0
 /**
  * Shows the widget
  */
 public function show()
 {
     parent::show();
     $min = $this->minLength;
     $orderColumn = isset($this->orderColumn) ? $this->orderColumn : $this->column;
     $criteria = '';
     if ($this->criteria) {
         $criteria = base64_encode(serialize($this->criteria));
     }
     $seed = APPLICATION_NAME . 's8dkld83kf73kf094';
     $hash = md5("{$seed}{$this->database}{$this->column}{$this->model}");
     $length = $this->minLength;
     $class = 'AdiantiAutocompleteService';
     $callback = array($class, 'onSearch');
     $method = $callback[1];
     $url = "engine.php?class={$class}&method={$method}&static=1&database={$this->database}&column={$this->column}&model={$this->model}&orderColumn={$orderColumn}&criteria={$criteria}&operator={$this->operator}&hash={$hash}";
     TScript::create(" tdbentry_start( '{$this->name}', '{$url}', '{$min}' );");
 }
Exemplo n.º 20
0
 /**
  * Class Constructor
  * @param  $message    A string containint the question
  * @param  $action_yes Action taken for YES response
  * @param  $action_no  Action taken for NO  response
  * @param  $title_msg  Dialog Title
  */
 public function __construct($message, TAction $action_yes = NULL, TAction $action_no = NULL, $title_msg = '')
 {
     $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';
     $image = new TImage("lib/adianti/images/question.png");
     $image->{'style'} = 'float:left';
     $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('Question'));
     $body = new TElement('div');
     $body->{'class'} = 'modal-body';
     $body->add($image);
     $span = new TElement('span');
     $span->{'style'} = 'margin-left:20px;float:left; display:inline-block';
     $span->add($message);
     $body->add($span);
     $footer = new TElement('div');
     $footer->{'class'} = 'modal-footer';
     if ($action_yes) {
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-default';
         $button->{'data-toggle'} = "modal";
         $button->{'data-dismiss'} = 'modal';
         $button->add(AdiantiCoreTranslator::translate('Yes'));
         $button->{'onclick'} = '__adianti_load_page(\'' . $action_yes->serialize() . '\')';
         $footer->add($button);
     }
     if ($action_no) {
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-default';
         $button->{'data-toggle'} = "modal";
         $button->{'data-dismiss'} = 'modal';
         $button->add(AdiantiCoreTranslator::translate('No'));
         $button->{'onclick'} = '__adianti_load_page(\'' . $action_no->serialize() . '\')';
         $footer->add($button);
     } else {
         $button = new TElement('button');
         $button->{'class'} = 'btn btn-default';
         $button->{'data-dismiss'} = 'modal';
         $button->add(AdiantiCoreTranslator::translate('No'));
         $footer->add($button);
     }
     $button = new TElement('button');
     $button->{'class'} = 'btn btn-default';
     $button->{'data-dismiss'} = 'modal';
     $button->add(AdiantiCoreTranslator::translate('Cancel'));
     $footer->add($button);
     $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($body);
     $modal_content->add($footer);
     $modal_wrapper->show();
     TScript::create("tdialog_start( '#{$this->id}' );");
 }
Exemplo n.º 21
0
 /**
  * Clear the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function clearField($form_name, $field)
 {
     TScript::create(" tmultifield_clear_field('{$form_name}', '{$field}'); ");
 }
Exemplo n.º 22
0
 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();
     }
 }
Exemplo n.º 23
0
 /**
  * Shows the tag
  */
 public function show()
 {
     $objectId = $this->{'id'};
     $collapsed = $this->collapsed ? 'true' : 'false';
     parent::add(TScript::create(" ttreeview_start( '#{$objectId}', {$collapsed} ); ", FALSE));
     parent::show();
 }
Exemplo n.º 24
0
 /**
  * Close all TJQueryDialog
  */
 public static function closeAll()
 {
     if (!isset($_REQUEST['ajax_lookup']) or $_REQUEST['ajax_lookup'] !== '1') {
         // it has to be inline (not external function call)
         TScript::create(' $(\'[widget="TWindow"]\').remove(); ');
     }
 }
Exemplo n.º 25
0
 /**
  * Send data for a form located in the parent window
  * @param $form_name  Form Name
  * @param $object     An Object containing the form data
  */
 public static function sendData($form_name, $object, $aggregate = FALSE)
 {
     // iterate the object properties
     if ($object) {
         foreach ($object as $field => $value) {
             if (is_object($value)) {
                 foreach ($value as $property => $data) {
                     // if inside ajax request, then utf8_encode if isn't utf8
                     if (utf8_encode(utf8_decode($data)) !== $data) {
                         $data = utf8_encode(addslashes($data));
                     } else {
                         $data = addslashes($data);
                     }
                     // send the property value to the form
                     TScript::create(" tform_send_data('{$form_name}', '{$field}_{$property}', '{$data}'); ");
                 }
             } else {
                 // if inside ajax request, then utf8_encode if isn't utf8
                 if (utf8_encode(utf8_decode($value)) !== $value) {
                     $value = utf8_encode(addslashes($value));
                 } else {
                     $value = addslashes($value);
                 }
                 // send the property value to the form
                 if ($aggregate) {
                     TScript::create(" tform_send_data_aggregate('{$form_name}', '{$field}', '{$value}'); ");
                 } else {
                     TScript::create(" tform_send_data('{$form_name}', '{$field}', '{$value}'); ");
                     TScript::create(" tform_send_data_by_id('{$form_name}', '{$field}', '{$value}'); ");
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
 /**
  * Show the widget
  */
 public function show()
 {
     // check if the field is not editable
     if (parent::getEditable()) {
         $tag = new TElement('textarea');
         $tag->{'id'} = $this->id;
         $tag->{'class'} = 'thtmleditor';
         // CSS
         $tag->name = $this->name;
         // tag name
         $this->setProperty('style', "width:{$this->size}px", FALSE);
         //aggregate style info
         $this->tag->add($tag);
         if ($this->height) {
             $tag->style .= "height:{$this->height}px";
         }
         // add the content to the textarea
         $tag->add(htmlspecialchars($this->value));
         TScript::create(" thtmleditor_start( '{$tag->{'id'}}', '{$this->size}', '{$this->height}' ); ");
     } else {
         $this->tag->style = "width:{$this->size}px;";
         $this->tag->style .= "height:{$this->height}px;";
         $this->tag->style .= "background-color:#FFFFFF;";
         $this->tag->style .= "border: 1px solid #000000;";
         $this->tag->style .= "padding: 5px;";
         $this->tag->style .= "overflow: auto;";
         // add the content to the textarea
         $this->tag->add($this->value);
     }
     // show the tag
     $this->tag->show();
 }
Exemplo n.º 27
0
 /**
  * Show the widget at the screen
  */
 public function show()
 {
     $wrapper = new TElement('div');
     $wrapper->{'mtf_name'} = $this->getName();
     // include the needed libraries and styles
     if ($this->fields) {
         $table = new TTable();
         $mandatories = array();
         // mandatory
         $fields = array();
         $i = 0;
         if ($this->orientation == 'horizontal') {
             $row_label = $table->addRow();
             $row_field = $table->addRow();
         }
         foreach ($this->fields as $name => $obj) {
             if ($this->orientation == 'vertical') {
                 $row = $table->addRow();
                 $row_label = $row;
                 $row_field = $row;
             }
             $label = new TLabel($obj->text);
             if ($obj->mandatory) {
                 $label->setFontColor('red');
             }
             $row_label->addCell($label);
             $row_field->addCell($obj->field);
             $mandatories[] = $obj->mandatory;
             $fields[] = $name;
             $post_fields[$name] = 1;
             $sizes[$name] = $obj->size;
             $obj->field->setName($this->name . '_' . $name);
             if (in_array(get_class($obj->field), array('TComboCombined', 'Adianti\\Widget\\Form\\TComboCombined'))) {
                 $aux_name = $obj->field->getTextName();
                 $aux_full_name = $this->name . '_' . $aux_name;
                 $mandatories[] = 0;
                 $obj->field->setTextName($aux_full_name);
                 $fields[] = $aux_name;
                 $post_fields[$aux_name] = 1;
                 // invert sizes
                 $sizes[$aux_name] = $obj->size;
                 $sizes[$name] = 20;
                 $i++;
             }
             $i++;
         }
         $wrapper->add($table);
     }
     // check whether the widget is non-editable
     if (parent::getEditable()) {
         // create three buttons to control the MultiField
         $add = new TButton("{$this->name}btnStore");
         $add->setLabel(AdiantiCoreTranslator::translate('Register'));
         $add->setImage('fa:angle-double-down');
         $add->addFunction("multifields['{$this->name}'].addRowFromFormFields()");
         $del = new TButton("{$this->name}btnDelete");
         $del->setLabel(AdiantiCoreTranslator::translate('Delete'));
         $del->setImage('fa:trash');
         $can = new TButton("{$this->name}btnCancel");
         $can->setLabel(AdiantiCoreTranslator::translate('Cancel'));
         $can->setImage('fa:times-circle');
         $hbox_buttons = new THBox();
         $hbox_buttons->{'style'} = 'margin-top:3px;margin-bottom:3px';
         $hbox_buttons->add($add);
         $hbox_buttons->add($del);
         $hbox_buttons->add($can);
         $wrapper->add($hbox_buttons);
     }
     // create the MultiField Panel
     $panel = new TElement('div');
     $panel->{'class'} = "multifieldDiv";
     $input = new THidden($this->name);
     $panel->add($input);
     // create the MultiField DataGrid Header
     $table = new TTable();
     $table->{'class'} = 'multifield';
     $table->{'id'} = "{$this->name}mfTable";
     $head = new TElement('thead');
     $table->add($head);
     $row = new TTableRow();
     $head->add($row);
     // fill the MultiField DataGrid
     if ($this->fields) {
         foreach ($this->fields as $obj) {
             $c = $obj->text;
             if (in_array(get_class($obj->field), array('TComboCombined', 'Adianti\\Widget\\Form\\TComboCombined'))) {
                 $cell = $row->addCell('ID');
                 $cell->{'width'} = '20px';
                 $cell->{'class'} = 'multifield_header';
             }
             $cell = $row->addCell($c);
             $cell->{'width'} = $obj->size . 'px';
             $cell->{'class'} = 'multifield_header';
         }
     }
     $body_height = $this->height - 34;
     $body = new TElement('tbody');
     $body->{'style'} = "height: {$body_height}px";
     $body->{'class'} = 'tmultifield_scrolling';
     $table->add($body);
     if ($this->objects) {
         foreach ($this->objects as $obj) {
             if (isset($obj->id)) {
                 $row = new TTableRow();
                 $row->dbId = $obj->id;
                 $body->add($row);
             } else {
                 $row = new TTableRow();
                 $body->add($row);
             }
             if ($fields) {
                 foreach ($fields as $name) {
                     $cellValue = is_null($obj->{$name}) ? '' : $obj->{$name};
                     $original = $cellValue;
                     if (is_array(json_decode($cellValue))) {
                         $content = json_decode($cellValue);
                         $rows = array();
                         foreach ($content as $_row) {
                             $rows[] = implode(':', array_values(get_object_vars($_row)));
                         }
                         $cellValue = implode(',', $rows);
                         $cell = $row->addCell($cellValue);
                         $cell->{'data'} = htmlspecialchars($original);
                     } else {
                         $cell = $row->addCell($cellValue);
                         $cell->{'data'} = $cellValue;
                     }
                     if (isset($sizes[$name])) {
                         $cell->style = 'width:' . $sizes[$name] . 'px;';
                     }
                 }
             }
         }
     }
     $panel->add($table);
     $wrapper->add($panel);
     $wrapper->show();
     $fields_json = json_encode($fields);
     $mandatories_json = json_encode($mandatories);
     TScript::create(" tmultifield_start( '{$this->name}', {$fields_json}, {$mandatories_json}, {$this->width},{$this->height} ) ");
 }
Exemplo n.º 28
0
 /**
  * Shows the DataGrid
  */
 function show()
 {
     // shows the datagrid
     parent::show();
     $params = $_REQUEST;
     unset($params['class']);
     unset($params['method']);
     // to keep browsing parameters (order, page, first_page, ...)
     $urlparams = '&' . http_build_query($params);
     // inline editing treatment
     TScript::create('$(function() {
     	$(".inlineediting").editInPlace({
     		callback: function(unused, enteredText)
     		{
     		    __adianti_load_page($(this).attr("action")+"' . $urlparams . '&key="+$(this).attr("key")+"&field="+$(this).attr("field")+"&value="+encodeURIComponent(enteredText));
     		    return enteredText;
     		},
     		show_buttons: false,
     		text_size:20,
     		params:column=name
 	    });
     });');
 }
Exemplo n.º 29
0
 /**
  * Disable the field
  * @param $form_name Form name
  * @param $field Field name
  */
 public static function disableField($form_name, $field)
 {
     TScript::create(" tbutton_disable_field('{$form_name}', '{$field}'); ");
 }
Exemplo n.º 30
0
    /**
     * 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 = '';
        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 = '$("#' . $this->id . '").select2("data", ' . json_encode($new_items) . ');';
            } else {
                $load_items = '$("#' . $this->id . '").select2("data", ' . json_encode($new_item) . ');';
            }
        }
        $orderColumn = isset($this->orderColumn) ? $this->orderColumn : $this->column;
        $criteria = '';
        if ($this->criteria) {
            $criteria = base64_encode(serialize($this->criteria));
        }
        $seed = APPLICATION_NAME . 's8dkld83kf73kf094';
        $hash = md5("{$seed}{$this->database}{$this->key}{$this->column}{$this->model}");
        $length = $this->minLength;
        $class = 'AdiantiMultiSearchService';
        $callback = array($class, 'onSearch');
        $method = $callback[1];
        $search_word = AdiantiCoreTranslator::translate('Search');
        $sp = <<<HTML
            \$('#{$this->id}').select2(
            {   
                minimumInputLength: '{$length}',
                separator: '||',
                placeholder: '{$search_word}',
                multiple: {$multiple},
                id: function(e) { return e.id+"::"+e.text; },
                ajax: {
                    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}",
                    dataType: 'json',
                    quietMillis: 100,
                    data: function(value, page) {
                        return {
                            value: value,
                            hash: '{$hash}'
                        };
                    },
                    results: function(data, page ) 
                    {
                        var aa = [];
                        \$(data.result).each(function(i) {
                            var item = this.split('::');
                            aa.push({
                                id: item[0],
                                text: item[1]
                            });
                        });               

                        return {                             
                            results: aa 
                        }
                    }
                },             
                              
            });
            \$('#s2id_{$this->id} > .select2-choices').height('{$this->height}px').width('{$this->size}px').css('overflow-y','auto');
            {$load_items}
HTML;
        // shows the component
        $this->tag->show();
        TScript::create($sp);
    }