public static function retriveByStudentCareerSchoolYearAndPeriod($student_career_school_year, $period)
 {
     $c = new Criteria();
     $c->add(StudentCareerSchoolYearConductPeer::STUDENT_CAREER_SCHOOL_YEAR_ID, $student_career_school_year->getId());
     $c->add(StudentCareerSchoolYearConductPeer::CAREER_SCHOOL_YEAR_PERIOD_ID, $period->getId());
     return StudentCareerSchoolYearConductPeer::doSelectOne($c);
 }
Example #2
0
    <?php 
foreach ($students as $student) {
    ?>
      <tr>
        <td><?php 
    echo $student;
    ?>
</td>
        <?php 
    $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $division->getCareerSchoolYear());
    ?>
        <?php 
    foreach ($periods as $period) {
        ?>
          <td><?php 
        echo $form['conduct_' . $student->getId() . '_' . $period->getId()]->render();
        include_partial('changelog', array('student_career_school_year_conduct' => StudentCareerSchoolYearConductPeer::retrieveOrCreate($student_career_school_year, $period)));
        ?>
</td>
          <?php 
        echo $form->renderHiddenFields();
        ?>
        <?php 
    }
    ?>
      </tr>
    <?php 
}
?>
  </tbody>
</table>
 public function save($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     try {
         $con->beginTransaction();
         $values = $this->getValues();
         $students = $this->getStudents();
         $periods = $this->getPeriods();
         $career_school_year = $this->getCareerSchoolYear();
         foreach ($students as $student) {
             $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year);
             foreach ($periods as $period) {
                 if (!$period->getIsClosed()) {
                     $conduct_id = $values['conduct_' . $student->getId() . '_' . $period->getId()];
                     $scsyc = StudentCareerSchoolYearConductPeer::retrieveOrCreate($student_career_school_year, $period);
                     if (!is_null($conduct_id)) {
                         $scsyc->setConductId($conduct_id);
                         $scsyc->save();
                     } elseif (!is_null($scsyc->getConduct())) {
                         $scsyc->delete();
                     }
                 }
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #4
0
 public function getConductPeriod(CareerSchoolYearPeriod $period)
 {
     $scsy = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($this, $period->getCareerSchoolYear());
     return StudentCareerSchoolYearConductPeer::retriveByStudentCareerSchoolYearAndPeriod($scsy, $period);
 }