Ejemplo n.º 1
0
 /**
  * @return \k1lib\html\div
  */
 public function do_html_object()
 {
     if (!empty($this->db_table_data_filtered)) {
         $this->div_container->set_attrib("class", "k1lib-crudlexs-create");
         /**
          * DIV content
          */
         $this->div_container->set_attrib("class", "k1lib-form-generator " . $this->html_form_column_classes, TRUE);
         $this->div_container->set_attrib("style", "margin:0 auto;", TRUE);
         /**
          * FORM time !!
          */
         $html_form = new \k1lib\html\form();
         $html_form->append_to($this->div_container);
         if ($this->enable_foundation_form_check) {
             $html_form->set_attrib("data-abide", TRUE);
         }
         $form_header = $html_form->append_div("k1lib-form-header row");
         $form_body = $html_form->append_div("k1lib-form-body row");
         $form_footer = $html_form->append_div("k1lib-form-footer row");
         $form_footer->set_attrib("style", "margin-top:0.9em;");
         $form_buttons = $html_form->append_div("k1lib-form-buttons row");
         /**
          * Hidden input
          */
         $hidden_input = new \k1lib\html\input("hidden", "k1magic", "123123");
         $hidden_input->append_to($html_form);
         // FORM LAYOUT
         // <div class="row">
         $row_number = 0;
         foreach ($this->db_table_data_filtered[1] as $field => $value) {
             $row_number++;
             $row = new \k1lib\html\foundation\label_value_row($this->db_table_data_filtered[0][$field], $value, $row_number);
             $row->append_to($form_body);
         }
         /**
          * BUTTONS
          */
         if ($this->show_cancel_button) {
             $cancel_button = \k1lib\html\get_link_button($this->back_url, creating_strings::$button_cancel, "small");
         }
         $submit_button = new \k1lib\html\input("submit", "k1send", creating_strings::$button_submit, "small button fi-check success");
         $buttons_div = new \k1lib\html\foundation\label_value_row(NULL, "{$cancel_button} {$submit_button}");
         $buttons_div->append_to($form_buttons);
         $buttons_div->col(1)->remove_childs();
         $buttons_div->col(2)->set_class("text-center", TRUE);
         /**
          * Prepare output
          */
         return $this->div_container;
     } else {
         return FALSE;
     }
 }
Ejemplo n.º 2
0
 static function default_type(creating $crudlex_obj, $field)
 {
     $field_encrypted = $crudlex_obj->encrypt_field_name($field);
     if (!empty($crudlex_obj->db_table->get_field_config($field, 'refereced_table_name')) && self::$do_fk_search_tool && array_search($field, self::$fk_fields_to_skip) === FALSE) {
         $div_input_group = new \k1lib\html\div("input-group");
         $input_tag = new \k1lib\html\input("text", $field_encrypted, NULL, "k1lib-input-insert input-group-field");
         if (!empty($crudlex_obj->db_table->get_field_config($field, 'placeholder'))) {
             $input_tag->set_attrib("placeholder", $crudlex_obj->db_table->get_field_config($field, 'placeholder'));
         } else {
             $input_tag->set_attrib("placeholder", input_helper_strings::$input_fk_placeholder);
         }
         $input_tag->set_attrib("k1lib-data-group-" . $crudlex_obj->db_table->get_field_config($field, 'refereced_table_name'), TRUE);
         $input_tag->append_to($div_input_group);
         $div_input_group_button = new \k1lib\html\div("input-group-button");
         $div_input_group_button->append_to($div_input_group);
         /**
          * FK TABLE EXTRACTOR
          */
         $refereced_column_config = $crudlex_obj->db_table->get_field_config($field, 'refereced_column_config');
         //            while (!empty($refereced_column_config['refereced_column_config'])) {
         ////                $refereced_column_config = $refereced_column_config['refereced_column_config'];
         //            }
         $this_table = $crudlex_obj->db_table->get_db_table_name();
         $this_table_alias = \k1lib\db\security\db_table_aliases::encode($this_table);
         $fk_table = $refereced_column_config['table'];
         $fk_table_alias = \k1lib\db\security\db_table_aliases::encode($fk_table);
         //            $crudlex_obj->set_do_table_field_name_encrypt();
         $static_values = $crudlex_obj->db_table->get_constant_fields();
         $static_values_enconded = $crudlex_obj->encrypt_field_names($static_values);
         $search_button = new \k1lib\html\input("button", "search", "&#xf18d;", "button fi-page-search fk-button");
         $search_button->set_attrib("style", "font-family:foundation-icons");
         $url_params = ["back-url" => $_SERVER['REQUEST_URI']];
         $url_params = array_merge($static_values_enconded, $url_params);
         $url_to_search_fk_data = url::do_url(self::$url_to_search_fk_data . "{$fk_table_alias}/list/{$this_table_alias}/", $url_params);
         $search_button->set_attrib("onclick", "javascript:use_select_row_keys(this.form,'{$url_to_search_fk_data}')");
         $search_button->append_to($div_input_group_button);
         $div_input_group->link_value_obj($input_tag);
         return $div_input_group;
     } elseif (strstr("date,date-past,date-future", $crudlex_obj->db_table->get_field_config($field, 'validation')) !== FALSE) {
         $div_input_group = new \k1lib\html\div("input-group");
         $input_tag = new \k1lib\html\input("text", $field_encrypted, NULL, "k1lib-input-insert input-group-field datepicker");
         $input_tag->set_attrib("placeholder", input_helper_strings::$input_date_placeholder);
         $input_tag->set_attrib("k1lib-data-datepickup", TRUE);
         $input_tag->append_to($div_input_group);
         $div_input_group_button = new \k1lib\html\div("input-group-button");
         $div_input_group_button->append_to($div_input_group);
         $search_button = new \k1lib\html\a("#", "", "_self", "button fi-calendar");
         $search_button->append_to($div_input_group_button);
         $div_input_group->link_value_obj($input_tag);
         return $div_input_group;
     } else {
         $input_tag = new \k1lib\html\input("text", $field_encrypted, NULL, "k1lib-input-insert");
         $input_tag->set_attrib("placeholder", $crudlex_obj->db_table->get_field_config($field, 'placeholder'));
         return $input_tag;
     }
 }