diff --git a/module/CudiBundle/Component/Document/Generator/SaleArticles.php b/module/CudiBundle/Component/Document/Generator/SaleArticles.php index 279ff59a6e..994d0ff058 100644 --- a/module/CudiBundle/Component/Document/Generator/SaleArticles.php +++ b/module/CudiBundle/Component/Document/Generator/SaleArticles.php @@ -18,7 +18,7 @@ class SaleArticles extends \CommonBundle\Component\Document\Generator\Csv * @param AcademicYear $academicYear The academic year * @param integer $semester The semester */ - public function __construct(EntityManager $entityManager, AcademicYear $academicYear, $semester) + public function __construct(EntityManager $entityManager, AcademicYear $academicYear, int $semester, bool $common) { $headers = array( 'Title', @@ -40,7 +40,7 @@ public function __construct(EntityManager $entityManager, AcademicYear $academic parent::__construct( $headers, - $this->getData($entityManager, $academicYear, $semester) + $this->getData($entityManager, $academicYear, $semester, $common) ); } @@ -49,7 +49,7 @@ public function __construct(EntityManager $entityManager, AcademicYear $academic * @param AcademicYear $academicYear * @param integer $semester */ - private function getData(EntityManager $entityManager, AcademicYear $academicYear, $semester) + private function getData(EntityManager $entityManager, AcademicYear $academicYear, int $semester, bool $common) { $articles = $entityManager ->getRepository('CudiBundle\Entity\Sale\Article') @@ -58,14 +58,34 @@ private function getData(EntityManager $entityManager, AcademicYear $academicYea $data = array(); foreach ($articles as $article) { $codes = $this->getSubjectCode($entityManager, $academicYear, $article); - foreach ($codes as $code) { + if ($codes) { + foreach ($codes as $code) { + $articleData = array( + $article->getMainArticle()->getTitle(), + $article->getBarcode(), + $article->getSupplier()->getName(), + $article->getMainArticle()->getAuthors(), + $code->getSubject()->getCode(), + $code->getSubject()->getName(), + $this->getNbSold($entityManager, $article, $academicYear), + $article->getStockValue(), + $this->getPagesBW($entityManager, $article), + $this->getPagesColored($entityManager, $article), + $this->getRectoVerso($entityManager, $article), + number_format($article->getPurchasePrice() / 100, 2), + number_format($article->getSellPrice() / 100, 2), + $article->getMainArticle()->getNameContact(), + $article->getMainArticle()->getEmailContact() + ); + } + } elseif ($common) { $articleData = array( $article->getMainArticle()->getTitle(), $article->getBarcode(), $article->getSupplier()->getName(), $article->getMainArticle()->getAuthors(), - $code->getSubject()->getCode(), - $code->getSubject()->getName(), + '', + '', $this->getNbSold($entityManager, $article, $academicYear), $article->getStockValue(), $this->getPagesBW($entityManager, $article), @@ -77,6 +97,7 @@ private function getData(EntityManager $entityManager, AcademicYear $academicYea $article->getMainArticle()->getEmailContact() ); } + if (!in_array($articleData, $data)) { $data[] = $articleData; } diff --git a/module/CudiBundle/Controller/Admin/Sale/ArticleController.php b/module/CudiBundle/Controller/Admin/Sale/ArticleController.php index 5b99a4f2fe..10ced13e43 100644 --- a/module/CudiBundle/Controller/Admin/Sale/ArticleController.php +++ b/module/CudiBundle/Controller/Admin/Sale/ArticleController.php @@ -90,9 +90,10 @@ public function downloadAction() ->findOneById($formData['academic_year']); $semester = $formData['semester']; + $common = $formData['common']; $file = new CsvFile(); - $document = new SaleArticlesGenerator($this->getEntityManager(), $academicYear, $formData['semester']); + $document = new SaleArticlesGenerator($this->getEntityManager(), $academicYear, $formData['semester'], $common); $document->generateDocument($file); $this->getResponse()->getHeaders() diff --git a/module/CudiBundle/Form/Admin/Sale/Article/Export.php b/module/CudiBundle/Form/Admin/Sale/Article/Export.php index ad49df42eb..7b1edc56c1 100644 --- a/module/CudiBundle/Form/Admin/Sale/Article/Export.php +++ b/module/CudiBundle/Form/Admin/Sale/Article/Export.php @@ -42,6 +42,15 @@ public function init() ) ); + $this->add( + array( + 'type' => 'checkbox', + 'name' => 'common', + 'label' => 'Common items', + 'required' => true, + ) + ); + $this->addSubmit('Download', 'download'); } diff --git a/module/CudiBundle/Resources/translations/site.en.php b/module/CudiBundle/Resources/translations/site.en.php index 8cc506e9f3..3bee046679 100644 --- a/module/CudiBundle/Resources/translations/site.en.php +++ b/module/CudiBundle/Resources/translations/site.en.php @@ -18,6 +18,7 @@ 'Actions' => 'Actions', 'Mandatory' => 'Mandatory', 'Booked' => 'Booked', + 'Bought' => 'Bought', 'Assigned' => 'Assigned', 'Remarks' => 'Remarks', 'Remark' => 'Remark', @@ -95,6 +96,6 @@ 'You currently have no personal retails!' => 'You currently have no personal retails!', 'You successfully deleted the retail!' => 'You successfully deleted the retail!', - 'To edit subjects here, go to' => 'To edit subject here, go to', - 'Profile' => 'Profile', + 'To edit subjects visible here, go to' => 'To edit subject visible here, go to', + 'profile' => 'profile', ); diff --git a/module/CudiBundle/Resources/translations/site.nl.php b/module/CudiBundle/Resources/translations/site.nl.php index 5fbe6d234f..5c79064fc7 100644 --- a/module/CudiBundle/Resources/translations/site.nl.php +++ b/module/CudiBundle/Resources/translations/site.nl.php @@ -18,6 +18,7 @@ 'Actions' => 'Acties', 'Mandatory' => 'Verplicht', 'Booked' => 'Gereserveerd', + 'Bought' => 'Gekocht', 'Assigned' => 'Toegewezen', 'Remarks' => 'Opmerkingen', 'Remark' => 'Opmerking', @@ -95,6 +96,6 @@ 'You currently have no personal retails!' => 'Je hebt momenteel geen persoonlijke aanbiedingen!', 'You successfully deleted the retail!' => 'De aanbieding is succesvol verwijderd!', - 'To edit subjects here, go to' => 'Om je vakken aan te passen, ga naar', - 'Profile' => 'Profiel', + 'To edit subjects visible here, go to' => 'Om je vakken aan te passen, ga naar', + 'profile' => 'profiel', );