コード例 #1
0
 public function save($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = Propel::getConnection(CareerStudentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     try {
         $con->beginTransaction();
         $values = $this->getValues();
         $career = CareerPeer::retrieveByPK($values["career_id"]);
         $orientation = OrientationPeer::retrieveByPK($values["orientation_id"]);
         $sub_orientation = SubOrientationPeer::retrieveByPK($values["sub_orientation_id"]);
         $start_year = $values["start_year"];
         unset($values["career_id"]);
         unset($values["orientation_id"]);
         unset($values["sub_orientation_id"]);
         unset($values["start_year"]);
         foreach ($values as $student_id) {
             $student = StudentPeer::retrieveByPk($student_id, $con);
             if (!$student->isRegisteredToCareer($career, $con)) {
                 $student->registerToCareer($career, $orientation, $sub_orientation, $start_year, $con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #2
0
 public static function getSubOrientations($widget, $value)
 {
     $orientation = OrientationPeer::retrieveByPk($value);
     $sub_orientations = array("" => "");
     foreach ($orientation->getSubOrientations() as $sub_orientation) {
         $sub_orientations[$sub_orientation->getId()] = $sub_orientation;
     }
     $widget->setOption("choices", $sub_orientations);
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: nvidela/kimkelen
 public function preExecute()
 {
     if (!$this->getUser()->getReferenceFor('orientation')) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar una orientación para poder administrar sus sub orientaciones.');
         $this->redirect('@orientation');
     }
     $this->orientation = OrientationPeer::retrieveByPK($this->getUser()->getReferenceFor('orientation'));
     if (is_null($this->orientation)) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar una orientación para poder administrar sus sub orientaciones.');
         $this->redirect('@orientation');
     }
     parent::preExecute();
 }