Esempio n. 1
0
})->bind('addProd');
$admin->get('/gestionCommandes', function () use($app) {
    //	CODE A INTEGRER !
    $commandeDAO = new CommandeDAO($app['db']);
    $mesCommandes = $commandeDAO->findAll();
    $quantiteCommandes = 0;
    foreach ($mesCommandes as $key => $value) {
        $quantiteCommandes += 1;
    }
    return $app['twig']->render('admin/gestComm.html.twig', array('tableauCommandes' => $mesCommandes, 'quantiteCommandes' => $quantiteCommandes));
})->bind('gestComm');
// Edition mot de passe admin
$app->post('/changeCommScr', function (Request $request) use($app) {
    $data = $request->request->all();
    $comid = $data["idCom"];
    $commandeDAO = new CommandeDAO($app['db']);
    $produitDAO = new produitDAO($app['db']);
    $mesCommandes = $commandeDAO->find($comid);
    $state = $data["etat"];
    if ($state == "Expédiée") {
        foreach ($mesCommandes as $key => $value) {
            $idProd = $value->getProdId();
            $quantiteProdCom = $value->getComQuantite();
            $prodObj = $produitDAO->find($idProd);
            $actualStock = $prodObj->getStock();
            $newStock = $actualStock - $quantiteProdCom;
            if ($newStock >= 0) {
                $prodObj->setStock($newStock);
                $produitDAO->save($prodObj);
            } else {
                $app['session']->getFlashBag()->add('error', array('title' => 'Oups, problème de stock...', 'message' => "Si vous demandez {$quantiteProdCom} Kg de " . $prodObj->getNomProduit() . ", le stock va passer en négatif, augmentez les stocks avant. Stock actuel : " . $prodObj->getStock() . " Kg."));
Esempio n. 2
0
    return $app->redirect('profil');
})->bind('changeTelScrU');
// Change tel page
$user->get('/changeAdrU', function (Request $request) use($app) {
    return $app['twig']->render('user/changeAdrU.html.twig', array());
})->bind('changeAdrU');
// Script edition mail utilisateur
$user->post('/changeAdrScrU', function (Request $request) use($app) {
    $data = $request->request->all();
    $userDao = new UserDAO($app['db']);
    $userTmp = $userDao->find($data["_id"]);
    $ville = $data["_ville"];
    $adresse = $data["_adr"];
    $userTmp->setVille($ville);
    $userTmp->setAdresse($adresse);
    $userDao->save($userTmp);
    return $app->redirect('profil');
})->bind('changeAdrScrU');
// Change password page
$user->get('/affichCommU', function (Request $request) use($app) {
    $CommandeDAO = new CommandeDAO($app['db']);
    $token = $app['security']->getToken();
    $user = $token->getUser();
    $Commandes = $CommandeDAO->findByUser($user->getId());
    if ($Commandes == false) {
        return $app['twig']->render('user/infoCommU.html.twig', array('error' => $app['security.last_error']($request), 'last_username' => $app['session']->get('_security.last_username')));
    }
    //$Commandes = intval($Commandes);
    return $app['twig']->render('user/infoCommU.html.twig', array('error' => $app['security.last_error']($request), 'last_username' => $app['session']->get('_security.last_username'), 'CommandeALL' => $Commandes));
})->bind('affichCommU');
return $user;