public function save($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     try {
         $con->beginTransaction();
         $values = $this->getValues();
         $school_year = SchoolYearPeer::retrieveByPK($values["school_year_id"]);
         $shift = ShiftPeer::retrieveByPK($values["shift_id"]);
         unset($values["school_year_id"]);
         unset($values["shift_id"]);
         foreach ($values as $student_id) {
             $student = StudentPeer::retrieveByPk($student_id);
             if (!$student->getIsRegistered($school_year)) {
                 $student->registerToSchoolYear($school_year, $shift, $con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public function configure()
 {
     $this->widgetSchema["school_year_id"] = new sfWidgetFormInputHidden();
     $this->setWidget('date_from', new csWidgetFormDateInput());
     $this->setWidget('date_to', new csWidgetFormDateInput());
     $this->setValidator('date_from', new mtValidatorDateString());
     $this->setValidator('date_to', new mtValidatorDateString());
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare("date_from", sfValidatorSchemaCompare::LESS_THAN_EQUAL, "date_to", array(), array("invalid" => "Date from must be lesser than date to.")));
     $school_year = SchoolYearPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor("schoolyear"));
     $this->getValidator('examination_number')->setOption('max', $school_year->getMaxCourseExaminationCount());
     $this->getValidator('examination_number')->setMessage('max', 'El número de instancia de mesa no puede ser mayor que %max%');
 }
Beispiel #3
0
 /**
  * Redefines preExecute because this action CANT BE RISED WITHOUT A REFERENCE
  *
  */
 public function preExecute()
 {
     if (!$this->getUser()->getReferenceFor('schoolyear')) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar un año lectivo para poder administrar sus carreras.');
         $this->redirect('@schoolyear');
     }
     $this->school_year = SchoolYearPeer::retrieveByPK($this->getUser()->getReferenceFor('schoolyear'));
     if (is_null($this->school_year)) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar un año lectivo para poder administrar sus carreras.');
         $this->redirect('@schoolyear');
     }
     parent::preExecute();
 }
 public function updateOptionalCareerSubject($widget, $value)
 {
     $school_year_id = array_shift($value);
     $criteria = new Criteria();
     if ($school_year_id != "") {
         $career_subject = $this->getObject()->getCareerSubject();
         $school_year = SchoolYearPeer::retrieveByPK($school_year_id);
         $career_subject_school_year = CareerSubjectSchoolYearPeer::retrieveByCareerSubjectAndSchoolYear($career_subject, $school_year);
         $opcions = array();
         foreach ($career_subject_school_year->getChoices() as $optional_career_subject_school_year) {
             $cs = CareerSubjectPeer::retrieveByCareerSubjectSchoolYearId($optional_career_subject_school_year->getChoiceCareerSubjectSchoolYearId());
             $opcions[] = $cs->getId();
         }
         //$opcions es un arreglo con todas las posibles optativas
         $criteria->add(CareerSubjectPeer::ID, $opcions, Criteria::IN);
         $widget->getOption('widget')->setOption('criteria', $criteria);
     }
 }
 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('backend');
     try {
         $connection->beginTransaction();
         $c = new Criteria();
         $c->add(StudentApprovedCareerSubjectPeer::SCHOOL_YEAR_ID, 1);
         $student_approved_career_subjects = StudentApprovedCareerSubjectPeer::doSelect($c);
         $arreglados = 0;
         foreach ($student_approved_career_subjects as $student_approved_career_subject) {
             if (!($student_approved_career_subject->hasStudentApprovedCourseSubject() || $student_approved_career_subject->hasStudentDisapprovedCourseSubject() || $student_approved_career_subject->hasStudentRepprovedCourseSubject())) {
                 $evaluetor = new LvmEvaluatorBehaviour();
                 $c = new Criteria();
                 $course_subject_student = CourseSubjectStudentPeer::retrieveByStudentApprovedCareerSubject($student_approved_career_subject, SchoolYearPeer::retrieveByPK(1));
                 if ($course_subject_student) {
                     $instanceResult = $evaluetor->getCourseSubjectStudentResult($course_subject_student, $connection);
                     if ($instanceResult instanceof StudentApprovedCourseSubject) {
                         $criteria = new Criteria();
                         $criteria->add(StudentApprovedCourseSubjectPeer::STUDENT_ID, $instanceResult->getStudentId());
                         $criteria->add(StudentApprovedCourseSubjectPeer::SCHOOL_YEAR_ID, $instanceResult->getSchoolYearId());
                         $criteria->add(StudentApprovedCourseSubjectPeer::COURSE_SUBJECT_ID, $instanceResult->getCourseSubjectId());
                         if (StudentApprovedCourseSubjectPeer::doCount($criteria)) {
                             $instanceResult = StudentApprovedCourseSubjectPeer::doSelectOne($criteria);
                         }
                         $instanceResult->setStudentApprovedCareerSubject($student_approved_career_subject);
                         $instanceResult->setStudentApprovedCareerSubjectId($student_approved_career_subject->getId());
                         $instanceResult->save();
                         $this->logSection("arreglado", $arreglados);
                         $this->logSection("alumno", $instanceResult->getStudent());
                         $this->logSection("careerSubject", $instanceResult->getCareerSubject());
                         $this->logSection("StudentApprovedCourseSubject", $instanceResult);
                         $this->logSection("StudentApprovedCareerSubject ID: ", $student_approved_career_subject->getId());
                         //var_dump($instanceResult);die();
                         $arreglados++;
                     }
                 } else {
                     $this->logSection("No se pudieron ubicar", $student_approved_career_subject->getStudent() . '- ' . $student_approved_career_subject->getCareerSubject() . '' . $student_approved_career_subject->getId());
                 }
             }
         }
         $this->logSection("arreglados", $arreglados);
         $connection->commit();
         $connection->beginTransaction();
         $c = new Criteria();
         $c->add(StudentApprovedCourseSubjectPeer::SCHOOL_YEAR_ID, 1);
         $c->add(StudentApprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL);
         //Se actualizan los cursos aprobados con la materia aprobada, esto existe por que hubo una version que no lo hacia de forma correcta y esto corrige dicho error.
         $update = 0;
         $news = 0;
         $student_approved_course_subjects_null = StudentApprovedCourseSubjectPeer::doSelect($c);
         foreach ($student_approved_course_subjects_null as $student_approved_course_subject) {
             $course_subject_student = $student_approved_course_subject->getCourseSubjectStudent();
             if ($course_subject_student) {
                 $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($course_subject_student->getCourseSubject()->getCareerSubject()->getId(), $student_approved_course_subject->getCourseSubjectStudent()->getStudentId());
             } else {
                 $this->logSection("Cuak!", $student_approved_course_subject->getId(), $student_approved_course_subject);
             }
             $student_approved_career_subject->setSchoolYearId(1);
             $student_approved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject);
             $student_approved_career_subject->isNew() ? $news++ : $update++;
             $student_approved_course_subject->save($connection);
             $student_approved_career_subject->save($connection);
         }
         $this->logSection("Actualizados", $update);
         $this->logSection("Nuevos", $news);
         //Este foreach corrige el error de una version, que creaba tambien el student_approved_course_subject, cuando no es real.
         $c = new Criteria();
         $student_dissapproved_course_subjects = StudentDisapprovedCourseSubjectPeer::doSelect($c);
         $delete = 0;
         foreach ($student_dissapproved_course_subjects as $student_dissapproved_course_subject) {
             $course_subject_student = $student_dissapproved_course_subject->getCourseSubjectStudent();
             $c = new Criteria();
             $c->add(StudentApprovedCourseSubjectPeer::STUDENT_ID, $course_subject_student->getStudentId());
             $c->add(StudentApprovedCourseSubjectPeer::COURSE_SUBJECT_ID, $course_subject_student->getCourseSubjectId());
             $student_approved_course_subject = StudentApprovedCourseSubjectPeer::doSelectOne($c);
             if (!is_null($student_approved_course_subject)) {
                 $student_approved_course_subject->delete($connection);
                 $delete++;
             }
         }
         $this->logSection("Borrados", $delete);
         $connection->commit();
         /*
          $c = new Criteria();
          $c->add(StudentDisapprovedCourseSubjectPeer::STUDENT_APPROVED_CAREER_SUBJECT_ID, null, Criteria::ISNULL);
         
          $student_dissapproved_course_subjects = StudentDisapprovedCourseSubjectPeer::doSelect($c);
          foreach ($student_dissapproved_course_subjects as $student_dissapproved_course_subject)
          {
          $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent(
          $student_dissapproved_course_subject->getCourseSubjectStudent()->getCourseSubject()->getCareerSubject()->getId(),
          $student_dissapproved_course_subject->getCourseSubjectStudent()->getStudentId());
         
          if (!is_null($student_approved_career_subject) && !$student_approved_career_subject->isNew())
          {
          $student_dissapproved_course_subject->setStudentApprovedCareerSubjectId($student_approved_career_subject->getId());
          $student_dissapproved_course_subject->save($connection);
          }
          else
          {
          $student_repproved_course_subject = StudentRepprovedCourseSubjectPeer::retrieveCourseSubjectStudent($student_dissapproved_course_subject->getCourseSubjectStudent());
         
          if (is_null($student_repproved_course_subject))
          {
          die(var_dump($student_dissapproved_course_subject->getId()));
          }
          }
          }
         */
         //$this->fixComissions($connection);
         //$this->fixCourseSubjectStudents($connection);
         //$this->fixStudentCareerSchoolYearStatus($connection);
         //$this->fixRepetidores($connection);
         //$this->fixApproved($connection);
     } catch (PropelException $e) {
         $connection->rollback();
         throw $e;
     }
     // add your code here
 }
