Ejemplo n.º 1
0
 /**
  * This action creates a career for the school_year selected
  */
 public function executeCreateCareer(sfWebRequest $request)
 {
     $career = CareerPeer::retrieveByPk($request->getParameter('career_id'));
     $this->school_year->createCareerSchoolYear($career);
     $this->getUser()->setFlash('notice', 'Se creo la carrera para el año lectivo');
     $this->redirect('@career_school_year');
 }
Ejemplo n.º 2
0
 /**
  * Answer and array of careers that have relation with the student_id pass by parameter
  *
  * @param integer $student_id
  *
  * @return array
  */
 public static function retrieveCareersForStudent($student_id)
 {
     $c = new Criteria();
     $c->add(self::STUDENT_ID, $student_id);
     $c->addJoin(self::CAREER_ID, CareerPeer::ID);
     return CareerPeer::doSelect($c);
 }
Ejemplo n.º 3
0
 public static function getOrientations($widget, $value)
 {
     $career = CareerPeer::retrieveByPk($value);
     $orientations = array('' => '');
     foreach ($career->getOrientations() as $orientation) {
         $orientations[$orientation->getId()] = $orientation->__toString();
     }
     $widget->setOption("choices", $orientations);
 }
 public static function getYears($widget, $values)
 {
     $career = CareerPeer::retrievebyPk($values);
     $max = $career->getMaxYear();
     $years = array('' => '');
     for ($i = 1; $i <= $max; $i++) {
         $years[$i] = $i;
     }
     $widget->setOption('choices', $years);
 }
