Example #1
0
 public function executeGrabarTurnosYPeriodos()
 {
     $ciclolectivo = $this->getRequestParameter('ciclolectivo');
     if (is_numeric($ciclolectivo['id'])) {
         $this->ciclolectivo = CiclolectivoPeer::retrieveByPk($ciclolectivo['id']);
         if (isset($ciclolectivo['descripcion'])) {
             $this->ciclolectivo->setDescripcion($ciclolectivo['descripcion']);
         }
         if (isset($ciclolectivo['fecha_fin'])) {
             if ($ciclolectivo['fecha_fin']) {
                 list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($ciclolectivo['fecha_fin'], $this->getUser()->getCulture());
                 $this->ciclolectivo->setFechaFin("{$y}-{$m}-{$d}");
             }
         }
         if (isset($ciclolectivo['fecha_inicio'])) {
             if ($ciclolectivo['fecha_inicio']) {
                 list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($ciclolectivo['fecha_inicio'], $this->getUser()->getCulture());
                 $this->ciclolectivo->setFechaInicio("{$y}-{$m}-{$d}");
             }
         }
         $this->ciclolectivo->save();
     }
     $aTurnos = $this->getRequestParameter('turnos');
     if (is_array($aTurnos)) {
         foreach ($aTurnos as $turnos) {
             $horaInicio = $this->_add_zeros($turnos['hora_inicio']['hour'], 2) . ":" . $this->_add_zeros($turnos['hora_inicio']['minute'], 2) . " " . $turnos['hora_inicio']['ampm'];
             $horaFin = $this->_add_zeros($turnos['hora_fin']['hour'], 2) . ":" . $this->_add_zeros($turnos['hora_fin']['minute'], 2) . " " . $turnos['hora_fin']['ampm'];
             if ($turnos['descripcion'] and $horaInicio != $horaFin) {
                 if (isset($turnos['id']) and is_numeric($turnos['id'])) {
                     $this->turnos = TurnoPeer::retrieveByPk($turnos['id']);
                 } else {
                     $this->turnos = new Turno();
                 }
                 if (isset($turnos['descripcion'])) {
                     $this->turnos->setDescripcion($turnos['descripcion']);
                 }
                 $this->turnos->setHoraInicio($horaInicio);
                 $this->turnos->setHoraFin($horaFin);
                 $this->turnos->setFkCiclolectivoId($ciclolectivo['id']);
                 $this->turnos->save();
             }
         }
     }
     $aPeriodo = $this->getRequestParameter('periodo');
     if (is_array($aPeriodo)) {
         foreach ($aPeriodo as $periodo) {
             if ($periodo['descripcion'] and ($periodo['fecha_inicio'] or $periodo['fecha_fin'])) {
                 if (isset($periodo['id']) and is_numeric($periodo['id'])) {
                     $this->periodo = PeriodoPeer::retrieveByPk($periodo['id']);
                 } else {
                     $this->periodo = new Periodo();
                 }
                 if (isset($periodo['descripcion'])) {
                     $this->periodo->setDescripcion($periodo['descripcion']);
                 }
                 if (isset($periodo['calcular'])) {
                     $this->periodo->setCalcular($periodo['calcular']);
                 } else {
                     $this->periodo->setCalcular(false);
                 }
                 if (isset($periodo['formula'])) {
                     $this->periodo->setFormula($periodo['formula']);
                 }
                 if (isset($periodo['fecha_inicio'])) {
                     if ($periodo['fecha_inicio']) {
                         list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($periodo['fecha_inicio'], $this->getUser()->getCulture());
                         $this->periodo->setFechaInicio("{$y}-{$m}-{$d}");
                     }
                 }
                 if (isset($periodo['fecha_fin'])) {
                     if ($periodo['fecha_fin']) {
                         list($d, $m, $y) = sfContext::getInstance()->getI18N()->getDateForCulture($periodo['fecha_fin'], $this->getUser()->getCulture());
                         $this->periodo->setFechaFin("{$y}-{$m}-{$d}");
                     }
                 }
                 $this->periodo->setFkCiclolectivoId($ciclolectivo['id']);
                 $this->periodo->save();
             }
         }
     }
     return $this->redirect('ciclolectivo/agregarTurnosYPeriodos?id=' . $ciclolectivo['id']);
 }
Example #2
0
 /**
  * Get the associated Periodo object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Periodo The associated Periodo object.
  * @throws     PropelException
  */
 public function getPeriodo(PropelPDO $con = null)
 {
     if ($this->aPeriodo === null && $this->periodo_id !== null) {
         $this->aPeriodo = PeriodoPeer::retrieveByPk($this->periodo_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aPeriodo->addGradeunits($this);
         		 */
     }
     return $this->aPeriodo;
 }