Subversion-Projekte lars-tiefland.webanos.faltradxxs.de

Revision

Revision 24 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<script src="/js/jstree/dist/jstree.js?{$smarty.now}"></script>
<script>
    $(document).ready(function(){


        $("#artikelListe").delegate(".setUp","click",function(){
            let setUpID = $(this).attr("id");
            let id = setUpID.split("_");
            let type = id[1];
            let artikelID = id[2];
            let aktionsID = $("#aktionsID").val();
            $.ajax({
                type: "POST",
                url: "artikel_2_Aktionen_v2.php",
                data: { scroll_up: artikelID, aktionsID: aktionsID, type: type }
            }).done(function(html){
                $("#artikelListe").html(html);
            });
        }).delegate(".setDown","click",function(){
            let setDownID = $(this).attr("id");
            let id = setDownID.split("_");
            let type = id[1];
            let artikelID = id[2];
            let aktionsID = $("#aktionsID").val();
            $.ajax({
                type: "POST",
                url: "artikel_2_Aktionen_v2.php",
                data: { scroll_down: artikelID, aktionsID: aktionsID, type: type }
            }).done(function(html){
                $("#artikelListe").html(html);
            });
        }).delegate(".delete","click",function(){
            let deleteID = $(this).attr("id");
            let id = deleteID.split("_");
            let type = id[1];
            let artikelID = id[2];
            let aktionsID = $("#aktionsID").val();
            $.ajax({
                type: "POST",
                url: "artikel_2_Aktionen_v2.php",
                data: { deleted: artikelID, aktionsID: aktionsID, type: type }
            }).done(function(html){
                $("#artikelListe").html(html);
            });
        });

        let nodeID = 0;
        let idArray;
        let daten;
        $("#directroyTree").jstree({
            "plugins": ["themes", "ui", "search", "contextmenu"],
            'core' : {
                'data' : {
                     'type': 'POST',
                     'url' : "aktions_tree_v2.php",
                     'data' :  function (node) {
                        if( node.id === '#'){
                            nodeID = -1;
                        }else{
                            idArray = node.id.split("_");
                            nodeID = idArray[1];
                        }
                        console.log(nodeID)
                        daten = {
                            "nodeID" : nodeID
                        }
                        return daten;
                     },
                    'dataType': 'json',
                    'async': true
                },
                'check_callback': true
            },
            "search": {
                "show_only_matches": true,
                "case_sensitive": false,
                "ajax": {
                    'type': 'POST',
                    "url" : "aktions_tree_v2.php",
                    'dataType': 'json',
                    'async': true
                }
            },
        })

        let to = false;
        $('#searchTree').keyup(function () {
            if( to ) {
                clearTimeout(to);
            }
            to = setTimeout(function () {
                let v = $('#searchTree').val();
                if( v.length > 2 || v.length === 0){
                    $('#directroyTree').jstree(true).search(v);
                }
            },300);
        });


        $('#directroyTree').on("select_node.jstree", function (e, data) {
            let addArtikelID = data.node.id
            let id = addArtikelID.split("_");
            let artikelID = id[1];
            let aktionsID = $("#aktionsID").val();

            if( id[0] === "artikel" ){
                $.ajax({
                    type: "POST",
                    url: "artikel_2_Aktionen_v2.php",
                    data: { id: artikelID, add: "Artikel", aktionsID: aktionsID }
                }).done(function(html){
                    $("#artikelListe").html(html);
                });
            }

            {if isset($user_rechte["online_shop"]["aktion"]["ordner_aktionen_zuweisen"])}
            if( id[0] === "artikel" ){
                $.ajax({
                    type: "POST",
                    url: "artikel_2_Aktionen_v2.php",
                    data: { id: artikelID, add: "Ordner", aktionsID: aktionsID }
                }).done(function(html){
                    $("#artikelListe").html(html);
                });
            }
            {/if}
        });

    });
    function strstr(haystack, needle, bool) {
        let pos;

        haystack += "";
        pos = haystack.indexOf(needle); if (pos === -1) {
            return false;
        } else {
            if (bool) {
                return haystack.substr(0, pos);
            } else {
                return haystack.slice(pos);
            }
        }
    }
</script>
<style>
    .tabelle div {
        padding: 1px 2px!important;
    }
</style>
<div>
    <div style="border-bottom: 1px solid #333;padding: 4px 2px;">{$webs["kunde_bezeichnung"]}</div>
    <label for="searchTree">Suche</label>
    <input id="searchTree" placeholder="Suche..."/>
    <div id="directroyTree"></div>
</div>