/** * This function builds common examples how to insert, update, delete and * display the data of order persons. * * @access public * @author kalmer:piiskop * @uses \shiporder\OrderPerson */ public static function buildRawExamples() { // Order persons require_once 'OrderPerson.php'; echo ' 8: Initial data: <pre>'; var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false))); echo '</pre>'; // Inserting an order person $newOrderPerson = new \shiporder\OrderPerson(); $newOrderPerson->setEmail('*****@*****.**'); $newOrderPerson->setFirstName('lilian'); $newOrderPerson->setLastName('tikk'); $newOrderPerson->insert(); echo ' 10: After insertion: <pre>'; var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false))); echo '</pre>'; // Querying full data of an order person $orderPerson = new \shiporder\OrderPerson(); $orderPerson->setIdOrdePerson(3); $orderPerson->setCompleteOrderPerson(); echo ' 20: Order person #3: <pre>'; var_dump($orderPerson); echo '</pre>'; // Updating data of an order person $orderPerson->setAddress('Pärnu, Pärnu'); $orderPerson->update(); echo ' 24: After updating the order person #3: <pre>'; var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false))); echo '</pre>'; // Deleting the order person #2 $orderPerson = new \shiporder\OrderPerson(); $orderPerson->setIdOrdePerson(2); $orderPerson->delete(); echo ' 43: After deleting the order person #2: <pre>'; var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false))); echo '</pre>'; // Items require_once dirname(__FILE__) . '/Item.php'; $item = new \shiporder\Item(); $item->setIdItem(1); $item->setName('õun'); $item->setPrice(1.0); $item->setAmount(20.0); $item->insertItem($item); $item = new \shiporder\Item(); $item->setIdItem(2); $item->setName('pirn'); $item->setPrice(2.0); $item->setAmount(10.0); $item->insertItem($item); $items = $item->getItems(); var_dump($items); }
//Inserting an order person $newOrderPerson = new \shiporder\OrderPerson(); $newOrderPerson->setEmail('*****@*****.**'); $newOrderPerson->setFirstName('lilian'); $newOrderPerson->setLastName('tikk'); $newOrderPerson->insert(); echo var_dump(\shiporder\OrderPerson::getListOfTypeOrderPerson(array('forAutocompletion' => false))); //Inserting new ShipTo location $newShipTo = new \shiporder\ShipTo(); $newShipTo->setNameOfRecipient('Peeter'); $newShipTo->setCity('Tallinn'); $newShipTo->setCountry('Estonia'); $newShipTo->insert(); echo var_dump(\shiporder\ShipTo::getListOfTypeShipTo(array('forAutocompletion' => false))); //Inserting a new item $newShipTo = new \shiporder\Item(); $newShipTo->setAmount('50'); $newShipTo->setPriece('30'); $newShipTo->setName('Auto'); $newShipTo->insert(); echo var_dump(\shiporder\Item::getListOfTypeItem(array('forAutocompletion' => false))); class OrderPersonController { public static function start() { require_once dirname(__FILE__) . '/OrderPerson.php'; $orderPersons = \shiporder\OrderPerson::getListOfTypeOrderPerson(array()); require_once dirname(__FILE__) . '/OrderPersonView.php'; $orderPersonView = \shiporder\OrderPersonView::buildListOfOrderPersons(array('orderPersons' => $orderPersons)); echo $orderPersonView; }