Ejemplo n.º 1
0
 public function getHeader($level, $mode = 'index')
 {
     global $cl;
     global $cdi;
     global $bdi;
     global $client;
     if (strcmp(trim($level), 'User') == 0) {
         echo "<header id=\"HRnavbar\" class=\"navbar navbar-inverse navbar-fixed-top\"\n\t\tstyle=\"background-color: #373c40;\">\n\t\t<div class=\"navbar-header\">\n\t\t\t<a class=\"navbar-brand\" href=\"\" id=\"logo\"><b><span\n\t\t\t\t\tclass=\"glyphicon glyphicon-book\"></span><span\n\t\t\t\t\tclass=\"dancing-script\"> ReadingFun</span></b> </a>\n\t\t\t<!-- this section is used when we surf the website with a phone or a device smaller than our pc ! -->\n\t\t\t<button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\"\n\t\t\t\tdata-target=\"#menuportable\">\n\t\t\t\t<span class=\"icon-bar\"></span> <span class=\"icon-bar\"></span> <span\n\t\t\t\t\tclass=\"icon-bar\"></span> <span class=\"icon-bar\"></span>\n\t\t\t</button>\n\t\t</div>\n\t\t<div class=\"collapse navbar-collapse\" id=\"menuportable\">";
         if (isset($_SESSION['client'])) {
             $cl = $_SESSION['client'];
             $cdi = new ClientDaoImp($GLOBALS['entityManager']);
             $bdi = new BookDaoImp($GLOBALS['entityManager']);
             $client = $cdi->getClientById($cl->getId());
             echo "<div class=\"dropdown btn navbar-btn pull-right\">\n  \t\t\t<a id=\"dLabel\" class=\"simple\" data-target=\"#\" href=\"#\" data-toggle=\"dropdown\" style=\"color:white;text-decoration:none;\" aria-haspopup=\"true\" role=\"button\" aria-expanded=\"false\">\n    \t\t<span class=\"marck-script\">&nbsp;<span class=\"glyphicon glyphicon-user \"></span><span class=\"marck-script\"> " . $client->getName() . "<span></span>\n    \t\t<span class=\"caret\"></span>\n  \t\t\t</a>\n\t\t\n  \t\t\t<ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\">\n    \t\t<li><a href=\"homeClient.php\"><span class=\"glyphicon glyphicon-book\"></span> <span class=\"marck-script\">Book Store</span></a></li>\n\t\t\t  <li><a href=\"clientCart.php\"><span class=\" glyphicon glyphicon-shopping-cart\"></span> <span class=\"marck-script\">Shoping cart</span></a></li>\n\t\t\t  <li><a href=\"clientProfile.php\"><span class=\" glyphicon glyphicon-cog\"></span> <span class=\"marck-script\">Account settings</span></a></li>\n\t\t      <li role=\"presentation\" class=\"divider\"></li>\n\t\t      <li><a id=\"logOut\" onclick=\"disconnect()\"><span class=\"glyphicon glyphicon-share-alt\"></span> <span class=\"marck-script\">Logout</span></a></li>\n  \t\t\t</ul>\n\t\t\t</div>";
             echo "<div class=\"navbar-btn pull-right\"><a href=\"clientCart.php\" style=\"color:white;margin-right:5px;\">  <span class=\"badge navbar-btn\"><span class=\"glyphicon glyphicon-shopping-cart\"><span> " . $client->getNumberOrders() . " </span></a></div>";
         } else {
             // this means not registered
             echo "\n\t\t\t<div class=\"loginGround\">\n\t\t\t<button class=\"btn btn-success navbar-btn navbar-right\"\n\t\t\tstyle=\"margin-right: 2px;\" data-toggle=\"modal\"\n\t\t\tdata-target=\"#registerModal\">\n\t\t\tRegister <span class=\"glyphicon glyphicon-pencil\"></span>\n\t\t\t</button>\n\t\t\t\n\t\t\t<button class=\"btn btn-primary navbar-btn navbar-right\"\n\t\t\tstyle=\"margin-right: 2px;\" data-toggle=\"modal\"\n\t\t\tdata-target=\"#loginModal\">\n\t\t\tLog in <span class=\"glyphicon glyphicon-user\"></span>\n\t\t\t</button>\n\t\t\t</div>";
         }
         if (strcmp(trim($mode), 'index') === 0) {
             echo "<ul class=\"nav navbar-nav\">\n\t\t\t\t\t<li><a href=\"#feedback\">Feedback</a></li>\n\t\t\t\t\t<li><a href=\"#gallery\">Gallery</a></li>\n\t\t\t\t\t<li><a href=\"#best\">Best sells</a></li>\n\t\t\t\t</ul>";
         } else {
             echo "<ul class=\"nav navbar-nav\">\n\t\t\t\t<li><a href=\"#\"><span class=\"glyphicon glyphicon-education\"></span>\n\t\t\t\t\t\tAbout us</a></li>\n\t\t\t\t<li><a href=\"#\"><span class=\"glyphicon glyphicon-comment\"></span>\n\t\t\t\t\t\tContact us</a></li>\n\t\t\t\t</ul>";
         }
         echo "</div>\n\t\t\t\t  </header>";
     } else {
         if (strcmp(trim($level), 'Admin') == 0) {
             echo "<header id=\"HRnavbar\" class=\"navbar navbar-inverse navbar-fixed-top\"\n\t\t\tstyle=\"background-color: #373c40; margin-bottom: 0.1px;\"\n\t\t\trole=\"banner\">\n\t\t<div class=\"navbar-header\">\n\t\t\t<a class=\"navbar-brand\" href=\"index.php\"><b><span\n\t\t\t\t\tclass=\"glyphicon glyphicon-book\"></span><span\n\t\t\t\t\tclass=\"dancing-script\"> ReadingFun</span></b></a>\n\t\t\t<!-- this section is used when we surf the website with a phone or a device smaller than our pc ! -->\n\t\t\t<button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\"\n\t\t\t\tdata-target=\"#menuportable\">\n\t\t\t\t<span class=\"icon-bar\"></span> <span class=\"icon-bar\"></span> <span\n\t\t\t\t\tclass=\"icon-bar\"></span> <span class=\"icon-bar\"></span>\n\t\t\t</button>\n\t\t</div>\n\t\t<!-- end navbar-header-->\n\n\t\t<div class=\"collapse navbar-collapse\" id=\"menuportable\">\n\t\t\t<!-- something should be done over here ! -->\n\t\t";
             if (isset($_SESSION['client'])) {
                 $cl = $_SESSION['client'];
                 $cdi = new ClientDaoImp($GLOBALS['entityManager']);
                 $client = $cdi->getClientById($cl->getId());
                 $bdi = new BookDaoImp($GLOBALS['entityManager']);
                 echo "\"<div class=\"dropdown btn navbar-btn pull-right\">\n  \t\t\t<a id=\"dLabel\" class=\"simple\" data-target=\"#\" href=\"#\" data-toggle=\"dropdown\" style=\"color:white;text-decoration:none;\" aria-haspopup=\"true\" role=\"button\" aria-expanded=\"false\">\n    \t\t<span class=\"marck-script\">&nbsp;<span class=\"glyphicon glyphicon-user\"></span> " . $client->getName() . "</span>\n    \t\t<span class=\"caret\"></span>\n  \t\t\t</a>\n\n  \t\t\t<ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\">\n\t\t      <li><a id=\"logOut\" onclick=\"disconnect()\"><span class=\"glyphicon glyphicon-share-alt\"></span> <span class=\"marck-script\">Logout</span></a></li>\n  \t\t\t</ul>\n\t\t\t</div>";
             }
             echo "</div>\n\t\t\t\t\t</header>";
         }
     }
 }
