public function select()
    {
        $dir = './themes';
        $files1 = scandir($dir);
        //pr($files1);
        $arrThemes = array();
        //ThemeItem::emptyAll();
        foreach ($files1 as $tname) {
            if (!strstr($tname, ".")) {
                if ($tname != "adminlte") {
                    $themeItem = new ThemeItem();
                    $themeItem->theme_dir = $tname;
                    $themeItem->save();
                    $arrThemes[] = $tname;
                }
            }
        }
        //get All
        $themeItem = new ThemeItem();
        $arrThemes2 = $themeItem->getAll();
        $t = time();
        //
        $adaPreview = 0;
        foreach ($arrThemes2 as $theme) {
            if (in_array($theme->theme_dir, $arrThemes)) {
                if (ThemeItem::getPreviewTheme() == $theme->theme_id) {
                    $adaPreview = 1;
                }
            }
        }
        ?>
<table class="table">
    <thead>
    <tr>
        <th><?php 
        echo Lang::t('Theme Name');
        ?>
</th>
        <th><?php 
        echo Lang::t('Status');
        ?>
</th>
        <th><?php 
        echo Lang::t('Preview');
        ?>
</th>
        <th><?php 
        echo Lang::t('Edit');
        ?>
</th>
    </tr>
    
    </thead>
    <tbody>
        <?php 
        foreach ($arrThemes2 as $theme) {
            if (in_array($theme->theme_dir, $arrThemes)) {
                if (ThemeItem::getPreviewTheme() == $theme->theme_id) {
                    $preview = 1;
                } else {
                    $preview = 0;
                }
                ?>
        <tr>
            <td><?php 
                echo $theme->theme_dir;
                ?>
</td>
            <td>
                <?php 
                if (!$theme->theme_active) {
                    ?>
                <select class="form-control" id="select_<?php 
                    echo $theme->theme_id;
                    ?>
_<?php 
                    echo $t;
                    ?>
">
                    <?php 
                    foreach ($this->arrActive as $num => $h) {
                        ?>
                    <option value="<?php 
                        echo $num;
                        ?>
" <?php 
                        if ($theme->theme_active == $num) {
                            echo "selected";
                        }
                        ?>
><?php 
                        echo $h;
                        ?>
</option>
                    <?php 
                    }
                    ?>
                </select>
                <?php 
                } else {
                    echo $this->arrActive[$theme->theme_active];
                }
                ?>
            </td>
            <td>
                <?php 
                if (!$theme->theme_active) {
                    ?>
                <?php 
                    if (!$preview) {
                        ?>
                <button id="activatebutton_<?php 
                        echo $theme->theme_id;
                        ?>
_<?php 
                        echo $t;
                        ?>
" class="btn btn-default"><?php 
                        echo Lang::t('Edit Mode');
                        ?>
</button>
                <?php 
                    } else {
                        ?>
                <button id="deactivatebutton_<?php 
                        echo $theme->theme_id;
                        ?>
_<?php 
                        echo $t;
                        ?>
" class="btn btn-default"><?php 
                        echo Lang::t('Remove Edit Mode');
                        ?>
</button>              
                <?php 
                    }
                }
                ?>
            </td>
            <td>
              <?php 
                if ($theme->theme_active) {
                    ?>
                <?php 
                    if (!$adaPreview) {
                        ?>
                <button onclick="openLw('ThemeSetting','<?php 
                        echo _SPPATH;
                        ?>
ThemeModWeb/ThemeMod?ti='+$.now(),'fade');" class="btn btn-default"><?php 
                        echo Lang::t('Edit Colors');
                        ?>
</button>
                <?php 
                    }
                    ?>
                <button onclick="if(confirm('<?php 
                    echo Lang::t('This will restore the themes to its initial state, all changes will be gone, are you sure?');
                    ?>
'))$.get( '<?php 
                    echo _SPPATH;
                    ?>
ThemeModWeb/restores?tdir=<?php 
                    echo $theme->theme_dir;
                    ?>
&t='+$.now(),function(data){alert(data);});" class="btn btn-default"><?php 
                    echo Lang::t('Restore to Default');
                    ?>
</button>
              <?php 
                }
                ?>
              <?php 
                if ($preview) {
                    ?>
                <button onclick="openLw('ThemeSetting','<?php 
                    echo _SPPATH;
                    ?>
ThemeModWeb/ThemeMod?ti='+$.now(),'fade');" class="btn btn-default"><?php 
                    echo Lang::t('Edit Colors');
                    ?>
</button>            
              <?php 
                }
                ?>
            </td>
        </tr>
    <script>
        $("#select_<?php 
                echo $theme->theme_id;
                ?>
_<?php 
                echo $t;
                ?>
").change(function(){
           var slc =  $("#select_<?php 
                echo $theme->theme_id;
                ?>
_<?php 
                echo $t;
                ?>
").val();
           $.get("<?php 
                echo _SPPATH;
                ?>
ThemeModWeb/activate?id=<?php 
                echo $theme->theme_id;
                ?>
&active="+slc,function(data){
                console.log(data);
                if(data.bool){
                    lwrefresh('ThemeSelector');
                }else{
                    alert('<?php 
                echo Lang::t('failed');
                ?>
');
                }
           },'json');
        });
        <?php 
                if (!$preview) {
                    ?>
        $("#activatebutton_<?php 
                    echo $theme->theme_id;
                    ?>
_<?php 
                    echo $t;
                    ?>
").click(function(){
            $.get("<?php 
                    echo _SPPATH;
                    ?>
ThemeModWeb/preview?id=<?php 
                    echo $theme->theme_id;
                    ?>
",function(data){
                console.log(data);
                if(data.bool){
                    lwrefresh('ThemeSelector');
                    //alert('<?php 
                    echo Lang::t('changes applied');
                    ?>
');
                }else{
                    alert('<?php 
                    echo Lang::t('failed');
                    ?>
');
                }
           },'json');
        });
         <?php 
                } else {
                    ?>
         $("#deactivatebutton_<?php 
                    echo $theme->theme_id;
                    ?>
_<?php 
                    echo $t;
                    ?>
").click(function(){
            $.get("<?php 
                    echo _SPPATH;
                    ?>
ThemeModWeb/depreview?id=<?php 
                    echo $theme->theme_id;
                    ?>
",function(data){
                console.log(data);
                if(data.bool){
                    lwrefresh('ThemeSelector');
                    //alert('<?php 
                    echo Lang::t('changes applied');
                    ?>
');
                }else{
                    alert('<?php 
                    echo Lang::t('failed');
                    ?>
');
                }
           },'json');
        });
         <?php 
                }
                ?>
        </script>
        <?php 
            }
            //if
        }
        ?>
    </tbody>
</table>
        <?php 
    }