Ejemplo n.º 5
0
 /**
  * redefines preExecute because this action CANT BE RISED WITHOUT A REFERENCE
  *
  */
 public function preExecute()
 {
     if (!$this->getUser()->getReferenceFor('career')) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar una carrera para poder administrar sus materias.');
         $this->redirect('@career');
     }
     $this->career = CareerPeer::retrieveByPK($this->getUser()->getReferenceFor('career'));
     if (is_null($this->career)) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar una carrera para poder administrar sus materias.');
         $this->redirect('@career');
     }
     parent::preExecute();
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $this->createContextInstance('backend');
     $c = new Criteria();
     $student_career_school_years = StudentCareerSchoolYearPeer::doSelect($c);
     try {
         $school_year = SchoolYearPeer::retrieveByPk(3);
         foreach ($student_career_school_years as $student_career_school_year) {
             $year = $student_career_school_year->getYear();
             $c = new Criteria();
             $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             StudentCareerSubjectAllowedPeer::doDelete($c);
             if ($year < 7) {
                 $year++;
                 if ($year == 1 || $year == 4) {
                     $career = CareerPeer::retrieveByPk(8);
                 } else {
                     $career = CareerPeer::retrieveByPk(4);
                 }
                 $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($career, $school_year);
                 $c = new Criteria();
                 $c->add(CareerStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
                 $career_student = CareerStudentPeer::doSelectOne($c);
                 $career_student->setCareer($career);
                 $career_student->setFileNumber($career_student->getFileNumber() + rand());
                 $career_student->save($con);
                 $career_student->createStudentsCareerSubjectAlloweds($year, $con);
                 $new_student_career_school_year = new StudentCareerSchoolYear();
                 $new_student_career_school_year->setStudent($student_career_school_year->getStudent());
                 $new_student_career_school_year->setCareerSchoolYear($career_school_year);
                 $new_student_career_school_year->setYear($year);
                 $new_student_career_school_year->save($con);
             } else {
                 $student_career_school_year->delete($con);
             }
         }
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     // add your code here
 }
Ejemplo n.º 7
0
 public function configure()
 {
     $this->unsetFields();
     $this->setWidget('student', new sfWidgetFormFilterInput(array('with_empty' => false)));
     $this->setValidator('student', new sfValidatorPass(array('required' => false)));
     $this->getWidgetSchema()->setHelp('student', 'Filtra por apellido o por número de documento');
     $sy_criteria = new Criteria(SchoolYearPeer::DATABASE_NAME);
     $sy_criteria->addAscendingOrderByColumn(SchoolYearPeer::YEAR);
     $this->setWidget('school_year', new sfWidgetFormPropelChoice(array('model' => 'SchoolYear', 'criteria' => $sy_criteria, 'add_empty' => true)));
     $this->setValidator('school_year', new sfValidatorPropelChoice(array('model' => 'SchoolYear', 'criteria' => new Criteria(SchoolYearPeer::DATABASE_NAME), 'required' => false)));
     $max = CareerPeer::getMaxYear();
     $years = array('' => '');
     for ($i = 1; $i <= $max; $i++) {
         $years[$i] = $i;
     }
     $this->setWidget('year', new sfWidgetFormChoice(array('choices' => $years)));
     $this->setValidator('year', new sfValidatorChoice(array('choices' => array_keys($years), 'required' => false)));
     $this->getWidgetSchema()->setHelp('year', 'El año filtra de acuerdo al año lectivo elegido.');
     $user_criteria = $this->getDivisionCriteriaForUser(sfContext::getInstance()->getUser());
     $this->setWidget('division', new sfWidgetFormPropelChoice(array('model' => 'Division', 'criteria' => $user_criteria, 'add_empty' => true)));
     $this->setValidator('division', new sfValidatorPropelChoice(array('model' => 'Division', 'criteria' => $user_criteria, 'required' => false)));
     $this->widgetSchema->setHelp('division', 'Filtra por la división actual del alumno.');
     $this->setWidget('is_matriculated', new sfWidgetFormChoice(array('choices' => array('' => 'si o no', 1 => 'si', 0 => 'no'))));
     $this->setValidator('is_matriculated', new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))));
     $this->setWidget('is_inscripted_in_career', new sfWidgetFormChoice(array('choices' => array('' => 'si o no', 1 => 'si', 0 => 'no'))));
     $this->setValidator('is_inscripted_in_career', new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))));
     $this->setWidget('is_free_in_some_period', new sfWidgetFormChoice(array('choices' => array('' => 'si o no', 1 => 'si', 0 => 'no'))));
     $this->setValidator('is_free_in_some_period', new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))));
     $this->getWidgetSchema()->setLabel('is_free_in_some_period', 'Is free in some career school year period?');
     $status = StudentCareerSchoolYearStatus::getInstance('StudentCareerSchoolYearStatus');
     $this->setWidget('status', new sfWidgetFormChoice(array('choices' => $status->getOptions(true))));
     $this->setValidator('status', new sfValidatorChoice(array('choices' => $status->getKeys(), 'required' => false)));
     $this->widgetSchema->setHelp('status', 'This status is the status of the student in the current school year.');
     $this->getWidgetSchema()->setLabel('status', 'Current status');
     $this->setWidget('is_graduated', new sfWidgetFormInputCheckbox());
     $this->setValidator('is_graduated', new sfValidatorBoolean());
     $this->widgetSchema->setHelp('is_graduated', 'If is checked, then will show only students graduated in some career in selected school year.');
     $this->setWidget('disciplinary_sanction_count', new sfWidgetFormInput());
     $this->setValidator('disciplinary_sanction_count', new sfValidatorNumber(array('required' => false)));
     $this->widgetSchema->setHelp('disciplinary_sanction_count', 'Students that have more or equal to disciplinary sanctions in current school year.');
     $this->setWidget('health_info', new sfWidgetFormChoice(array('choices' => BaseCustomOptionsHolder::getInstance('HealthInfoStatus')->getOptions(true))));
     $this->setValidator('health_info', new sfValidatorChoice(array('choices' => BaseCustomOptionsHolder::getInstance('HealthInfoStatus')->getKeys(), 'required' => false)));
 }
 public function closeStudentExaminationRepprovedSubject(StudentExaminationRepprovedSubject $student_examination_repproved_subject, PropelPDO $con)
 {
     if ($student_examination_repproved_subject->getMark() >= $this->getExaminationNote()) {
         $student_approved_career_subject = new StudentApprovedCareerSubject();
         $student_approved_career_subject->setCareerSubject($student_examination_repproved_subject->getExaminationRepprovedSubject()->getCareerSubject());
         $student_approved_career_subject->setStudent($student_examination_repproved_subject->getStudent());
         $student_approved_career_subject->setSchoolYear($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getSchoolYear());
         if ($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getExaminationType() == ExaminationRepprovedType::REPPROVED) {
             //Final average is the average of the course_subject_student and the mark of student_examination_repproved_subject
             $average = (string) (($student_examination_repproved_subject->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()->getMarksAverage() + $student_examination_repproved_subject->getMark()) / 2);
             $average = sprintf('%.4s', $average);
             if ($average < self::MIN_NOTE) {
                 $average = self::MIN_NOTE;
             }
             $student_approved_career_subject->setMark($average);
         } else {
             //Final calification is the mark of student_examination_repproved_subject
             $student_approved_career_subject->setMark($student_examination_repproved_subject->getMark());
         }
         $student_repproved_course_subject = $student_examination_repproved_subject->getStudentRepprovedCourseSubject();
         $student_repproved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
         $student_repproved_course_subject->save($con);
         $career = $student_repproved_course_subject->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getCareer();
         ##se corrobora si la previa es la última y del último año, hay que egresarlo
         $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student_repproved_course_subject->getStudent(), $career);
         if ($student_repproved_course_subject->getStudent()->getCurrentOrLastStudentCareerSchoolYear()->getYear() >= CareerPeer::getMaxYear() && $previous == 0) {
             $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career->getId(), $student_repproved_course_subject->getStudent()->getId());
             $career_student->setStatus(CareerStudentStatus::GRADUATE);
             //se guarda el school_year en que termino esta carrera
             $career_student->setGraduationSchoolYearId(SchoolYearPeer::retrieveCurrent()->getId());
             $career_student->save($con);
             //se guarda el estado en el student_career_school_year
             $scsy = $student_repproved_course_subject->getCourseSubjectStudent()->getStudent()->getCurrentOrLastStudentCareerSchoolYear();
             $scsy->setStatus(StudentCareerSchoolYearStatus::APPROVED);
             $scsy->save();
         }
         ##se agrega el campo en student_disapproved_course_subject a el link del resultado final
         $student_repproved_course_subject->getCourseSubjectStudent()->getCourseResult()->setStudentApprovedCareerSubject($student_approved_career_subject)->save($con);
         $student_approved_career_subject->save($con);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $this->createContextInstance();
     $username = '******';
     $user = sfContext::getInstance()->getUser();
     $sf_user = sfGuardUserPeer::retrieveByUsername($username);
     $user->signin($sf_user, false);
     $new_career_school_year_2014 = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK(8), SchoolYearPeer::retrieveCurrent());
     $old_career_school_year_2013 = CareerSchoolYearPeer::retrieveByPk(21);
     $new_career_school_year_2013 = CareerSchoolYearPeer::retrieveByPk(22);
     $old_career_school_year_2014 = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK(4), SchoolYearPeer::retrieveCurrent());
     $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear(SchoolYearPeer::retrieveCurrent());
     // ---------------------------------------------------------------------------------------------- //
     // Alumnos que promueven 6to deben seguir en el plan viejo
     $this->log('1 -Alumnos que promueven 6to deben seguir en el plan viejo');
     $c = new Criteria();
     $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $old_career_school_year_2013->getId());
     $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true);
     $c->add(StudentCareerSchoolYearPeer::YEAR, 6);
     $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED);
     $students_to_old_career_school_years = StudentCareerSchoolYearPeer::doSelect($c);
     try {
         $connection->beginTransaction();
         foreach ($students_to_old_career_school_years as $socsy) {
             $shift = $socsy->getStudent()->getShiftForSchoolYear($last_year_school_year);
             if (!$socsy->getStudent()->getIsRegistered($old_career_school_year_2014->getSchoolYear())) {
                 $socsy->getStudent()->registerToSchoolYear($old_career_school_year_2014->getSchoolYear(), $shift, $connection);
             }
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // ---------------------------------------------------------------------------------------------- //
     // 2 - Resto de los alumnos que no son del CBFE van al plan nuevo en el año que les corresponda
     $this->log('2 - Resto de los alumnos que no son del CBFE van al plan nuevo en el año que les corresponda');
     try {
         $connection->beginTransaction();
         // con este criteria voy a excluir a los que aprueban 6to y deben ir a 7mo del plan viejo
         $c = new Criteria();
         $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $old_career_school_year_2013->getId());
         $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true);
         $c->add(StudentCareerSchoolYearPeer::YEAR, 6);
         $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED);
         $c->clearSelectColumns();
         $c->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID);
         $stmt = StudentCareerSchoolYearPeer::doSelectStmt($c);
         $students_to_old_career_school_years_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
         // con este criteria voy a excluir a los que son del CBFE
         $c = new Criteria();
         $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, 23);
         $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true);
         $c->clearSelectColumns();
         $c->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID);
         $stmt = StudentCareerSchoolYearPeer::doSelectStmt($c);
         $student_cbfe_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
         // al total le saco $students_to_old_career_school_years_ids y los
         // student_cbfe_ids
         $c = new Criteria();
         //$c = StudentCareerSchoolYearPeer::retrieveLastYearStudentNotGraduatedCriteria($new_career_school_year_2014);
         $c->add(StudentCareerSchoolYearPeer::YEAR, 7, Criteria::NOT_EQUAL);
         $c->addJoin(StudentCareerSchoolYearPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN);
         $c->add(StudentPeer::ID, array_merge($students_to_old_career_school_years_ids, $student_cbfe_ids), Criteria::NOT_IN);
         $students = StudentPeer::doSelectActive($c);
         foreach ($students as $student) {
             $shift = $student->getShiftForSchoolYear($last_year_school_year);
             if (!$student->getIsRegistered($new_career_school_year_2014->getSchoolYear()) && $shift) {
                 $slcsy = $student->getLastStudentCareerSchoolYear();
                 $slcs = $student->getLastCareerStudent();
                 if ($slcsy->getStatus() == StudentCareerSchoolYearStatus::APPROVED) {
                     $start_year = $slcsy->getYear() + 1;
                 } else {
                     $start_year = $slcsy->getYear();
                 }
                 if ($slcs->getCareerId() != $new_career_school_year_2014->getCareerId()) {
                     $student->registerToCareer($new_career_school_year_2014->getCareer(), null, null, $start_year, $connection);
                     $sys = new SchoolYearStudent();
                     $sys->setStudentId($student->getId());
                     $sys->setSchoolYearId($new_career_school_year_2014->getSchoolYear()->getId());
                     $sys->setShift($shift);
                     $sys->save($connection);
                     $this->verify($student, $new_career_school_year_2014, $connection);
                 } else {
                     $sys = new SchoolYearStudent();
                     $sys->setStudentId($student->getId());
                     $sys->setSchoolYearId($new_career_school_year_2014->getSchoolYear()->getId());
                     $sys->setShift($shift);
                     $sys->save($connection);
                     $this->verify($student, $new_career_school_year_2014, $connection);
                 }
                 if (!is_null($shift)) {
                     $shift->clearAllReferences(true);
                 }
                 $student->clearAllReferences(true);
                 unset($student);
                 unset($shift);
             }
             StudentPeer::clearInstancePool();
             unset($students);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
 }
