コード例 #1
0
 /**
  * @test
  */
 public function gettersShouldRetrieveConfiguredData()
 {
     $phone = new Phone(11, 999999999);
     $address = new Address('aa', 'aa', '2123', 'aa', 'asdad', 12312);
     $customer = new Customer('*****@*****.**', 'aa', $phone, $address);
     $this->assertEquals('*****@*****.**', $customer->getEmail());
     $this->assertEquals('aa', $customer->getName());
     $this->assertSame($phone, $customer->getPhone());
     $this->assertSame($address, $customer->getAddress());
 }
コード例 #2
0
 public function updateForm(Customer $customerToUpdate)
 {
     $this->name = $customerToUpdate->getName();
     $this->surname = $customerToUpdate->getSurname();
     $this->telephone = $customerToUpdate->getTelephone();
     $this->email = $customerToUpdate->getEmail();
     $form = $this->renderHTMLForCustomerForm('update');
     // Set page title
     $this->pageTitle = 'Update customer';
     // Set HTML
     $this->HTML = $form;
 }
コード例 #3
0
 protected function runPage()
 {
     if (WebRequest::wasPosted()) {
         if (!WebRequest::postInt("calroom")) {
             $this->showCal();
             return;
         }
         $startdate = new DateTime(WebRequest::post("qbCheckin"));
         $enddate = new DateTime(WebRequest::post("qbCheckout"));
         $room = Room::getById(WebRequest::postInt("calroom"));
         for ($date = $startdate; $date < $enddate; $date->modify("+1 day")) {
             if (!$room->isAvailable($date)) {
                 $this->error("room-not-available");
                 $this->showCal();
                 return;
             }
         }
         // search for customer
         if (!($customer = Customer::getByEmail(WebRequest::post("qbEmail")))) {
             $customer = new Customer();
             $suTitle = WebRequest::post("qbTitle");
             $suFirstname = WebRequest::post("qbFirstname");
             $suLastname = WebRequest::post("qbLastname");
             $suAddress = WebRequest::post("qbAddress");
             $suCity = WebRequest::post("qbCity");
             $suPostcode = WebRequest::post("qbPostcode");
             $suCountry = WebRequest::post("qbCountry");
             $suEmail = WebRequest::post("qbEmail");
             $customer->setPassword($suEmail);
             // set values
             $customer->setTitle($suTitle);
             $customer->setFirstname($suFirstname);
             $customer->setSurname($suLastname);
             $address = new Address();
             $address->setLine1($suAddress);
             $address->setCity($suCity);
             $address->setPostCode($suPostcode);
             $address->setCountry($suCountry);
             $address->save();
             $customer->setAddress($address);
             $customer->setEmail($suEmail);
             // save it
             $customer->save();
             $customer->sendMailConfirm();
             // save it again
             $customer->save();
         }
         $booking = new Booking();
         $booking->setStartDate(WebRequest::post("qbCheckin"));
         $booking->setEndDate(WebRequest::post("qbCheckout"));
         $booking->setAdults(WebRequest::post("qbAdults"));
         $booking->setChildren(WebRequest::post("qbChildren"));
         $booking->setPromocode(WebRequest::post("qbPromoCode"));
         $booking->setRoom($room->getId());
         $booking->setCustomer($customer->getId());
         $booking->save();
         $msg = Message::getMessage("booking-confirmation");
         $msg = str_replace("\$1", $booking->getStartDate(), $msg);
         $msg = str_replace("\$2", $booking->getEndDate(), $msg);
         $msg = str_replace("\$3", $booking->getAdults(), $msg);
         $msg = str_replace("\$4", $booking->getChildren(), $msg);
         $msg = str_replace("\$5", $booking->getRoom()->getName(), $msg);
         Mail::send($customer->getEmail(), Message::getMessage("booking-confimation-subject"), $msg);
         $this->mSmarty->assign("content", $msg);
         return;
     }
     throw new YouShouldntBeDoingThatException();
 }
コード例 #4
0
 private function updateDatabase(Customer $customerToUpdate)
 {
     $stmt = $this->db->db->prepare("UPDATE " . self::$dbTable . " SET `name`= :name, `surname`= :surname, `telephone`= :telephone, `email`= :email WHERE `id`=:id");
     $name = $customerToUpdate->getName();
     $surname = $customerToUpdate->getSurname();
     $telephone = $customerToUpdate->getTelephone();
     $email = $customerToUpdate->getEmail();
     $id = $customerToUpdate->getId();
     $stmt->bindParam(':name', $name);
     $stmt->bindParam(':surname', $surname);
     $stmt->bindParam(':telephone', $telephone);
     $stmt->bindParam(':email', $email);
     $stmt->bindParam(':id', $id);
     try {
         $stmt->execute();
     } catch (\PDOException $e) {
         print "Error!: " . $e->getMessage();
         die;
         //Remove or change message in production code
     }
 }
コード例 #5
0
ファイル: CustomerTest.php プロジェクト: hilltool/tray-php
 public function testSetEmailWorks()
 {
     $customer = new Customer();
     $customer->setEmail('*****@*****.**');
     $this->assertEquals('*****@*****.**', $customer->getEmail());
 }
コード例 #6
0
             $daysList['Friday'] = 'Friday';
         }
         if (isset($_POST["chkSaturday"])) {
             $daysList['Saturday'] = 'Saturday';
         }
         if (isset($_POST["chkSunday"])) {
             $daysList['Sunday'] = 'Sunday';
         }
         $sDate = $_POST["txtStartDate"];
         $fDate = $_POST["txtFinalDate"];
         $response = $customer->editStandingOrder($idorder, $idcustomer, $date, $reference, $note, $items, $sDate, $fDate, $daysList);
     } else {
         $response = $customer->editOrder($idorder, $idcustomer, $date, $reference, $note, $items);
     }
     if ($response != "false") {
         if ($customer->getEmail($idcustomer) != "") {
             $_GET["idCustomerOrder"] = $idorder;
             include "../view/customerOrderPrint.php";
         }
         $msg = "All changes were successfully saved";
         header("Location: ../view/customerOrderAdd.php?edit=true&idCustomerOrder={$idorder}&msg={$msg}");
     } else {
         header("Location: ../view/customerOrderAdd.php?msg=Couldn't edit the customer order");
     }
     break;
 case "deleteOrder":
     $customer = new Customer();
     $idorder = $_GET["idcustomer_order"];
     $result = $customer->deleteOrder($idorder);
     if ($result == "ok") {
         header("Location: ../view/customerOrders.php");