Esempio n. 1
0
 public static function getFieldsConfig()
 {
     $obj = array_merge(parent::getFieldsConfig(), array('_seo_title_preview' => array('DataType' => 'Text', 'FieldClass' => 'FlowField', 'Description' => array('vi-VN' => sprintf(Qdmvc_Message::getMsg('fd_seometa_field_title'), 'chi tiết BDS'))), '_seo_description_preview' => array('DataType' => 'Text', 'FieldClass' => 'FlowField', 'Description' => array('vi-VN' => sprintf(Qdmvc_Message::getMsg('fd_seometa_field_description'), 'chi tiết BDS'))), '_product_cat_name' => array('Name' => '_product_cat_name', 'Caption' => array('en-US' => 'Product Cat Name', 'vi-VN' => 'Vị trí BDS'), 'Description' => array(), 'DataType' => 'Text', 'FieldClass' => 'FlowField', 'FieldClass_FlowField' => array('Method' => 'Lookup', 'Table' => 'QdProductCat', 'Field' => 'name', 'TableFilter' => array(0 => array('Field' => 'id', 'Type' => 'FIELD', 'Value' => 'product_cat_id')))), '_price_discount' => array('Name' => '_price_discount', 'DataType' => 'Decimal', 'FieldClass' => 'FlowField', 'Description' => array('vi-VN' => sprintf('Giá sau khi giảm - sửa Field \'discount_percent\' để thay đổi'))), 'product_cat_id' => array('Name' => 'product_cat_id', 'Caption' => array('en-US' => 'Product Cat ID', 'vi-VN' => 'Mã Vị trí BDS'), 'DataType' => 'Code', 'Numeric' => true, 'Description' => array(), 'Editable' => true, 'InitValue' => '0', 'FieldClass' => 'Normal', 'TableRelation' => array('Table' => 'QdProductCat', 'Field' => 'id', 'TableFilter' => array()), 'DataPort' => 'product_cat_port'), 'avatar' => array('Caption' => array('en-US' => 'Avatar', 'vi-VN' => 'Hình đại diện'), 'DataType' => 'Image', 'Description' => array('vi-VN' => 'Hình đại diện hiển thị ở trang tìm kiếm SP hoặc những khu vực tương tự (hình đơn)<br>Muốn chọn nhiều hình cho trang chi tiết SP, dùng chức năng \'Hình ảnh\' để thêm hình'), 'Require' => true), '_avatar_preview' => array('Caption' => array('en-US' => 'Image Preview', 'vi-VN' => 'Xem trước'), 'DataType' => 'ImagePreview', 'FieldClass' => 'System', 'ImagePreviewField' => 'avatar'), 'active' => array('Caption' => array('en-US' => 'Active', 'vi-VN' => 'Kích hoạt'), 'DataType' => 'Boolean', 'InitValue' => true, 'Description' => array('vi-VN' => 'Có hiển thị ra ngoài Web hay không ?'), 'ReadOnly' => true), 'name' => array('Caption' => array('vi-VN' => 'Tên SP'), 'Require' => true), 'price' => array('Caption' => array('vi-VN' => 'Giá')), 'description' => array('Caption' => array('vi-VN' => 'Mô tả'), 'DataType' => 'WYSIWYG', 'Description' => array('vi-VN' => 'Thông tin mô tả phía dưới Hình đại diện, trang chi tiết BDS'), 'Require' => true), 'stock_status' => array('Caption' => array('vi-VN' => 'Tình trạng BDS'), 'DataType' => 'Option', 'Description' => array('vi-VN' => 'Đánh dấu tình trạng kho của SP'), 'Options' => array(static::$STOCK_DF => array('Caption' => array('en-US' => 'Default', 'vi-VN' => 'Mặc định')), static::$STOCK_FINISH => array('Caption' => array('en-US' => 'Finish', 'vi-VN' => 'Đã hoàn tất')), static::$STOCK_NGUNG => array('Caption' => array('en-US' => 'Stop', 'vi-VN' => 'Ngưng giao dịch')))), 'discount_percent' => array('DataType' => 'Decimal', 'Caption' => array('en-US' => 'Manual Discount Amt', 'vi-VN' => '% Giảm giá'), 'Description' => array('vi-VN' => '% giảm giá so với Field \'Giá\', nhập số thập phân vd: 0.56<br>Độ ưu tiên thấp hơn \'Giảm giá\'')), 'struct_lv_1' => array('Caption' => array('en-US' => 'Category', 'vi-VN' => 'Nhóm SP'), 'DataType' => 'Option', 'Options' => array(QdProductCat::$LV1_DF => array('Caption' => array('en-US' => 'Default', 'vi-VN' => 'Mặc định')), QdProductCat::$LV1_BAN => array('Caption' => array('en-US' => 'Selling', 'vi-VN' => 'Bán')), QdProductCat::$LV1_CHOTHUE => array('Caption' => array('en-US' => 'For rent', 'vi-VN' => 'Cho thuê')))), 'price_range_type' => array(), 'noseries' => array(), '_permalink' => array('Name' => '_permalink', 'DataType' => 'Text', 'FieldClass' => 'FlowField'), 'manual_discount_amt' => array('Caption' => array('en-US' => 'Manual Discount Amt', 'vi-VN' => 'Giảm giá'), 'DataType' => 'Integer', 'Description' => array('vi-VN' => 'Giá giảm giá so với \'Giá\', nhập số nguyên vd: 135000<br>Độ ưu tiên cao hơn \'% Giảm giá\'')), 'dtdat' => array('DataType' => 'Decimal', 'Caption' => array('en-US' => 'Dien tich dat', 'vi-VN' => 'Diện tích đất'), 'Description' => array('vi-VN' => '')), 'dtxaydung' => array('DataType' => 'Decimal', 'Caption' => array('en-US' => 'Dien tich xay dung', 'vi-VN' => 'Diện tích xây dựng'), 'Description' => array('vi-VN' => 'Hiển thị trên trang chi tiết BDS')), 'dtsudung' => array('DataType' => 'Decimal', 'Caption' => array('en-US' => 'Dien tich su dung', 'vi-VN' => 'Diện tích sử dụng'), 'Description' => array('vi-VN' => 'Hiển thị trên trang chi tiết BDS')), 'phaply' => array('DataType' => 'WYSIWYG', 'Caption' => array('en-US' => 'Phap ly', 'vi-VN' => 'Pháp lý'), 'Description' => array('vi-VN' => 'Pháp lý')), 'thongtinlh' => array('DataType' => 'WYSIWYG', 'Caption' => array('en-US' => 'Contact Info', 'vi-VN' => 'Thông tin liên hệ'), 'Description' => array('vi-VN' => 'Định nghĩa trong \'Cấu hình khác\'')), 'ggm_embeded' => array('DataType' => 'Text', 'Caption' => array('en-US' => 'Google Map Embeded', 'vi-VN' => 'Mã nhúng Google Map'), 'Description' => array('vi-VN' => 'Mã nhúng Google dạng iFrame'))));
     $obj['id']['Description'] = array('vi-VN' => sprintf('Mã BDS quản lý trong hệ thống, không hiển thị trên Web<br>Muốn hiển thị mã trên Web, dùng Field \'%s\'', $obj['code']['Caption']['vi-VN']));
     $obj['__sys_lines_url']['Caption'] = array('en-US' => 'Related Products', 'vi-VN' => 'BDS liên kết');
     $obj['__sys_lines_url']['TableRelation'] = array('Table' => 'QdPro2Pro', 'Field' => 'id', 'TableFilter' => array(array('Condition' => array('Field' => '', 'Type' => 'CONST', 'Value' => ''), 'Field' => 'product_id', 'Type' => 'FIELD', 'Value' => 'id')));
     $obj['__sys_seometa_url'] = array('FieldClass' => 'System', 'Caption' => array('en-US' => 'SEO Meta', 'vi-VN' => 'SEO Meta'), 'TableRelation' => array('Table' => 'QdSEOMeta', 'Field' => 'id', 'TableFilter' => array(array('Condition' => array('Field' => '', 'Type' => 'CONST', 'Value' => ''), 'Field' => 'model_id', 'Type' => 'FIELD', 'Value' => 'id'), array('Condition' => array('Field' => '', 'Type' => 'CONST', 'Value' => ''), 'Field' => 'model', 'Type' => 'CONST', 'Value' => 'QdProduct'))));
     $obj['id']['ReadOnly'] = false;
     /*
             $obj['__sys_lines_url'] = array(
                 'FieldClass' => 'System',
                 'Caption' => array('en-US' => 'UOM', 'vi-VN' => 'Đơn vị tính'),
                 'TableRelation' => array(
                     'Table' => 'QdProUOM',
                     'Field' => 'id',
                     'TableFilter' => array(
                         array(
                             'Condition' => array(
                                 'Field' => '',
                                 'Type' => 'CONST',//'FIELD'
                                 'Value' => ''
                             ),
                             'Field' => 'product_id',
                             'Type' => 'FIELD',
                             'Value' => 'id'
                         )
                     )
                 )
             );*/
     $obj['__sys_lines_url']['TableRelation'] = array('Table' => 'QdPro2Pro', 'Field' => 'id', 'TableFilter' => array(array('Field' => 'product_id', 'Type' => 'FIELD', 'Value' => 'id')));
     return $obj;
 }