Ejemplo n.º 10
0
 /**
  * Adds the career menu to the main menu.
  *
  * @param pmJSCookMenu $menu
  * @return void
  */
 public function addCareerMenu(pmJSCookMenu $menu)
 {
     $career = CareerPeer::retrieveByPK($this->getReferenceFor("career"));
     sfContext::getInstance()->getConfiguration()->loadHelpers(array("I18N"));
     if (!is_null($career)) {
         $menu->addChild("menu_separator", new pmJSCookMenuSeparator());
         $submenu = new pmJSCookMenu();
         $submenu->setTitle("<strong>" . __("Current career") . "</strong>")->setCredentials("edit_career");
         $item = new pmJSCookMenuItem();
         $item->setTitle($career);
         $submenu->addChild("career_name", $item);
         $submenu->addChild("first_separator", new pmJSCookMenuSeparator());
         // edit
         if ($career->canBeEdited()) {
             $item = new pmJSCookMenuItem();
             $item->setTitle("Edit")->setUrl("@career_edit?id=" . $career->getId())->setCredentials("edit_career");
             $submenu->addChild("edit", $item);
         }
         // delete
         if ($career->canBeDeleted()) {
             // TODO: ver esto porque REST no funciona con JS
             $delete_url = url_for(array("sf_route" => "career_delete", "sf_subject" => $career, "sf_method" => "delete"));
             $item = new pmJSCookMenuItem();
             $item->setTitle("Delete")->setUrl($delete_url)->setCredentials("edit_career");
             $submenu->addChild("delete", $item);
         }
         if ($career->canBeEdited() || $career->canBeDeleted()) {
             $submenu->addChild("second_separator", new pmJSCookMenuSeparator());
         }
         // copy
         $item = new pmJSCookMenuItem();
         $item->setTitle("Copy")->setUrl("career/copy?id=" . $career->getId())->setCredentials("edit_career");
         $submenu->addChild("copy", $item);
         // subjects
         $item = new pmJSCookMenuItem();
         $item->setTitle("Subjects")->setUrl("career/subjects?id=" . $career->getId())->setCredentials("edit_career");
         $submenu->addChild("subjects", $item);
         // subject options
         $item = new pmJSCookMenuItem();
         $item->setTitle("Subject options")->setUrl("career/subjectOptions?id=" . $career->getId())->setCredentials("edit_career");
         $submenu->addChild("subject_options", $item);
         // career view
         $item = new pmJSCookMenuItem();
         $item->setTitle("Career view")->setUrl("career/careerView?id=" . $career->getId())->setCredentials("edit_career");
         $submenu->addChild("career_view", $item);
         // show inscripted
         $item = new pmJSCookMenuItem();
         $item->setTitle("Show inscripted")->setUrl("career/students?id=" . $career->getId())->setCredentials("edit_career");
         $submenu->addChild("career_view", $item);
         $menu->addChild("career", $submenu);
     }
 }
