public function enterAdminPanel()
 {
     $html = "";
     if (AppUserRolesConfig::isAdmin()) {
         $url = \EShop\Config\RouteConfig::getBasePath() . 'admin/admin/adminPanel';
         $html .= "<a class='list-group-item' href=\"{$url}\">Admin Panel</a>";
         echo $html;
     }
 }
 public function renderAddCategoryMenu()
 {
     if (AppUserRolesConfig::hasAddEditDeletePriviligies()) {
         FormViewHelper::init();
         FormViewHelper::setMethod("post");
         FormViewHelper::setAction(\EShop\Config\RouteConfig::getBasePath() . "categories/add");
         FormViewHelper::initTextField()->setName('name')->setAttribute('placeholder', 'Category name')->setAttribute('class', 'add-category-field')->create();
         FormViewHelper::initSubmitButton()->setValue('Add Category')->setAttribute('class', 'btn btn-default')->create()->render();
     }
 }
 public function renderDeleteProductButton($productId)
 {
     if (AppUserRolesConfig::hasAddEditDeletePriviligies()) {
         FormViewHelper::init();
         FormViewHelper::setMethod("post");
         FormViewHelper::setAction(\EShop\Config\RouteConfig::getBasePath() . 'products/deleteProduct');
         FormViewHelper::initHiddenField()->setName('productId')->setValue($productId)->create();
         FormViewHelper::initHiddenField()->setName('categoryId')->setValue(substr($_GET['uri'], strlen($_GET['uri']) - 1, strlen($_GET['uri'])))->create();
         FormViewHelper::initSubmitButton()->setValue('Delete')->setAttribute('class', 'btn-default product-btn')->create()->render();
     }
 }
 public function renderSoldProducts()
 {
     if (AppUserRolesConfig::hasAddEditDeletePriviligies()) {
         if ($this->soldProducts) {
             FormViewHelper::init();
             FormViewHelper::setMethod("post");
             FormViewHelper::setAction(\EShop\Config\RouteConfig::getBasePath() . 'account/reorder');
             FormViewHelper::setAttribute('class', 'productForm');
             $select = FormViewHelper::initSelect();
             $select->setName('productId');
             foreach ($this->soldProducts as $product) {
                 $select->addOption($product->getId(), $product->getName());
             }
             $select->create();
             FormViewHelper::initNumberField()->setName('quantity')->setAttribute('min', '1')->setAttribute('placeholder', 'Order counts')->create();
             FormViewHelper::initSubmitButton()->setValue('Reorder')->setAttribute('class', 'btn btn-primary')->create();
             FormViewHelper::render();
         }
     }
 }
 public function renderProduct()
 {
     if (AppUserRolesConfig::hasAddEditDeletePriviligies()) {
         FormViewHelper::init();
         FormViewHelper::setAttribute('class', 'productForm');
         FormViewHelper::setMethod("post");
         FormViewHelper::setAction(\EShop\Config\RouteConfig::getBasePath() . 'products/edit');
         FormViewHelper::initTextField()->setName('productName')->setValue($this->productOldInformation->getProductName())->setAttribute('class', 'form-group')->create();
         FormViewHelper::initHiddenField()->setName('productId')->setValue($this->productOldInformation->getProductId())->setAttribute('class', 'form-group')->create();
         FormViewHelper::initTextField()->setName('quantity')->setValue($this->productOldInformation->getQuantity())->create();
         $select = FormViewHelper::initSelect();
         $select->setAttribute('class', 'form-group');
         $select->setName('categoryId');
         foreach ($this->categories as $category) {
             if ($category->getId() == $this->productOldInformation->getCategoryId()) {
                 $select->addOption($category->getId(), $category->getName(), true);
             } else {
                 $select->addOption($category->getId(), $category->getName());
             }
         }
         $select->create();
         FormViewHelper::initSubmitButton()->setValue('Edit')->setAttribute('class', 'btn-primary btn-lg')->create()->render();
     }
 }
예제 #6
0
account/renderChangePasswordMenu">Change password</a>
                    </div>
                    <div>
                        <a class="list-group-item" href="<?php 
echo \EShop\Config\RouteConfig::getBasePath();
?>
account/viewCart">View Cart</a>
                    </div>
                    <div>
                        <a class="list-group-item" href="<?php 
echo \EShop\Config\RouteConfig::getBasePath();
?>
account/products">View my products</a>
                    </div>
                    <?php 
if (\EShop\Config\AppUserRolesConfig::hasAddEditDeletePriviligies()) {
    ?>
                    <div>
                        <a class="list-group-item" href="<?php 
    echo \EShop\Config\RouteConfig::getBasePath();
    ?>
account/getSoldProducts">Reorder product</a>
                    </div>
                    <?php 
}
?>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="bs-component">
                    <div class="panel panel-primary">
 public function renderCertainProductsPromoMenu()
 {
     if (AppUserRolesConfig::isAdmin()) {
         FormViewHelper::init();
         FormViewHelper::setMethod("post");
         FormViewHelper::setAction(\EShop\Config\RouteConfig::getBasePath() . 'admin/admin/addPromotionOnCertainProduct');
         $select = FormViewHelper::initSelect();
         $select->setName('productId');
         foreach ($this->allProducts as $product) {
             $select->addOption($product->getid(), $product->getName());
         }
         $select->create();
         FormViewHelper::initNumberField()->setAttribute('placeholder', 'Product promo in %')->setName('discount')->setAttribute('class', 'discount')->create();
         FormViewHelper::initSubmitButton()->setValue('Add promotion')->setAttribute('class', 'btn btn-primary')->create();
         FormViewHelper::render();
     }
 }
 /**
  * @param BindModels\LoginBindingModel $loginBindingModel
  * @throws \Exception
  * @Route("login")
  */
 public function loginUser(BindModels\LoginBindingModel $loginBindingModel)
 {
     $username = $loginBindingModel->getUsername();
     $password = $loginBindingModel->getPassword();
     $user = $this->_eshopData->getUsersRepository()->findByUsername($username);
     if ($user == null || !password_verify($password, $user->getPassword())) {
         throw new InvalidCredentialsException('Invalid credentials');
     }
     $_SESSION['role'] = AppUserRolesConfig::getUserRoleName($user->getRole());
     $this->setIdInSession($user->getId());
     RouteService::redirect('account', 'profile', true);
 }