Beispiel #6
0
          <th class="th_stats"><?php 
echo __('School year');
?>
</th>
          <?php 
if (!isset($filters['school_year']) || is_null($filters['school_year'])) {
    ?>
            <td><?php 
    echo CareerSchoolYearPeer::retrieveByPK($filters['career_school_year'])->getSchoolYear();
    ?>
</td>
          <?php 
} else {
    ?>
            <td><?php 
    echo SchoolYearPeer::retrieveByPK($filters['school_year']);
    ?>
</td>
          <?php 
}
?>
        </tr>
      <tr>
        <th class="th_stats"><?php 
echo __('Career school year');
?>
</th>
        <?php 
if (!isset($filters['career_school_year']) || is_null($filters['career_school_year'])) {
    ?>
          <td class="td_stats"><?php 
Beispiel #7
0
 public function canCreateFinalExamination()
 {
     $school_year = SchoolYearPeer::retrieveByPK($this->getReferenceFor("schoolyear"));
     return $school_year->getIsActive();
 }
Beispiel #8
0
 public function getShiftFromStudentStatsFilters()
 {
     $user = sfContext::getInstance()->getUser();
     $filters = $user->getAttribute('student_stats.filters', null, 'admin_module');
     if (!isset($filters['shift']) || is_null($filters['shift'])) {
         if (!isset($filters['division']) || is_null($filters['division'])) {
             $result = array();
             if (!isset($filters['career_school_year']) || is_null($filters['career_school_year'])) {
                 foreach (DivisionPeer::retrieveStudentSchoolYearDivisions(SchoolYearPeer::retrieveByPK($filters['school_year']), $this) as $division) {
                     $result[$division->getShift()->getName()] = $division->getShift();
                 }
             } else {
                 $career_school_year_id = $filters['career_school_year'];
                 $divisions = $this->getCurrentDivisions($career_school_year_id);
                 foreach ($divisions as $division) {
                     $result[$division->getShift()->getName()] = $division->getShift()->getName();
                 }
             }
             return implode(', ', $result);
         } else {
             return DivisionPeer::retrieveByPK($filters['division'])->getShift();
         }
     } else {
         return ShiftPeer::retrieveByPK($filters['shift']);
     }
 }