Ejemplo n.º 1
0
 public function testDelete()
 {
     $person = new Person();
     $person->setPersonKindID(1);
     $person->setUsername("timmy");
     $person->setName("Timothy");
     $person->setPhone("000-101-1010");
     $person->save();
     $this->assertTrue(Person::personExists($person->getUsername()) != false);
     $person->delete();
     $this->assertTrue(!Person::personExists($person->getUsername()));
 }
Ejemplo n.º 2
0
 public function getPerson()
 {
     $sqlStr = "SELECT u.uid, u.firstname, u.lastname, u.title, u.institution, u.department, " . "u.address, u.city, u.state, u.zip, u.country, u.phone, u.email, " . "u.url, u.biography, u.ispublic, u.notes, ul.username, ul.lastlogindate " . "FROM users u LEFT JOIN userlogin ul ON u.uid = ul.uid " . "WHERE (u.uid = " . $this->uid . ")";
     $person = new Person();
     //echo $sqlStr;
     $badUserNameArr = array();
     $result = $this->conn->query($sqlStr);
     if ($row = $result->fetch_object()) {
         $person->setUid($row->uid);
         $person->setUserName($row->username);
         $person->setLastLoginDate($row->lastlogindate);
         $person->setFirstName($row->firstname);
         $person->setLastName($row->lastname);
         $person->setTitle($row->title);
         $person->setInstitution($row->institution);
         $person->setDepartment($row->department);
         $person->setAddress($row->address);
         $person->setCity($row->city);
         $person->setState($row->state);
         $person->setZip($row->zip);
         $person->setCountry($row->country);
         $person->setPhone($row->phone);
         $person->setEmail($row->email);
         $person->setUrl($row->url);
         $person->setBiography($row->biography);
         $person->setIsPublic($row->ispublic);
         $this->setUserTaxonomy($person);
         while ($row = $result->fetch_object()) {
             //Old code allowed folks to maintain more than one login names. This code will make sure the most recently active one is used
             if ($row->lastlogindate && (!$person->getLastLoginDate() || $row->lastlogindate > $person->getLastLoginDate())) {
                 $badUserNameArr[] = $person->getUserName();
                 $person->setUserName($row->username);
                 $person->setLastLoginDate($row->lastlogindate);
             } else {
                 $badUserNameArr[] = $row->userName;
             }
         }
     }
     if ($badUserNameArr) {
         //Delete the none active logins
         $sql = 'DELETE FROM userlogin WHERE username IN("' . implode('","', $badUserNameArr) . '")';
         if (!$this->conn->query($sql)) {
             $this->errorStr = 'ERROR removing extra logins: ' . $this->conn->error;
         }
     }
     $result->free();
     return $person;
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public static function getPersons()
 {
     $dados = Database::ReadAll("person", "*");
     if (!$dados) {
         return '';
     }
     foreach ($dados as $dado) {
         $person = new Person();
         $person->setId($dado['ID_PERSON']);
         $person->setName($dado['NAME_PERSON']);
         $person->setEmail($dado['EMAIL']);
         $person->setAge($dado['AGE']);
         $person->setSex($dado['SEX']);
         $person->setPhone($dado['PHONE']);
         $person->setOperator($dado['OPERATOR']);
         $person->setMaritalStatus($dado['MARITAL_STATUS']);
         $person->setChildren($dado['CHILDREN']);
         $religion = Religion::getReligion("WHERE id_religion = " . $dado['ID_RELIGION']);
         $person->setReligion($religion);
         $address = Address::getAddress("AND id_address = " . $dado['ID_ADDRESS']);
         $person->setAddress($address);
         $login = Login::getLogin($dado['ID_PERSON']);
         $person->setLogin($login);
         $persons[] = $person;
     }
     return $persons;
 }
Ejemplo n.º 5
0
<?php

/**
 * @copyright 2011 City of Bloomington, Indiana
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
 * @author Cliff Ingham <*****@*****.**>
 */
include '../../../configuration.inc';
include './migrationConfig.inc';
$pdo = new PDO(MIGRATION_DSN, MIGRATION_USER, MIGRATION_PASS);
$sql = "select distinct\r\n\t\tfirstname,lastname,email,phone,address,city,state,zip\t\t\r\n\t\tfrom contacts";
$result = $pdo->query($sql);
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $person = new Person();
    $person->setFirstname(ucwords(strtolower($row['firstname'])));
    $person->setPhone($row['phone']);
    $person->setLastname(ucwords(strtolower($row['lastname'])));
    $person->setEmail($row['email']);
    if ($row['address'] && strtolower($row['city']) == 'bloomington') {
        $row['address'] = preg_replace('/[^a-zA-Z0-9\\-\\&\\s\'\\/]/', '', $row['address']);
        $url = new URL(ADDRESS_SERVICE . '/addresses/parse.php');
        $url->format = 'xml';
        $url->address = $row['address'];
        $parsed = new SimpleXMLElement($url, null, true);
        if ($parsed->street_number && $parsed->street_name) {
            // Look up their address in Master Address
            $url = new URL(ADDRESS_SERVICE . '/home.php');
            $url->queryType = 'address';
            $url->format = 'xml';
            $url->query = $row['address'];
            echo $url->query . " ==> ";
Ejemplo n.º 6
0
                $peopleInfoXML = file_get_contents($baseURL . $searchURL, false, $context) or die("The mospace server might failed\n");
                //echo $baseURL.$searchURL;
                $peopleInfoXMLObject = simplexml_load_string($peopleInfoXML, null, LIBXML_NOCDATA);
                if ($peopleInfoXMLObject['found'] == 0 || $peopleInfoXMLObject['found'] >= 49) {
                    continue;
                }
                //echo "<pre>";
                ///print_r($peopleInfoXMLObject->Person);
                //echo "</pre>";
                $personObject = new Person();
                $personObject->setLastName($parser->getLast());
                $personObject->setFirstName($parser->getFirst());
                //For test purpose only
                //echo $personObject->getLastName().", ".$personObject->getFirstName().";   ";
                $personObject->setDepartment($peopleInfoXMLObject->Person->Department);
                $personObject->setTitle($peopleInfoXMLObject->Person->Title);
                //$personObject->setImageURL("http://freelanceme.net/Images/default%20profile%20picture.png");
                if ($peopleInfoXMLObject->Person->Phone != null) {
                    $personObject->setPhone($peopleInfoXMLObject->Person->Phone);
                }
                $personObject->setEmail($peopleInfoXMLObject->Person->{'E-mail'});
                $personObject->insertToDatabase();
            }
            echo "\n";
            //For testing purpose only
            //if($i++ > 10){
            //break;
            //}
        }
    }
}
Ejemplo n.º 7
0
 if ($row['e_mail_address']) {
     $list = new PersonList(array('email' => $row['e_mail_address']));
     if (count($list)) {
         continue;
     }
 }
 $list = new PersonList(array('firstname' => $row['first_name'], 'lastname' => $row['last_name']));
 if (count($list)) {
     continue;
 }
 $person = new Person();
 $person->setFirstname(ucwords(strtolower($row['first_name'])));
 $person->setMiddlename(ucwords(strtolower($row['middle_initial'])));
 $person->setLastname(ucwords(strtolower($row['last_name'])));
 $person->setEmail(strtolower($row['e_mail_address']));
 $person->setPhone($row['home_phone'] ? $row['home_phone'] : $row['bus_phone']);
 if ($row['address']) {
     $row['address'] = preg_replace('/[^a-zA-Z0-9\\-\\&\\s\'\\/]/', '', $row['address']);
     $url = new URL(ADDRESS_SERVICE . '/addresses/parse.php');
     $url->format = 'xml';
     $url->address = $row['address'];
     $parsed = new SimpleXMLElement($url, null, true);
     if ($parsed->street_number && $parsed->street_name) {
         // Look up their address in Master Address
         $url = new URL(ADDRESS_SERVICE . '/home.php');
         $url->queryType = 'address';
         $url->format = 'xml';
         $url->query = $row['address'];
         echo $url->query . " ==> ";
         $xml = new SimpleXMLElement($url, null, true);
         if (count($xml) == 1) {
Ejemplo n.º 8
0
 private function setUpPerson()
 {
     $person = new Person();
     $person->setPersonKindID(getPersonKindID($this->request['personKind']));
     $person->setUsername($this->request['username']);
     $person->setName($this->request['name']);
     $person->setPhone($this->request['phone']);
     $person->save();
     return $person->getID();
 }