Ejemplo n.º 1
0
 public function testCreate()
 {
     $tc = new PersonController(false);
     $tc->init();
     $_POST['Name'] = 'Robert Johnson';
     $_POST['Introduction'] = 'Fatguy';
     $tc->create();
     $stmt = self::$db->db->query("select * from person where name='Robert Johnson'");
     $rows = $stmt->fetchAll();
     $this->assertEquals(1, sizeof($rows));
 }
Ejemplo n.º 2
0
 /**
  * @covers PersonController::Remove
  * @todo Implement testRemove().
  */
 public function testRemove()
 {
     $request = Application::getInstance()->request;
     $request->setParams(array('name' => 'Louise the Zero', 'type' => 'adult'));
     $res = $this->object->Add();
     $this->assertTrue(isset($res['id']));
     $id = $res['id'];
     $request->setParams(array('id' => $id));
     $res = $this->object->Remove();
     $this->assertFalse(isset($res['error']));
 }
Ejemplo n.º 3
0
 private function setPersonParam(PersonController $cPerson)
 {
     $this->_id = $cPerson->getId();
     $this->_lastName = $cPerson->getLastName();
     $this->_firstName = $cPerson->getFirstName();
     $this->_middleName = $cPerson->getMiddleName();
     $this->_aliasName = $cPerson->getAliasName();
     $this->_birthMonth = $cPerson->getBirthMonth();
     $this->_birthDay = $cPerson->getBirthDay();
     $this->_birthYear = $cPerson->getBirthYear();
     $this->_note = $cPerson->getNote();
 }
Ejemplo n.º 4
0
/**
 * Created by PhpStorm.
 * User: roessler
 * Date: 16/09/15
 * Time: 1:22 PM
 */
/**
 * Backend page for administrators and Staff of Cyril's Classic Employees to edit employees
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'config/config.php';
if (isset($_SESSION['authenticated'])) {
    if ($_SESSION['authenticated'] == true) {
        $editResult = null;
        $sellerCon = new SellerController();
        $personCon = new PersonController();
        $offerCon = new OfferController();
        $featureCon = new FeatureController();
        $foCon = new Feature_OfferController();
        $mediaCon = new MediaController();
        $carCon = new CarController();
        $offerId = null;
        $sellerId = null;
        $personId = null;
        $selectedFeatureIds = array();
        $media = array();
        $carId = null;
        $sellerName = null;
        $carRego = null;
        $preferredPrice = null;
        $description = null;
Ejemplo n.º 5
0
    public function printSellers()
    {
        $sellers = $this->getSellers();
        $personCon = new PersonController();
        if ($sellers->errorInfo()[2] == null) {
            $rows = $sellers->fetchAll();
            $rowCount = count($rows);
            if ($rowCount > 0) {
                ?>
                <table class="table table-responsive table-hover">
                    <tr>
                        <th>Surname</th><th>First Name</th><th>Email Address</th><th>Actions</th>
                    </tr>
                    <?php 
                foreach ($rows as $row) {
                    $person = $personCon->getPerson($row['person_id']);
                    if ($person->errorInfo()[2] == null) {
                        $personRow = $person->fetch();
                        $personCount = count($personRow);
                        if ($personCount > 0) {
                            ?>
                                <tr>
                                    <td><?php 
                            echo $personRow['surname'];
                            ?>
</td><td><?php 
                            echo $personRow['first_name'];
                            ?>
</td><td><?php 
                            echo $personRow['email_address'];
                            ?>
</td>
                                    <td><a href="./view.php?id=<?php 
                            echo $row['seller_id'];
                            ?>
" class="btn btn-info"><span class="glyphicon glyphicon-briefcase"></span> View</a> <a href="./edit.php?id=<?php 
                            echo $row['seller_id'];
                            ?>
" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span> Edit</a> <a href="./delete.php?id=<?php 
                            echo $row['seller_id'];
                            ?>
" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Delete</a></td>
                                </tr>
                            <?php 
                        }
                    } else {
                        ?>
                            <div class="alert alert-danger" role="alert">
                                <strong>Uh oh!</strong> The database returned the following error:<br/>
                                <em><?php 
                        echo $person->errorInfo()[2];
                        ?>
</em>
                            </div>
                        <?php 
                    }
                }
                ?>
                </table>
            <?php 
            } else {
                ?>
                <div class="alert alert-info" role="alert">
                    <strong>No results.</strong> There are no sellers to display<br/>
                    Use the form above to add some.
                </div>
            <?php 
            }
        } else {
            ?>
            <div class="alert alert-danger" role="alert">
                <strong>Uh oh!</strong> The database returned the following error:<br/>
                <em><?php 
            echo $sellers->errorInfo()[2];
            ?>
</em>
            </div>
        <?php 
        }
        $sellers->closeCursor();
    }
Ejemplo n.º 6
0
 $personId = null;
 $addressId = null;
 $firstName = null;
 $surname = null;
 $phoneNumber = null;
 $mobileNumber = null;
 $emailAddress = null;
 $mailingList = null;
 $streetAddress = null;
 $suburb = null;
 $city = null;
 $postcode = null;
 $state = null;
 $addressDate = null;
 $sellerCon = new SellerController();
 $personCon = new PersonController();
 $addressCon = new AddressController();
 function checkSelected($id1, $id2)
 {
     if ($id1 == $id2) {
         echo 'selected';
     }
 }
 if (isset($_GET['id'])) {
     $sellerId = $_GET['id'];
     $seller = $sellerCon->getSeller($sellerId);
     if ($seller->errorInfo()[2] == null) {
         $row = $seller->fetch();
         $rowCount = count($row);
         if ($rowCount > 0) {
             $personId = $row['person_id'];
Ejemplo n.º 7
0
/**
 * Created by PhpStorm.
 * User: roessler
 * Date: 16/09/15
 * Time: 1:22 PM
 */
