<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                   ATTENTION!
 * If you see this message in browser (Internet Explorer, Mozilla firefox, etc.)
 * this means that
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 */


    require_once 'components/utils/check_utils.php';
    CheckPHPVersion();



    require_once 'database_engine/mysql_engine.php';
    require_once 'components/page.php';
    require_once 'phpgen_settings.php';
    require_once 'authorization.php';

    function GetConnectionOptions()
    {
        $result = GetGlobalConnectionOptions();
        $result['client_encoding'] = 'utf8';
        GetApplication()->GetUserAuthorizationStrategy()->ApplyIdentityToConnectionOptions($result);
        return $result;
    }

    
    ?><?php
    
    ?><?php
    
    class per_capPage extends Page
    {
        protected function DoBeforeCreate()
        {
            $this->dataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`per_cap`');
            $field = new IntegerField('PC_ID', null, null, true);
            $this->dataset->AddField($field, true);
            $field = new StringField('PC_PerDNI');
            $this->dataset->AddField($field, false);
            $field = new IntegerField('PC_CapID');
            $this->dataset->AddField($field, false);
            $this->dataset->AddLookupField('PC_PerDNI', 'm_personal', new StringField('Per_Dni'), new StringField('Per_Nombres', 'PC_PerDNI_Per_Nombres', 'PC_PerDNI_Per_Nombres_m_personal'), 'PC_PerDNI_Per_Nombres_m_personal');
            $this->dataset->AddLookupField('PC_CapID', 's7_capacitacion', new IntegerField('Cap_ID', null, null, true), new StringField('Cap_Materia', 'PC_CapID_Cap_Materia', 'PC_CapID_Cap_Materia_s7_capacitacion'), 'PC_CapID_Cap_Materia_s7_capacitacion');
        }
    
        protected function CreatePageNavigator()
        {
            $result = new CompositePageNavigator($this);
            
            $partitionNavigator = new PageNavigator('pnav', $this, $this->dataset);
            $partitionNavigator->SetRowsPerPage(50);
            $result->AddPageNavigator($partitionNavigator);
            
            return $result;
        }
    
        public function GetPageList()
        {
            $currentPageCaption = $this->GetShortCaption();
            $result = new PageList();
            if (GetCurrentUserGrantForDataSource('m_personal')->HasViewGrant())
                $result->AddPage(new PageLink($this->RenderText('Personal'), 'm_personal.php', $this->RenderText('Personal'), $currentPageCaption == $this->RenderText('Personal')));
            if (GetCurrentUserGrantForDataSource('per_cap')->HasViewGrant())
                $result->AddPage(new PageLink($this->RenderText('Enlace'), 'per_cap.php', $this->RenderText('Enlace'), $currentPageCaption == $this->RenderText('Enlace')));
            if (GetCurrentUserGrantForDataSource('s7_capacitacion')->HasViewGrant())
                $result->AddPage(new PageLink($this->RenderText('Materia'), 's7_capacitacion.php', $this->RenderText('Materia'), $currentPageCaption == $this->RenderText('Materia')));
            
            if ( HasAdminPage() && GetApplication()->HasAdminGrantForCurrentUser() )
              $result->AddPage(new PageLink($this->RenderText('Admin page'), 'phpgen_admin.php', 'Admin page', false, true));
            return $result;
        }
    
        protected function CreateRssGenerator()
        {
            return null;
        }
    
        protected function CreateGridSearchControl($grid)
        {
            $grid->UseFilter = true;
            $grid->SearchControl = new SimpleSearch('per_capssearch', $this->dataset,
                array('PC_ID', 'PC_PerDNI_Per_Nombres', 'PC_CapID_Cap_Materia'),
                array($this->RenderText('PC ID'), $this->RenderText('PC PerDNI'), $this->RenderText('PC CapID')),
                array(
                    '=' => $this->GetLocalizerCaptions()->GetMessageString('equals'),
                    '<>' => $this->GetLocalizerCaptions()->GetMessageString('doesNotEquals'),
                    '<' => $this->GetLocalizerCaptions()->GetMessageString('isLessThan'),
                    '<=' => $this->GetLocalizerCaptions()->GetMessageString('isLessThanOrEqualsTo'),
                    '>' => $this->GetLocalizerCaptions()->GetMessageString('isGreaterThan'),
                    '>=' => $this->GetLocalizerCaptions()->GetMessageString('isGreaterThanOrEqualsTo'),
                    'ILIKE' => $this->GetLocalizerCaptions()->GetMessageString('Like'),
                    'STARTS' => $this->GetLocalizerCaptions()->GetMessageString('StartsWith'),
                    'ENDS' => $this->GetLocalizerCaptions()->GetMessageString('EndsWith'),
                    'CONTAINS' => $this->GetLocalizerCaptions()->GetMessageString('Contains')
                    ), $this->GetLocalizerCaptions(), $this, 'CONTAINS'
                );
        }
    
        protected function CreateGridAdvancedSearchControl($grid)
        {
            $this->AdvancedSearchControl = new AdvancedSearchControl('per_capasearch', $this->dataset, $this->GetLocalizerCaptions(), $this->GetColumnVariableContainer(), $this->CreateLinkBuilder());
            $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateStringSearchInput('PC_ID', $this->RenderText('PC ID')));
            
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`m_personal`');
            $field = new BlobField('Per_Foto');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Dni');
            $lookupDataset->AddField($field, true);
            $field = new StringField('Per_Nombres');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Per_FechaNac');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Celular');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Correo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Renaes');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_OfiActual');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_NivelRemu');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_CondLabo');
            $lookupDataset->AddField($field, false);
            $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateLookupSearchInput('PC_PerDNI', $this->RenderText('PC PerDNI'), $lookupDataset, 'Per_Dni', 'Per_Nombres', false));
            
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`s7_capacitacion`');
            $field = new IntegerField('Cap_ID', null, null, true);
            $lookupDataset->AddField($field, true);
            $field = new StringField('Cap_Materia');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Desde');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Hasta');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Proveedor');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Creditos');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Horas');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Nota');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_NumFolio');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_TipDoc');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Tipo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Costo');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Detalle');
            $lookupDataset->AddField($field, false);
            $this->AdvancedSearchControl->AddSearchColumn($this->AdvancedSearchControl->CreateLookupSearchInput('PC_CapID', $this->RenderText('PC CapID'), $lookupDataset, 'Cap_ID', 'Cap_Materia', false));
        }
    
        protected function AddOperationsColumns($grid)
        {
            $actionsBandName = 'actions';
            $grid->AddBandToBegin($actionsBandName, $this->GetLocalizerCaptions()->GetMessageString('Actions'), true);
            if ($this->GetSecurityInfo()->HasViewGrant())
            {
                $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('View'), OPERATION_VIEW, $this->dataset), $actionsBandName);
                $column->SetImagePath('images/view_action.png');
            }
            if ($this->GetSecurityInfo()->HasEditGrant())
            {
                $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Edit'), OPERATION_EDIT, $this->dataset), $actionsBandName);
                $column->SetImagePath('images/edit_action.png');
                $column->OnShow->AddListener('ShowEditButtonHandler', $this);
            }
            if ($this->GetSecurityInfo()->HasDeleteGrant())
            {
                $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Delete'), OPERATION_DELETE, $this->dataset), $actionsBandName);
                $column->SetImagePath('images/delete_action.png');
                $column->OnShow->AddListener('ShowDeleteButtonHandler', $this);
            $column->SetAdditionalAttribute("modal-delete", "true");
            $column->SetAdditionalAttribute("delete-handler-name", $this->GetModalGridDeleteHandler());
            }
            if ($this->GetSecurityInfo()->HasAddGrant())
            {
                $column = $grid->AddViewColumn(new RowOperationByLinkColumn($this->GetLocalizerCaptions()->GetMessageString('Copy'), OPERATION_COPY, $this->dataset), $actionsBandName);
                $column->SetImagePath('images/copy_action.png');
            }
        }
    
        protected function AddFieldColumns($grid)
        {
            //
            // View column for PC_ID field
            //
            $column = new TextViewColumn('PC_ID', 'PC ID', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDescription($this->RenderText(''));
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for Per_Nombres field
            //
            $column = new TextViewColumn('PC_PerDNI_Per_Nombres', 'PC PerDNI', $this->dataset);
            $column->SetOrderable(true);
            
            /* <inline edit column> */
            //
            // Edit column for PC_PerDNI field
            //
            $editor = new ComboBox('pc_perdni_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`m_personal`');
            $field = new BlobField('Per_Foto');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Dni');
            $lookupDataset->AddField($field, true);
            $field = new StringField('Per_Nombres');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Per_FechaNac');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Celular');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Correo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Renaes');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_OfiActual');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_NivelRemu');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_CondLabo');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Per_Nombres', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC PerDNI', 
                'PC_PerDNI', 
                $editor, 
                $this->dataset, 'Per_Dni', 'Per_Nombres', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $column->SetEditOperationColumn($editColumn);
            /* </inline edit column> */
            
            /* <inline insert column> */
            //
            // Edit column for PC_PerDNI field
            //
            $editor = new ComboBox('pc_perdni_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`m_personal`');
            $field = new BlobField('Per_Foto');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Dni');
            $lookupDataset->AddField($field, true);
            $field = new StringField('Per_Nombres');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Per_FechaNac');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Celular');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Correo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Renaes');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_OfiActual');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_NivelRemu');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_CondLabo');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Per_Nombres', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC PerDNI', 
                'PC_PerDNI', 
                $editor, 
                $this->dataset, 'Per_Dni', 'Per_Nombres', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $column->SetInsertOperationColumn($editColumn);
            /* </inline insert column> */
            $column->SetDescription($this->RenderText(''));
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for Cap_Materia field
            //
            $column = new TextViewColumn('PC_CapID_Cap_Materia', 'PC CapID', $this->dataset);
            $column->SetOrderable(true);
            
            /* <inline edit column> */
            //
            // Edit column for PC_CapID field
            //
            $editor = new ComboBox('pc_capid_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`s7_capacitacion`');
            $field = new IntegerField('Cap_ID', null, null, true);
            $lookupDataset->AddField($field, true);
            $field = new StringField('Cap_Materia');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Desde');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Hasta');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Proveedor');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Creditos');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Horas');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Nota');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_NumFolio');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_TipDoc');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Tipo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Costo');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Detalle');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Cap_Materia', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC CapID', 
                'PC_CapID', 
                $editor, 
                $this->dataset, 'Cap_ID', 'Cap_Materia', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $column->SetEditOperationColumn($editColumn);
            /* </inline edit column> */
            
            /* <inline insert column> */
            //
            // Edit column for PC_CapID field
            //
            $editor = new ComboBox('pc_capid_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`s7_capacitacion`');
            $field = new IntegerField('Cap_ID', null, null, true);
            $lookupDataset->AddField($field, true);
            $field = new StringField('Cap_Materia');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Desde');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Hasta');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Proveedor');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Creditos');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Horas');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Nota');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_NumFolio');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_TipDoc');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Tipo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Costo');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Detalle');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Cap_Materia', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC CapID', 
                'PC_CapID', 
                $editor, 
                $this->dataset, 'Cap_ID', 'Cap_Materia', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $column->SetInsertOperationColumn($editColumn);
            /* </inline insert column> */
            $column->SetDescription($this->RenderText(''));
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
        }
    
        protected function AddSingleRecordViewColumns($grid)
        {
            //
            // View column for PC_ID field
            //
            $column = new TextViewColumn('PC_ID', 'PC ID', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for Per_Nombres field
            //
            $column = new TextViewColumn('PC_PerDNI_Per_Nombres', 'PC PerDNI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for Cap_Materia field
            //
            $column = new TextViewColumn('PC_CapID_Cap_Materia', 'PC CapID', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
        }
    
        protected function AddEditColumns($grid)
        {
            //
            // Edit column for PC_PerDNI field
            //
            $editor = new ComboBox('pc_perdni_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`m_personal`');
            $field = new BlobField('Per_Foto');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Dni');
            $lookupDataset->AddField($field, true);
            $field = new StringField('Per_Nombres');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Per_FechaNac');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Celular');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Correo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Renaes');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_OfiActual');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_NivelRemu');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_CondLabo');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Per_Nombres', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC PerDNI', 
                'PC_PerDNI', 
                $editor, 
                $this->dataset, 'Per_Dni', 'Per_Nombres', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for PC_CapID field
            //
            $editor = new ComboBox('pc_capid_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`s7_capacitacion`');
            $field = new IntegerField('Cap_ID', null, null, true);
            $lookupDataset->AddField($field, true);
            $field = new StringField('Cap_Materia');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Desde');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Hasta');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Proveedor');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Creditos');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Horas');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Nota');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_NumFolio');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_TipDoc');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Tipo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Costo');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Detalle');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Cap_Materia', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC CapID', 
                'PC_CapID', 
                $editor, 
                $this->dataset, 'Cap_ID', 'Cap_Materia', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
        }
    
        protected function AddInsertColumns($grid)
        {
            //
            // Edit column for PC_PerDNI field
            //
            $editor = new ComboBox('pc_perdni_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`m_personal`');
            $field = new BlobField('Per_Foto');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Dni');
            $lookupDataset->AddField($field, true);
            $field = new StringField('Per_Nombres');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Per_FechaNac');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Celular');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_Correo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_Renaes');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Per_OfiActual');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_NivelRemu');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Per_CondLabo');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Per_Nombres', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC PerDNI', 
                'PC_PerDNI', 
                $editor, 
                $this->dataset, 'Per_Dni', 'Per_Nombres', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for PC_CapID field
            //
            $editor = new ComboBox('pc_capid_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                new MyConnectionFactory(),
                GetConnectionOptions(),
                '`s7_capacitacion`');
            $field = new IntegerField('Cap_ID', null, null, true);
            $lookupDataset->AddField($field, true);
            $field = new StringField('Cap_Materia');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Desde');
            $lookupDataset->AddField($field, false);
            $field = new DateField('Cap_Hasta');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Proveedor');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Creditos');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Horas');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Nota');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_NumFolio');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_TipDoc');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Tipo');
            $lookupDataset->AddField($field, false);
            $field = new IntegerField('Cap_Costo');
            $lookupDataset->AddField($field, false);
            $field = new StringField('Cap_Detalle');
            $lookupDataset->AddField($field, false);
            $lookupDataset->SetOrderBy('Cap_Materia', GetOrderTypeAsSQL(otAscending));
            $editColumn = new LookUpEditColumn(
                'PC CapID', 
                'PC_CapID', 
                $editor, 
                $this->dataset, 'Cap_ID', 'Cap_Materia', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption())));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            if ($this->GetSecurityInfo()->HasAddGrant())
            {
                $grid->SetShowAddButton(true);
                $grid->SetShowInlineAddButton(false);
            }
            else
            {
                $grid->SetShowInlineAddButton(false);
                $grid->SetShowAddButton(false);
            }
        }
    
        protected function AddPrintColumns($grid)
        {
            //
            // View column for PC_ID field
            //
            $column = new TextViewColumn('PC_ID', 'PC ID', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for Per_Nombres field
            //
            $column = new TextViewColumn('PC_PerDNI_Per_Nombres', 'PC PerDNI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for Cap_Materia field
            //
            $column = new TextViewColumn('PC_CapID_Cap_Materia', 'PC CapID', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
        }
    
        protected function AddExportColumns($grid)
        {
            //
            // View column for PC_ID field
            //
            $column = new TextViewColumn('PC_ID', 'PC ID', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for Per_Nombres field
            //
            $column = new TextViewColumn('PC_PerDNI_Per_Nombres', 'PC PerDNI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for Cap_Materia field
            //
            $column = new TextViewColumn('PC_CapID_Cap_Materia', 'PC CapID', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
        }
    
        public function GetPageDirection()
        {
            return null;
        }
    
        protected function ApplyCommonColumnEditProperties($column)
        {
            $column->SetShowSetToNullCheckBox(false);
    	$column->SetVariableContainer($this->GetColumnVariableContainer());
        }
    
        function GetCustomClientScript()
        {
            return ;
        }
        
        function GetOnPageLoadedClientScript()
        {
            return ;
        }
        public function ShowEditButtonHandler($show)
        {
            if ($this->GetRecordPermission() != null)
                $show = $this->GetRecordPermission()->HasEditGrant($this->GetDataset());
        }
        public function ShowDeleteButtonHandler($show)
        {
            if ($this->GetRecordPermission() != null)
                $show = $this->GetRecordPermission()->HasDeleteGrant($this->GetDataset());
        }
        
        public function GetModalGridDeleteHandler() { return 'per_cap_modal_delete'; }
        protected function GetEnableModalGridDelete() { return true; }
    
        protected function CreateGrid()
        {
            $result = new Grid($this, $this->dataset, 'per_capGrid');
            if ($this->GetSecurityInfo()->HasDeleteGrant())
               $result->SetAllowDeleteSelected(false);
            else
               $result->SetAllowDeleteSelected(false);   
            
            ApplyCommonPageSettings($this, $result);
            
            $result->SetUseImagesForActions(true);
            $result->SetUseFixedHeader(false);
            
            $result->SetShowLineNumbers(false);
            
            $result->SetHighlightRowAtHover(false);
            $result->SetWidth('');
            $this->CreateGridSearchControl($result);
            $this->CreateGridAdvancedSearchControl($result);
    
            $this->AddFieldColumns($result);
            $this->AddSingleRecordViewColumns($result);
            $this->AddEditColumns($result);
            $this->AddInsertColumns($result);
            $this->AddPrintColumns($result);
            $this->AddExportColumns($result);
            $this->AddOperationsColumns($result);
            $this->SetShowPageList(true);
            $this->SetExportToExcelAvailable(true);
            $this->SetExportToWordAvailable(false);
            $this->SetExportToXmlAvailable(false);
            $this->SetExportToCsvAvailable(false);
            $this->SetExportToPdfAvailable(false);
            $this->SetPrinterFriendlyAvailable(false);
            $this->SetSimpleSearchAvailable(true);
            $this->SetAdvancedSearchAvailable(false);
            $this->SetVisualEffectsEnabled(true);
            $this->SetShowTopPageNavigator(true);
            $this->SetShowBottomPageNavigator(true);
    
            //
            // Http Handlers
            //
    
            return $result;
        }
        
        protected function OpenAdvancedSearchByDefault()
        {
            return false;
        }
    
        protected function DoGetGridHeader()
        {
            return '';
        }
    }

    SetUpUserAuthorization(GetApplication());

    try
    {
        $Page = new per_capPage("per_cap.php", "per_cap", GetCurrentUserGrantForDataSource("per_cap"), 'UTF-8');
        $Page->SetShortCaption('Enlace');
        $Page->SetHeader(GetPagesHeader());
        $Page->SetFooter(GetPagesFooter());
        $Page->SetCaption('Enlace');
        $Page->SetRecordPermission(GetCurrentUserRecordPermissionsForDataSource("per_cap"));

        GetApplication()->SetMainPage($Page);
        GetApplication()->Run();
    }
    catch(Exception $e)
    {
        ShowErrorPage($e->getMessage());
    }

?>