Esempio n. 2
0
/**
 * Created by PhpStorm.
 * User: quocd_000
 * Date: 27/05/2015
 * Time: 10:20 PM
 */
class Qdmvc_Message
{
    private static $custom_loaded = false;
    private static $msg = array('msg_update_ok' => 'Cập nhật thành công, ID = %s', 'msg_delete_ok' => 'Xóa thành công, ID = %s', 'msg_insert_ok' => 'Thêm mới thành công, ID = %s', 'msg_confirm' => 'Bạn có chắc ?', 'msg_logout' => 'Đăng xuất', 'msg_confirm_deletion' => 'Xác nhận xóa', 'msg_confirm_callfn' => 'Xác nhận thực thi cho', 'msg_fk_constrain' => '%s mã %s đã được gán cho %s mã %s', 'msg_field_mandatory' => 'ID: %s, %s bắt buộc phải có giá trị', 'btn_viewreport' => 'Xem báo cáo', 'btn_addtosel' => 'Đánh dấu chọn', 'btn_save' => 'Lưu', 'btn_delete' => 'Xóa', 'btn_new' => 'Tạo mới', 'btn_clone' => 'Sao chép', 'btn_wpeditordone' => 'Hoàn tất', 'btn_choose' => 'Chọn', 'btn_gotopagenavigate' => 'Bật chế độ chỉnh sửa', 'btn_log' => 'Nhật ký', 'btn_note' => 'Ghi chú', 'btn_image' => 'Hình ảnh', 'btn_function' => 'Chức năng', 'btn_reloadcard' => 'Tải lại', 'btn_print' => 'In', 'btn_exportexcel' => 'Xuất Excel', 'btn_showall' => 'Xem tất cả', 'btn_active' => 'Kích hoạt', 'btn_deactive' => 'Ngưng kích hoạt', 'btn_multiselection' => 'Bật chọn nhiều', 'btn_multiselection_guide' => 'Dùng kết hợp các phím Ctrl, Shift, Lên, Xuống: để chọn nhiều dòng', 'btn_singleselection' => 'Tắt chọn nhiều', 'btn_selectallrows' => 'Chọn tất cả', 'btn_clearfilter' => 'Gỡ bộ lọc', 'btn_scancode' => 'Quét mã QR', 'fd_seometa_field_title' => 'Tiêu đề Web hiển thị thực tế khi người dùng mở trang %s<br>Dùng chức năng SEO Meta để thay đổi', 'fd_seometa_field_description' => 'Mô tả Web hiển thị thực tế khi người dùng mở trang %s<br>Dùng chức năng SEO Meta để thay đổi');
    private static $msg2 = array('msg_update_ok' => 'Update OK, ID = %s', 'msg_delete_ok' => 'Delete OK, ID = %s', 'msg_insert_ok' => 'Insert OK, ID = %s', 'msg_confirm' => 'Are you sure ?', 'msg_logout' => 'Logout', 'msg_confirm_deletion' => 'Confirm deletion', 'msg_confirm_callfn' => 'Confirm execution for', 'msg_fk_constrain' => '%s with ID %s was assigned to %s with ID %s', 'msg_field_mandatory' => 'ID: %s, %s must have a value', 'btn_viewreport' => 'View report', 'btn_addtosel' => 'Mark selection', 'btn_save' => 'Save', 'btn_delete' => 'Delete', 'btn_new' => 'New', 'btn_clone' => 'Clone', 'btn_wpeditordone' => 'Done', 'btn_choose' => 'Choose', 'btn_gotopagenavigate' => 'Open editor', 'btn_log' => 'Logs', 'btn_note' => 'Notes', 'btn_image' => 'Images', 'btn_function' => 'Functions', 'btn_reloadcard' => 'Reload', 'btn_print' => 'Print', 'btn_exportexcel' => 'Export Excel', 'btn_showall' => 'Show All', 'btn_active' => 'Active', 'btn_deactive' => 'Deactive', 'btn_multiselection' => 'Turn on multi-select', 'btn_multiselection_guide' => 'Use Ctrl, Shift, Up, Down keys in combination to implement multi rows selection', 'btn_singleselection' => 'Turn off multi-select', 'btn_selectallrows' => 'Select all', 'btn_clearfilter' => 'Clear filter', 'btn_scancode' => 'Scan QR code');
    public static function getMsg($key)
    {
        if (Qdmvc_Config::getLanguage() == 'vi-VN') {
            return isset(static::$msg[$key]) ? static::$msg[$key] : '@' . $key;
        } else {
            return isset(static::$msg2[$key]) ? static::$msg2[$key] : '@' . $key;
        }
    }
    public static function loadCustom()
    {
        if (static::$custom_loaded === false) {
            Qdmvc::loadIndex('messages/custom');
            static::$msg = array_merge(static::$msg, Qdmvc_Message_Custom::$msg);
            static::$msg2 = array_merge(static::$msg2, Qdmvc_Message_Custom::$msg2);
            static::$custom_loaded = true;
        }
    }
}
Qdmvc_Message::loadCustom();
    protected function btnDeleteAction()
    {
        //Multi item deletion
        ?>
        <script>
            (function ($) {
                $(document).ready(function () {
                    $("#qddelete").bind("click", function (event) {
                        //get Grid
                        var gridf = MYAPP.getGridFrame();
                        var grid = gridf.MYAPP.getGrid();
                        var msg_confirm = '<?php 
        echo Qdmvc_Message::getMsg('msg_confirm_deletion');
        ?>
';

                        if (gridf.MYAPP.isMultiSelection()) {
                            var list_ids = gridf.MYAPP.getSelectedRowsId();
                            if (!confirm(msg_confirm + " "+list_ids+" ?")) {
                                return false;
                            }
                            //AJAX loader
                            MYAPP.ajax_loader = new ajaxLoader("#cardForm");

                            if(list_ids.length > 0){
                                $.post(MYAPP.data_port, {submit: "submit", action: "delete_multi", data: {id: list_ids}})
                                    .done(function (data) {

                                        MYAPP.formValidation = data.msg;
                                        //....
                                        MYAPP.showMsg(data.msg);

                                        <?php 
        echo $this->OnDeleteOK();
        ?>
                                    })
                                    .fail(function (data) {
                                        console.log("FAIL:" + data);
                                    })
                                    .always(function () {
                                        //release lock
                                        MYAPP.ajax_loader.remove();
                                    });
                            }
                        } else {
                            var id_ = MYAPP.viewModel.id();
                            if (!confirm(msg_confirm + " "+id_+"?")) {
                                return false;
                            }
                            //AJAX loader
                            MYAPP.ajax_loader = new ajaxLoader("#cardForm");

                            $.post(MYAPP.data_port, {submit: "submit", action: "delete", data: {id: id_}})
                                .done(function (data) {
                                    //data JSON
                                    //var obj = data;//"ok";//jQuery.parseJSON( data );//may throw error if data aldreay JSON format
                                    MYAPP.formValidation = data.msg;
                                    //....
                                    MYAPP.showMsg(data.msg);

                                    <?php 
        echo $this->OnDeleteOK();
        ?>
                                })
                                .fail(function (data) {
                                    console.log("FAIL:" + data);
                                })
                                .always(function () {
                                    //release lock
                                    MYAPP.ajax_loader.remove();
                                });
                        }
                    });
                })
            })(jQuery);

        </script>
    <?php 
    }
    public function render()
    {
        $this->style();
        parent::render();
        $this->onReadyHook();
        ?>
        <div id="qdmvcRootDiv" style="display: none; width: inherit; height: inherit">
            <style>
                #wpbody-content {
                    overflow-y: hidden !important;
                }
            </style>
            <script>
                MYAPP = {};
                MYAPP.openInNewTab = function (url) {
                    if (window == window.parent) {
                        window.open(url, '_blank');
                        return;
                    }
                    window.parent.MYAPP.openInNewTab(url);
                };
                MYAPP.TreeUnflatten = function( array, parent, tree ){

                    tree = typeof tree !== 'undefined' ? tree : [];
                    parent = typeof parent !== 'undefined' ? parent : { key: -1 };

                    var children = _.filter( array, function(child){ return child.parentid == parent.key; });

                    if( !_.isEmpty( children )  ){
                        if( parent.key == -1 ){
                            tree = children;
                        }else{
                            parent['children'] = children
                        }
                        _.each( children, function( child ){ MYAPP.TreeUnflatten( array, child ) } );
                    }

                    return tree;
                };

                (function ($) {
                    $(document).ready(function () {
                        //height = $(window).height()-3;

                        $("#splitter").jqxSplitter({width: '100%', height: '100%', panels: [{size: 230}]});
                        $("#splitter2").jqxSplitter({orientation: 'horizontal', width: '100%', height: '100%', panels: [{size: '90%'}]});

                        // Create jqxTree
                        Array.prototype.insert = function (index, item) {
                            this.splice(index, 0, item);
                        };

                        var data = <?php 
        echo Qdmvc_Page_Index::buildJSONTree($this->data['language']);
        ?>
;
                        data = MYAPP.TreeUnflatten(data);
                        var autoexpand = false;
                        <?php 
        if ($this->data['setup']->autoexpandmenu == true) {
            ?>
                        autoexpand = true;
                        <?php 
        }
        ?>

                        $("#jqxTree").fancytree({
                            extensions: ["filter"],
                            quicksearch: true,
                            checkbox: false,
                            source: data,
                            autoScroll: true,
                            filter: {
                                autoApply: true,  // Re-apply last filter if lazy data is loaded
                                counter: true,  // Show a badge with number of matching child nodes near parent icons
                                fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
                                hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
                                highlight: true,  // Highlight matches by wrapping inside <mark> tags
                                mode: "hide"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
                            },
                            click: function(event, data) {
                                var node = data.node;
                                //add tab
                                var args = event.args;

                                var label = node.title;
                                var url = node.data.value;
                                if (url == '') {
                                    return;//ignore folder
                                }

                                //check existed
                                var totaltab = $('#jqxTabs').jqxTabs('length');
                                var i = 0;
                                for (i = 0; i < totaltab; i++) {
                                    var title = $('#jqxTabs').jqxTabs('getTitleAt', i);
                                    if (title == label) {
                                        $('#jqxTabs').jqxTabs('select', i);//switch to tab
                                        return;//ignore duplicate tab
                                    }
                                }

                                $('#jqxTabs').jqxTabs('addLast', label, '<iframe id="pagepart" src="' + url + '" width="100%" height="99%" scrolling="yes" frameborder="0"><p>Your browser does not support iframes</p> </iframe>');
                            },
                            create: function(event, data){
                                //alert('create done');
                            },
                            init: function(event, data){
                                if(autoexpand!=undefined && autoexpand==true) {
                                    $("#jqxTree").fancytree("getRootNode").visit(function (node) {
                                        node.setExpanded(true);
                                    });
                                }
                            }
                        });

                        //Tabs
                        $('#jqxTabs').jqxTabs({height: '100%', width: '100%', showCloseButtons: true, reorder: true});


                        /*Handle Tab Panel Context Menu
                        var contextMenu = $("#jqxMenu").jqxMenu({ width: '120px', height: '80px', autoOpenPopup: false, mode: 'popup'});
                        $("#jqxMenu").bind('itemclick', function(event)
                        {
                            var item = $(event.args).text();
                            var tabS = $('#jqxTabs');
                            switch (item)
                            {
                                case "Close Others":
                                    var currentIndex = tabS.jqxTabs('selectedItem');
                                    var currentTabTitle = tabS.jqxTabs('getTitleAt', currentIndex);
                                    for(var kk=currentIndex+1;kk<tabS.jqxTabs('length');kk++)
                                    {
                                        tabS.jqxTabs('removeAt', kk);
                                    }
                                    while(tabS.jqxTabs('length') > 1){
                                        tabS.jqxTabs('removeFirst');
                                    }
                                    break;
                                case "Close All":

                                    while(tabS.jqxTabs('length') > 0){
                                        tabS.jqxTabs('removeLast');
                                    }
                                    break;
                            }
                        });
                        */
                        // open the context menu when the user presses the mouse right button.
                        $("#jqxTabs").bind('mousedown', function (event) {
                            var rightClick = isRightClick(event);
                            if (rightClick) {
                                var scrollTop = $(window).scrollTop();
                                var scrollLeft = $(window).scrollLeft();

                                contextMenu.jqxMenu('open', parseInt(event.clientX) + 5 + scrollLeft, parseInt(event.clientY) + 5 + scrollTop);
                                return false;
                            }
                        });
                        /*

                        // disable the default browser's context menu.
                        $(document).bind('contextmenu', function (e) {
                            //return false;
                        });
                        */

                        function isRightClick(event) {
                            var rightclick;
                            if (!event) var event = window.event;
                            if (event.which) rightclick = (event.which == 3);
                            else if (event.button) rightclick = (event.button == 2);
                            return rightclick;
                        }
                        /*Handle Context Menu*/
                        $("#searchbox").keyup(function(e){
                            var match = $(this).val();
                            var tree = $("#jqxTree").fancytree("getTree");
                            if(e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === ""){
                                //reset filter
                                tree.clearFilter();
                                return;
                            }

                            // Pass text as filter string (will be matched as substring in the node title)
                            var n = tree.filterNodes(match, {autoExpand: true});
                        }).focus();

                    });
                })(jQuery);
            </script>
            <div id="splitter">
                <div>
                    <div id="splitter2">
                        <div>
                            <div style="width: 100%;">
                                <div style="float: left;">Search:</div>
                                <input id="searchbox" style="float: left;" />
                                <div style="clear: both"></div>
                            </div>

                            <div id='jqxTree' style="height: 95%; overflow: auto;">

                            </div>
                        </div>
                        <div>
                            <a target="_blank" href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        $tmp = wp_get_current_user();
        echo $tmp->user_login;
        ?>
 </a> |
                            <a onclick="return confirm('<?php 
        echo Qdmvc_Message::getMsg('msg_confirm');
        ?>
