コード例 #1
0
function reset_company_view()
{
    global $wb;
    // Empty listview
    wb_delete_items(wb_get_control($wb->right_control, IDC_COMPANY_LIST), null);
    $keyword = $wb->keyword;
    $where_is = " where 1 ";
    if ($keyword) {
        $where_is .= " AND name LIKE '%{$keyword}%' ";
    }
    $max_row = 22;
    $table_name = $wb->setting["Settings"]["company_table"];
    $start_num = ($wb->current_page - 1) * $max_row;
    $sql = " SELECT COUNT(*) AS num FROM {$table_name} {$where_is} ";
    $wb->db->query($sql);
    $wb->db->next_record();
    $total_num = $wb->db->f("num");
    $wb->total_page = ceil($total_num / $max_row);
    include PATH_CONFIG . "common.php";
    $sql = " SELECT * FROM {$table_name} {$where_is} ORDER BY id DESC LIMIT {$start_num}," . $max_row;
    $wb->db->query($sql);
    $data = array();
    while ($wb->db->next_record()) {
        $row = array();
        $row[] = $wb->db->f("id");
        $row[] = $wb->db->f("name");
        $row[] = $wb->db->f("link_man");
        $row[] = $wb->db->f("phone");
        $row[] = $wb->db->f("email");
        $row[] = $wb->db->f("addrees");
        $data[] = $row;
    }
    // Create listview items
    wb_create_items(wb_get_control($wb->right_control, IDC_COMPANY_LIST), $data);
    //	navigator
    wb_set_text(wb_get_control($wb->right_control, IDC_NAV_BAR), $wb->vars["Lang"]["lang_total"] . " " . $total_num . " " . $wb->vars["Lang"]["lang_records"] . " " . $wb->vars["Lang"]["lang_current"] . $wb->current_page . "/" . $wb->total_page . " " . $wb->vars["Lang"]["lang_page"]);
    wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_PRE), true);
    wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_FIRST), true);
    wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_NEXT), true);
    wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_LAST), true);
    if ($wb->current_page == $wb->total_page) {
        wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_NEXT), false);
        wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_LAST), false);
    }
    if ($wb->current_page == 1) {
        wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_PRE), false);
        wb_set_enabled(wb_get_control($wb->right_control, IDC_NAV_FIRST), false);
    }
}
コード例 #2
0
function reset_form($class, $parent, $title, $width, $height, $style = 0, $value = 0)
{
    global $wb;
    $wb->currentform = 0;
    $wb->proj_filename = null;
    if (!isset($wb->form[$wb->currentform])) {
        $wb->form[$wb->currentform] = new stdclass();
    }
    // Reset form data with fixed attributes
    $wb->form[$wb->currentform]->ct = array();
    $wb->form[$wb->currentform]->numcontrols = 0;
    $wb->form[$wb->currentform]->ncurrindex = 0;
    $wb->form[$wb->currentform]->nselcontrol = -1;
    $wb->form[$wb->currentform]->treenode = 0;
    foreach ($wb->project_array as $var) {
        $wb->form[$wb->currentform]->{$var} = constant("DEFAULT_" . strtoupper($var));
    }
    // Variable attributes
    $wb->form[$wb->currentform]->width = $width;
    $wb->form[$wb->currentform]->height = $height;
    $wb->form[$wb->currentform]->caption = $title;
    $wb->form[$wb->currentform]->cclass = $class;
    $wb->form[$wb->currentform]->style = (int) $style;
    $wb->form[$wb->currentform]->value = (int) $value;
    // Resize, reposition and show form
    $pos = wb_get_position($parent);
    wb_set_position($wb->formwin, $pos[0] + 180, $pos[1] + 76);
    wb_set_size($wb->formwin, $width, $height);
    wb_set_text($wb->formwin, $title);
    wb_set_visible($wb->formwin, true);
    // Create a treeview item for this form
    wb_delete_items($wb->tree, $wb->form[$wb->currentform]->treenode);
    $root = $wb->rootnode;
    $node = wb_create_items($wb->tree, array(array($title, $wb->currentform, $root, 8, 9, 2)));
    $wb->form[$wb->currentform]->treenode = $node;
    // numforms is always set to 1
    $wb->numforms = 1;
    // Expand the root and select the new node
    wb_set_state($wb->tree, $root, 1);
    wb_set_selected($wb->tree, $node);
}
コード例 #3
0
function wb_create_items($ctrl, $items, $clear = false, $param = null)
{
    switch (wb_get_class($ctrl)) {
        case ListView:
            if ($clear) {
                wb_send_message($ctrl, LVM_DELETEALLITEMS, 0, 0);
            }
            $last = -1;
            // For each row
            for ($i = 0; $i < count($items); $i++) {
                if (!is_scalar($items[$i])) {
                    $last = wbtemp_create_listview_item($ctrl, -1, -1, (string) $items[$i][0]);
                } else {
                    $last = wbtemp_create_listview_item($ctrl, -1, -1, (string) $items[$i]);
                }
                wbtemp_set_listview_item_text($ctrl, -1, 0, (string) $items[$i][0]);
                // For each column except the first
                for ($sub = 0; $sub < count($items[$i]) - 1; $sub++) {
                    if ($param) {
                        $result = call_user_func($param, $items[$i][$sub + 1], $i, $sub);
                        wbtemp_set_listview_item_text($ctrl, $last, $sub + 1, $result);
                    } else {
                        wbtemp_set_listview_item_text($ctrl, $last, $sub + 1, (string) $items[$i][$sub + 1]);
                    }
                }
            }
            return $last;
            break;
        case TreeView:
            if ($clear) {
                $handle = wb_delete_items($ctrl);
            }
            // Empty the treeview
            if (!$items) {
                break;
            }
            $ret = array();
            for ($i = 0; $i < count($items); $i++) {
                $ret[] = wbtemp_create_treeview_item($ctrl, (string) $items[$i][0], isset($items[$i][1]) ? $items[$i][1] : 0, isset($items[$i][2]) ? $items[$i][2] : 0, isset($items[$i][3]) ? $items[$i][3] : -1, isset($items[$i][4]) ? $items[$i][4] : -1, isset($items[$i][5]) ? $items[$i][5] : 0);
            }
            return count($ret) > 1 ? $ret : $ret[0];
            break;
        case StatusBar:
            wbtemp_create_statusbar_items($ctrl, $items, $clear, $param);
            return true;
        default:
            if (is_array($items)) {
                foreach ($items as $item) {
                    wbtemp_create_item($ctrl, $item);
                }
                return true;
            } else {
                return wbtemp_create_item($ctrl, $items);
            }
            break;
    }
}
コード例 #4
0
 function reset_category_listview($keyword = "")
 {
     global $wb;
     // Empty listview
     wb_delete_items($this->category_list, null);
     $where_is = " where 1 ";
     if ($keyword) {
         $where_is .= " AND category_name LIKE '%{$keyword}%' ";
     }
     $category_table_name = $wb->setting["Settings"]["contact_category_table"];
     $start_num = ($wb->current_category_page - 1) * $this->max_row;
     $sql2 = " SELECT * FROM {$category_table_name} {$where_is} ";
     $wb->db->query($sql2);
     $this->total_category_num = $wb->db->num_rows();
     $wb->total_category_page = ceil($this->total_category_num / $this->max_row);
     $sql2 = " SELECT * FROM {$category_table_name} {$where_is} ORDER BY id DESC LIMIT {$start_num}," . $this->max_row;
     $wb->db->query($sql2);
     $category_data = array();
     while ($wb->db->next_record()) {
         $row = array();
         $row[] = $wb->db->f("id");
         $row[] = $wb->db->f("category_name");
         $row[] = $wb->db->f("active");
         $category_data[] = $row;
     }
     // Create listview items
     wb_create_items($this->category_list, $category_data);
     //category navigator
     $dim = wb_get_size($this->left_control, true);
     $nav_button_y = $dim[1] - 280;
     $nav_button_x = 80 + 150;
     $nav_button_space = 120;
     wb_create_control($this->left_control, Label, $wb->vars["Lang"]["lang_total"] . " " . $this->total_category_num . " " . $wb->vars["Lang"]["lang_records"] . " " . $wb->vars["Lang"]["lang_current"] . $wb->current_category_page . "/" . $wb->total_category_page . " " . $wb->vars["Lang"]["lang_page"], 20, $nav_button_y + 5, 150, 14, 0, WBC_VISIBLE, 0, 1);
     $category_nav_first = wb_create_control($this->left_control, PushButton, $wb->vars["Lang"]["lang_first_page"], $nav_button_x, $nav_button_y, 80, 22, IDC_CATEGORY_NAV_FIRST, WBC_VISIBLE, 0, 1);
     $category_nav_pre = wb_create_control($this->left_control, PushButton, $wb->vars["Lang"]["lang_pre_page"], $nav_button_x + $nav_button_space, $nav_button_y, 80, 22, IDC_CATEGORY_NAV_PRE, WBC_VISIBLE, 0, 1);
     $category_nav_next = wb_create_control($this->left_control, PushButton, $wb->vars["Lang"]["lang_next_page"], $nav_button_x + $nav_button_space * 2, $nav_button_y, 80, 22, IDC_CATEGORY_NAV_NEXT, WBC_VISIBLE, 0, 1);
     $category_nav_last = wb_create_control($this->left_control, PushButton, $wb->vars["Lang"]["lang_last_page"], $nav_button_x + $nav_button_space * 3, $nav_button_y, 80, 22, IDC_CATEGORY_NAV_LAST, WBC_VISIBLE, 0, 1);
     //category
     if ($wb->current_category_page == $wb->total_category_page) {
         wb_set_enabled($category_nav_next, false);
         wb_set_enabled($category_nav_last, false);
     }
     if ($wb->current_category_page == 1) {
         wb_set_enabled($category_nav_pre, false);
         wb_set_enabled($category_nav_first, false);
     }
 }