public function _run($request, $xcontext) { $id = intval(Utils::testInput($request->id)); $this->logger->info("Input id: {$id}"); if (empty($id)) { $this->logger->error("Input id is empty!"); throw new Exception("need id!"); } $bookService = new BookService(); $bookList = $bookService->lists(); foreach ($bookList as $book) { if ($book->getAuthor()->id() == $id) { $nodeletion = "该作者与书籍关联,不能删除"; return XNext::action("listauthor", array("nodeletion" => $nodeletion)); } } $authorService = new AuthorService(); $author = $authorService->delete($id); $this->logger->info("Delete an author whose id is {$id}"); if (!$author || $author->id() <= 0) { $this->logger->error("failed in deleting author!"); throw new Exception("failed in deleting author!"); } return XNext::action("listauthor"); }
public function test_lists() { $as = XAppSession::begin(); $bookService = new BookService(); $bookList = $bookService->lists(); $as->commit(); $this->logger->info("Book list number: " . count($bookList)); $sameBookList = DDA::ins()->list_Book_by_status(Constants::USING); $this->assertTrue(count($bookList) == count($sameBookList)); $as = null; }
public function saveDb($id) { if ($id != "") { $model = BookService::model()->findByAttributes(array('id' => $id)); } else { $model = new BookService(); } $model->airport = $this->airport; $model->date = $this->date; $model->flight_time = $this->flight_time; $model->flight_number = $this->flight_number; $model->name = $this->name; $model->add1 = $this->add1; $model->type = $this->type; // $model->add2 = $this->add2; // $model->add3 = $this->add3; $model->city = $this->city; // $model->province = $this->province; // $model->country = $this->country; $model->post_code = $this->postCode; $model->email = $this->email; $model->contact_num = $this->contact_num; $model->contact_num_2 = $this->contact_num_2; $model->size = $this->size; $model->save(FALSE); }
public function actionReject() { $request = Yii::app()->request; if (isset($_GET)) { $id = Yii::app()->request->getQuery('id'); $order = BookService::model()->findByAttributes(array('id' => $id)); $order->status = 5; $this->sendMailSorry($order->email); $order->save(FALSE); Yii::app()->user->setFlash('success', "Order rejected !"); $this->redirect(Yii::app()->createUrl('admin/staff')); } }
public function SendMailConfirm() { try { $data = BookService::model()->findByAttributes(array('id' => Yii::app()->session['order_id'])); $this->title = "Mail test"; $mail = new YiiMailer(); $mail->setView('confirm'); $mail->setData(array('data' => $data)); $mail->setFrom('*****@*****.**', 'John Doe'); $mail->setSubject('Confirm your order'); $mail->setTo($data->email); $mail->send(); var_dump($mail->getError()); } catch (Exception $e) { var_dump($e->getMessage()); } }
public function _run($request, $xcontext) { $authorService = new AuthorService(); $xcontext->authorList = $authorService->lists(); $this->logger->info("Get all authors " . count($xcontext->authorList)); $bookService = new BookService(); $xcontext->bookList = $bookService->lists(); $this->logger->info("List all books " . count($xcontext->bookList)); return XNext::useTpl("book/list.html"); }