')"
                               href="<?php 
        echo wp_logout_url(Qdmvc_Helper::getCompactPageListLink('navigation'));
        ?>
">
                                <?php 
        echo Qdmvc_Message::getMsg('msg_logout');
        ?>
                            </a>
                        </div>
                    </div>

                </div>
                <div id="ContentPanel">
                    <!--
                    <div id='jqxMenu'>
                        <ul>
                            <li>Close Others</li>
                            <li>Close All</li>
                        </ul>
                    </div>-->
                    <div id='jqxTabs' style="float: left;">
                        <ul style="margin-left: 30px;" id="unorderedList">
                            <li>Home</li>
                        </ul>
                        <div>
                            Home page content
                        </div>
                    </div>
                </div>
            </div>
            <script>
                (function ($) {
                    $(document).ready(function () {
                        $('#panelContentpaneljqxTree li').click(function () {
                            //alert('wtf');
                        });


                    });
                })(jQuery);
            </script>
            <style>
                #hidden {
                    display: none
                }
            </style>
        </div>
    <?php 
    }
Esempio n. 5
0
 protected function delete($id)
 {
     $this->working_mode = 'delete_fail';
     if (!static::canDelete()) {
         $this->pushMsg('Permission: Could not Delete!', 'error');
         return;
     }
     $c = static::$model;
     $this->obj = $c::GET($id);
     if ($this->obj == null) {
         $this->pushMsg('Record does not existed for delete, ID=' . $id, 'error');
         return;
     }
     $class_name = $this->getCalledClassName();
     $location = "|{$class_name}|delete";
     if (!$this->checkPermission(__FUNCTION__)) {
         return false;
     }
     if ($this->obj->delete($location)) {
         $this->pushMsg(sprintf(Qdmvc_Message::getMsg('msg_delete_ok'), $this->obj->id));
         $this->working_mode = 'delete_ok';
         return true;
     } else {
         $this->pushMsg($this->obj->GETVALIDATION());
         return false;
     }
 }