/**
 * Backend page for administrators and Staff of Cyril's Classic Cars to add and view buyers
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'config/config.php';
if (isset($_SESSION['authenticated'])) {
    if ($_SESSION['authenticated'] == true) {
        $addResult = null;
        $custCon = new CustomerController();
        $personCon = new PersonController();
        $addressCon = new AddressController();
        if (isset($_POST['hdnAction'])) {
            if ($_POST['hdnAction'] == 'insert') {
                if (!isset($_POST['chkMailingList'])) {
                    $chkMailingList = 0;
                } else {
                    $chkMailingList = $_POST['chkMailingList'];
                }
                $result = $personCon->insertPerson($_POST['txtFirstName'], $_POST['txtSurname'], $_POST['txtPhone'], $_POST['txtMobile'], $_POST['txtEmail'], $chkMailingList);
                $personId = $result['personId'];
                if ($result['stmt']->errorInfo()[2] == null) {
                    $custResult = $custCon->insertCustomer($personId);
                    if ($custResult->errorInfo()[2] == null) {
                        $addressResult = $addressCon->insertAddress($_POST['txtStreetAddress'], $_POST['txtSuburb'], $_POST['txtCity'], $_POST['txtPostcode'], $_POST['txtState'], $personId);
                        if ($addressResult->errorInfo()[2] == null) {
Ejemplo n.º 8
0
    public function printSales()
    {
        $sales = $this->getSales();
        $offerCon = new OfferController();
        $sellerCon = new SellerController();
        $custCon = new CustomerController();
        $personCon = new PersonController();
        $carCon = new CarController();
        if ($sales->errorInfo()[2] == null) {
            $rows = $sales->fetchAll();
            $rowCount = count($rows);
            if ($rowCount > 0) {
                ?>
                <table class="table table-responsive table-hover">
                    <tr>
                        <th>Sale Date</th><th>Car Rego</th><th>Seller</th><th>Buyer</th><th>Sold Price</th><th>Actions</th>
                    </tr>
                    <?php 
                foreach ($rows as $row) {
                    $offer = $offerCon->getOffer($row['offer_id']);
                    $offerRow = $offer->fetch();
                    if (count($offerRow) > 0) {
                        $buyer = $custCon->getCustomer($row['customer_id']);
                        $buyerRow = $buyer->fetch();
                        if (count($buyerRow) > 0) {
                            $person = $personCon->getPerson($buyerRow['person_id']);
                            $personRow = $person->fetch();
                            $buyerName = $personRow['first_name'] . ' ' . $personRow['surname'];
                            $seller = $sellerCon->getSeller($offerRow['seller_id']);
                            $sellerRow = $seller->fetch();
                            if (count($sellerRow) > 0) {
                                $person = $personCon->getPerson($sellerRow['person_id']);
                                $personRow = $person->fetch();
                                if (count($personRow) > 0) {
                                    $car = $carCon->getCar($offerRow['car_id']);
                                    $carRow = $car->fetch();
                                    if (count($carRow) > 0) {
                                        ?>
                                            <tr>
                                                <td><?php 
                                        echo $row['sale_date'];
                                        ?>
</td><td><?php 
                                        echo $carRow['rego_number'];
                                        ?>
</td><td><?php 
                                        echo $personRow['first_name'] . ' ' . $personRow['surname'];
                                        ?>
</td><td><?php 
                                        echo $buyerName;
                                        ?>
</td><td>$<?php 
                                        echo ucfirst($row['total_price']);
                                        ?>
</td><td><a href="./edit.php?id=<?php 
                                        echo $row['sale_id'];
                                        ?>
" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span> Edit</a> <a href="./delete.php?id=<?php 
                                        echo $row['sale_id'];
                                        ?>
" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Delete</a></td>
                                            </tr>
                                        <?php 
                                    } else {
                                        ?>
                                            <div class="alert alert-danger" role="alert">
                                                <strong>Uh oh!</strong> The database returned the following error:<br/>
                                                <em><?php 
                                        echo $carRow->errorInfo()[2];
                                        ?>
</em>
                                            </div>
                                        <?php 
                                    }
                                } else {
                                    ?>
                                        <div class="alert alert-danger" role="alert">
                                            <strong>Uh oh!</strong> The database returned the following error:<br/>
                                            <em><?php 
                                    echo $personRow->errorInfo()[2];
                                    ?>
</em>
                                        </div>
                                    <?php 
                                }
                            } else {
                                ?>
                                    <div class="alert alert-danger" role="alert">
                                        <strong>Uh oh!</strong> The database returned the following error:<br/>
                                        <em><?php 
                                echo $sellerRow->errorInfo()[2];
                                ?>
</em>
                                    </div>
                                <?php 
                            }
                        } else {
                            ?>
                                <div class="alert alert-danger" role="alert">
                                    <strong>Uh oh!</strong> The database returned the following error:<br/>
                                    <em><?php 
                            echo $buyerRow->errorInfo()[2];
                            ?>
</em>
                                </div>
                            <?php 
                        }
                    } else {
                        ?>
                            <div class="alert alert-danger" role="alert">
                                <strong>Uh oh!</strong> The database returned the following error:<br/>
                                <em><?php 
                        echo $offerRow->errorInfo()[2];
                        ?>
</em>
                            </div>
                        <?php 
                    }
                }
                ?>
                </table>
            <?php 
            } else {
                ?>
                <div class="alert alert-info" role="alert">
                    <strong>No results.</strong> There are no sales to display<br/>
                    Use the form above to add some.
                </div>
            <?php 
            }
        } else {
            ?>
            <div class="alert alert-danger" role="alert">
                <strong>Uh oh!</strong> The database returned the following error:<br/>
                <em><?php 
            echo $sales->errorInfo()[2];
            ?>
</em>
            </div>
        <?php 
        }
        $sales->closeCursor();
    }
Ejemplo n.º 9
0
<?php

/**
 * Created by PhpStorm.
 * User: roessler
 * Date: 9/27/15
 * Time: 2:01 PM
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'config/config.php';
if (isset($_POST['txtOfferId'])) {
    $sellerCon = new SellerController();
    $custCon = new CustomerController();
    $personCon = new PersonController();
    $offerCon = new OfferController();
    $featureCon = new FeatureController();
    $foCon = new Feature_OfferController();
    $mediaCon = new MediaController();
    $carCon = new CarController();
    $makeCon = new MakeController();
    $modelCon = new ModelController();
    $saleCon = new SaleController();
    $empCon = new EmployeeController();
    $offer = $offerCon->getOffer($_POST['txtOfferId']);
    if ($offer->errorInfo()[2] == null) {
        $row = $offer->fetch();
        $rowCount = count($row);
        if ($rowCount > 0) {
            $seller = $sellerCon->getSeller($row['seller_id']);
            $seller = $seller->fetch();
            $person = $personCon->getPerson($seller['person_id']);
            $person = $person->fetch();
Ejemplo n.º 10
0
        $this->validate = 1;
        if ($this->_lastName == null && $this->_firstName == null && $this->_middleName == null && $this->_aliasName == null) {
            $this->validate = 0;
        }
        return $this->validate;
    }
    public function getAge($birth_year, $birth_month, $birth_day)
    {
        $birthday = $birth_year . "-" . $birth_month . "-" . $birth_day;
        $age = date_create($birthday)->diff(date_create('today'))->y;
        return $age;
    }
}
// End class PersonController
if (array_key_exists('addNewContact', $_POST)) {
    $cPerson = new PersonController((int) $_POST['personId'], trim($_POST['lastName']), trim($_POST['firstName']), trim($_POST['middleName']), trim($_POST['aliasName']), (int) $_POST['birthMonth'], (int) $_POST['birthDay'], (int) $_POST['birthYear'], trim($_POST['note']));
    $model = new PersonPDO();
    if ($cPerson->nameFieldValidate()) {
        if (isset($_GET['action']) && $_GET['action'] === 'create') {
            $insertId = $model->create($cPerson);
            header("Location: ../profile.php?id=" . (int) $insertId);
        }
        if (isset($_GET['action']) && $_GET['action'] === 'update') {
            $model->updateById($cPerson);
            header("Location: ../profile.php?id=" . $_POST['personId']);
        }
    } elseif ($_GET['action'] === 'update') {
        header("Location: ../newcontact.php?id={$_POST['personId']}&action=update&validate=error");
    } else {
        header("Location: ../newcontact.php?validate=error");
    }
Ejemplo n.º 11
0
 $personId = null;
 $addressId = null;
 $firstName = null;
 $surname = null;
 $phoneNumber = null;
 $mobileNumber = null;
 $emailAddress = null;
 $mailingList = null;
 $streetAddress = null;
 $suburb = null;
 $city = null;
 $postcode = null;
 $state = null;
 $addressDate = null;
 $sellerCon = new SellerController();
 $personCon = new PersonController();
 $addressCon = new AddressController();
 function checkSelected($id1, $id2)
 {
     if ($id1 == $id2) {
         echo 'selected';
     }
 }
 if (isset($_GET['id'])) {
     $sellerId = $_GET['id'];
     $seller = $sellerCon->getSeller($sellerId);
     if ($seller->errorInfo()[2] == null) {
         $row = $seller->fetch();
         $rowCount = count($row);
         if ($rowCount > 0) {
             $personId = $row['person_id'];
Ejemplo n.º 12
0
/**
 * Created by PhpStorm.
 * User: roessler
 * Date: 16/09/15
 * Time: 1:22 PM
 */
