public function init()
 {
     $this->setAction('/admin/agregargrado')->setMethod('post')->setAttrib('id', 'formLogin');
     $grados = new Application_Model_Grado();
     $listagrados = $grados->listarGradosPeriodoActual();
     if ($listagrados == NULL) {
         $configuracion = new Application_Model_Configuracion();
         $grados = $configuracion->getGradosPrimaria();
         foreach ($grados as $aux) {
             $name = $aux["tConfDescripcion"];
             $recordarme = $this->createElement('checkbox', $name, array('label' => $name));
             $recordarme->setName($name);
             $recordarme->setLabel($name);
             $recordarme->setDecorators(array('ViewHelper', 'Description', 'Errors', array('Label', array('placement' => 'APPEND')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div'))));
             $this->addElement($recordarme);
         }
     } else {
         foreach ($listagrados as $aux) {
             $name = $aux["vGradoDescripcion"];
             $estado = $aux["tiGradoEstado"];
             if ($estado == 'I') {
                 $recordarme = $this->createElement('checkbox', $name, array('label' => $name));
             } else {
                 $recordarme = $this->createElement('checkbox', $name, array('label' => $name, 'checked' => true));
             }
             $recordarme->setName($name);
             $recordarme->setLabel($name);
             $recordarme->setDecorators(array('ViewHelper', 'Description', 'Errors', array('Label', array('placement' => 'APPEND')), array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div'))));
             $this->addElement($recordarme);
         }
     }
     $boton = $this->createElement('submit', 'login', array('label' => 'Registrar'));
     $boton->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td'))));
     $this->addElement($boton);
 }
 public function init()
 {
     $seccion = new Application_Model_Seccion();
     $array = $seccion->listarSeccionesPeriodoActualActivos();
     $include = new Application_Model_Includes();
     //$q2a=$include->query2array($array, 'iSeccIdSeccion','vSeccDescripcion');
     $q2a = $include->querytoeach($array, "iSeccIdSeccion");
     $validator = new Zend_Validate_InArray($q2a);
     $validator->setHaystack($q2a);
     $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Eliga una sección'));
     $this->setAction('/admin/agregarcurso')->setMethod('post')->setAttrib('id', 'formLogin');
     // Crea un y configura el elemento username
     $nombrecurso = $this->createElement('text', 'nombrecurso', array('label' => 'Nombre del Curso', 'placeholder' => 'Máximo 150 caracteres'));
     $nombrecurso->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo requerido')))->addValidator('regex', true, array('pattern' => '/^[(a-z A-Z)]+$/', 'messages' => array('regexNotMatch' => 'Sólo Letras')))->addValidator('stringLength', false, array(5, 150, 'messages' => "Entre 5 a 150 caracteres"))->setRequired(true)->addFilter('StringToUpper');
     $nombrecurso->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $descripcion = $this->createElement('text', 'descripcion', array('label' => 'Descripción', 'placeholder' => 'Breve descripción del curso'));
     $descripcion->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo requerido')))->addValidator('regex', true, array('pattern' => '/^[(a-z A-Z 0-9)]+$/', 'messages' => array('regexNotMatch' => 'Sólo Letras')))->setRequired(true)->addFilter('StringToUpper');
     $descripcion->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $gradosactuales = new Application_Model_Grado();
     $includes = new Application_Model_Includes();
     $arraygrados = $gradosactuales->listarGradosActivos();
     $arraygradostoarray = $includes->query2array($arraygrados, 'iGradoIdGrado', 'vGradoDescripcion');
     $grado = $this->createElement('select', 'cbogrado', array('label' => 'Grado', 'autocomplete' => false, 'multiOptions' => $arraygradostoarray, 'onChange' => 'cargarseccion();'));
     $grado->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $seccion = $this->createElement('select', 'cboseccion', array('label' => 'Seccion', 'multiOptions' => array("0" => "Seleccionar Sección")));
     $seccion->addValidator($validator);
     $seccion->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo requerido')));
     $seccion->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     // Añade los elementos al formulario:
     $this->addElement($nombrecurso)->addElement($descripcion)->addElement($grado)->addElement($seccion)->addElement('submit', 'registrar', array('label' => 'Registrar'));
 }
 public function init()
 {
     $this->setAction('/admin/agregarseccion')->setMethod('post')->setAttrib('id', 'formLogin');
     $seccion = new Application_Model_Seccion();
     $listasecciones = $seccion->listarSeccionesPeriodoActual();
     $includes = new Application_Model_Includes();
     $gradosactuales = new Application_Model_Grado();
     $arraygrados = $gradosactuales->listarGradosActivos();
     $arraygradostoarray = $includes->query2array($arraygrados, 'iGradoIdGrado', 'vGradoDescripcion');
     $combo = $this->createElement('select', 'cbogrado', array('label' => 'Grado', 'placeholder' => 'Seleccionar Grado', 'autocomplete' => false, 'multiOptions' => $arraygradostoarray));
     $combo->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $this->addElement($combo);
     // Añade los elementos al formulario:
     // uso de addElement() como fábrica para crear el botón 'Login':
     $boton = $this->createElement('submit', 'login', array('label' => 'Registrar'));
     $boton->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td'))));
     $this->addElement($boton);
 }
 public function init()
 {
     $seccion = new Application_Model_Seccion();
     $array = $seccion->listarSeccionesPeriodoActualActivos();
     $include = new Application_Model_Includes();
     //$q2a=$include->query2array($array, 'iSeccIdSeccion','vSeccDescripcion');
     $q2a = $include->querytoeach($array, "iSeccIdSeccion");
     $validator = new Zend_Validate_InArray($q2a);
     $validator->setHaystack($q2a);
     $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Eliga una sección'));
     $this->setAction('/admin/agregaralumno')->setMethod('post')->setAttrib('id', 'formLogin')->setAttrib('enctype', 'multipart/form-data');
     $nombreusuario = $this->createElement('text', 'nombreusuario', array('label' => 'Nombre del Usuario', 'placeholder' => 'Máximo 25 caracteres'));
     $nombreusuario->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('alpha')->addValidator('stringLength', false, array(5, 25, 'messages' => "Entre 5 y 25 caracteres"))->setRequired(true)->addFilter("StringToUpper");
     $nombreusuario->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $clave = $this->createElement('password', 'clave', array('label' => 'Contraseña'));
     $clave->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addFilter('alnum', array('allowwhitespace' => true))->addValidator('stringLength', false, array(5, 20, 'messages' => "Entre 5 y 20 caracteres"))->setRequired(true)->addFilter("StringToUpper");
     $clave->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $email = $this->createElement('text', 'email', array('label' => 'Direccion de Correo', 'placeholder' => '*****@*****.**'));
     $email->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('regex', true, array('patern' => '/^[(a-zA-Z0-9@)].+$/', array('regexNotMatch' => 'Solo Letras y numeros')))->addValidator('stringLength', false, array(5, 100, 'messages' => "Entre 5 y 100 caracteres"))->setRequired(true)->addFilter("StringToUpper");
     $email->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $dni = $this->createElement('text', 'dni', array('label' => 'Numero Dni', 'placeholder' => '8 Dígitos'));
     $dni->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('regex', true, array('patern' => '/^[(0-9)]+$/', array('regexNotMatch' => 'Solo Numeros')))->addValidator('stringLength', false, array(8, 8, 'messages' => "DNI se Compone e 8 Carateres"))->setRequired(true)->addFilter("StringTrim");
     $dni->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $dniapo = $this->createElement('text', 'dniapo', array('label' => 'DNI Apoderado', 'disabled' => true));
     $dniapo->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('regex', true, array('patern' => '/^[(0-9)]+$/', array('regexNotMatch' => 'Solo Numeros')))->addValidator('stringLength', false, array(8, 8, 'messages' => "DNI se Compone e 8 Carateres"))->addFilter("StringTrim");
     $dniapo->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $nombreapo = $this->createElement('text', 'nombreapo', array('label' => 'Nombre del Apoderado', 'disabled' => true));
     $nombreapo->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('regex', true, array('patern' => '/^[(a-z A-Z)]+$/', array('regexNotMatch' => 'Solo Letras')))->addValidator('stringLength', false, array(2, 150, 'messages' => "Entre 2 y 150 caracteres"))->addFilter("StringToUpper")->addFilter("StringTrim");
     $nombreapo->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $idapoderado = $this->createElement('text', 'idapoderado', array('label' => 'Id del Apoderado', 'disabled' => true));
     $idapoderado->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('regex', true, array('patern' => '/^[(0-9)]+$/', array('regexNotMatch' => 'Solo Numeros')))->addValidator('stringLength', false, array(1, 8, 'messages' => "Elegir DNI"))->addFilter("StringTrim");
     $idapoderado->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     // creating object for Zend_Form_Element_File
     $doc_file = new Zend_Form_Element_File('foto');
     $doc_file->setLabel('Foto: ')->setRequired(true)->setDestination('main/fotos')->addValidator('Extension', false, 'jpg,png,gif')->addValidator('Size', false, 5120000);
     //5Mb
     $doc_file->setDecorators(array(array('Description', array('tag' => 'p', 'class' => 'description', 'escape' => false)), array('File'), array('Errors'), array('HtmlTag', array('tag' => 'div')), array('Label')));
     $nombre = $this->createElement('text', 'nombre', array('label' => 'Nombre '));
     $nombre->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('stringLength', false, array(2, 150, 'messages' => "Entre 2 y 150 caracteres"))->setRequired(true)->addFilter("StringToUpper")->addFilter('alpha', array('allowwhitespace' => true))->addFilter("StringTrim");
     $nombre->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $appaterno = $this->createElement('text', 'appaterno', array('label' => 'Apellido Paterno '));
     $appaterno->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('stringLength', false, array(2, 150, 'messages' => "Entre 2 y 150 caracteres"))->setRequired(true)->addFilter("StringToUpper")->addFilter('alpha', array('allowwhitespace' => true))->addFilter("StringTrim");
     $appaterno->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $apmaterno = $this->createElement('text', 'apmaterno', array('label' => 'Apellido Materno '));
     $apmaterno->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo Requerido')))->addValidator('stringLength', false, array(2, 150, 'messages' => "Entre 2 y 150 caracteres"))->setRequired(true)->addFilter("StringToUpper")->addFilter('alpha', array('allowwhitespace' => true))->addFilter("StringTrim");
     $apmaterno->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $btnregistrar = $this->createElement('submit', 'registrar', array('label' => 'Registrar'));
     $btnregistrar->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td'))));
     $btnapoderado = $this->createElement('button', 'buscar', array('label' => 'Buscar Apoderado', 'onclick' => 'buscaapoderado();'));
     $btnapoderado->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td'))));
     $gradosactuales = new Application_Model_Grado();
     $includes = new Application_Model_Includes();
     $arraygrados = $gradosactuales->listarGradosActivos();
     $arraygradostoarray = $includes->query2array($arraygrados, 'iGradoIdGrado', 'vGradoDescripcion');
     $grado = $this->createElement('select', 'cbogrado', array('label' => 'Grado', 'autocomplete' => false, 'multiOptions' => $arraygradostoarray, 'onChange' => 'cargarseccion();'));
     $grado->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $seccion = $this->createElement('select', 'cboseccion', array('label' => 'Seccion', 'multiOptions' => array("0" => "Seleccionar Sección")));
     $seccion->addValidator($validator);
     $seccion->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo requerido')));
     $seccion->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $sexo = $this->createElement('radio', 'sexo', array('value' => 'M', 'checked' => 'true', 'Label' => 'Sexo'));
     $sexo->addMultiOptions(array('M' => 'Masculino', 'F' => 'Femenino'));
     $sexo->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
     $idapo = $this->createElement('hidden', 'idapo');
     $this->addElement($btnapoderado)->addElement($idapo)->addElement($idapoderado)->addElement($nombreapo)->addElement($dniapo)->addElement($grado)->addElement($seccion)->addElement($nombre)->addElement($appaterno)->addElement($apmaterno)->addElement($sexo)->addElement($doc_file)->addElement($dni)->addElement($email)->addElement($nombreusuario)->addElement($clave)->addElement($btnregistrar);
 }
 public function agregargradoAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('nuevogrado');
     }
     $form = new Application_Form_FormNuevoGrado();
     if (!$form->isValid($_POST)) {
         // Falla la validación; Se vuelve a mostrar el formulario
         $this->view->formnuevogrado = $form;
         //return $this->render('form');
     }
     $grados = new Application_Model_Grado();
     $listagrados = $grados->listarGradosPeriodoActual();
     //$recordarme = $form->createElement('checkbox', 'remember');
     foreach ($listagrados as $aux) {
         $nombregrado = $aux["vGradoDescripcion"];
         $grado2 = $form->getValue($nombregrado);
         $id = $aux['iGradoIdGrado'];
         if ($grado2 == 1) {
             $grados->actualizarGradoPorId($id, 'A');
         } else {
             $grados->actualizarGradoPorId($id, 'I');
         }
     }
     return $this->_redirect('/admin/plataforma');
 }