Esempio n. 1
0
 public function postSendEmail($p, $z)
 {
     $person = new Person($p[1]);
     $token = $person->generateToken('resetPassword');
     $message = new GuiMessage();
     $message->setFrom('*****@*****.**', 'The System');
     $message->addTo($person->getEmail(), $person->getName());
     $message->setSubject('password reset');
     $message->assign('token', $token);
     $message->send('messages/setPassword.tpl');
     die;
 }
Esempio n. 2
0
 function getOwnerName($ownerType, $id)
 {
     $ownerName = "";
     switch ($ownerType) {
         case "Person":
             $person = new Person();
             $person->selectRecord($id);
             $ownerName = $person->getName();
             $this->tpl->set_var("openWin", "PersonDetails.php" . $this->sess->url("") . "&personID=" . $id . "&formAction=viewOnly");
             break;
         case "Company":
             $company = new Company();
             $company->selectRecord($id);
             $ownerName = $company->getCompanyName();
             $this->tpl->set_var("openWin", "CompanyDetails.php" . $this->sess->url("") . "&companyID=" . $id . "&formAction=viewOnly");
             break;
     }
     return $ownerName;
 }
Esempio n. 3
0
 public function testSave()
 {
     $person = new Person();
     $person->setPersonKindID(1);
     $person->setUsername("timmy");
     $person->setName("Timothy");
     $person->setPhone("000-101-1010");
     $person->save();
     $this->assertTrue($person->getID() != NULL);
     $fetched = new Person();
     $fetched->fetch($person->getID());
     $this->assertEquals($person->getID(), $fetched->getID());
     $this->assertEquals($person->getPersonKindID(), $fetched->getPersonKindID());
     $this->assertEquals($person->getUsername(), $fetched->getUsername());
     $this->assertEquals($person->getName(), $fetched->getName());
     $this->assertEquals($person->getPhone(), $fetched->getPhone());
     //delete from DB for cleanup
     //TODO -- replace with proper delete method
     $sql = "DELETE FROM `people` WHERE id=?";
     $sql = $this->db->prepareQuery($sql, $person->getID());
     $this->db->query($sql);
 }
Esempio n. 4
0
<body>
    <?php 
function printAllEmployees($employees)
{
    foreach ($employees as $employee) {
        echo "Id : " . $employee->id . "\n" . "Name : " . $employee->name . "\n";
    }
}
include_once "Entities\\Person.php";
include_once "Entities\\Employee.php";
include_once "Entities\\Manager.php";
include_once "Entities\\Department.php";
$ivan = new Person("vano", 111);
//        $ivan -> id = 111123;
//        $ivan -> name = "vano";
echo $ivan->getName() . "\n";
echo $ivan->getId() . "\n";
echo $ivan->__get("name") . "\n";
echo $ivan->__get("id") . "\n";
$ivanSalary = $ivan->__get("salary") . "\n";
$ivanAge = $ivan->age . "\n";
// неявно вызывает функцию __get
echo "ivan has salary :" . $ivanSalary;
echo "ivan has age :" . $ivanAge;
$he = new Employee();
$hisResult = $he->work(true);
echo "Он работал весь день и результат: " . $hisResult . "\n";
$she = new Manager(10000000);
$herSalary = $she->salary;
echo "Она не работала весь день и ее зарплата: " . $herSalary . "\n";
$employees = array();
Esempio n. 5
0
 function writeName(Person $p)
 {
     print $p->getName() . "\n";
 }