Ejemplo n.º 11
0
 public function getUnrelatedCareers()
 {
     $already = array();
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $this->getId());
     foreach (CareerSchoolYearPeer::doSelect($c) as $csy) {
         $already[] = $csy->getCareerId();
     }
     $c2 = new Criteria();
     $c2->add(CareerPeer::ID, $already, Criteria::NOT_IN);
     return CareerPeer::doSelect($c2);
 }
Ejemplo n.º 12
0
 public function canMatriculateGraduatedFromOtherCareer()
 {
     $last_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($this->getSchoolYear());
     return $last_school_year && $last_school_year->getIsClosed() && CareerPeer::moreThanOneCareer();
 }
Ejemplo n.º 13
0
 * the Free Software Foundation.
 *
 * Kimkëlen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Kimkëlen.  If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
 */
use_helper('I18N', 'Object', 'Form');
include_partial('career/assets');
?>

<?php 
$career = CareerPeer::RetrieveByPk($sf_user->getAttribute('career_id'));
$students = CareerStudentPeer::retrieveStudentsForCareer($sf_user->getAttribute('career_id'));
?>

<div id="sf_admin_container">
  <div class="career_view_title">
    <h1><?php 
echo $career->getCareerName() . ' | ' . $career->getPlanName();
?>
</h1>
    <h2><?php 