Esempio n. 6
0
    protected function onReadyHook()
    {
        parent::onReadyHook();
        //must place at the end or knockout not binding to appended html
        ?>
        <script type="text/javascript">
            (function ($) {
                $(document).ready(function () {
                    var btn_active_label = '<?php 
        echo Qdmvc_Message::getMsg('btn_active');
        ?>
';
                    var btn_deactive_label = '<?php 
        echo Qdmvc_Message::getMsg('btn_deactive');
        ?>
';
                    //Change Button label
                    $('#cardForm input[name=active]').on('change', function(){
                        var label = this.checked?btn_deactive_label:btn_active_label;
                        $('#btn_active').html(label);
                    });
                    //
                    $('#btn_active').click(function () {
                        MYAPP.callFn('fn_active', null, function (data) {
                            if (data.fn_result != false) {
                                console.log(data.fn_result.subinfo);
                            }
                        });
                    });

                    $('#qdsysbtn').append(
                        '<button class="btn btn-info btn-xs qd-action-btn" type="button" id="qdseometa" style="display: inline-block">' +
                        '<span data-bind="text: MYAPP.getURIParam($root.__sys_seometa_url(),\'item_count\')"></span>' +
                        ' <?php 
        echo $this->page->getFieldCaption("__sys_seometa_url", $this->data["language"]);
        ?>
' +
                        '</button>'
                    );
                    $("#qdseometa").bind("click", function (event) {
                        MYAPP.requestLookupWindow(MYAPP.getObj()['__sys_seometa_url']);
                    });
                    $('#btn_view_in_frontend').click(function () {
                        MYAPP.openInNewTab(MYAPP.viewModel._permalink());
                    });
                    $('#btn_view_qrcode').click(function () {
                        var qrlink = MYAPP.getQRCodeLink(MYAPP.viewModel.id());
                        MYAPP.openInNewTab(qrlink);
                    });
                    $('#lookup_cs_manufacturer_id').click(function () {
                        var lurl = $(this).data('lookupurl');
                        var struct_lv_2 = MYAPP.viewModel.struct_lv_2();
                        if (struct_lv_2 != '') {
                            lurl = MYAPP.addDataPortFilter(lurl, 199, 'struct_lv_2', struct_lv_2);
                        }
                        MYAPP.requestLookupWindow(lurl);
                    });

                    $('#lookup_cs_product_cat_id').click(function () {
                        var lurl = $(this).data('lookupurl');
                        MYAPP.requestLookupWindow(lurl, function(obj){
                            //set struct value
                            MYAPP.viewModel.struct_lv_1(obj[0].struct_lv_1);
                            MYAPP.viewModel.struct_lv_2(obj[0].struct_lv_2);
                            MYAPP.viewModel.struct_lv_3(obj[0].struct_lv_3);
                            MYAPP.viewModel.struct_lv_4(obj[0].struct_lv_4);
                        });
                    });

                    if($('#lookup_cs_size_id').length > 0){
                        $('#lookup_cs_size_id').click(function () {
                            var lurl = $(this).data('lookupurl');
                            var struct_lv_4 = MYAPP.viewModel.struct_lv_4();
                            if (struct_lv_4 != '') {
                                lurl = MYAPP.addDataPortFilter(lurl, 199, 'type', struct_lv_4);
                            }
                            MYAPP.requestLookupWindow(lurl);
                        });
                    }
                });
            })(jQuery);
        </script>
    <?php 
    }