Esempio n. 6
0
function testsperengine()
{
    global $tests;
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "perform generic bean manipulation";
    $ok = 1;
    $bean = RedBean_OODB::dispense("note");
    $bean->message = "hai";
    $bean->color = 3;
    $bean->date = time();
    $bean->special = 'n';
    $bean->state = 90;
    RedBean_OODB::set($bean);
    $bean2 = RedBean_OODB::getById("note", 1);
    if ($bean2->state != 90 || $bean2->special != 'n' || $bean2->message != 'hai') {
        $ok = 0;
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $bean->message = "lorem ipsum";
    RedBean_OODB::set($bean);
    $bean->message = 1;
    $bean->color = "green";
    $bean->date = str_repeat("BLABLA", 100);
    RedBean_OODB::set($bean);
    $note = $bean;
    SmartTest::instance()->progress();
    $person = RedBean_OODB::dispense("person");
    $person->age = 50;
    $person->name = "Bob";
    $person->gender = "m";
    RedBean_OODB::set($person);
    RedBean_OODB::associate($person, $note);
    $memo = RedBean_OODB::getById("note", 1);
    $authors = RedBean_OODB::getAssoc($memo, "person");
    if (count($authors) !== 1) {
        SmartTest::failedTest();
    }
    RedBean_OODB::trash($authors[1]);
    $authors = RedBean_OODB::getAssoc($memo, "person");
    if (count($authors) > 0) {
        $ok = 0;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    //unit tests
    //drop the note table
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "dispense an RedBean_OODB Bean";
    $oBean = RedBean_OODB::dispense();
    if (!$oBean instanceof OODBBean) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "put a bean in the database";
    $person = RedBean_OODB::dispense("person");
    $person->name = "John";
    $person->age = 35;
    $person->gender = "m";
    $person->hasJob = true;
    $id = RedBean_OODB::set($person);
    $johnid = $id;
    $person2 = RedBean_OODB::getById("person", $id);
    if ($person2->age != $person->age) {
        SmartTest::failedTest();
    }
    $person2->anotherprop = 2;
    RedBean_OODB::set($person2);
    $person = RedBean_OODB::dispense("person");
    $person->name = "Bob";
    $person->age = 50;
    $person->gender = "m";
    $person->hasJob = false;
    $bobid = RedBean_OODB::set($person);
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "find records on basis of similarity";
    $ids = RedBean_OODB::getBySQL("`gender`={gender} order by `name` asc", array("gender" => "m"), "person");
    if (count($ids) != 2) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $ids = RedBean_OODB::getBySQL("`gender`={gender} OR `color`={clr} ", array("gender" => "m", "clr" => "red"), "person");
    if (count($ids) != 0) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $ids = RedBean_OODB::getBySQL("`gender`={gender} AND `color`={clr} ", array("gender" => "m", "clr" => "red"), "person");
    if (count($ids) != 0) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    R::gen("Person");
    $dummy = new Person();
    $dummy->age = 40;
    SmartTest::instance()->test(count(Person::find($dummy, array("age" => ">"))), 1);
    $dummy->age = 20;
    SmartTest::instance()->test(count(Person::find($dummy, array("age" => ">"))), 2);
    $dummy->age = 100;
    SmartTest::instance()->test(count(Person::find($dummy, array("age" => ">"))), 0);
    $dummy->age = 100;
    SmartTest::instance()->test(count(Person::find($dummy, array("age" => "<="))), 2);
    $dummy->name = "ob";
    SmartTest::instance()->test(count(Person::find($dummy, array("name" => "LIKE"))), 1);
    $dummy->name = "o";
    SmartTest::instance()->test(count(Person::find($dummy, array("name" => "LIKE"))), 2);
    $dummy->gender = "m";
    SmartTest::instance()->test(count(Person::find($dummy, array("gender" => "="))), 2);
    $dummy->gender = "f";
    SmartTest::instance()->test(count(Person::find($dummy, array("gender" => "="))), 0);
    SmartTest::instance()->test(count(Person::listAll()), 2);
    SmartTest::instance()->test(count(Person::listAll(0, 1)), 1);
    SmartTest::instance()->test(count(Person::listAll(1)), 1);
    $can = Person::where("`gender`={gender} order by `name`  asc", array("gender" => "m"), "person");
    //test array access
    foreach ($can as $item) {
        if ($item->getName() == "Bob" || $item->getName() == "John") {
            SmartTest::instance()->progress();
        } else {
            SmartTest::failedTest();
        }
    }
    //test array access
    $bean = $can[0];
    if ($bean->name == "Bob") {
        SmartTest::instance()->progress();
    } else {
        SmartTest::failedTest();
    }
    if ($can->count() != 2) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $can->rewind();
    SmartTest::instance()->test($can->key(), 0);
    SmartTest::instance()->test($can->valid(), true);
    SmartTest::instance()->test($can->current()->getName(), "Bob");
    $can->next();
    SmartTest::instance()->test($can->key(), 1);
    SmartTest::instance()->test($can->valid(), false);
    SmartTest::instance()->test($can->current()->getName(), "John");
    $can->seek(0);
    SmartTest::instance()->test($can->key(), 0);
    $beans = $can->getBeans();
    if (count($beans) != 2) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    //test slicing
    $can->slice(0, 1);
    $can->rewind();
    SmartTest::instance()->test($can->current()->getName(), "Bob");
    SmartTest::instance()->test($can->count(), 1);
    $b1 = array_shift($beans);
    if ($b1->name != "Bob") {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    //basic functionality where()
    $beans = Person::where("`gender`={gender} order by `name` asc", array("gender" => "m"), "person")->getBeans();
    if (count($beans) != 2) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    //without backticks should still work
    $beans = Person::where("gender={person} order by `name` asc", array("person" => "m"), "person")->getBeans();
    if (count($beans) != 2) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    //like comparing should still work
    $beans = Person::where("gender={gender} and `name` LIKE {name} order by `name` asc", array("gender" => "m", "name" => "B%"), "person")->getBeans();
    if (count($beans) != 1) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $searchBean = RedBean_OODB::dispense("person");
    $searchBean->gender = "m";
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "associate beans with eachother?";
    $app = RedBean_OODB::dispense("appointment");
    $app->kind = "dentist";
    RedBean_OODB::set($app);
    RedBean_OODB::associate($person2, $app);
    $appforbob = array_shift(RedBean_OODB::getAssoc($person2, "appointment"));
    if (!$appforbob || $appforbob->kind != "dentist") {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "delete a bean?";
    $person = RedBean_OODB::getById("person", $bobid);
    RedBean_OODB::trash($person);
    try {
        $person = RedBean_OODB::getById("person", $bobid);
        $ok = 0;
    } catch (ExceptionFailedAccessBean $e) {
        $ok = true;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "unassociate two beans?";
    $john = RedBean_OODB::getById("person", $johnid);
    //hmmmmmm gaat mis bij innodb
    $app = RedBean_OODB::getById("appointment", 1);
    RedBean_OODB::unassociate($john, $app);
    $john2 = RedBean_OODB::getById("person", $johnid);
    $appsforjohn = RedBean_OODB::getAssoc($john2, "appointment");
    if (count($appsforjohn) > 0) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "unassociate by deleting a bean?";
    $anotherdrink = RedBean_OODB::dispense("whisky");
    $anotherdrink->name = "bowmore";
    $anotherdrink->age = 18;
    $anotherdrink->singlemalt = 'y';
    RedBean_OODB::set($anotherdrink);
    RedBean_OODB::associate($anotherdrink, $john);
    $hisdrinks = RedBean_OODB::getAssoc($john, "whisky");
    if (count($hisdrinks) !== 1) {
        SmartTest::failedTest();
    }
    RedBean_OODB::trash($anotherdrink);
    $hisdrinks = RedBean_OODB::getAssoc($john, "whisky");
    if (count($hisdrinks) !== 0) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "create parent child relationships?";
    $pete = RedBean_OODB::dispense("person");
    $pete->age = 48;
    $pete->gender = "m";
    $pete->name = "Pete";
    $peteid = RedBean_OODB::set($pete);
    $rob = RedBean_OODB::dispense("person");
    $rob->age = 19;
    $rob->name = "Rob";
    $rob->gender = "m";
    $saskia = RedBean_OODB::dispense("person");
    $saskia->age = 20;
    $saskia->name = "Saskia";
    $saskia->gender = "f";
    RedBean_OODB::set($saskia);
    RedBean_OODB::set($rob);
    RedBean_OODB::addChild($pete, $rob);
    RedBean_OODB::addChild($pete, $saskia);
    $children = RedBean_OODB::getChildren($pete);
    $names = 0;
    if (is_array($children) && count($children) === 2) {
        foreach ($children as $child) {
            if ($child->name === "Rob") {
                $names++;
            }
            if ($child->name === "Saskia") {
                $names++;
            }
        }
    }
    if (!$names) {
        SmartTest::failedTest();
    }
    $daddies = RedBean_OODB::getParent($saskia);
    $daddy = array_pop($daddies);
    if ($daddy->name === "Pete") {
        $ok = 1;
    } else {
        $ok = 0;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "remove a child from a parent-child tree?";
    RedBean_OODB::removeChild($daddy, $saskia);
    $children = RedBean_OODB::getChildren($pete);
    $ok = 0;
    if (count($children) === 1) {
        $only = array_pop($children);
        if ($only->name === "Rob") {
            $ok = 1;
        }
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "save on the fly while associating?";
    $food = RedBean_OODB::dispense("dish");
    $food->name = "pizza";
    RedBean_OODB::associate($food, $pete);
    $petesfood = RedBean_OODB::getAssoc($pete, "food");
    if (is_array($petesfood) && count($petesfood) === 1) {
        $ok = 1;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    //some extra tests... quick without further notice.
    $food = RedBean_OODB::dispense("dish");
    $food->name = "spaghetti";
    RedBean_OODB::trash($food);
    //test aggregation functions
    //insert stat table
    $s = RedBean_OODB::dispense("stattest");
    $s->amount = 1;
    RedBean_OODB::set($s);
    $s = RedBean_OODB::dispense("stattest");
    $s->amount = 2;
    RedBean_OODB::set($s);
    $s = RedBean_OODB::dispense("stattest");
    $s->amount = 3;
    RedBean_OODB::set($s);
    SmartTest::instance()->testPack = "can we use aggr functions using Redbean?";
    if (RedBean_OODB::numberof("stattest") != 3) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if (RedBean_OODB::maxof("stattest", "amount") != 3) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if (RedBean_OODB::minof("stattest", "amount") != 1) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if (RedBean_OODB::avgof("stattest", "amount") != 2) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if (RedBean_OODB::sumof("stattest", "amount") != 6) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if (count(RedBean_OODB::distinct("stattest", "amount")) != 3) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    RedBean_OODB::setLocking(true);
    $i = 3;
    SmartTest::instance()->testPack = "generate only valid classes?";
    try {
        $i += RedBean_OODB::gen("");
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    //nothing
    try {
        $i += RedBean_OODB::gen(".");
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    //illegal chars
    try {
        $i += RedBean_OODB::gen(",");
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    //illegal chars
    try {
        $i += RedBean_OODB::gen("null");
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    //keywords
    try {
        $i += RedBean_OODB::gen("Exception");
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    //reserved
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "generate classes using Redbean?";
    if (!class_exists("Bug")) {
        $i += RedBean_OODB::gen("Bug");
        if ($i !== 4) {
            SmartTest::failedTest();
        }
    } else {
        if ($i !== 3) {
            SmartTest::failedTest();
        }
    }
    if (!class_exists("Bug")) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "use getters and setters";
    $bug = new Bug();
    $bug->setSomething(sha1("abc"));
    if ($bug->getSomething() != sha1("abc")) {
        SmartTest::failedTest();
    }
    //can we use non existing props? --triggers fatal..
    $bug->getHappy();
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "Use boolean values and retrieve them with is()?";
    if ($bug->isHappy()) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $bug->setHappy(true);
    $bug->save();
    $bug = new Bug(1);
    if (!$bug->isHappy()) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $bug->setHappy(false);
    if ($bug->isHappy()) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "avoid race-conditions by locking?";
    RedBean_OODB::gen("Cheese,Wine");
    $cheese = new Cheese();
    $cheese->setName('Brie');
    $cheese->save();
    $cheese = new Cheese(1);
    //try to mess with the locking system...
    $oldkey = RedBean_OODB::$pkey;
    RedBean_OODB::$pkey = 1234;
    $cheese = new Cheese(1);
    $cheese->setName("Camembert");
    $ok = 0;
    try {
        $cheese->save();
    } catch (ExceptionFailedAccessBean $e) {
        $ok = 1;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    $bordeaux = new Wine();
    $bordeaux->setRegion("Bordeaux");
    try {
        $bordeaux->add($cheese);
    } catch (ExceptionFailedAccessBean $e) {
        $ok = 1;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    try {
        $bordeaux->attach($cheese);
    } catch (ExceptionFailedAccessBean $e) {
        $ok = 1;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    try {
        $bordeaux->add(new Wine());
        $ok = 1;
    } catch (ExceptionFailedAccessBean $e) {
        $ok = 0;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    RedBean_OODB::$pkey = $oldkey;
    $cheese = new Cheese(1);
    $cheese->setName("Camembert");
    $ok = 0;
    try {
        $cheese->save();
        $ok = 1;
    } catch (ExceptionFailedAccessBean $e) {
        $ok = 0;
    }
    if (!$ok) {
        SmartTest::failedTest();
    }
    SmartTest::instance()->progress();
    try {
        RedBean_OODB::$pkey = 999;
        RedBean_OODB::setLockingTime(0);
        $cheese = new Cheese(1);
        $cheese->setName("Cheddar");
        $cheese->save();
        RedBean_OODB::setLockingTime(10);
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    try {
        RedBean_OODB::$pkey = 123;
        RedBean_OODB::setLockingTime(100);
        $cheese = new Cheese(1);
        $cheese->setName("Cheddar2");
        $cheese->save();
        RedBean_OODB::setLockingTime(10);
        SmartTest::failedTest();
    } catch (Exception $e) {
        SmartTest::instance()->progress();
    }
    try {
        RedBean_OODB::$pkey = 42;
        RedBean_OODB::setLockingTime(0);
        $cheese = new Cheese(1);
        $cheese->setName("Cheddar3");
        $cheese->save();
        RedBean_OODB::setLockingTime(10);
        SmartTest::instance()->progress();
    } catch (Exception $e) {
        SmartTest::failedTest();
    }
    //test value ranges
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "protect inner state of RedBean";
    try {
        RedBean_OODB::setLockingTime(-1);
        SmartTest::failedTest();
    } catch (ExceptionInvalidArgument $e) {
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "protect inner state of RedBean";
    try {
        RedBean_OODB::setLockingTime(1.5);
        SmartTest::failedTest();
    } catch (ExceptionInvalidArgument $e) {
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "protect inner state of RedBean";
    try {
        RedBean_OODB::setLockingTime("aaa");
        SmartTest::failedTest();
    } catch (ExceptionInvalidArgument $e) {
    }
    SmartTest::instance()->progress();
    SmartTest::instance()->testPack = "protect inner state of RedBean";
    try {
        RedBean_OODB::setLockingTime(null);
        SmartTest::failedTest();
    } catch (ExceptionInvalidArgument $e) {
    }
    SmartTest::instance()->progress();
    //test convenient tree functions
    SmartTest::instance()->testPack = "convient tree functions";
    if (!class_exists("Person")) {
        RedBean_OODB::gen("person");
    }
    $donald = new Person();
    $donald->setName("Donald");
    $donald->save();
    $kwik = new Person();
    $kwik->setName("Kwik");
    $kwik->save();
    $kwek = new Person();
    $kwek->setName("Kwek");
    $kwek->save();
    $kwak = new Person();
    $kwak->setName("Kwak");
    $kwak->save();
    $donald->attach($kwik);
    $donald->attach($kwek);
    $donald->attach($kwak);
    if (count($donald->children()) != 3) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if (count($kwik->siblings()) != 2) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    //todo
    if ($kwik->hasParent($donald) != true) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($donald->hasParent($kwak) != false) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($donald->hasChild($kwak) != true) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($donald->hasChild($donald) != false) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($kwak->hasChild($kwik) != false) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($kwak->hasSibling($kwek) != true) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($kwak->hasSibling($kwak) != false) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($kwak->hasSibling($donald) != false) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    //copy
    SmartTest::instance()->testPack = "copy functions";
    $kwak2 = $kwak->copy();
    $id = $kwak2->save();
    $kwak2 = new Person($id);
    if ($kwak->getName() != $kwak2->getName()) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    SmartTest::instance()->testPack = "countRelated";
    R::gen("Blog,Comment");
    $blog = new Blog();
    $blog2 = new Blog();
    $blog->setTitle("blog1");
    $blog2->setTitle("blog2");
    for ($i = 0; $i < 5; $i++) {
        $comment = new Comment();
        $comment->setText("comment no.  {$i} ");
        $blog->add($comment);
    }
    for ($i = 0; $i < 3; $i++) {
        $comment = new Comment();
        $comment->setText("comment no.  {$i} ");
        $blog2->add($comment);
    }
    if ($blog->numofComment() !== 5) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($blog2->numofComment() !== 3) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    SmartTest::instance()->testPack = "associate tables of the same name";
    $blog = new Blog();
    $blogb = new Blog();
    $blog->title = 'blog a';
    $blogb->title = 'blog b';
    $blog->add($blogb);
    $b = $blog->getRelatedBlog();
    if (count($b) !== 1) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $b = array_pop($b);
    if ($b->title != 'blog b') {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    SmartTest::instance()->testPack = "inferTypeII patch";
    $blog->rating = 4294967295.0;
    $blog->save();
    $id = $blog->getID();
    $blog2->rating = -1;
    $blog2->save();
    $blog = new Blog($id);
    if ($blog->getRating() != 4294967295.0) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    SmartTest::instance()->testPack = "Longtext column type";
    $blog->message = str_repeat("x", 65535);
    $blog->save();
    $blog = new Blog($id);
    if (strlen($blog->message) != 65535) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $rows = RedBean_OODB::$db->get("describe blog");
    if ($rows[3]["Type"] != "text") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $blog->message = str_repeat("x", 65536);
    $blog->save();
    $blog = new Blog($id);
    if (strlen($blog->message) != 65536) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $rows = RedBean_OODB::$db->get("describe blog");
    if ($rows[3]["Type"] != "longtext") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    Redbean_OODB::clean();
    SmartTest::instance()->testPack = "Export";
    RedBean_OODB::gen("justabean");
    $oBean = new JustABean();
    $oBean->setA("a");
    $oOtherBean = new OODBBean();
    $oOtherBean->a = "b";
    $oBean2 = new OODBBean();
    $oBean->exportTo($oBean2);
    if ($oBean2->a !== "a") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $oBean2 = $oBean->exportTo($oBean2);
    if ($oBean2->a !== "a") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $oBean->exportTo($oBean2, $oOtherBean);
    if ($oBean2->a !== "b") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $arr = array();
    $oBean->exportTo($arr);
    if ($arr["a"] !== "a") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $arr = array();
    $arr = $oBean->exportTo($arr);
    if ($arr["a"] !== "a") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    $arr = $oBean->exportTo($arr, $oOtherBean);
    if ($arr["a"] !== "b") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    SmartTest::instance()->testPack = "Export Array";
    $oBean->a = "a";
    $oInnerBean = new JustABean();
    $oInnerBean->setID(123);
    $oBean->innerbean = $oInnerBean;
    $arr = $oBean->exportAsArr();
    if (!is_array($arr)) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($arr["innerbean"] !== 123) {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    if ($arr["a"] !== "a") {
        SmartTest::failedTest();
    } else {
        SmartTest::instance()->progress();
    }
    //test 1-to-n
    SmartTest::instance()->testPack = "1-to-n relations";
    R::gen("Track,Disc");
    $cd1 = new Disc();
    $cd1->name = 'first';
    $cd1->save();
    $cd2 = new Disc();
    $cd2->name = 'second';
    $cd2->save();
    $track = new Track();
    $track->title = "song 1";
    $track->belongsTo($cd1);
    $discs = $track->getRelatedDisc();
    SmartTest::instance()->test(count($discs), 1);
    $track->belongsTo($cd2);
    $discs = $track->getRelatedDisc();
    SmartTest::instance()->test(count($discs), 1);
    $track2 = new Track();
    $track2->title = "song 2";
    $cd1->exclusiveAdd($track2);
    SmartTest::instance()->test(count($track->getRelatedDisc()), 1);
    $cd2->exclusiveAdd($track2);
    SmartTest::instance()->test(count($track->getRelatedDisc()), 1);
}
Esempio n. 7
0
 if ($kwak->hasSibling($kwak) != false) {
     die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
 } else {
     SmartTest::instance()->progress();
 }
 if ($kwak->hasSibling($donald) != false) {
     die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
 } else {
     SmartTest::instance()->progress();
 }
 //copy
 SmartTest::instance()->canwe = "copy functions";
 $kwak2 = $kwak->copy();
 $id = $kwak2->save();
 $kwak2 = new Person($id);
 if ($kwak->getName() != $kwak2->getName()) {
     die("<b style='color:red'>Error CANNOT:" . SmartTest::instance()->canwe);
 } else {
     SmartTest::instance()->progress();
 }
 SmartTest::instance()->canwe = "countRelated";
 R::gen("Blog,Comment");
 $blog = new Blog();
 $blog2 = new Blog();
 $blog->setTitle("blog1");
 $blog2->setTitle("blog2");
 for ($i = 0; $i < 5; $i++) {
     $comment = new Comment();
     $comment->setText("comment no.  {$i} ");
     $blog->add($comment);
 }
Esempio n. 8
0
<?php

class Name
{
    function Name($_name)
    {
        $this->name = $_name;
    }
    function display()
    {
        echo $this->name . "\n";
    }
}
class Person
{
    private $name;
    function person($_name, $_address)
    {
        $this->name = new Name($_name);
    }
    function getName()
    {
        return $this->name;
    }
}
$person = new Person("John", "New York");
$person->getName()->display();
Esempio n. 9
0
<?php

require_once 'autoload.php';
$person = new Person('Nikol', 121213048, false, 500000);
$person2 = new Person('Ivan', 12123048, true, 200000);
$car = new Car('Honda Accord', 36000, true, 'white', 260);
$car2 = new Car('Nissan GTR', 150000, true, 'black', 320);
$carShop = new CarShop();
$carShop->addCar($car);
$carShop->addCar($car2);
echo ' The price of the ' . $car->getModel() . ' for scrap is ' . $car->calculatePriceForScrap(10000) . '.', PHP_EOL;
echo $person->buyCar($car2), PHP_EOL;
echo 'After buying a new ' . $person->getCar()->getModel() . ', ' . $person->getName() . ' has ' . $person->getMoney() . ' money left.', PHP_EOL;
echo 'After selling the car for scrap, ' . $person->getName() . ' has ' . $person->sellCarForScrap(15000) . ' money left.', PHP_EOL;
$car2->changeOwner($person2);
echo 'The new owner of the ' . $car2->getModel() . ' is: ' . $car2->getOwner()->getInfo();
Esempio n. 10
0
<?php

/* @var $this PersonController */
/* @var $model Person */
$this->breadcrumbs = array('Сотрудники' => array('index'), $model->id);
$this->menu = array(array('label' => 'Список сотрудников', 'url' => array('index')), array('label' => 'Создать', 'url' => array('create')), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id)), array('label' => 'Управление', 'url' => array('admin')));
?>

<h1><?php 
echo Person::getName($model->id);
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'first_name', 'middle_name', 'last_name', array('label' => 'Подразделение', 'type' => 'raw', 'value' => !empty($model->department_id) ? CHtml::encode($model->department->name) : 'Not Set'), array('label' => 'Организация', 'value' => CHtml::encode($model->company->name)), array('label' => 'Пользователь', 'value' => !empty($model->user->username) ? CHtml::encode($model->user->username) : 'Not Set'), 'status', 'position')));
Esempio n. 11
0
 public function isEqualTo(Person $person)
 {
     return $this->getName() == $person->getName();
 }
Esempio n. 12
0
 /**
  * @param Person $person
  *
  * @return bool
  */
 public function equals(Person $person)
 {
     return $person->getName() === $this->name && $person->getEmail() === $this->email;
 }
Esempio n. 13
0
 /**
  * Tests Person->getName()
  */
 public function testGetName()
 {
     $this->assertEquals('NAME', $this->Person->getName());
 }
 /**
  * @dataProvider getNames
  * @param string $in
  * @param string $out
  */
 public function testName($in, $out)
 {
     $this->contact->expects($this->once())->method('getName')->will($this->returnValue($in));
     $this->assertSame($out, $this->entity->getName());
 }
Esempio n. 15
0
<?php

require_once dirname(dirname(__FILE__)) . '/models/config.php';
$reports = json_decode(CallAPI("GET", "https://people.cs.clemson.edu/~jacksod/api/v1/reports?filter=new"), true)['data'];
//expand report location and person to show details, not just ID
if (is_array($reports)) {
    for ($i = 0; $i < count($reports); $i++) {
        $person = new Person();
        $person->fetch($reports[$i]['personID']);
        $reports[$i]['personKind'] = $person->getPersonKindName();
        $reports[$i]['personName'] = $person->getName();
        $reports[$i]['personUsername'] = $person->getUsername();
        $reports[$i]['personPhone'] = $person->getPhone();
        $location = new Location();
        $location->fetch($reports[$i]['locationID']);
        $reports[$i]['locationBuilding'] = $location->getBuildingName();
        $reports[$i]['locationRoom'] = $location->getRoom();
    }
}
//var_dump($reports);
?>


<?php 
include 'header.php';
?>
<!-- in .container div -->

<div class='row'>
	<div class='col-sm-12'>
		<div class="page-header">
<?php

$rasmus = new Person();
$rasmus->setName('Rasmus Lerdorf');
$rasmus->setCity('Sunnyvale');
print $rasmus->getName() . ' lives in ' . $rasmus->getCity() . '.';
Esempio n. 17
0
 function writeName(Person $p)
 {
     // получает обьект класса Person
     print $p->getName();
     // выводит функцию обьекта класса Person
 }
Esempio n. 18
0
foreach ($courses as $c) {
    echo $c->getDescription() . "\n";
}
$c = new Course();
$c->setId(1);
$c->load();
echo $c->getDescription() . "\n";
$students = $c->getStudents();
foreach ($students as $s) {
    echo $s->getName() . "\n";
}
//SEARCH
$p = new Person();
$p->setName('Mat');
$search = $p->search();
$search->orderBy('name');
$list = $search->execute();
foreach ($list as $p) {
    echo $p->getName() . "\n";
}
//Recursive Search
$c = new City();
$c->setName('San');
$p = new Person();
$p->setCity($c);
$b = new Book();
$b->setAuthor($p);
$list = $b->search()->execute();
foreach ($list as $b) {
    echo $b->getTitle() . "\n";
}
 function Main()
 {
     $this->getSignatory();
     if (is_array($this->formArray["personCompanyIDArray"])) {
         $this->tpl->set_block("rptsTemplate", "Page", "PageBlock");
         foreach ($this->formArray["personCompanyIDArray"] as $personCompanyID) {
             $this->tpl->set_var("pageNumber", $this->pageNumber);
             switch ($this->formArray["ownerType"]) {
                 case "Company":
                     $company = new Company();
                     $company->selectRecord($personCompanyID);
                     $nameList = $company->getCompanyName();
                     break;
                 case "Person":
                 default:
                     $person = new Person();
                     $person->selectRecord($personCompanyID);
                     $nameList = $person->getName();
                     break;
             }
             $this->tpl->set_var("nameList", $nameList);
             $tdNumberList = "";
             $tdArray = $this->getTDArrayFromOwner($personCompanyID);
             if (is_array($tdArray)) {
                 foreach ($tdArray as $td) {
                     if ($tdNumberList != "") {
                         $tdNumberList .= "\n";
                     }
                     $tdNumberList .= $this->getTDNumberListLine($td);
                 }
             }
             $this->tpl->set_var("tdNumberList", $tdNumberList);
             $this->tpl->parse("PageBlock", "Page", true);
             $this->pageNumber++;
         }
     } else {
         exit("no owners selected");
     }
     $this->setLguDetails();
     $this->setForm();
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $testpdf = new PDFWriter();
     $testpdf->setOutputXML($this->tpl->get("templatePage"), "test");
     if (isset($this->formArray["print"])) {
         $testpdf->writePDF($name);
         //,$this->formArray["print"]);
     } else {
         $testpdf->writePDF($name);
     }
 }
Esempio n. 20
0
 function writeName(Person $p)
 {
     return $p->getName();
 }
Esempio n. 21
0
<?php

/* @var $this DepartmentController */
/* @var $model Department */
$this->breadcrumbs = array('Подразделение' => array('index'), $model->name);
$this->menu = array(array('label' => 'Список подразделений', 'url' => array('index')), array('label' => 'Создать', 'url' => array('create')), array('label' => 'Изменить', 'url' => array('update', 'id' => $model->id)), array('label' => 'Управление', 'url' => array('admin')));
?>

<h1><?php 
echo $model->name;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'company.name', 'name', 'parent_id', 'desc', array('label' => 'Руководитель', 'value' => Person::getName($model->id)))));
Esempio n. 22
0
            return false;
        }
    }
    public function __unset($name)
    {
        unset($this->arg[$name]);
    }
    //析构方法
    function __destruct()
    {
        echo "析构函数被调用" . "\n";
    }
}
$p = new Person("liyang");
echo $p->name . "\n";
echo $p->getName(), "\n";
//测试静态方法和属性
echo Person::$type . "\n";
Person::changeType("unhuman");
echo Person::$type . "\n";
//测试魔术方法
$p();
$p->__unset("mother");
$p->mother = "tsm";
echo $p->mother . "\n";
echo $p->__isset("mother") . "\n";
echo $p->getMotherName() . "\n";
$person = clone $p;
echo $person->name . "--clone\n";
$person->mother = "tongshimei";
echo $p->mother . "\n";
Esempio n. 23
0
 public function __construct(Person $person)
 {
     parent::__construct($person->getName());
 }
Esempio n. 24
0
 function getMessageNode()
 {
     $messageA = array();
     $node = false;
     if ($r = Request::get('redirect')) {
         list($type, $id) = explode('_', $r);
         switch ($type) {
             case 's':
                 $query = 'SELECT * FROM `series` WHERE `id`=' . (int) $id;
                 $res = Database::sql2row($query);
                 if ($res && isset($res['is_s_duplicate']) && $res['is_s_duplicate']) {
                     $messageA = array('html' => 'Cерия «' . $res['title'] . '» была склеена с данной серией');
                     $node = XMLClass::createNodeFromObject($messageA, false, 'message', true);
                 }
                 break;
             case 'b':
                 $query = 'SELECT * FROM `book` WHERE `id`=' . (int) $id;
                 $book = new Book((int) $id);
                 if ($book->getDuplicateId()) {
                     $messageA = array('html' => 'Книга «' . $book->getTitle(true) . '» была склеена с данной книгой');
                     $node = XMLClass::createNodeFromObject($messageA, false, 'message', true);
                 }
                 break;
             case 'a':
                 $person = new Person((int) $id);
                 if ($person->getDuplicateId()) {
                     $messageA = array('html' => 'Автор «' . $person->getName() . '» был склеен с данным автором');
                     $node = XMLClass::createNodeFromObject($messageA, false, 'message', true);
                 }
                 break;
         }
     }
     return $node;
 }
Esempio n. 25
0
<?php

require_once 'autoload.php';
$p = new Product('da', 5);
$c = new Car();
$p->addQuantity(2);
$c->addQuantity(1);
var_dump($p->getQuantity(), $c->getQuantity());
$per = new Person('Mr', 'Bean');
var_dump($per->getNameFromTrait(), $per->getName());
Esempio n. 26
0
?>
:</b>
	<?php 
if (empty($data->parent_id)) {
    echo "";
} else {
    echo CHtml::encode($data->parent->name);
}
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('desc'));
?>
:</b>
	<?php 
echo CHtml::encode($data->desc);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('lead_person_id'));
?>
:</b>
	<?php 
echo CHtml::encode(Person::getName($data->lead_person_id));
?>
	<br />


</div>
Esempio n. 27
0
<?php

/**
 * Created by PhpStorm.
 * User: Jensenkong
 * Date: 2015/8/9
 * Time: 10:10
 */
require_once 'Person.php';
$m2 = new Person("Jensenkong", 27);
echo $m2->getName() . $m2->getAge() . '</br>';
echo $m2->getFile();
echo $m2->getDir();
Esempio n. 28
0
 function Main()
 {
     $RPTOPDetails = new SoapObject(NCCBIZ . "RPTOPDetails.php", "urn:Object");
     $this->tpl->set_block("rptsTemplate", "Page", "PageBlock");
     // start batch loop
     $rptopIDArray = $this->formArray["rptopIDArray"];
     foreach ($rptopIDArray as $key => $rptopID) {
         $this->formArray["rptopID"] = $rptopID;
         $this->pageNumber++;
         if (!($xmlStr = $RPTOPDetails->getRPTOP($this->formArray["rptopID"]))) {
             exit("xml failed");
         } else {
             //echo($xmlStr);
             if (!($domDoc = domxml_open_mem($xmlStr))) {
                 exit("error xmlDoc");
             } else {
                 $rptop = new RPTOP();
                 $rptop->parseDomDocument($domDoc);
                 //print_r($rptop);
                 foreach ($rptop as $key => $value) {
                     switch ($key) {
                         case "owner":
                             //$RPTOPEncode = new SoapObject(NCCBIZ."RPTOPEncode.php", "urn:Object");
                             if (is_a($value, "Owner")) {
                                 $this->formArray["ownerID"] = $rptop->owner->getOwnerID();
                                 $xmlStr = $rptop->owner->domDocument->dump_mem(true);
                                 if (!$xmlStr) {
                                     // xml failed
                                 } else {
                                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                                         // error domdoc
                                     } else {
                                         $this->displayOwnerList($domDoc);
                                     }
                                 }
                             }
                             break;
                         case "cityAssessor":
                             if (is_numeric($value)) {
                                 $cityAssessor = new Person();
                                 $cityAssessor->selectRecord($value);
                                 $this->formArray["municipalAssessor"] = $cityAssessor->getName();
                             } else {
                                 $cityAssessor = $value;
                                 $this->formArray["municipalAssessor"] = $cityAssessor;
                             }
                             break;
                         case "cityTreasurer":
                             if (is_numeric($value)) {
                                 $cityTreasurer = new Person();
                                 $cityTreasurer->selectRecord($value);
                                 $this->formArray["municipalTreasurer"] = $cityTreasurer->getName();
                             } else {
                                 $cityTreasurer = $value;
                                 $this->formArray["municipalTreasurer"] = $cityTreasurer;
                             }
                             break;
                         case "tdArray":
                             $tdCtr = 1;
                             $tdPageNumber = 1;
                             // RC 20091012 Modified to handle multiple page RPTOPS
                             $totalBasic = 0;
                             $totalSef = 0;
                             $totalTaxes = 0;
                             if (count($value)) {
                                 $tdTotalPages = intval((count($value) - 1) / 6) + 1;
                                 //RC 20091012 Calculate 1 to 6 = 1.
                                 foreach ($value as $tkey => $tvalue) {
                                     if ($tdCtr > 6) {
                                         // RC 20091012 Deal with multiple page RPTOP (i.e. more than 6 TDs)
                                         $this->formArray["tdPageNumber"] = $tdPageNumber;
                                         $this->formArray["tdTotalPages"] = $tdTotalPages;
                                         $this->formArray["totalOnLastPage"] = "Please Refer to Totals on Last Page...";
                                         $this->setForm();
                                         // generate page of output
                                         $this->clearDetails();
                                         // clear the values from Form
                                         $this->pageNumber++;
                                         //increment PDF Page Number
                                         $tdPageNumber++;
                                         $tdCtr = 1;
                                         //reset count for lines on new page of RPTOP
                                         $this->formArray["totalOnLastPage"] = "";
                                     }
                                     $this->formArray["arpNumber" . $tdCtr] = $tvalue->getTaxDeclarationNumber();
                                     // word wrap arpNumber
                                     if (strlen($this->formArray["arpNumber" . $tdCtr]) > 13) {
                                         $this->formArray["arpNumber" . $tdCtr . "a"] = substr($this->formArray["arpNumber" . $tdCtr], 0, 12);
                                         $this->formArray["arpNumber" . $tdCtr . "b"] = substr($this->formArray["arpNumber" . $tdCtr], 12);
                                         $this->formArray["arpNumber" . $tdCtr] = "";
                                     }
                                     $this->formArray["afsID"] = $tvalue->getAfsID();
                                     $AFSDetails = new SoapObject(NCCBIZ . "AFSDetails.php", "urn:Object");
                                     if (!($xmlStr = $AFSDetails->getAFS($tvalue->getAfsID()))) {
                                         // xml failed
                                     } else {
                                         if (!($domDoc = domxml_open_mem($xmlStr))) {
                                             // error domDoc
                                         } else {
                                             $afs = new AFS();
                                             $afs->parseDomDocument($domDoc);
                                             $this->formArray["odID"] = $afs->getOdID();
                                             $od = new OD();
                                             $od->selectRecord($this->formArray["odID"]);
                                             $locationNumber = $od->locationAddress->getNumber();
                                             $locationStreet = $od->locationAddress->getStreet();
                                             $locationBarangay = $od->locationAddress->getBarangay();
                                             $locationDistrict = $od->locationAddress->getDistrict();
                                             $locationMunicipalityCity = $od->locationAddress->getMunicipalityCity();
                                             $locationProvince = $od->locationAddress->getProvince();
                                             $this->formArray["location" . $tdCtr] = $locationNumber . " " . $locationStreet . " " . $locationBarangay;
                                             // word wrap location
                                             if (strlen($this->formArray["location" . $tdCtr]) > 26) {
                                                 $this->formArray["location" . $tdCtr . "a"] = $locationNumber . " " . $locationStreet;
                                                 $this->formArray["location" . $tdCtr . "b"] = $locationBarangay;
                                                 $this->formArray["location" . $tdCtr] = "";
                                             }
                                             $this->formArray["province"] = $locationProvince;
                                             $this->formArray["municipalityCity"] = strtoupper($locationMunicipalityCity);
                                             $this->formArray["area" . $tdCtr] = $od->getLandArea();
                                             $this->formArray["lotNo" . $tdCtr] = $od->getLotNumber();
                                             $this->formArray["pin" . $tdCtr] = $afs->getPropertyIndexNumber();
                                             // word wrap pin
                                             if (strlen($this->formArray["pin" . $tdCtr]) > 25) {
                                                 $this->formArray["pin" . $tdCtr . "a"] = substr($this->formArray["pin" . $tdCtr], 0, 25);
                                                 $this->formArray["pin" . $tdCtr . "b"] = substr($this->formArray["pin" . $tdCtr], 25);
                                                 $this->formArray["pin" . $tdCtr] = "";
                                             }
                                             $landList = $afs->getLandArray();
                                             $plantsTreesList = $afs->getPlantsTreesArray();
                                             $improvementsBuildingsList = $afs->getImprovementsBuildingsArray();
                                             $machineriesList = $afs->getMachineriesArray();
                                             $kind = "";
                                             $actualUse = "";
                                             if (count($landList)) {
                                                 $kind = "Land";
                                                 $land = $landList[0];
                                                 $actualUse = $land->getActualUse();
                                                 $landActualUses = new LandActualUses();
                                                 $landActualUses->selectRecord($actualUse);
                                                 $actualUse = $landActualUses->getDescription();
                                                 $actualUseReportCode = $landActualUses->getReportCode();
                                             } else {
                                                 if (count($plantsTreesList)) {
                                                     $kind = "Land";
                                                     $plantsTrees = $plantsTreesList[0];
                                                     $actualUse = $plantsTrees->getActualUse();
                                                     $plantsTreesActualUses = new PlantsTreesActualUses();
                                                     $plantsTreesActualUses->selectRecord($actualUse);
                                                     $actualUse = $plantsTreesActualUses->getDescription();
                                                     $actualUseReportCode = $plantsTreesActualUses->getReportCode();
                                                 } else {
                                                     if (count($improvementsBuildingsList)) {
                                                         $kind = "Improvements/Buildings";
                                                         $improvementsBuildings = $improvementsBuildingsList[0];
                                                         $actualUse = $improvementsBuildings->getActualUse();
                                                         $improvementsBuildingsActualUses = new ImprovementsBuildingsActualUses();
                                                         $improvementsBuildingsActualUses->selectRecord($actualUse);
                                                         $actualUse = $improvementsBuildingsActualUses->getDescription();
                                                         $actualUseReportCode = $improvementsBuildingsActualUses->getReportCode();
                                                     } else {
                                                         if (count($machineriesList)) {
                                                             $kind = "Machineries";
                                                             $machineries = $machineriesList[0];
                                                             $actualUse = $machineries->getActualUse();
                                                             $machineriesActualUses = new MachineriesActualUses();
                                                             $machineriesActualUses->selectRecord($actualUse);
                                                             $actualUse = $machineriesActualUses->getDescription();
                                                             $actualUseReportCode = $machineriesActualUses->getReportCode();
                                                         }
                                                     }
                                                 }
                                             }
                                             eval(REPORT_CODE_LIST);
                                             foreach ($reportCodeList as $key => $reportCode) {
                                                 if ($reportCode["code"] == $actualUseReportCode) {
                                                     $reportCodeDescription = $reportCode["description"];
                                                     break;
                                                 }
                                             }
                                             $this->formArray["classification" . $tdCtr] = $reportCodeDescription;
                                             $this->formArray["landTotalMarketValue"] += $afs->getLandTotalMarketValue();
                                             $this->formArray["landTotalAssessedValue"] += $afs->getLandTotalAssessedValue();
                                             $this->formArray["plantTotalMarketValue"] += $afs->getPlantTotalMarketValue();
                                             $this->formArray["plantTotalAssessedValue"] += $afs->getPlantTotalAssessedValue();
                                             $this->formArray["bldgTotalMarketValue"] += $afs->getBldgTotalMarketValue();
                                             $this->formArray["bldgTotalAssessedValue"] += $afs->getBldgTotalAssessedValue();
                                             $this->formArray["machTotalMarketValue"] += $afs->getMachTotalMarketValue();
                                             $this->formArray["machTotalAssessedValue"] += $afs->getMachTotalAssessedValue();
                                             $this->formArray["marketValue" . $tdCtr] += $afs->getTotalMarketValue();
                                             $this->formArray["assessedValue" . $tdCtr] += $afs->getTotalAssessedValue();
                                             //RC											$this->formArray["totalMarketValue"] += $this->formArray["marketValue"];
                                             //RC											$this->formArray["totalAssessedValue"] += $this->formArray["assessedValue"];
                                             // grab Due from tdID
                                             $this->formArray["totalTaxDue"] = 0.0;
                                             $DueDetails = new SoapObject(NCCBIZ . "DueDetails.php", "urn:Object");
                                             if (!($xmlStr = $DueDetails->getDueFromTdID($tvalue->getTdID()))) {
                                                 $this->formArray["basic" . $tdCtr] = "";
                                                 $this->formArray["sef" . $tdCtr] = "";
                                                 $this->formArray["totalTax" . $tdCtr] = "";
                                                 $this->formArray["totalBasic"] += 0;
                                                 $this->formArray["totalSef"] += 0;
                                                 $this->formArray["totalTaxes"] += 0;
                                             } else {
                                                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                                                     $this->formArray["basic" . $tdCtr] = "";
                                                     $this->formArray["sef" . $tdCtr] = "";
                                                     $this->formArray["totalTax" . $tdCtr] = "";
                                                     $this->formArray["totalBasic"] += 0;
                                                     $this->formArray["totalSef"] += 0;
                                                     $this->formArray["totalTaxes"] += 0;
                                                 } else {
                                                     $due = new Due();
                                                     $due->parseDomDocument($domDoc);
                                                     $this->formArray["basic" . $tdCtr] = $due->getBasicTax();
                                                     $this->formArray["sef" . $tdCtr] = $due->getSEFTax();
                                                     $this->formArray["totalTax" . $tdCtr] = $due->getTaxDue();
                                                     /* RC 20091012 revised to not print total until last page of RPTOP 
                                                     			$this->formArray["totalBasic"] += $due->getBasicTax();
                                                     			$this->formArray["totalSef"] += $due->getSEFTax();
                                                     			$this->formArray["totalTaxes"] += $due->getTaxDue();  */
                                                     $totalBasic += $due->getBasicTax();
                                                     $totalSef += $due->getSEFTax();
                                                     $totalTaxes += $due->getTaxDue();
                                                 }
                                             }
                                         }
                                     }
                                     $tdCtr++;
                                 }
                             }
                             break;
                         default:
                             $this->formArray[$key] = $value;
                     }
                 }
                 $this->formArray["tdPageNumber"] = $tdPageNumber;
                 $this->formArray["tdTotalPages"] = $tdTotalPages;
                 $this->formArray["totalBasic"] += $totalBasic;
                 // RC 20091012 set values for last page of RPTOP
                 $this->formArray["totalSef"] += $totalSef;
                 $this->formArray["totalTaxes"] += $totalTaxes;
                 $this->formArray["totalMarketValue"] = $this->formArray["landTotalMarketValue"] + $this->formArray["plantTotalMarketValue"] + $this->formArray["bldgTotalMarketValue"] + $this->formArray["machTotalMarketValue"];
                 $this->formArray["totalAssessedValue"] = $this->formArray["landTotalAssessedValue"] + $this->formArray["plantTotalAssessedValue"] + $this->formArray["bldgTotalAssessedValue"] + $this->formArray["machTotalAssessedValue"];
                 unset($rptop);
             }
         }
         $this->setForm();
         // send XML to file
         $this->clearForm();
         // clear the XML form values
     }
     // end batch loop
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $testpdf = new PDFWriter();
     $testpdf->setOutputXML($this->tpl->get("templatePage"), "test");
     $testpdf->writePDF("RPTOPBatch.pdf");
     // popup the IE Save to File thingee...
     exit;
 }
 *
 * Move members from subclass to superclass or from superclass to subclass.
 */
namespace Refactoring12\JetBrains;

// 1. Pull the getName() function from SilverCustomer to Person. Use Refactor This.
// 2. Push the calculateDiscount() down to Customer. Use Refactor This.
//    Note that the move will throw a problem detection because calculateDiscount() is used
//    in calling code and expected on the Person class.
class Person
{
    protected $_name;
    public function calculateDiscount($amount)
    {
    }
}
class Customer extends Person
{
}
class SilverCustomer extends Customer
{
    public function getName()
    {
        return $this->_name;
    }
}
$customer = new SilverCustomer();
$customer->getName();
$person = new Person();
$person->getName();
$person->calculateDiscount(100);
echo "<p> Changed color :" . $bmw->getColor() . "</p>";
//Set owner
$bmw->setOwner("Harry Potter");
echo "<p> And the happy owner of the BMW is : " . $bmw->getOwner() . " </p>";
//Set owner's age
$bmw->setOwnerage(19);
echo "<p> The owner's age is: " . $bmw->getOwnerage() . " </p>";
$priceForscrap = $bmw->calculateCarPriceForScrap(200);
echo "<p> The price for scrap is : " . $priceForscrap . " </p>";
$bmw->setPrice(70000);
echo "<hr>";
//----------------------------Harry Potter ----------------------
//Initialize Harry Potter Obejct
$harryPotter = new Person("Harry Potter", "1234", true, 90000);
//Label
echo "<h3>" . $harryPotter->getName() . "</h3>";
// Can buy car ?
echo "<p>" . $harryPotter->getName() . " can buy the car?", PHP_EOL;
$bmw2 = clone $bmw;
//Buy car
//$harryPotter->buyCar($bmw);
//Show owned car :
echo "<p>Person's money after the transaction: " . $harryPotter->buyCar($bmw2) . "</p>";
var_dump($bmw2);
echo "buy car:";
var_dump($harryPotter->buyCar($bmw2));
//echo "<p>" .$harryPotter->getName() . "owns". $harryPotter->getOwnedCar()."</p>";
echo "Test aggregation: ";
$bmw->generateObjPerson("David Coperfield", "007", true, 200000);
//($name, $personalNumber, $isMale, $money)
echo "<p>Person: " . $bmw->getName() . "</p>";