Ejemplo n.º 2
0
         // 			$ex->getMessage();
         echo json_encode(array('flag', 'false'));
     }
 } else {
     if (strcmp($_POST['action'], 'login') == 0 && isset($_POST['email']) && isset($_POST['password'])) {
         $email = trim($_POST['email']);
         $password = trim($_POST['password']);
         $cdi = new ClientDaoImp($entityManager);
         $client = $cdi->getClientByEmail($email);
         if ($client == null) {
             echo json_encode(array('flag' => 'EMAIL_NULL'));
         } else {
             if (strcmp($client->getPassword(), md5($password)) == 0) {
                 $cl = $_SESSION['client'];
                 $cdi = new ClientDaoImp($entityManager);
                 $client = $cdi->getClientById($cl->getId());
                 if ($client != null) {
                     foreach ($client->getOrders() as $order) {
                         if (!$order->getValid()) {
                             $order->setValid(true);
                         }
                     }
                 }
                 $entityManager->flush();
                 echo json_encode(array('flag' => 'PASSWD_OK'));
             } else {
                 echo json_encode(array('flag' => 'PASSWD_NULL'));
             }
         }
     } else {
         echo json_encode(array('flag', 'error: Action not found'));
Ejemplo n.º 3
0
 $cdi = new ClientDaoImp($entityManager);
 $obi = new OrderBookDaoImp($entityManager);
 if (isset($_POST['action'])) {
     $see = array();
     $seeall = array();
     $ffinale = array();
     $tmp = array();
     $tmpp = array();
     if (strcmp(trim($_POST['action']), 'edit') == 0) {
         $orderId = intval(trim($_POST['id']));
         $orderDate = new DateTime(trim($_POST['data']['orders']['Order Date']));
         $orderValid = trim($_POST['data']['orders']['Valid']);
         $clientId = intval(trim($_POST['data']['orders']['Client Id']));
         $orderBookId = trim($_POST['data']['orders']['Order Book Id']);
         $order = $odi->getOrderById($orderId);
         $client = $cdi->getClientById($clientId);
         if ($order !== null) {
             $order->setOrderDate($orderDate);
             if (strcmp(strtolower($orderValid), 'true') === 0) {
                 $order->setValid(true);
             } else {
                 $order->setValid(false);
             }
             if ($client !== null) {
                 $order->setClient($client);
             }
             $entityManager->flush();
             $array['DT_RowId'] = $orderId;
             $see['Order Date'] = $orderDate->format("d-m-Y");
             if ($order->getValid()) {
                 $see['Valid'] = 'true';
Ejemplo n.º 4
0
     $cdi = new ClientDaoImp($entityManager);
     foreach ($cdi->getAllClients() as $client) {
         if ($client->getLevel() === 0) {
             $array['Client Level'] = 'User';
             // 			$array['Client Id'] = $client->getId();
             $array['Client Name'] = $client->getName();
             $array['Client Age'] = $client->getAge();
             $array['Client Email'] = $client->getEmail();
             $array['Client Password'] = $client->getPassword();
             $final[] = $array;
         }
     }
     echo json_encode(array('flag' => true, 'data' => $final));
 } else {
     if (strcmp(trim($_POST['action']), 'updateClient') == 0) {
         $c = $cdi->getClientById(intval(trim($_POST['id'])));
         $c->setName(trim($_POST['name']));
         $c->setAge(trim($_POST['age']));
         $c->setEmail(trim($_POST['email']));
         if (strcmp(strtolower(trim($_POST['level'])), strtolower('User')) == 0) {
             $c->setLevel(0);
         } else {
             $c->setLevel(1);
         }
         if (strlen(trim($_POST['password'])) !== 0) {
             $c->setPassword(md5(trim($_POST['password'])));
         }
         //the unitofWork will automatically detect the changes & it will be saved eventually
         $entityManager->flush();
         echo json_encode(array('flag' => true));
     } else {
Ejemplo n.º 5
0
    require_once '../vendor/autoload.php';
    require_once '../Persistance/ClientDaoImp.php';
    require_once '../../vendor/autoload.php';
    require_once '../Model/Client.php';
} else {
    $root = $_SERVER['DOCUMENT_ROOT'];
    require_once $root . '/phoenix/Project/bootstrap.php';
    require_once $root . '/phoenix/Project/vendor/autoload.php';
    require_once $root . '/phoenix/Project/Persistance/ClientDaoImp.php';
    require_once $root . '/phoenix/Project/vendor/autoload.php';
    require_once $root . '/phoenix/Project/Model/Client.php';
}
$cdi = new ClientDaoImp($entityManager);
if (isset($_POST['action'])) {
    if (strcmp(trim($_POST['action']), 'edit') == 0) {
        $client = $cdi->getClientById(trim($_POST['id']));
        if ($client !== null) {
            $array = array();
            $client->setName(trim($_POST['data']['Client Name']));
            $client->setAge(trim($_POST['data']['Client Age']));
            $client->setEmail(trim($_POST['data']['Client Email']));
            $client->setPassword(md5(trim($_POST['data']['Client Password'])));
            if (strcmp(trim($_POST['data']['Client Level']), 'User') == 0) {
                $client->setLevel(0);
            } else {
                $client->setLevel(1);
            }
            $entityManager->flush();
            $array['DT_RowId'] = "" . $client->getId() . "";
            $array['Client Name'] = $client->getName();
            $array['Client Age'] = $client->getAge();
Ejemplo n.º 6
0
// 	}
// foreach($categories as $name)
// echo $name."\n";
// if( (count($books)%6)== 0 )echo "Result1".count($books/6)."\n";
// else echo "Result2".(round(count($books)/6)+1)."\n";
// function getNumberBooks($page,$size){
// 	$a = round($size/6);
// 	$b = $size%6;
// 	if($b==0)return 6;
// 	else if($page ==($a+1))return $b;
// 	else return 6;
// }
// echo "Pages: ".getNumberBooks(2, count($books));
// $book = $bdi->getBookById(8);
$cdi = new ClientDaoImp($entityManager);
$client = $cdi->getClientById(3);
// $order = new Order('12/02/2001');
// $ob = new orderbook();
// $ob->setBook($book);
// $ob->setQuantity(2);
// $ob->setOrder($order);
// $order->addOrderBook($ob);
// $order->setClient($client);
// $client->addOrder($order);
// $entityManager->persist($order);
// $entityManager->flush();
// echo $client->getOrders()[0]->getOrderBook()[0]->getBook()->getTitle();
// echo "number: ".count($client->getOrders()[0]->getOrderBook());
// foreach($client->getOrders() as $order)
// 	if(!$order->getValid())
// 		foreach($order->getOrderBook() as $orderbook)