/**
 * Backend page for administrators and Staff of Cyril's Classic Employees to delete sellers
 */
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'config/config.php';
if (isset($_SESSION['authenticated'])) {
    if ($_SESSION['authenticated'] == true) {
        $deleteResult = null;
        $sellerCon = new SellerController();
        $personCon = new PersonController();
        $offerCon = new OfferController();
        $featureCon = new FeatureController();
        $foCon = new Feature_OfferController();
        $mediaCon = new MediaController();
        $carCon = new CarController();
        $offerId = null;
        $sellerId = null;
        $personId = null;
        $featureIds = array();
        $featureNames = array();
        $features = array();
        $media = array();
        $carId = null;
        $sellerName = null;
        $carRego = null;
Ejemplo n.º 13
0
<?php

include_once "controller/personController.php";
$controller = new PersonController();
$controller->invoke();
Ejemplo n.º 14
0
<?php

// require("models/Address.php");
require "controllers/PersonController.php";
$nameObj = new PersonController();
$name = $nameObj->getById(2);
echo $name['last'];
    public function peopleNewPeopleAction()
    {
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $rows = $db->fetchAll('select
			person.*,qualification_phrase,facility.facility_name,location.location_name,user.username as created_by from person
			left join person_qualification_option on person_qualification_option.id = primary_qualification_option_id
			left join facility on facility_id = facility.id
			left join location on facility.location_id = location.id
			left join user on user.id=person.created_by
			where person.approved is null and person.is_deleted = 0');
        $this->viewAssignEscaped('primary_results', $rows);
        $go = $this->getSanParam('go');
        if ($go) {
            require_once 'PersonController.php';
            $c = new PersonController($this->getRequest(), $this->getResponse());
            $c->searchAction();
            $this->viewAssignEscaped('primary_results', $rows);
        }
        // fill form dropdowns
        $this->viewAssignEscaped('locations', Location::getAll());
        //training titles
        require_once 'models/table/TrainingTitleOption.php';
        $titleArray = TrainingTitleOption::suggestionList(false, 10000);
        $this->viewAssignEscaped('courses', $titleArray);
        //types
        $qualificationsArray = OptionList::suggestionListHierarchical('person_qualification_option', 'qualification_phrase', false, false);
        $this->viewAssignEscaped('qualifications', $qualificationsArray);
        //facilities list
        $rowArray = OptionList::suggestionList('facility', array('facility_name', 'id'), false, 9999);
        $facilitiesArray = array();
        foreach ($rowArray as $key => $val) {
            if ($val['id'] != 0) {
                $facilitiesArray[] = $val;
            }
        }
        $this->viewAssignEscaped('facilities', $facilitiesArray);
    }