counting stuff

This commit is contained in:
Kayn Ty 2018-04-19 11:41:05 +02:00
parent e76d6ec225
commit 922fa73e94
3 changed files with 34 additions and 19 deletions

View File

@ -36,6 +36,8 @@
{% endif %}" href="{{ path('productcategory_index') }}">
<i class="fa fa-file-archive-o"></i>
Catégories
{{ app.user.categories|length }}
</a>
</li>
<li>
@ -46,6 +48,7 @@
{% endif %}" href="{{ path('product_index') }}" data-toggle="tab">
<i class="fa fa-gears"></i>
Produits
{{ app.user.products|length }}
</a>
</li>
<li>
@ -57,6 +60,7 @@
data-toggle="tab">
<i class="fa fa-th-large"></i>
Festivals
{{ app.user.festivals|length }}
</a>
</li>
<li>

View File

@ -45,17 +45,17 @@ class DefaultController extends Controller {
$lastFestival = $currentUser->getActiveFestival();
if(!$lastFestival){
if ( ! $lastFestival ) {
$lastFestival = $m->getRepository( 'AppBundle:Festival' )
->findOneBy( [ 'user' => $this->getUser()->getId() ],
[ 'id' => 'desc' ],
0,
1 );
}
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$categories = $categRepo->findAll();
$recentSells = $sellingRepo->findBy( [], [ 'id' => 'desc' ], 0, 5 );
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$categories = $categRepo->findAll();
$recentSells = $sellingRepo->findBy( [], [ 'id' => 'desc' ], 0, 5 );
return $this->render( 'logged/dashboard.html.twig',
[
@ -368,28 +368,36 @@ class DefaultController extends Controller {
* @Route("/import", name="import")
*/
public function importAction() {
$currentUser = $this->getUser();
$m = $this->getDoctrine()->getManager();
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
$currentUser = $this->getUser();
$m = $this->getDoctrine()->getManager();
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
return $this->render( 'logged/import.html.twig',
[
'base_dir' => '',
'base_dir' => '',
] );
}
/**
* @Route("/mass-create", name="mass_create")
*/
public function massCreateAction() {
$currentUser = $this->getUser();
$m = $this->getDoctrine()->getManager();
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
public function massCreateAction( Request $request ) {
$currentUser = $this->getUser();
$m = $this->getDoctrine()->getManager();
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$myCategories = $sellingRepo->findByUser( $currentUser->getId() );
if ( $request->getMethod() == 'POST' ) {
var_dump( nl2br($request->request->get( 'produits' )) );
// check with existing categories and products, sort them by name.
// save all
}
return $this->render( 'logged/import.html.twig',
[
'base_dir' => '',
'base_dir' => '',
] );
}

View File

@ -39,16 +39,19 @@ class ProductCategoryController extends Controller {
*/
public function newAction( Request $request ) {
$productCategory = new Productcategory();
$productCategory->setUsers($this->getUser());
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
$currentUser = $this->getUser();
$currentUser->addCategory( $productCategory );
$productCategory->setUsers( [ $currentUser ] );
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
$form->handleRequest( $request );
if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager();
$em->persist( $productCategory );
$em->persist( $currentUser );
$em->flush();
return $this->redirectToRoute( 'productcategory_show', [ 'id' => $productCategory->getId() ] );
return $this->redirectToRoute( 'productcategory_index' );
}
return $this->render( 'productcategory/new.html.twig',