Esempio n. 7
0
 protected function getToolbar()
 {
     $obj = array('qdchoose' => array('Order' => 0, 'Label' => Qdmvc_Message::getMsg('btn_choose'), 'Hidden' => $this->data['role'] !== 'lookup'), 'qdupdate' => array('Order' => 100, 'Label' => Qdmvc_Message::getMsg('btn_save')), 'qdnew' => array('Order' => 200, 'Label' => Qdmvc_Message::getMsg('btn_new')), 'qddelete' => array('Order' => 300, 'Label' => Qdmvc_Message::getMsg('btn_delete')), 'qdclone' => array('Order' => 400, 'Label' => Qdmvc_Message::getMsg('btn_clone')), 'qdsysbtn' => array('Type' => 'Container', 'Order' => 500, 'Style' => 'Flat', 'Childs' => array('qdnote' => array('Order' => 500, 'Label' => array(array('Type' => 'Binding', 'Formula' => 'text: MYAPP.getURIParam($root.__sys_note_url(),\'item_count\')'), array('Type' => 'Text', 'Formula' => Qdmvc_Message::getMsg('btn_note')))), 'qdimage' => array('Order' => 600, 'Label' => array(array('Type' => 'Binding', 'Formula' => 'text: MYAPP.getURIParam($root.__sys_image_url(),\'item_count\')'), array('Type' => 'Text', 'Formula' => Qdmvc_Message::getMsg('btn_image')))), 'qdlog' => array('Order' => 600, 'Label' => array(array('Type' => 'Binding', 'Formula' => 'text: MYAPP.getURIParam($root.__sys_log_url(),\'item_count\')'), array('Type' => 'Text', 'Formula' => Qdmvc_Message::getMsg('btn_log')))))), 'qdreloadcard' => array('Order' => 600, 'Label' => Qdmvc_Message::getMsg('btn_reloadcard')), 'qdsysbtn2' => array('Type' => 'Container', 'Order' => 700, 'Style' => 'Flat', 'Label' => 'Tiện ích', 'Childs' => array('qdlines' => array('Order' => 100, 'Label' => array(array('Type' => 'Binding', 'Formula' => 'text: MYAPP.getURIParam($root.__sys_lines_url(),\'item_count\')'), array('Type' => 'Text', 'Formula' => $this->page->getFieldCaption('__sys_lines_url', $this->data['language']))), 'Hidden' => true), 'qdviewreport' => array('Order' => 200, 'Label' => Qdmvc_Message::getMsg('btn_viewreport'), 'Hidden' => true), 'qdhelp' => array('Order' => 300, 'Label' => '?'))), 'qdpagebtn' => array('Type' => 'Container', 'Order' => 800, 'Style' => 'Flat', 'Childs' => array()));
     return $obj;
 }
