public function configure() { $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this); $this->getWidgetSchema()->addFormFormatter('Revisited', $sf_formatter_revisited); $this->getWidgetSchema()->setFormFormatterName('Revisited'); unset($this['created_at'], $this['career_school_year_id'], $this['is_processed'], $this['id'], $this['year']); $this->setWidget('student_id', new sfWidgetFormInputHidden()); $status = BaseCustomOptionsHolder::getInstance('StudentCareerSchoolYearStatus')->getOptionsSelect(); $this->setWidget('status', new sfWidgetFormSelect(array('choices' => $status))); $w = new sfWidgetFormChoice(array('choices' => array())); $this->setWidget('change_status_motive_id', new dcWidgetAjaxDependence(array('dependant_widget' => $w, 'observe_widget_id' => 'student_career_school_year_status', 'message_with_no_value' => 'Seleccione un estado y aparecerán los motivos correspondientes', 'get_observed_value_callback' => array(get_class($this), 'getMotives')))); $this->setWidget('start_date_reserve', new csWidgetFormDateInput()); $this->setValidator('start_date_reserve', new mtValidatorDateString(array('date_output' => 'Y-m-d'))); $this->setWidget('end_date_reserve', new csWidgetFormDateInput()); $this->setValidator('end_date_reserve', new mtValidatorDateString(array('date_output' => 'Y-m-d'))); //si ya tiene reserva muestro la fecha if ($this->getObject()->getStatus() == StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE) { $reserve = $this->getObject()->getStudent()->hasActiveReserve(); if (!is_null($reserve)) { $start_date = new DateTime($reserve->getStartDate()); if (!is_null($start_date)) { $this->getWidget('start_date_reserve')->setOption('default', $start_date->format('d/m/Y')); } } } $this->setValidators(array('student_id' => new sfValidatorPropelChoice(array('model' => 'Student', 'column' => 'id', 'required' => false)), 'status' => new sfValidatorChoice(array('choices' => array_keys($status))), 'change_status_motive_id' => new sfValidatorPropelChoice(array('required' => false, 'model' => 'ChangeStatusMotive', 'column' => 'id')))); $this->validatorSchema->setOption("allow_extra_fields", true); }
public function configure() { unset($this['address_id']); unset($this['user_id']); $this->setWidget('change_password_at', new csWidgetFormDateInput(array('change_year' => true))); $this->setValidator('change_password_at', new mtValidatorDateString(array('required' => false))); $this->setWidget('identification_type', new sfWidgetFormSelect(array('choices' => BaseCustomOptionsHolder::getInstance('IdentificationType')->getOptions()))); $this->setValidator('identification_type', new sfValidatorChoice(array('choices' => BaseCustomOptionsHolder::getInstance('IdentificationType')->getKeys()))); }
public function configure() { $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this); $this->getWidgetSchema()->addFormFormatter('Revisited', $sf_formatter_revisited); $this->getWidgetSchema()->setFormFormatterName('Revisited'); unset($this['id']); $status = BaseCustomOptionsHolder::getInstance('StudentCareerSchoolYearStatus')->getOptionsSelect(); $this->setWidget('status_id', new sfWidgetFormSelect(array('choices' => $status))); $this->setValidators(array('name' => new sfValidatorString(array('max_length' => 50)), 'status_id' => new sfValidatorChoice(array('choices' => array_keys($status))))); }
public function configure() { $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this); $this->getWidgetSchema()->addFormFormatter('Revisited', $sf_formatter_revisited); $this->getWidgetSchema()->setFormFormatterName('Revisited'); unset($this['created_at'], $this['school_year_id'], $this['student_id']); $this->getWidget('shift_id')->setOption('add_empty', false); $this->setWidget('health_info', new sfWidgetFormSelect(array('choices' => BaseCustomOptionsHolder::getInstance('HealthInfoStatus')->getOptions()))); $this->setWidget('date_health_info', new csWidgetFormDateInput()); $this->setValidator('date_health_info', new mtValidatorDateString(array('required' => false, 'date_output' => 'Y-m-d'))); }
protected function doSave($con = null) { parent::doSave($con); $guard_user = $this->getObject()->getPersonSfGuardUser(); if (!is_null($guard_user)) { $student_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::STUDENT); if (!array_key_exists($student_group, $guard_user->getGroups())) { $guard_user->addGroupByName($student_group); $guard_user->save($con); } } }
public function doSave($con = null) { if (is_null($con)) { $con = $this->getConnection(); } parent::doSave($con); $this->updateObject(); //$this->object->setCourseMarks(3); $this->object->setEvaluationMethod(BaseCustomOptionsHolder::getInstance('CourseType')->getEvaluationMethodFor($this->object->getCourseType())); $this->object->save($con); // embedded forms $this->saveEmbeddedForms($con); }
public function createTeacher(PropelPDO $con = null) { $con = is_null($con) ? Propel::getConnection() : $con; $teacher = new Teacher(); $teacher->setPerson($this->getPerson()); $teacher->save($con); $guard_user = $this->getPersonSfGuardUser(); if (!is_null($guard_user)) { $teacher_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::TEACHER); if (!array_key_exists($teacher_group, $guard_user->getGroups())) { $guard_user->addGroupByName($teacher_group); $guard_user->save($con); } } }
public function doSave($con = null) { if (is_null($con)) { $con = $this->getConnection(); } $this->updateObject(); // $this->object->setCourseMarks(3); if ($this->object->getCourseType() == CourseType::BIMESTER) { $this->object->setEvaluationMethod(EvaluationMethod::FINAL_PROM); } else { $this->object->setEvaluationMethod(BaseCustomOptionsHolder::getInstance('CourseType')->getEvaluationMethodFor($this->object->getCourseType())); } //$this->object->setAttendanceType($this->getValues('attendance_type')); $this->object->save($con); // embedded forms $this->saveEmbeddedForms($con); }
protected function doSave($con = null) { parent::doSave($con); $guard_user = $this->getObject()->getPersonSfGuardUser(); if (!is_null($guard_user)) { $teacher_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::TEACHER); if (!array_key_exists($teacher_group, $guard_user->getGroups())) { $guard_user->addGroupByName($teacher_group); $guard_user->save($con); } } $values = $this->getValues(); if (is_null($values['person-photo'])) { if (isset($values['person-delete_photo']) && $values['person-delete_photo']) { $this->getObject()->getPerson()->deleteImage(); } } }
protected function doSave($con = null) { $this->getObject()->setPersonalType(PersonalType::HEAD_PRECEPTOR); parent::doSave($con); $guard_user = $this->getObject()->getPersonSfGuardUser(); if (!is_null($guard_user)) { $personal_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::HEAD_PERSONAL); if (!array_key_exists($personal_group, $guard_user->getGroups())) { $guard_user->addGroupByName($personal_group); $guard_user->save($con); } } if (isset($values['person-photo']) && !$values['person-photo']) { $values = $this->getValues(); if (isset($values['person-delete_photo']) && $values['person-delete_photo']) { $this->getObject()->getPerson()->deleteImage(); } } }
public function configure() { unset($this['person_id']); $person = $this->getObject()->getPerson(); if (is_null($person)) { $person = new Person(); $this->getObject()->setPerson($person); } $personForm = new PersonForm($person, array('related_class' => 'tutor', 'embed_as' => 'person')); $personForm->getValidator('phone')->setOption('required', false); $this->embedMergeForm('person', $personForm); $this->getWidget('occupation_id')->setLabel('Occupation'); $this->setWidget('student_list', new csWidgetFormStudentMany(array('criteria' => new Criteria()))); $this->getWidget('student_list')->setLabel('Students'); $this->setValidator('student_list', new sfValidatorPass()); $this->setWidget('nationality', new sfWidgetFormChoice(array('choices' => BaseCustomOptionsHolder::getInstance('Nationality')->getOptions()))); $this->setValidator('nationality', new sfValidatorChoice(array('choices' => BaseCustomOptionsHolder::getInstance('Nationality')->getKeys(), 'required' => false))); $this->setDefault('student_list', array_map(create_function('$st', 'return $st->getStudentId();'), $this->getObject()->getStudentTutors())); }
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 save($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (is_null($con)) { $con = Propel::getConnection(CareerSubjectSchoolYearPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } try { $con->beginTransaction(); $values = $this->getValues(); // TODO: ver si se puede mejorar esto: $fields = array("final_examination_required", "course_required", "course_minimun_mark", "course_examination_count", "max_previous", "evaluation_method", "course_type", "attendance_type"); $to_save = array(); foreach ($fields as $field) { $to_save[$field] = isset($values[$field]) ? $values[$field] : null; unset($values[$field]); } foreach ($values as $career_subject_school_year_id) { $career_subject_school_year = CareerSubjectSchoolYearPeer::retrieveByPk($career_subject_school_year_id, $con); $subject_configuration = $career_subject_school_year->getSubjectConfigurationOrCreate(); foreach ($to_save as $field => $value) { if (!is_null($value)) { $method = "set" . sfInflector::camelize($field); $subject_configuration->{$method}($value); } } $career_subject_school_year->setSubjectConfiguration($subject_configuration); $subject_configuration->setCourseMarks(BaseCustomOptionsHolder::getInstance('CourseType')->getMarksFor($subject_configuration->getCourseType())); $subject_configuration->setEvaluationMethod(BaseCustomOptionsHolder::getInstance('CourseType')->getEvaluationMethodFor($subject_configuration->getCourseType())); $subject_configuration->save($con); } $con->commit(); } catch (Exception $e) { $con->rollBack(); throw $e; } return $this->object; }
public function getExaminationRepprovedTypeStr() { return BaseCustomOptionsHolder::getInstance('ExaminationRepprovedType')->getStringFor($this->getExaminationType()); }
echo date('Y-m-d'); ?> </div> <div> <label> Nombres y Apellido del Alumno: </label> <?php echo $student; ?> <label> Sexo: </label> <?php echo BaseCustomOptionsHolder::getInstance('SexType')->getStringFor($student->getPerson()->getSex()); ?> </div> <div> <label> Tipo y Nro. de Documento: </label> <?php echo BaseCustomOptionsHolder::getInstance('IdentificationType')->getStringFor($student->getPerson()->getIdentificationType()); ?> <?php echo $student->getPerson()->getIdentificationNumber(); ?> <label> CUIL: </label> <?php echo is_null($student->getPerson()->getCuil()) | $student->getPerson()->getCuil() == '' ? '...............................................................................' : $student->getPerson()->getCuil(); ?> </div> <div> <label> Fecha y Lugar de Nac.: </label> <?php echo is_null($student->getPersonFormattedBirthDate()) | $student->getPersonFormattedBirthDate() == '' ? '....................................' : $student->getPersonFormattedBirthDate(); ?> <?php
/** * Returns the Identification type string * * @return string */ public function getIdentificationTypeString() { return BaseCustomOptionsHolder::getInstance('IdentificationType')->getStringFor($this->getIdentificationType()); }
public function executeConfirmStudent(sfWebRequest $request) { sfContext::getInstance()->set("user", new FakeUser()); //tomo las intancias de las librerias. $i_identification_type = BaseCustomOptionsHolder::getInstance('IdentificationType'); $i_sex_type = BaseCustomOptionsHolder::getInstance('SexType'); $i_nationality = BaseCustomOptionsHolder::getInstance('Nationality'); $s_lastname = $this->getRequestParameter('apellido'); // Es obligatorio $s_firstname = $this->getRequestParameter('nombres'); // Es obligatorio $s_identification_type = $i_identification_type->getIdentificationType($this->getRequestParameter('tipo_documento_id')); $s_identification_number = $this->getRequestParameter('nro_documento'); $s_sex = $i_sex_type->getSexType($this->getRequestParameter('sexo')); //Es obligatorio $s_phone = $this->getRequestParameter('telefono_fijo'); $s_birthdate = $this->getRequestParameter('fecha_nacimiento'); $s_birth_city = $this->getRequestParameter('ciudad_nacimiento_id'); $s_health_coverage_id = $this->getRequestParameter('obra_social_id'); $s_origin_school_id = $request->getParameter('escuela_procedencia_numero'); //domicilio $s_city = $this->getRequestParameter('domicilio_ciudad_id'); $s_street = $this->getRequestParameter('domicilio_calle'); $s_number = $this->getRequestParameter('domicilio_numero'); $s_floor = $this->getRequestParameter('domicilio_piso'); $s_flat = $this->getRequestParameter('domicilio_departamento'); //Chequeo tutor (madre) $m_identification_type = $i_identification_type->getIdentificationType($this->getRequestParameter('madre_tipo_documento_id')); $m_identification_number = $this->getRequestParameter('madre_nro_documento'); $m_firstname = $this->getRequestParameter('madre_nombres'); $m_lastname = $this->getRequestParameter('madre_apellido'); $m_occupation = $this->getRequestParameter('madre_actividad_id'); $m_occupation_category = $this->getRequestParameter('madre_ocupacion_id'); $m_study = $this->getRequestParameter('madre_estudios_id'); $m_email = $this->getRequestParameter('madre_email'); $m_phone = $this->getRequestParameter('madre_telefono_celular'); $m_birthdate = $this->getRequestParameter('madre_fecha_nacimiento'); $m_birth_city = $this->getRequestParameter('madre_ciudad_nacimiento_id'); $m_nationality = $i_nationality->getNationality($this->getRequestParameter('madre_nacionalidad_id')); $m_is_alive = $this->getRequestParameter('madre_vive'); //chequeo is_alive if ($m_is_alive == 'S') { $m_is_alive = true; } elseif ($m_is_alive == 'N') { $m_is_alive = false; } //domicilio $m_city = $this->getRequestParameter('madre_domicilio_ciudad_id'); $m_street = $this->getRequestParameter('madre_domicilio_calle'); $m_number = $this->getRequestParameter('madre_domicilio_numero'); $m_floor = $this->getRequestParameter('madre_domicilio_piso'); $m_flat = $this->getRequestParameter('madre_domicilio_departamento'); //Chequeo tutor (padre) $p_identification_type = $i_identification_type->getIdentificationType($this->getRequestParameter('padre_tipo_documento_id')); $p_identification_number = $this->getRequestParameter('padre_nro_documento'); $p_firstname = $this->getRequestParameter('padre_nombres'); $p_lastname = $this->getRequestParameter('padre_apellido'); $p_occupation = $this->getRequestParameter('padre_actividad_id'); $p_occupation_category = $this->getRequestParameter('padre_ocupacion_id'); $p_study = $this->getRequestParameter('padre_estudios_id'); $p_email = $this->getRequestParameter('padre_email'); $p_phone = $this->getRequestParameter('padre_telefono_celular'); $p_birthdate = $this->getRequestParameter('padre_fecha_nacimiento'); $p_birth_city = $this->getRequestParameter('padre_ciudad_nacimiento_id'); $p_nationality = $i_nationality->getNationality($this->getRequestParameter('padre_nacionalidad_id')); $p_is_alive = $this->getRequestParameter('padre_vive'); //chequeo is_alive if ($p_is_alive == 'S') { $p_is_alive = true; } elseif ($p_is_alive == 'N') { $p_is_alive = false; } //domicilio $p_city = $this->getRequestParameter('padre_domicilio_ciudad_id'); $p_street = $this->getRequestParameter('padre_domicilio_calle'); $p_number = $this->getRequestParameter('padre_domicilio_numero'); $p_floor = $this->getRequestParameter('padre_domicilio_piso'); $p_flat = $this->getRequestParameter('padre_domicilio_departamento'); $data = array(); //chequeo campos obligatorios if (is_null($s_identification_type) || is_null($s_identification_number) || is_null($s_lastname) || trim($s_lastname) == "" || is_null($s_firstname) || trim($s_firstname) == "" || is_null($s_sex)) { throw new Exception('Missing data'); } else { $con = Propel::getConnection(); try { //chequeo que el alumno no haya sido ingresado en un año anterior (por lista de espera) $student = StudentPeer::retrieveByDocumentTypeAndNumber($s_identification_type, $s_identification_number); $con->beginTransaction(); if (is_null($student)) { //el alumno no existe. Creo la persona y el alumno $s_person = new Person(); $s_person->setLastname($s_lastname); $s_person->setFirstname($s_firstname); $s_person->setSex($s_sex); $s_person->setIdentificationType($s_identification_type); $s_person->setIdentificationNumber($s_identification_number); $s_person->setPhone($s_phone); $s_person->setBirthdate($s_birthdate); $s_person->setIsActive(true); $s_person->setBirthCity($s_birth_city); $s_person->save(Propel::getConnection()); $student = new Student(); $student->setPerson($s_person); $student->setGlobalFileNumber('888888'); //Nro de legajo?? $student->setOriginSchoolId($s_origin_school_id); $student->setHealthCoverageId($s_health_coverage_id); $student->save(Propel::getConnection()); /* Recupero department, state ,country*/ if (!is_null($s_birth_city)) { $city = CityPeer::retrieveByPk($s_birth_city); $student->getPerson()->setBirthCountry($city->getDepartment()->getState()->getCountry()->getId()); $student->getPerson()->setBirthState($city->getDepartment()->getState()->getId()); $student->getPerson()->setBirthDepartment($city->getDepartment()->getId()); } //chequeo domicilio if (!is_null($s_city) || !is_null($s_street) || !is_null($s_number) || !is_null($s_floor) || is_null($s_flat)) { $a = new Address(); $a->setCityId($s_city); $a->setStreet($s_street); $a->setNumber($s_number); $a->setFloor($s_floor); $a->setFlat($s_flat); $student->getPerson()->setAddress($a); $student->getPerson()->save(Propel::getConnection()); $data['message'] = "El alumno ha sido confirmado."; } } else { //seteo isActive $student->getPerson()->setIsActive(true); $student->save(Propel::getConnection()); $data['message'] = "El alumno fue actualizado correctamente."; } //chequeo campos obligatorios if (!is_null($m_identification_type) && !is_null($m_identification_number) && !is_null($m_lastname) && trim($m_lastname) != "" && !is_null($m_firstname) && trim($m_firstname) != "") { //busco si ya existe. $m_tutor = TutorPeer::findByDocumentTypeAndNumber($m_identification_type, $m_identification_number); if (is_null($m_tutor)) { //el tutor no existe. Lo creo $m_person = new Person(); $m_person->setLastname($m_lastname); $m_person->setFirstname($m_firstname); $m_person->setIdentificationType($m_identification_type); $m_person->setIdentificationNumber($m_identification_number); $m_person->setSex(SexType::FEMALE); $m_person->setPhone($m_phone); $m_person->setEmail($m_email); $m_person->setBirthdate($m_birthdate); $m_person->setIsActive(true); $m_person->setBirthCity($m_birth_city); $m_person->save(Propel::getConnection()); $m_tutor = new Tutor(); $m_tutor->setPerson($m_person); $m_tutor->setOccupationId($m_occupation); $m_tutor->setOccupationCategoryId($m_occupation_category); $m_tutor->setStudyId($m_study); //coincide con la tabla sga_tipos_est_cur $m_tutor->setNationality($m_nationality); $m_tutor->setIsAlive($m_is_alive); $m_tutor->save(Propel::getConnection()); /* Recupero department, state ,country*/ if (!is_null($m_birth_city)) { $m_city = CityPeer::retrieveByPk($m_birth_city); $m_tutor->getPerson()->setBirthCountry($m_city->getDepartment()->getState()->getCountry()->getId()); $m_tutor->getPerson()->setBirthState($m_city->getDepartment()->getState()->getId()); $m_tutor->getPerson()->setBirthDepartment($m_city->getDepartment()->getId()); } //chequeo domicilio if (!is_null($m_city) || !is_null($m_street) || !is_null($m_number) || !is_null($m_floor) || is_null($m_flat)) { $a = new Address(); $a->setCityId($m_birth_city); $a->setStreet($m_street); $a->setNumber($m_number); $a->setFloor($m_floor); $a->setFlat($m_flat); $m_tutor->getPerson()->setAddress($a); $m_tutor->getPerson()->save(Propel::getConnection()); } } else { $data['info'] = "El tutor con " . $i_identification_type->getStringFor($m_identification_type) . " " . $m_identification_number; } $st = StudentTutorPeer::retrieveByStudentAndTutor($student, $m_tutor); if (is_null($st)) { //datos de tutor(madre) $student_tutor = new StudentTutor(); $student_tutor->setStudent($student); $student_tutor->setTutor($m_tutor); $student_tutor->save(Propel::getConnection()); $m_tutor->addStudentTutor($student_tutor); $m_tutor->save(Propel::getConnection()); } } //chequeo campos obligatorios if (!is_null($p_identification_type) && !is_null($p_identification_number) && !is_null($p_lastname) && trim($p_lastname) != "" && !is_null($p_firstname) && trim($p_firstname) != "") { //busco si ya existe. $tutor = TutorPeer::findByDocumentTypeAndNumber($p_identification_type, $p_identification_number); if (is_null($tutor)) { //el tutor no existe. Lo creo $p_person = new Person(); $p_person->setLastname($p_lastname); $p_person->setFirstname($p_firstname); $p_person->setIdentificationType($p_identification_type); $p_person->setIdentificationNumber($p_identification_number); $p_person->setSex(SexType::MALE); $p_person->setPhone($p_phone); $p_person->setEmail($p_email); $p_person->setBirthdate($p_birthdate); $p_person->setIsActive(true); $p_person->setBirthCity($p_birth_city); $p_person->save(Propel::getConnection()); $tutor = new Tutor(); $tutor->setPerson($p_person); $tutor->setOccupationId($p_occupation); $tutor->setOccupationCategoryId($p_occupation_category); $tutor->setStudyId($p_study); //coincide con la tabla sga_tipos_est_cur $tutor->setNationality($p_nationality); $tutor->save(Propel::getConnection()); /* Recupero department, state ,country*/ if (!is_null($p_birth_city)) { $p_city = CityPeer::retrieveByPk($p_birth_city); $tutor->getPerson()->setBirthCountry($p_city->getDepartment()->getState()->getCountry()->getId()); $tutor->getPerson()->setBirthState($p_city->getDepartment()->getState()->getId()); $tutor->getPerson()->setBirthDepartment($p_city->getDepartment()->getId()); } //chequeo domicilio if (!is_null($p_city) || !is_null($p_street) || !is_null($p_number) || !is_null($p_floor) || is_null($p_flat)) { $a = new Address(); $a->setCityId($p_birth_city); $a->setStreet($p_street); $a->setNumber($p_number); $a->setFloor($p_floor); $a->setFlat($p_flat); $tutor->getPerson()->setAddress($a); $tutor->getPerson()->save(Propel::getConnection()); } if (!is_null($data['info'])) { $data['info'] = $data['info'] . " ya existe en el sistema. Por favor actualice los datos."; } } else { if (!is_null($data['info'])) { $data['info'] = "Los tutores con " . $i_identification_type->getStringFor($m_identification_type) . " " . $m_identification_number . " y " . $i_identification_type->getStringFor($p_identification_type) . " " . $p_identification_number . " ya existen en el sistema. Por favor actualice los datos."; } else { $data['info'] = "El tutor con " . $i_identification_type->getStringFor($p_identification_type) . " " . $p_identification_number . " ya existe en el sistema. Por favor actualice los datos."; } } //datos de tutor(padre) $st = StudentTutorPeer::retrieveByStudentAndTutor($student, $tutor); if (is_null($st)) { $student_tutor = new StudentTutor(); $student_tutor->setStudent($student); $student_tutor->setTutor($tutor); $student_tutor->save(Propel::getConnection()); $tutor->addStudentTutor($student_tutor); $tutor->save(Propel::getConnection()); } } $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } } $this->data = $data; $this->getResponse()->setHttpHeader('Content-type', 'application/json'); $this->getResponse()->setContent(json_encode($data)); $this->setLayout(false); }
</span> de la <?php echo __("Universidad Nacional de La Plata"); ?> CERTIFICA que <strong><?php echo $student; ?> </strong> <strong><?php echo BaseCustomOptionsHolder::getInstance('IdentificationType')->getStringFor($student->getPerson()->getIdentificationType()); ?> <?php echo $student->getPerson()->getIdentificationNumber(); ?> </strong> sexo <strong><?php echo BaseCustomOptionsHolder::getInstance('SexType')->getStringFor($student->getPerson()->getSex()); ?> </strong> nacido/a en <span><?php echo ucwords($student->getPerson()->getBirthCityRepresentation()); ?> , <?php echo ucwords($student->getPerson()->getBirthStaterepresentation()); ?> , <?php echo $student->getPerson()->getBirthCountryRepresentation(); ?> </span>, el día <strong><?php echo format_date($student->getPerson()->getBirthDate(), "D"); ?>
public function configure() { //Fields remove unset($this['user_id']); unset($this['address_id']); unset($this['is_active']); sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset', 'Tag', 'Url')); //identification type $this->setWidget('identification_type', new sfWidgetFormSelect(array('choices' => BaseCustomOptionsHolder::getInstance('IdentificationType')->getOptions()))); $this->setValidator('identification_type', new sfValidatorChoice(array('choices' => BaseCustomOptionsHolder::getInstance('IdentificationType')->getKeys(), 'required' => false))); //birthday $this->setWidget('birthdate', new csWidgetFormDateInput(array('change_year' => true, 'change_month' => true))); $this->getWidget('birthdate')->setOption('year_range', date('Y') - 80 . ':' . date('Y')); $this->setValidator('birthdate', new mtValidatorDateString(array('required' => false))); //email $this->setValidator('email', new sfValidatorEmail(array('required' => false))); //identification number //$this->setValidator('identification_number', new sfValidatorNumber(array('required'=>false))); //Birth country, state and city widgets $c = new Criteria(); $c->addAscendingOrderByColumn('name'); $this->setWidget('birth_country', new sfWidgetFormPropelchoice(array('model' => 'Country', 'add_empty' => true, 'criteria' => $c))); $this->setDefault('birth_country', SchoolBehaviourFactory::getInstance()->getDefaultCountryId()); $widget_birth_state = new sfWidgetFormPropelChoice(array('model' => 'State', 'add_empty' => true)); #This string is necesary to assemble the id needed for the html object $related_class = $this->getOption('related_class'); if (empty($related_class)) { throw new LogicException(get_class($this) . ": Can't be used without related_class option setted. SEE README of this classs!"); } $embed_str = $this->getOption('embed_as', ''); $embed_str = empty($embed_str) ? '' : "{$embed_str}-"; $related_class .= '_' . $embed_str; $this->setWidget('birth_state', new dcWidgetAjaxDependencePropel(array('related_column' => 'country_id', 'dependant_widget' => $widget_birth_state, 'observe_widget_id' => $related_class . 'birth_country', 'message_with_no_value' => __('Select a country first')))); $this->setDefault('birth_state', SchoolBehaviourFactory::getInstance()->getDefaultStateId()); $c = new Criteria(); $c->addAscendingOrderByColumn('name'); $widget_birth_department = new sfWidgetFormPropelChoice(array('model' => 'Department', 'add_empty' => true, 'criteria' => $c)); $this->setWidget('birth_department', new dcWidgetAjaxDependencePropel(array('related_column' => 'state_id', 'dependant_widget' => $widget_birth_department, 'observe_widget_id' => $related_class . 'birth_state', 'message_with_no_value' => __('Select a state first')))); $c = new Criteria(); $c->addAscendingOrderByColumn('name'); $widget_birth_city = new sfWidgetFormPropelChoice(array('model' => 'City', 'add_empty' => true, 'criteria' => $c)); $this->setWidget('birth_city', new dcWidgetAjaxDependencePropel(array('related_column' => 'department_id', 'dependant_widget' => $widget_birth_city, 'observe_widget_id' => $related_class . 'birth_department', 'message_with_no_value' => __('Select a department first')))); $this->setDefault('birth_city', SchoolBehaviourFactory::getInstance()->getDefaultCityId()); //field sex widget and validator $this->setWidget('sex', new sfWidgetFormSelect(array('choices' => BaseCustomOptionsHolder::getInstance('SexType')->getOptions()))); $this->setValidator('sex', new sfValidatorChoice(array('choices' => BaseCustomOptionsHolder::getInstance('SexType')->getKeys()))); //widgets and validators for username and password if ($this->getObject()->getsfGuardUser()) { $this->setWidget('username', new sfWidgetFormReadOnly(array('plain' => false, 'value_callback' => array($this->getObject()->getsfGuardUser(), 'getUsername')))); $this->setValidator('username', new sfValidatorPass()); } else { $this->setWidget('username', new sfWidgetFormInput()); $this->setValidator('username', new sfValidatorString(array('min_length' => 4, 'max_length' => 128, 'required' => false), array('min_length' => __('Username must be at least 4 characters long'), 'max_length' => __('Username must be at most 128 characters long')))); $this->getWidgetSchema()->setHelp('username', __('if blank no username will be assigned')); } $this->setWidget('password', new sfWidgetFormInputPassword()); $this->setWidget('password_again', new sfWidgetFormInputPassword()); $this->setValidator('password', new sfGuardSecurePasswordValidator(array('required' => false))); $this->setValidator('password_again', new sfGuardSecurePasswordValidator(array('required' => false))); $this->setWidget('photo', new sfWidgetFormInputFile()); $this->setValidator('photo', new sfValidatorFile(array('path' => Person::getPhotoDirectory(), 'max_size' => '2097152', 'mime_types' => 'web_images', 'required' => false, 'validated_file_class' => 'sfCustomValidatedFile'))); if ($this->getObject()->getPhoto()) { $this->setWidget('current_photo', new mtWidgetFormPartial(array('module' => 'personal', 'partial' => 'downloable_photo', 'form' => $this))); $this->setValidator('current_photo', new sfValidatorPass(array('required' => false))); $this->setWidget('delete_photo', new sfWidgetFormInputCheckbox()); $this->setValidator('delete_photo', new sfValidatorBoolean(array('required' => false))); } $this->getWidgetSchema()->setHelp('photo', 'The file must be of the following types: jpeg, jpg, gif, png.'); $this->getValidatorSchema()->setPostValidator(new sfValidatorAnd(array(new sfValidatorPropelUnique(array('model' => 'sfGuardUser', 'field' => array($embed_str . 'username'), 'column' => array('username')), array('invalid' => __('There is another user with the same username'))), new sfValidatorCallback(array('callback' => array($this, 'checkUsername'), 'arguments' => array('username' => $embed_str . 'username', 'password' => $embed_str . 'password')), array('invalid' => 'If username is set, then password must be setted')), new sfValidatorSchemaCompare($embed_str . 'password', sfValidatorSchemaCompare::EQUAL, $embed_str . 'password_again', array(), array('invalid' => __('Password missmatch'))), new sfValidatorPropelUnique(array('model' => 'Person', 'primary_key' => 'person-id', 'field' => array($embed_str . 'identification_type', $embed_str . 'identification_number'), 'column' => array('identification_type', 'identification_number')), array('invalid' => __('There is another user with the same identification number')))))); //ADDRESS FORM $address = $this->getObject()->getAddress(); if (is_null($address)) { $address = new Address(); $this->getObject()->setAddress($address); } $addressForm = new AddressForm($address, array('related_class' => $related_class)); $this->embedForm('address', $addressForm); }
public function createPreceptor(PropelPDO $con = null) { $con = is_null($con) ? Propel::getConnection() : $con; $personal = new Personal(); $personal->setPerson($this->getPerson()); $personal->save($con); $guard_user = $this->getPersonSfGuardUser(); if (!is_null($guard_user)) { $personal_group = BaseCustomOptionsHolder::getInstance('GuardGroups')->getStringFor(GuardGroups::PERSONAL); if (!array_key_exists($personal_group, $guard_user->getGroups())) { $guard_user->addGroupByName($personal_group); $guard_user->save($con); } } }
public function getMarksForCourseType($mark_number) { return BaseCustomOptionsHolder::getInstance('CourseType')->getMarksFor($mark_number); }
public function executePrintSocialCard(sfWebRequest $request) { $this->setLayout('cleanLayout'); $this->student = StudentPeer::retrieveByPK($request->getParameter('id')); $this->options_nationality = BaseCustomOptionsHolder::getInstance('Nationality')->getOptions(); $this->options_occupation = OccupationCategoryPeer::getOccupationCategories(); $this->options_study = StudyPeer::getStudies(); }