Example #1
0
    /**
     * An easy way to make a paginated bootStrapTable
     *
     * @param String $sql
     * @param Array $buttons
     * @param String $hideColumns
     * @param String $toolbar
     * @param Integer $rowLimit
     * @param Integer $selected_page
     * @param Array $customFields
     * @param String $name
     * @param String $class
     * @param Boolean $paginate
     * @param Boolean $searchable
     * @param Boolean $checked
     * @param String $checkPostURL
     * @return type
     */
    function bootStrapTable($sql = "select * from user_detail", $buttons = "", $hideColumns = "", $toolbar = "My Grid", $customFields = null, $name = "grid", $tableInfo = "", $formHideFields = "", $class = "table table-striped", $rowLimit = 10, $paginate = true, $searchable = true, $checked = false, $selected_page = 1, $checkedPostURL = "", $checkSingleSelect = true, $event = "", $mobiletooltip = "")
    {
        $DEB = $this->DEB;
        $hideColumns = explode(",", strtoupper($hideColumns));
        $object = rawurlencode(json_encode(func_get_args()));
        $paginating = "false";
        if ($paginate) {
            $paginating = "true";
        }
        $options = ["id" => $name, "class" => $class, "data-toolbar" => "#toolbar" . $name, "data-pagination" => "{$paginating}", "data-side-pagination" => "server", "data-search" => "false", "data-height" => "400", "data-page-list" => "[5, 10, 20, 50, 100, 200]", "data-page-size" => $rowLimit];
        if ($searchable) {
            $options["data-search"] = "true";
        }
        if ($checked) {
            $options["data-click-to-select"] = "true";
            if ($checkSingleSelect) {
                $options["data-single-select"] = "true";
            }
        }
        $data = @$DEB->getRow("select first 1 * from ({$sql}) t ");
        $fieldInfo = @$DEB->fieldinfo;
        if (empty($fieldInfo)) {
            die("Perhaps the SQL for this query is broken {$sql} or the table does not exist, have you specified the correct database in your Cody initialization, Try running migrations with maggy");
        }
        $header = "";
        if ($checked) {
            $header .= th(["data-field" => "checked" . $name . "[]", "class" => "text-left", "data-checkbox" => "true"], "");
        }
        foreach ($fieldInfo as $fid => $field) {
            if (!in_array(strtoupper($field["name"]), $hideColumns)) {
                if (isset($customFields[$field["name"]])) {
                    $customField = $customFields[$field["name"]];
                    if (empty($customField["type"])) {
                        $customField["type"] = "text";
                    }
                    switch ($customField["type"]) {
                        default:
                            $header .= th(["data-field" => $field["name"], "class" => "text-" . $field["align"], "data-sortable" => "true"], ucwords(str_replace("_", " ", strtolower($field["alias"]))));
                            break;
                        case "checkbox":
                            $header .= th(["data-field" => $field["name"], "class" => "text-" . $field["align"], "data-checkbox" => "true"], "");
                            break;
                        case "hidden":
                            $header .= th(["data-field" => $field["name"], "class" => "hidden"], ucwords(str_replace("_", " ", strtolower($field["alias"]))));
                            break;
                    }
                } else {
                    $header .= th(["data-field" => $field["name"], "class" => "text-" . $field["align"], "data-sortable" => "true"], ucwords(str_replace("_", " ", strtolower($field["alias"]))));
                }
            }
        }
        $addColumn = "";
        if ($buttons) {
            $addColumn .= th(["data-field" => "BUTTONS"], "Options");
        }
        $header = thead(tr($header . $addColumn));
        if (empty($toolbar["caption"])) {
            $toolbar = array();
            $toolbar["caption"] = "";
        }
        $insertButton = $this->bootStrapButton("btnInsert", "Add", "call{$name}Ajax('/cody/form/insert','{$name}Target', {object : a{$name}object, record: null, db: '{$DEB->tag}' })", "btn btn-success pull-left", "", true);
        if (empty($toolbar["buttons"])) {
            $toolbar["buttons"] = "";
        }
        $toolbar["buttons"] = $insertButton . $toolbar["buttons"];
        if (empty($toolbar["filter"])) {
            $toolbar["filter"] = "";
        }
        $tableHeading = "";
        if (!empty($toolbar["caption"])) {
            $tableHeading = h3($toolbar["caption"]) . hr();
        }
        $toolbarButtons = $toolbar["buttons"];
        $toolbarFilters = $toolbar["filter"];
        if ($searchable) {
            $toolbarFilters .= div(["class" => "search"], input(["id" => "search{$name}", "class" => "search form-control", "type" => "text", "placeholder" => "Search " . $toolbar["caption"], "onkeyup" => '$table' . $name . '.bootstrapTable(\'getData\')']));
        }
        $toolbarFilters = div(["class" => "form-inline", "role" => "form"], $toolbarFilters);
        $html = $tableHeading . div(["class" => "table-responsive"], div(["class" => "table-toolbar clearfix"], div(["class" => "toolbar-buttons"], $toolbarButtons) . div(["class" => "toolbar-filters"], $toolbarFilters)) . table($options, $header, tbody()));
        $html .= script('
                    var a' . $name . 'object = "' . $object . '";
                    var $table' . $name . ' =  $("#' . $name . '").bootstrapTable({search : false, url : "/cody/data/ajax/' . $this->DEB->tag . '",
                                                                                method : "post",
                                                                                onCheck: function (row) {
                                                                                            eventType = \'check\';
                                                                                           ' . $event . '
                                                                                },
                                                                                onUnCheck: function (row) {
                                                                                           eventType = \'uncheck\';
                                                                                           ' . $event . '
                                                                                },
                                                                                queryParams: function (p) {  return {object: a' . $name . 'object, limit: p.limit, offset :p.offset, order: p.order, search : $("#search' . $name . '").val(), sort: p.sort }

                                                                                } });
                   $search = $("#search' . $name . '");
                    var timeoutId = null;
                    $search.off("keyup").on("keyup", function (event) {
                        clearTimeout(timeoutId);
                        timeoutId = setTimeout(function () {

                          $table' . $name . '.bootstrapTable("refresh", {pageNumber: 1});

                        }, 1000);
                    });

                  ');
        if ($checked) {
            $html = form(["method" => "post", "action" => $checkedPostURL, "enctype" => "multipart/form-data"], $html);
        }
        $html .= div(["id" => "{$name}Target"]);
        $html .= $this->ajaxHandler("", "{$name}Target", "call{$name}Ajax");
        return $html;
    }
Example #2
0
$formdata['c_q_first_name'] = array('type' => 'checkbox', 'parent_class' => 'multi_checkbox', 'settings' => array('data' => array('1' => v('CMT_FIRST_NAME'))), 'value' => 1);
$formdata['c_q_last_name'] = array('type' => 'checkbox', 'parent_class' => 'multi_checkbox', 'settings' => array('data' => array('1' => v('CMT_LAST_NAME'))), 'value' => 1);
$formdata['c_q_email'] = array('type' => 'checkbox', 'parent_class' => 'multi_checkbox', 'settings' => array('data' => array('1' => v('CMT_EMAIL'))), 'value' => 1);
foreach ($formdata as $key => $val) {
    if (isset(${$key})) {
        $formdata[$key]['value'] = ${$key};
    }
}
$filter_array['SEARCH'] = $formdata;
$formdata = NULL;
print "<div class='filter'>";
show_filter($filter_array);
print "</div><!-- /.filter -->";
$head_array['TABLE'] = array("CMT_DATE" => "date", "CMT_USERNAME" => "username", "CMT_FIRST_NAME" => "first_name", "CMT_LAST_NAME" => "last_name");
$head_array['CONSTRUCT'] = array("add" => true);
$data_array['TABLE'] = array("date" => "date", "username" => "default", "first_name" => "default", "last_name" => "default");
$data_array['CONSTRUCT'] = array("edit" => true, "copy" => true, "delete" => true, "activate" => true);
if (!isset($order)) {
    $data_array['SORT'] = array("date" => $direction);
} else {
    $data_array['SORT'] = array($order => $direction);
}
foreach ($head_array['CONSTRUCT'] as $key => $value) {
    if ($value === true) {
        print "<div class='engine-function'><a href='#' class='" . $key . "' data-content='" . $modul . "' ><i class='icon-" . $key . "'></i></a></div><!-- /.engine-function -->";
    }
}
print "<div class='table'>";
thead($head_array);
tbody($data_array);
print "</div><!-- /.table -->";
Example #3
0
                $val_length = strlen($d_val);
                $i = 0;
                while ($i++ < $tr_length) {
                    if ($i == 2) {
                        echo $d_val;
                        $i += $val_length - 1;
                    } else {
                        echo ' ';
                    }
                }
                echo '|';
            }
            echo PHP_EOL;
        }
    }
    echo PHP_EOL;
    ascLogo($table);
    line($table, '--  Exception Start  --');
    printf("\n Line: %s \n File: %s \n\n", $message['line'], $message['file']);
    th($table);
    thead($table);
    th($table);
    if (!empty($trace)) {
        foreach ($trace as $t) {
            tBody($t, $table);
            th($table);
        }
    }
    echo PHP_EOL;
    line($table, sprintf("--  Exception END  %s  --", date('Y-m-d H:i:s', time())));
}