Beispiel #1
0
function process_main($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0)
{
    global $wb;
    switch ($id) {
        case ID_CREATE:
            $wb->current_ids = null;
            $wb->current_action = "insert";
            switch ($wb->current_module) {
                case "contact":
                    include_once PATH_FORM . "yc_contact_edit.form.inc.php";
                    create_contact_edit_dlg();
                    break;
                case "contact_category":
                case "company":
                case "product":
                case "product_category":
                case "opportunity":
                case "order":
                case "order_category":
                case "agreement":
                case "agreement_category":
                case "complaints":
                case "complaints_category":
                case "refundment":
                case "refundment_category":
                case "review":
                    $module_name = $wb->current_module;
                    $function_name = "create_{$module_name}_edit_dlg";
                    include_once PATH_FORM . "yc_{$module_name}_edit.form.inc.php";
                    $function_name();
                    break;
            }
            wb_set_text($wb->statusbar, "Create module: " . $wb->current_module);
            break;
        case IDC_TOOLBAR_SEARCH:
            switch ($wb->current_module) {
                case "contact":
                    create_contact_search_dlg($window);
                    break;
                case "contact_category":
                    create_category_contact_search_dlg($window);
                    break;
                case "company":
                case "product":
                case "product_category":
                case "opportunity":
                case "order":
                case "order_category":
                case "agreement":
                case "agreement_category":
                case "complaints":
                case "complaints_category":
                case "refundment":
                case "refundment_category":
                case "review":
                    $module_name = $wb->current_module;
                    $function_name = "create_{$module_name}_search_dlg";
                    include_once PATH_FORM . "yc_{$module_name}_search.form.inc.php";
                    $function_name();
                    break;
            }
            wb_set_text($wb->statusbar, "Search module: " . $wb->current_module);
            break;
        case ID_DELETE:
            switch ($wb->current_module) {
                case "contact":
                    del_selected_contact();
                    break;
                case "contact_category":
                case "company":
                case "product":
                case "product_category":
                case "opportunity":
                case "order":
                case "order_category":
                case "agreement":
                case "agreement_category":
                case "complaints":
                case "complaints_category":
                case "refundment":
                case "refundment_category":
                case "review":
                    $module_name = $wb->current_module;
                    $function_name = "del_selected_{$module_name}";
                    $function_name();
                    break;
            }
            wb_set_text($wb->statusbar, "Deleted module: " . $wb->current_module);
            break;
        case IDC_LEFT_TREE:
            $selnode = wb_get_selected($wb->tree_view);
            if ($wb->right_control) {
                wb_set_visible($wb->right_control, false);
            }
            switch (wb_get_value($wb->tree_view)) {
                case 2001:
                case 2002:
                    $wb->current_module = "contact";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    displayContactForm();
                    break;
                case 2003:
                    $wb->current_module = "company";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_company.form.inc.php";
                    displayCompanyMainTabForm();
                    break;
                case 2004:
                    $wb->current_module = "product";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_product.form.inc.php";
                    display_product_main_tab_form();
                    break;
                case 2005:
                case 2006:
                    $wb->current_module = "opportunity";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_opportunity.form.inc.php";
                    display_opportunity_main_tab_form();
                    break;
                case 2007:
                    $wb->current_module = "order";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_order.form.inc.php";
                    display_order_main_tab_form();
                    break;
                case 2008:
                    $wb->current_module = "agreement";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_agreement.form.inc.php";
                    display_agreement_main_tab_form();
                    break;
                case 2009:
                case 2010:
                    $wb->current_module = "complaints";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_complaints.form.inc.php";
                    display_complaints_main_tab_form();
                    break;
                case 2011:
                    $wb->current_module = "refundment";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_refundment.form.inc.php";
                    display_refundment_main_tab_form();
                    break;
                case 2012:
                    $wb->current_module = "review";
                    $wb->keyword = null;
                    $wb->current_page = 1;
                    $wb->del_ids = null;
                    include_once PATH_FORM . "yc_review.form.inc.php";
                    display_review_main_tab_form();
                    break;
            }
            wb_set_text($wb->statusbar, "Selected item: " . wb_get_text($wb->tree_view, $selnode) . " / Value: " . wb_get_value($wb->tree_view) . " / Parent: " . wb_get_parent($wb->tree_view, $selnode) . " / Level: " . wb_get_level($wb->tree_view, $selnode) . " / State: " . (wb_get_state($wb->tree_view, $selnode) ? "expanded" : "collapsed"));
            break;
        case IDCLOSE:
            // IDCLOSE is predefined
            if (wb_message_box($wb->mainwin, $wb->vars["Lang"]["lang_sure_logout"], $wb->vars["Lang"]["system_name"], WBC_QUESTION | WBC_YESNO)) {
                wb_destroy_window($window);
            }
            break;
        case ID_ABOUT:
            include_once PATH_FORM . "yc_about.form.inc.php";
            display_about_dlg();
            break;
        case ID_SETTING:
            include_once PATH_FORM . "yc_setting.form.inc.php";
            display_setting_dlg();
            break;
        default:
            if (process_contact($window, $id, $ctrl, $lparam1, $lparam2)) {
                break;
            }
            if (wb_get_class($ctrl) == TabControl && $lparam1 & WBC_HEADERSEL) {
                switch ($id) {
                    case IDC_CONTACT_FORM:
                        if ($lparam2 == 0) {
                            $wb->current_module = "contact";
                        } else {
                            $wb->current_module = "contact_category";
                        }
                        break;
                    case IDC_PRODUCTS_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "product";
                        } else {
                            $wb->current_module = "product_category";
                        }
                        break;
                    case IDC_ORDER_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "order";
                        } else {
                            $wb->current_module = "order_category";
                        }
                        break;
                    case IDC_AGREEMENT_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "agreement";
                        } else {
                            $wb->current_module = "agreement_category";
                        }
                        break;
                    case IDC_COMPLAINTS_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "complaints";
                        } else {
                            $wb->current_module = "complaints_category";
                        }
                        break;
                    case IDC_REFUNDMENT_TAB:
                        if ($lparam2 == 0) {
                            $wb->current_module = "refundment";
                        } else {
                            $wb->current_module = "refundment_category";
                        }
                        break;
                }
                wb_set_text($wb->statusbar, "Tab #{$lparam2} of tab control #{$id} selected.");
            } else {
                wb_set_text($wb->statusbar, "Control ID: " . $id);
            }
            break;
    }
}
function process_contact($window, $id, $ctrl, $lparam1 = 0, $lparam2 = 0)
{
    global $wb;
    switch ($id) {
        case IDC_NAV_FIRST:
            $wb->current_page = 1;
            reset_contact_view();
            break;
        case IDC_NAV_PRE:
            $wb->current_page -= 1;
            $wb->current_page = $wb->current_page < 1 ? 1 : $wb->current_page;
            reset_contact_view();
            break;
        case IDC_NAV_NEXT:
            $wb->current_page += 1;
            $wb->current_page = $wb->current_page > $wb->total_page ? $wb->total_page : $wb->current_page;
            reset_contact_view();
            return true;
        case IDC_NAV_LAST:
            $wb->current_page = $wb->total_page;
            reset_contact_view();
            break;
        case IDC_CONTACT_DATA_LIST:
            if ($lparam1 == WBC_DBLCLICK) {
                $current_rows = wb_get_text($ctrl);
                $current_id = $current_rows[0][0];
                $wb->current_ids = $current_id;
                $wb->current_form_state = false;
                $wb->current_action = 'update';
                include_once PATH_FORM . "yc_contact_edit.form.inc.php";
                create_contact_edit_dlg();
            }
            // Show current selection and checked items
            $sel = wb_get_selected($ctrl);
            $sel = $sel ? implode(", ", $sel) : "none";
            $contents = wb_get_text($ctrl);
            $text = "";
            if ($contents) {
                foreach ($contents as $row) {
                    $text .= $row ? "[" . implode(", ", $row) . "]  " : "";
                }
            }
            $checked = wb_get_value($wb->contact_list);
            $temp_str = "";
            if ($checked) {
                foreach ($checked as $value) {
                    $row_data = wb_get_text($wb->contact_list, $value, 0);
                    $temp_str .= $row_data . ",";
                }
                $del_ids = rtrim($temp_str, ',');
                $wb->del_ids = $del_ids;
            }
            $checked = $checked ? implode(", ", $checked) : "none";
            wb_set_text($wb->statusbar, "Selected lines: " . $sel . " / checked: " . $checked . " / deleted: " . $del_ids . " / contents: " . $text);
            return true;
        case IDC_CONTACT_CATEGORY_DATA_LIST:
            if ($lparam1 == WBC_DBLCLICK) {
                $current_rows = wb_get_text($ctrl);
                $current_id = $current_rows[0][0];
                $wb->current_ids = $current_id;
                $wb->current_form_state = false;
                $wb->current_action = 'update';
                include_once PATH_FORM . "yc_contact_category_edit.form.inc.php";
                create_contact_category_edit_dlg();
            }
            // Show current selection and checked items
            $sel = wb_get_selected($ctrl);
            $sel = $sel ? implode(", ", $sel) : "none";
            $contents = wb_get_text($ctrl);
            $text = "";
            if ($contents) {
                foreach ($contents as $row) {
                    $text .= $row ? "[" . implode(", ", $row) . "]  " : "";
                }
            }
            $checked = wb_get_value($wb->contact_category_list);
            $temp_str = "";
            if ($checked) {
                foreach ($checked as $value) {
                    $row_data = wb_get_text($wb->contact_category_list, $value, 0);
                    $temp_str .= $row_data . ",";
                }
                $del_ids = rtrim($temp_str, ',');
                $wb->del_ids = $del_ids;
            }
            $checked = $checked ? implode(",", $checked) : "none";
            wb_set_text($wb->statusbar, "Selected lines: " . $sel . " / checked: " . $checked . " / deleted: " . $del_ids . " / contents: " . $text);
            return true;
    }
    return false;
}