Esempio n. 8
0
 private function checkMandatory()
 {
     $cf = static::getFieldsConfig();
     $re = true;
     foreach ($cf as $key => $config) {
         if (Qdmvc_Helper::isNullOrEmpty($this->{$key})) {
             if (static::ISMANDATORY($key)) {
                 $this->pushValidateError($key, sprintf(Qdmvc_Message::getMsg('msg_field_mandatory'), $this->id, static::getFieldCaption($key, Qdmvc_Config::getLanguage())), 'error');
                 $re = false;
             }
         }
     }
     return $re;
 }
Esempio n. 9
0
    protected function generalToolbar()
    {
        ?>
        <!-- General toolbar -->
        <div style="margin-bottom: 5px">
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdshowall" type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_showall');
        ?>
                </button>
            </span>
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdclearfilter" type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_clearfilter');
        ?>
                </button>
            </span>
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdreload" type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_reloadcard');
        ?>
                </button>
            </span>
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdprint" type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_print');
        ?>
                </button>
            </span>
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdexport" type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_exportexcel');
        ?>
                </button>
            </span>
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdscancode" type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_scancode');
        ?>
                </button>
            </span>
        <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdselectionmode"
                        type="button">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_multiselection');
        ?>
                </button>
            </span>
            <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdaddtosel"
                        type="button">
                    <span id="selectedqueuecount" data-bind="text: selectedQueue_length"></span>
                    <?php 
        echo Qdmvc_Message::getMsg('btn_addtosel');
        ?>
                </button>
            </span>



        <span>
                <button class="btn btn-primary btn-xs qd-action-btn" id="qdselectallrows" type="button"
                        style="display: none">
                    <?php 
        echo Qdmvc_Message::getMsg('btn_selectallrows');
        ?>
                </button>
            </span>
            <script type="text/javascript">
                (function ($) {
                    $(document).ready(function () {
                        $("#qdprint").click(function () {
                            var gridContent = $("#jqxgrid").jqxGrid('exportdata', 'html');
                            MYAPP.printDocPreview(gridContent, 800, 500);
                        });
                        $("#qdreload").click(function () {
                            MYAPP.updateGrid(true);
                        });
                        $("#qdshowall").click(function () {
                            $("#jqxgrid").jqxGrid({pagesize: 999999});
                        });
                        $("#qdexport").click(function () {
                            $("#jqxgrid").jqxGrid('exportdata', 'xls', 'jqxGrid');
                        });
                        $("#qdclearfilter").click(function () {
                            $('#jqxgrid').jqxGrid('clearfilters');
                        });
                        $("#qdselectallrows").click(function () {
                            if (MYAPP.isMultiSelection()) {
                                $('#jqxgrid').jqxGrid('selectallrows');
                            }
                        });
                        $("#qdaddtosel").click(function () {
                            var getselectedrowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
                            for (var i = 0; i < getselectedrowindexes.length; i++) {
                                row = $('#jqxgrid').jqxGrid('getrowdata', getselectedrowindexes[i]);
                                if (row == undefined) {
                                    continue;
                                }
                                var exist = false;
                                for (var j = 0; j < MYAPP.selectedQueue.length; j++) {
                                    if (MYAPP.selectedQueue[j].id == row.id) {
                                        exist = true;
                                    }
                                }
                                if (!exist) {
                                    MYAPP.selectedQueue.push(row);
                                }
                                MYAPP.viewModel.selectedQueue_length(MYAPP.selectedQueue.length);
                            }
                        });
                        $("#qdaddtosel").mousedown(function(e){
                            if( e.button == 2 ) {
                                MYAPP.selectedQueue = [];
                                MYAPP.viewModel.selectedQueue_length(MYAPP.selectedQueue.length);
                                return false;
                            }
                            return true;
                        });
                        $('#qdaddtosel').contextmenu( function() {
                            console.log('MYAPP.selectedQueue cleared!');
                            return false;
                        });


                        $("#qdselectionmode").click(function () {
                            var grid = $('#jqxgrid');
                            var mode = grid.jqxGrid('selectionmode');
                            /*jqxGrid bug: could not switch back to other mode whenever stay in checkbox mode*/
                            /*Bug report: http://www.jqwidgets.com/community/topic/could-not-switch-to-other-selectionmode-once-stay-in-checkbox-mode/*/
                            /*Checkbox selectionmode has lot of Bug, checkAll apply to all Pages but UnCheckAll apply for current Page only*/
                            if (mode === 'singlerow') {
                                $('#qdselectallrows').show();

                                alert('<?php 
        echo Qdmvc_Message::getMsg('btn_multiselection_guide');
        ?>
');
                                grid.jqxGrid('selectionmode', 'multiplerowsextended');
                                $(this).text('<?php 
        echo Qdmvc_Message::getMsg('btn_singleselection');
        ?>
');
                            } else {
                                $('#qdselectallrows').hide();

                                //clear queue
                                MYAPP.selectedQueue = [];
                                //reload page
                                //location.reload();//checkbox mode must use this solution
                                grid.jqxGrid('clearselection');
                                grid.jqxGrid('selectionmode', 'singlerow');
                                $(this).text('<?php 
        echo Qdmvc_Message::getMsg('btn_multiselection');
        ?>
');
                            }
                            MYAPP.viewModel.selectedQueue_length(MYAPP.selectedQueue.length);
                        });

                        var scanner_decoder = null;
                        $("#qdscancode").click(function () {
                            //$('#jqxgrid').jqxGrid('clearfilters');
                            $("#qdQRModal").modal('show');
                            $('#qdQRModal').on('hidden.bs.modal', function () {
                                //alert('Stop');
                                setTimeout(function () {
                                    scanner_decoder.stop();//fail when stop immediately, need use time out
                                }, 0);
                            });

                            (function ($) {
                                var arg = {
                                    zoom: 1,
                                    frameRate: 15,
                                    width: 360,
                                    height: 240,
                                    DecodeBarCodeRate: null,
                                    beep: '<?php 
        echo QdJqwidgets::getResourcePath('plugin/qr/beep.mp3');
        ?>
',
                                    //flipHorizontal: true,//not supported
                                    resultFunction: function (resText, lastImageSrc) {
                                        //$('#jqxgrid').jqxGrid('clearfilters');
                                        MYAPP.addGridFilter('id', resText.code);
                                        //$("#qdMsgModal").modal('hide');
                                    }
                                };

                                scanner_decoder = $("#qdscanport").WebCodeCamJQuery(arg).data().plugin_WebCodeCamJQuery;
                                scanner_decoder.play();
                            })(jQuery);
                        });
                    });
                })(jQuery);
            </script>
        </div>

    <?php 
    }