示例#1
0
 public function create()
 {
     Order::createOrder();
     Customer::updateNotes();
     OrderDetail::createOrderDetail();
     Cart::deleteCartAfterCheckout();
     parent::redirectTo('indexHome');
 }
示例#2
0
 public function showOrderDetail($init, $id)
 {
     if ($init == 'admin') {
         $idData = explode('/', $_SERVER['REQUEST_URI']);
         $idAny = end($idData);
         parent::routes()->render('admin_order_detail.twig', array('app_base' => $this->appBase, 'results' => OrderDetail::showOrderDetail($id), 'title' => 'Order Details #' . $idAny));
     } else {
         parent::routes()->render('order_detail.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'results' => OrderDetail::showOrderDetail($id), 'title' => 'Your Order Details'));
     }
 }
示例#3
0
 public function flashAny($init, $id = null)
 {
     $req = $this->app->request();
     self::$errors = array();
     $idData = explode('/', $_SERVER['REQUEST_URI']);
     $idAny = end($idData);
     if (filter_var($idAny, FILTER_VALIDATE_INT) === false) {
         if (User::countUser($req->post('email'))->fetchColumn() == 1) {
             self::$errors[] = 'Email sudah terdaftar';
         }
     }
     if (count(self::$errors) > 0) {
         $this->app->flash('errors', self::$errors);
         $this->app->flash('tmpEmail', self::$tmpEmail);
         if ($init == 'add') {
             parent::redirectTo('addUser');
         } else {
             self::$url = $this->app->urlFor('editUser', array('id' => $id));
             $this->app->redirect(self::$url);
         }
     }
 }
示例#4
0
 public function delete($id)
 {
     Comment::deleteComment($id);
     parent::redirectTo('indexComment');
 }
示例#5
0
 public function flashAny($init, $id = null)
 {
     $req = $this->app->request();
     self::$errors = array();
     $idData = explode('/', $_SERVER['REQUEST_URI']);
     $idAny = end($idData);
     if (filter_var($idAny, FILTER_VALIDATE_INT) === false) {
         if (Customer::countCustomer($req->post('email'))->fetchColumn() == 1) {
             self::$errors[] = 'That email already exists.';
         }
     }
     if (count(self::$errors) > 0) {
         $this->app->flash('errors', self::$errors);
         $this->app->flash('tmpAddress', $req->post('address'));
         $this->app->flash('tmpEmail', $req->post('email'));
         $this->app->flash('tmpName', $req->post('name'));
         $this->app->flash('tmpNotes', $req->post('notes'));
         $this->app->flash('tmpPhone', $req->post('phone'));
         if ($init == 'add') {
             parent::redirectTo('addCustomer');
         } elseif ($init == 'adminAdd') {
             parent::redirectTo('adminAddCustomer');
         } else {
             self::$url = $this->app->urlFor('editCustomer', array('id' => $id));
             $this->app->redirect(self::$url);
         }
     }
 }
示例#6
0
 public function delete($id)
 {
     Carousel::deleteCarousel($id);
     parent::redirectTo('indexCarousel');
 }
示例#7
0
 public function loggedOut()
 {
     unset($_SESSION['emailAdmin']);
     unset($_SESSION['levelAdmin']);
     parent::redirectTo('loginAdmin');
 }
示例#8
0
 public function delete($id)
 {
     Cart::deleteCart($id);
     parent::redirectTo('cart');
 }
 public function delete($id)
 {
     PaymentConfirmation::deletePaymentConfirmation($id);
     parent::redirectTo('indexPaymentConfirmation');
 }
示例#10
0
 public function delete($id)
 {
     Product::deleteProduct($id);
     parent::redirectTo('indexProduct');
 }
示例#11
0
 public function __construct()
 {
     $this->app = Controller::routes();
     $this->appBase = $this->app->request()->getRootURI();
     $app = $this->app->setName('app');
     $authAdmin = function ($app) {
         return function ($app) {
             if (!isset($_SESSION['emailAdmin'])) {
                 $_SESSION['urlRedirect'] = $this->app->request()->getPathInfo();
                 $this->app->flash('error', 'Login required');
                 Controller::redirectTo('loginAdmin');
             }
         };
     };
     $authCustomer = function ($app) {
         return function ($app) {
             if (!isset($_SESSION['emailCustomer'])) {
                 $_SESSION['urlRedirect'] = $this->app->request()->getPathInfo();
                 $this->app->flash('error', 'Login required');
                 Controller::redirectTo('loginCustomer');
             }
         };
     };
     $this->app->notFound(function () {
         $this->app->render('not_found.twig', array('app_base' => $this->appBase, 'title' => 'Error 404'));
     });
     // Untuk memeriksa ada atau tidaknya nilai (hanya ada pada proses development)
     $this->app->get('/dev', function () {
         $this->app->render('dev.twig', array('var1' => isset($_SESSION['order_date']) ? sizeof($_SESSION['order_date']) : 'gak'));
     });
     $this->app->get('/', function () {
         ProductController::index('customer');
     })->name('indexHome');
     $this->app->get('/page/:id', function ($id) {
         ProductController::index('customer', $id);
     });
     $this->app->get('/carts', $authCustomer($app), function () {
         CartController::index();
     })->name('cart');
     $this->app->post('/products/show/:id', $authCustomer($app), function () {
         CartController::create();
     });
     $this->app->post('/carts/:id', $authCustomer($app), function ($id) {
         CartController::update($id);
     });
     $this->app->get('/carts/:id', $authCustomer($app), function ($id) {
         CartController::delete($id);
     });
     $this->app->get('/checkout', $authCustomer($app), function () {
         CheckoutController::index();
     });
     $this->app->post('/checkout', $authCustomer($app), function () {
         CheckoutController::create();
     });
     $this->app->get('/products/show/:id', function ($id) {
         ProductController::show($id);
     });
     $this->app->get('/login-admin', function () {
         if (isset($_SESSION['emailAdmin'])) {
             Controller::redirectTo('indexAdmin');
         } else {
             AdminController::loginAdmin();
         }
     })->name('loginAdmin');
     $this->app->post('/login-admin', function () {
         AdminController::loggedIn();
     });
     $this->app->get('/logout-admin', function () {
         AdminController::loggedOut();
     });
     $this->app->get('/login-customer', function () {
         if (isset($_SESSION['emailCustomer'])) {
             Controller::redirectTo('indexHome');
         } else {
             CustomerController::loginCustomer();
         }
     })->name('loginCustomer');
     $this->app->post('/login-customer', function () {
         CustomerController::loggedIn();
     });
     $this->app->get('/logout-customer', function () {
         CustomerController::loggedOut();
     });
     $this->app->get('/customer-profile', $authCustomer($app), function () {
         CustomerController::showCustomerProfile(isset($_SESSION['emailCustomer']) ? $_SESSION['emailCustomer'] : null);
     })->name('indexCustomerProfile');
     $this->app->get('/customer-profile/edit', $authCustomer($app), function () {
         CustomerController::editCustomerProfile(isset($_SESSION['emailCustomer']) ? $_SESSION['emailCustomer'] : null);
     });
     $this->app->post('/customer-profile/edit', $authCustomer($app), function () {
         CustomerController::updateCustomerProfile(isset($_SESSION['idCustomer']) ? $_SESSION['idCustomer'] : null);
     });
     $this->app->get('/admin', $authAdmin($app), function () {
         require_once 'CreateChart.php';
         AdminController::index();
     })->name('indexAdmin');
     $this->app->get('/admin/comments', $authAdmin($app), function () {
         CommentController::index();
     })->name('indexComment');
     $this->app->get('/admin/comments/page/:id', $authAdmin($app), function ($id) {
         CommentController::index($id);
     });
     $this->app->post('/add-comment', $authCustomer($app), function () {
         CommentController::create();
     });
     $this->app->get('/admin/carousels', $authAdmin($app), function () {
         CarouselController::index();
     })->name('indexCarousel');
     $this->app->get('/admin/carousels/page/:id', $authAdmin($app), function ($id) {
         CarouselController::index($id);
     });
     $this->app->get('/admin/carousels/new', $authAdmin($app), function () {
         CarouselController::add();
     });
     $this->app->post('/admin/carousels/new', $authAdmin($app), function () {
         CarouselController::create();
     });
     $this->app->get('/admin/carousels/edit/:id', $authAdmin($app), function ($id) {
         CarouselController::edit($id);
     });
     $this->app->post('/admin/carousels/edit/:id', $authAdmin($app), function ($id) {
         CarouselController::update($id);
     });
     $this->app->get('/admin/carousels/delete/:id', $authAdmin($app), function ($id) {
         CarouselController::delete($id);
     });
     $this->app->post('/admin/comments/:id', $authAdmin($app), function ($id) {
         CommentController::update($id);
     });
     $this->app->get('/admin/comments/delete/:id', $authAdmin($app), function ($id) {
         CommentController::delete($id);
     });
     $this->app->get('/admin/customers', $authAdmin($app), function () {
         CustomerController::index();
     })->name('indexCustomer');
     $this->app->get('/admin/customers/page/:id', $authAdmin($app), function ($id) {
         CustomerController::index($id);
     });
     $this->app->get('/admin/customers/new', $authAdmin($app), function () {
         CustomerController::add('admin');
     })->name('adminAddCustomer');
     $this->app->post('/admin/customers/new', $authAdmin($app), function () {
         CustomerController::create();
     });
     $this->app->get('/admin/customers/edit/:id', $authAdmin($app), function ($id) {
         CustomerController::edit($id);
     })->name('editCustomer');
     $this->app->post('/admin/customers/edit/:id', $authAdmin($app), function ($id) {
         CustomerController::update($id);
     });
     $this->app->get('/admin/customers/delete/:id', $authAdmin($app), function ($id) {
         CustomerController::delete($id);
     });
     $this->app->get('/new-customer', function () {
         CustomerController::add('customer');
     })->name('addCustomer');
     $this->app->post('/new-customer', function () {
         CustomerController::create('customer');
     });
     $this->app->get('/order-status', $authCustomer($app), function () {
         OrderController::orderStatus();
     })->name('indexOrderStatus');
     $this->app->get('/order-status/show-order-details/:id', $authCustomer($app), function ($id) {
         OrderController::showOrderDetail('customer', $id);
     });
     $this->app->post('/order-status/delete/:id', $authCustomer($app), function ($id) {
         OrderController::deleteOrderStatus($id);
     });
     $this->app->get('/admin/orders', $authAdmin($app), function () {
         OrderController::index();
     })->name('indexOrder');
     $this->app->get('/admin/orders/page/:id', $authAdmin($app), function ($id) {
         OrderController::index($id);
     });
     $this->app->get('/admin/orders/order_details/:id', $authAdmin($app), function ($id) {
         OrderController::showOrderDetail('admin', $id);
     });
     $this->app->post('/admin/orders/:id', $authAdmin($app), function ($id) {
         OrderController::update($id);
     });
     $this->app->get('/admin/orders/delete/:id', $authAdmin($app), function ($id) {
         OrderController::delete($id);
     });
     $this->app->get('/payment-confirmation', $authCustomer($app), function () {
         PaymentConfirmationController::add();
     })->name('newPaymentConfirmation');
     $this->app->post('/payment-confirmation', $authCustomer($app), function () {
         PaymentConfirmationController::create();
     });
     $this->app->post('/admin/payment_confirmations/:id', $authAdmin($app), function ($id) {
         PaymentConfirmationController::update($id);
     });
     $this->app->get('/admin/payment_confirmations/delete/:id', $authAdmin($app), function ($id) {
         PaymentConfirmationController::delete($id);
     });
     $this->app->get('/admin/payment_confirmations', $authAdmin($app), function () {
         PaymentConfirmationController::index();
     })->name('indexPaymentConfirmation');
     $this->app->get('/admin/payment_confirmations/page/:id', $authAdmin($app), function ($id) {
         PaymentConfirmationController::index($id);
     });
     $this->app->get('/admin/products', $authAdmin($app), function () {
         ProductController::index('admin');
     })->name('indexProduct');
     $this->app->get('/admin/products/page/:id', $authAdmin($app), function ($id) {
         ProductController::index('admin', $id);
     });
     $this->app->get('/admin/products/new', $authAdmin($app), function () {
         ProductController::add();
     })->name('addProduct');
     $this->app->post('/admin/products/new', $authAdmin($app), function () {
         ProductController::create();
     });
     $this->app->get('/admin/products/edit/:id', $authAdmin($app), function ($id) {
         ProductController::edit($id);
     })->name('editProduct');
     $this->app->post('/admin/products/edit/:id', $authAdmin($app), function ($id) {
         ProductController::update($id);
     });
     $this->app->get('/admin/products/delete/:id', $authAdmin($app), function ($id) {
         ProductController::delete($id);
     });
     $this->app->get('/admin/sales_report', function () {
         SalesReportController::index();
     });
     $this->app->get('/admin/sales_report/page/:id', $authAdmin($app), function ($id) {
         SalesReportController::index($id);
     });
     $this->app->post('/admin/sales_report', $authAdmin($app), function () {
         SalesReportController::indexByDate();
     });
     $this->app->get('/admin/users', $authAdmin($app), function () {
         UserController::index();
     })->name('indexUser');
     $this->app->get('/admin/users/page/:id', $authAdmin($app), function ($id) {
         UserController::index($id);
     });
     $this->app->get('/admin/users/new', function () {
         UserController::add();
     })->name('addUser');
     $this->app->post('/admin/users/new', function () {
         UserController::create();
     });
     $this->app->get('/admin/users/edit/:id', $authAdmin($app), function ($id) {
         UserController::edit($id);
     })->name('editUser');
     $this->app->post('/admin/users/edit/:id', $authAdmin($app), function ($id) {
         UserController::update($id);
     });
     $this->app->get('/admin/users/delete/:id', $authAdmin($app), function ($id) {
         UserController::delete($id);
     });
     $this->app->run();
 }
示例#12
0
 public function indexByDate($id = null)
 {
     parent::routes()->render('sales_report.twig', array('app_base' => $this->appBase, 'grand_total' => Order::grandTotalSalesReportByDate(), 'results' => Order::salesReportByDate(), 'title' => 'Sales Report By Date'));
 }