<?php
require_once("../includes/bootstrap.php");
$sesion = new sesion();
$sesion->set('permiso', permisos($_POST['privilegio']));

$academia = bootstrap::initBd($sesion->get('anio'));
//cache();
$permisos = str_split($sesion->get('permiso'));
?>

<script  type="text/javascript">
    $(function() {
        $("#panelColegio").panel({
        tools: [
<?php if (in_array("M", $permisos)) { ?>
            {
                iconCls:'ui-btn-save',
                    handler:function() {
                        if (!$(":input, select, textarea", "#formColegio").hasClass('campos_error')) {
                            var dts = $("#formColegio").serializeObject();
                            dts['txtpiepagina'] = tinyMCE.get('txtpiepagina').getContent()
                            $.ajax({
                                type: "POST",
                                url: 'mod_colegio/opera_colegio.php',
                                data: dts,
                                dataType: "json",
                                beforeSend: function() {
                                    $.messager.progress({title: dtsLang['project']['empresa'], msg: dtsLang['mod_colegio']['msg_save']})
                                },
                                success: function(rta) {
                                    $.unblockUI();
                                    if (rta.error != 0) {
                                        if (rta == 'session') {
                                            modulo = 'global'
                                        }
                                        else {
                                            modulo = 'mod_colegio'
                                        }
                                        jAlert(dtsLang[modulo][rta.error], 'error', function() {
                                            if (rta == 'session') {
                                                location.reload();
                                            }
                                        });
                                    } else {
                                        $.messager.progress('close');
                                        notifica_ok(dtsLang['mod_colegio']['msg_exito']);
                                    }
                                },
                            });
                        } else {
                            jAlert(dtsLang['globals']['cmpobl'], dtsLang['globals']['empresa'])
                        }
                        }
            }
<?php } ?>
        ]
        });
    });


    tinymce.create('tinymce.plugins.dispnCampos', {
        createControl: function(n, cm) {
            switch (n) {
                case 'dtsColegio':
                    var mlb = cm.createListBox('dtsColegio', {
                        title: 'Informacion Colegio',
                        onselect: function(v) {
                            tinyMCE.activeEditor.execCommand('mceInsertContent', false, v);
                        }
                    });
                    mlb.add('Nombre', '{nom_colegio}');
                    mlb.add('Nombre Abreviado', '{abr_colegio}');
                    mlb.add('Nit', '{nit_colegio}');
                    mlb.add('Resolución', '{res_colegio}');
                    mlb.add('Decreto', '{dec_colegio}');
                    mlb.add('ICFES', '{icfes_colegio}');
                    mlb.add('DANE', '{dan_colegio}');
                    return mlb;
            }
            return null;
        }
    });
    /* Register plugin with a short name*/
    tinymce.PluginManager.add('cmpsInfor', tinymce.plugins.dispnCampos);
    tinyMCE.init({
        mode: "textareas",
        theme: "advanced",
        language: "es",
        skin: "o2k7",
        plugins: "autolink,lists,pagebreak,table,advhr,-cmpsInfor",
        // Theme options
        theme_advanced_buttons1: "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect,|,dtsColegio",
        theme_advanced_buttons2: "outdent,indent,blockquote,|,undo,redo,|,forecolor,backcolor,|,tablecontrols,|,hr,removeformat,|,code,advhr",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
    });
</script>
<div id="panelColegio" class="easyui-panel" title="<?php echo $dtsLang['mod_colegio']['tit_colegio'] ?>"   
     style="width:auto;height:auto;padding:1px 8px;background:#fafafa;"  
     data-options="iconCls:'ui-icon-configure',closable:false,  
     collapsible:true,minimizable:false,maximizable:false">
    <form id="formColegio" name="formColegio" method="post" action="">				
        <table border="0" cellspacing="0" cellpadding="0" class="table table-condensed">
            <tr>
                <td colspan="4">
                    <div class="tit1">
                        <?php echo $dtsLang['mod_colegio']['lbl_nom'] ?>
                    </div>
                    <input name="txt_nomcol" type="text" id="txt_nomcol" value="<?php echo $sesion->getVar('info_colegio.nombre') ?>" size="80" />			
                </td>
            </tr>
            <tr>
                <td colspan="4"><div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_abr'] ?></div>
                    <input name="txt_abrcol" type="text" id="txt_abrcol" value="<?php echo $sesion->getVar('info_colegio.abreviatura') ?>" size="50" /></td>
            </tr>
            <tr>
                <td><div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_res'] ?></div>
                    <input name="txt_rescol" type="text" id="txt_rescol" value="<?php echo $sesion->getVar('info_colegio.resolucion') ?>" size="35" /></td>
                <td colspan="3"><div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_decreto'] ?></div>
                    <input name="txt_deccol" type="text" id="txt_deccol" value="<?php echo $sesion->getVar('info_colegio.decreto') ?>" size="35" /></td>
            </tr>
            <tr>
                <td colspan="4"><table border="0" cellspacing="0" cellpadding="0" class="noborder">
                        <tr>
                            <td ><span class="tit1">
                                    <div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_nit'] ?></div>
                                    <input name="txt_nitcol" type="text" id="txt_nitcol" value="<?php echo $sesion->getVar('info_colegio.nit') ?>" size="20" />
                                </span></td>
                            <td><div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_icfes'] ?></div>
                                <input name="txt_icfes" type="text" id="txt_icfes" value="<?php echo $sesion->getVar('info_colegio.icfes') ?>" size="20" /></td>
                            <td><span class="tit1">
                                    <div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_dane'] ?></div>
                                    <input name="txt_danecol" type="text" id="txt_danecol" value="<?php echo $sesion->getVar('info_colegio.dane') ?>" size="20" />
                                </span></td>
                            <td><span class="tit1">
                                    <div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_daneante'] ?></div>
                                    <input name="txt_danant" type="text" id="txt_danant" value="<?php echo $sesion->getVar('info_colegio.dan_ant') ?>" size="20" />
                                </span></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <div class="tit1"><?php echo $dtsLang['mod_colegio']['lbl_pie'] ?></div>
                    <textarea name="txtpiepagina" cols="80" rows="5" id="txtpiepagina" class="tinymce"><?php echo $sesion->getVar('info_colegio.pie') ?></textarea>
                </td>
            </tr>
        </table>
    </form>
</div>