echo __('Alumnos Inscriptos');
?>
:</h2>
     <table class="sf_career_table">
       <thead>
Ejemplo n.º 14
0
<h2>Mesa de exámen: <?php 
echo $examination;
?>
</h2>

<ul>
	<div class="info-box">
		<div class="info-box-title">
			<strong><?php 
echo link_to_function(__("Create examinations"), "jQuery('#not_created_examination_subjects').toggle();");
?>
</strong>
		</div>
		<div class="info-box-collapsable" style="display: block" id="not_created_examination_subjects" >
			<?php 
for ($i = 1; $i <= CareerPeer::getMaxYear(); $i++) {
    ?>
				<?php 
    if ($examination->countExaminationSubjectsForYear($i) == 0) {
        ?>
					<li><?php 
        echo link_to(__("Create examination subjects for %year%° year", array('%year%' => $i)), 'examination/createExaminationSubjects?year=' . $i . '&id=' . $examination->getId());
        ?>
</li>
				<?php 
    }
    ?>
			<?php 
}
?>
		</div>
 protected function doSave($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     // Delete only the subjects off the selected career
     $c = new Criteria();
     $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $this->object->getPrimaryKey());
     // added:
     $subc = new Criteria();
     $subc->clearSelectColumns();
     $subc->addSelectColumn(CareerSubjectPeer::ID);
     $subc->add(CareerSubjectPeer::CAREER_ID, $this->getValue("career_id"));
     $stmt = CareerSubjectPeer::doSelectStmt($subc);
     $ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
     $c->add(StudentCareerSubjectAllowedPeer::CAREER_SUBJECT_ID, $ids, Criteria::IN);
     $allowed = StudentCareerSubjectAllowedPeer::doSelectOne($c, $con);
     if ($allowed) {
         // Se consulta si el alumno esta en trayectorias antes de eliminarlo
         $student_id = $this->object->getPrimaryKey();
         $criteria = new Criteria();
         $criteria->add(PathwayStudentPeer::STUDENT_ID, $student_id);
         $pathway = PathwayStudentPeer::doSelectOne($criteria, $con);
         if (!$pathway) {
             StudentCareerSubjectAllowedPeer::doDelete($c, $con);
         }
     }
     $year = $this->getValue('year');
     $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK($this->getValue('career_id')), SchoolYearPeer::retrieveCurrent());
     //First update the year at student_career_school_year
     //    var_dump($career_school_year);die();
     $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($this->getObject(), $career_school_year);
     //    if (!$student_career_school_year)
     //    {
     //      $student_career_school_year = new StudentCareerSchoolYear();
     //      $student_career_school_year->setCareerSchoolYear($career_school_year);
     //      $student_career_school_year->setStudent($this->getObject());
     //      $student_career_school_year->save();
     //    }
     $career_student = CareerStudentPeer::retrieveByCareerAndStudent($this->getValue('career_id'), $this->getObject()->getId());
     try {
         $con->beginTransaction();
         $student_career_school_year->setYear($year);
         $student_career_school_year->save($con);
         $c = new Criteria();
         $c->add(CareerSubjectPeer::CAREER_ID, $this->getValue('career_id'));
         $c->add(CareerSubjectPeer::YEAR, $year);
         foreach (CareerSubjectPeer::doSelect($c) as $career_subject) {
             $obj = new StudentCareerSubjectAllowed();
             $obj->setStudentId($this->object->getPrimaryKey());
             $obj->setCareerSubject($career_subject);
             $obj->save($con);
         }
         $prev_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($career_school_year->getSchoolYear());
         if ($prev_school_year) {
             $prev_student_career_school_year = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($this->getObject(), $prev_school_year);
         }
         if (!empty($prev_student_career_school_year)) {
             $prev_student_career_school_year = array_shift($prev_student_career_school_year);
             if ($year <= $prev_student_career_school_year->getYear()) {
                 $prev_student_career_school_year->setStatus(StudentCareerSchoolYearStatus::REPPROVED);
                 $prev_student_career_school_year->save($con);
             }
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Ejemplo n.º 16
0
 public static function getYears($widget, $values)
 {
     $choices = CareerPeer::retrieveByPk($values)->getYearsForOption(true);
     $widget->setOption('choices', $choices);
 }