counting stuff
This commit is contained in:
parent
e76d6ec225
commit
922fa73e94
|
@ -36,6 +36,8 @@
|
||||||
{% endif %}" href="{{ path('productcategory_index') }}">
|
{% endif %}" href="{{ path('productcategory_index') }}">
|
||||||
<i class="fa fa-file-archive-o"></i>
|
<i class="fa fa-file-archive-o"></i>
|
||||||
Catégories
|
Catégories
|
||||||
|
|
||||||
|
{{ app.user.categories|length }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
@ -46,6 +48,7 @@
|
||||||
{% endif %}" href="{{ path('product_index') }}" data-toggle="tab">
|
{% endif %}" href="{{ path('product_index') }}" data-toggle="tab">
|
||||||
<i class="fa fa-gears"></i>
|
<i class="fa fa-gears"></i>
|
||||||
Produits
|
Produits
|
||||||
|
{{ app.user.products|length }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
@ -57,6 +60,7 @@
|
||||||
data-toggle="tab">
|
data-toggle="tab">
|
||||||
<i class="fa fa-th-large"></i>
|
<i class="fa fa-th-large"></i>
|
||||||
Festivals
|
Festivals
|
||||||
|
{{ app.user.festivals|length }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -45,17 +45,17 @@ class DefaultController extends Controller {
|
||||||
|
|
||||||
|
|
||||||
$lastFestival = $currentUser->getActiveFestival();
|
$lastFestival = $currentUser->getActiveFestival();
|
||||||
if(!$lastFestival){
|
if ( ! $lastFestival ) {
|
||||||
$lastFestival = $m->getRepository( 'AppBundle:Festival' )
|
$lastFestival = $m->getRepository( 'AppBundle:Festival' )
|
||||||
->findOneBy( [ 'user' => $this->getUser()->getId() ],
|
->findOneBy( [ 'user' => $this->getUser()->getId() ],
|
||||||
[ 'id' => 'desc' ],
|
[ 'id' => 'desc' ],
|
||||||
0,
|
0,
|
||||||
1 );
|
1 );
|
||||||
}
|
}
|
||||||
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
|
$categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
|
||||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||||
$categories = $categRepo->findAll();
|
$categories = $categRepo->findAll();
|
||||||
$recentSells = $sellingRepo->findBy( [], [ 'id' => 'desc' ], 0, 5 );
|
$recentSells = $sellingRepo->findBy( [], [ 'id' => 'desc' ], 0, 5 );
|
||||||
|
|
||||||
return $this->render( 'logged/dashboard.html.twig',
|
return $this->render( 'logged/dashboard.html.twig',
|
||||||
[
|
[
|
||||||
|
@ -368,28 +368,36 @@ class DefaultController extends Controller {
|
||||||
* @Route("/import", name="import")
|
* @Route("/import", name="import")
|
||||||
*/
|
*/
|
||||||
public function importAction() {
|
public function importAction() {
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||||
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
|
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
|
||||||
|
|
||||||
return $this->render( 'logged/import.html.twig',
|
return $this->render( 'logged/import.html.twig',
|
||||||
[
|
[
|
||||||
'base_dir' => '',
|
'base_dir' => '',
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/mass-create", name="mass_create")
|
* @Route("/mass-create", name="mass_create")
|
||||||
*/
|
*/
|
||||||
public function massCreateAction() {
|
public function massCreateAction( Request $request ) {
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
|
||||||
$mySellings = $sellingRepo->findByUser( $currentUser->getId() );
|
$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',
|
return $this->render( 'logged/import.html.twig',
|
||||||
[
|
[
|
||||||
'base_dir' => '',
|
'base_dir' => '',
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,19 @@ class ProductCategoryController extends Controller {
|
||||||
*/
|
*/
|
||||||
public function newAction( Request $request ) {
|
public function newAction( Request $request ) {
|
||||||
$productCategory = new Productcategory();
|
$productCategory = new Productcategory();
|
||||||
$productCategory->setUsers($this->getUser());
|
$currentUser = $this->getUser();
|
||||||
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
$currentUser->addCategory( $productCategory );
|
||||||
|
$productCategory->setUsers( [ $currentUser ] );
|
||||||
|
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||||
$form->handleRequest( $request );
|
$form->handleRequest( $request );
|
||||||
|
|
||||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist( $productCategory );
|
$em->persist( $productCategory );
|
||||||
|
$em->persist( $currentUser );
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute( 'productcategory_show', [ 'id' => $productCategory->getId() ] );
|
return $this->redirectToRoute( 'productcategory_index' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render( 'productcategory/new.html.twig',
|
return $this->render( 'productcategory/new.html.twig',
|
||||||
|
|
Loading…
Reference in New Issue