Skip to content

Commit

Permalink
stock report
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapjansma committed Aug 29, 2022
1 parent 059e0f9 commit 96b0f7a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description":"Isotope Stock.",
"type": "contao-bundle",
"license":"AGPL-3.0-or-later",
"version": "1.0.6",
"version": "1.0.7",
"require": {
"contao/core-bundle": "^4.9",
"isotope/isotope-core": "^2.6",
Expand Down
1 change: 0 additions & 1 deletion src/Controller/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public function updateBalanceStatus(): RedirectResponse
*/
public function massBooking(Request $request): Response
{

$GLOBALS['TL_JAVASCRIPT'][] = 'assets/jquery/js/jquery.min.js|static';
$response = new Response();
\Contao\System::loadLanguageFile(BookingModel::getTable());
Expand Down
22 changes: 19 additions & 3 deletions src/Controller/OverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\StreamedResponse;
Expand All @@ -53,12 +54,22 @@ public function __construct(ContaoCsrfTokenManager $tokenManager)
}

/**
* @Route("/contao/tl_isotope_stock_booking/overview",
* @Route("/contao/tl_isotope_stock_booking/overview_all",
* name="tl_isotope_stock_booking_overview_all",
* defaults={"_scope": "backend", "_token_check": true}
* )
*/
public function overviewAll(Request $request): Response {
return $this->overview($request, false);
}

/**
* @Route("/contao/tl_isotope_stock_booking/overview/{onlyActive}",
* name="tl_isotope_stock_booking_overview",
* defaults={"_scope": "backend", "_token_check": true}
* )
*/
public function overview(): Response
public function overview(Request $request, bool $onlyActive=true): Response
{
\Contao\System::loadLanguageFile('default');
$spreadsheet = new Spreadsheet();
Expand Down Expand Up @@ -91,8 +102,13 @@ public function overview(): Response
}
$sheet->freezePane('A2');

$sql = "SELECT id, name, sku FROM tl_iso_product WHERE `pid` = '0'";
if ($onlyActive) {
$sql .= " AND `published` = '1'";
}
$sql .= " ORDER BY sku ASC, name ASC";
$db = Database::getInstance();
$products = $db->prepare("SELECT id, name, sku FROM tl_iso_product WHERE `pid` = '0' ORDER BY sku ASC, name ASC")->execute();
$products = $db->prepare($sql)->execute();
$i = 2;
while($product = $products->fetchAssoc()) {
if (empty($product['name']) && empty($product['sku'])) {
Expand Down
9 changes: 9 additions & 0 deletions src/Resources/contao/dca/tl_iso_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
'icon' => 'tablewizard.svg',
);

$GLOBALS['TL_DCA']['tl_iso_product']['list']['global_operations']['stock_report_all'] = array
(
'label' => $GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report_all'],
'route' => 'tl_isotope_stock_booking_overview_all',
'class' => 'stock_report',
'attributes' => 'onclick="Backend.getScrollOffset()" accesskey="c"',
'icon' => 'tablewizard.svg',
);

$GLOBALS['TL_DCA']['tl_iso_product']['list']['operations']['stock'] = [
'label' => &$GLOBALS['TL_LANG']['tl_iso_product']['stock'],
//'icon' => 'rows.svg',
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/contao/languages/en/tl_iso_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
$GLOBALS['TL_LANG']['tl_iso_product']['stock'] = 'View Stock';
$GLOBALS['TL_LANG']['tl_iso_product']['isostock_legend'] = 'Isotope Stock';
$GLOBALS['TL_LANG']['tl_iso_product']['isostock_preorder'] = ['Product Pre-Order', 'The Product is available for pre-order.'];
$GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report'] ='Stock Report';
$GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report'] ='Stock Report';
$GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report_all'] ='Stock Report (include inactive)';
3 changes: 2 additions & 1 deletion src/Resources/contao/languages/nl/tl_iso_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
$GLOBALS['TL_LANG']['tl_iso_product']['stock'] = 'Bekijk voorraad';
$GLOBALS['TL_LANG']['tl_iso_product']['isostock_legend'] = 'Isotope Voorraad';
$GLOBALS['TL_LANG']['tl_iso_product']['isostock_preorder'] = ['Product Pre-Order', 'Is beschikbaar voor Pre-Order.'];
$GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report'] ='Voorraad rapport';
$GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report'] ='Voorraad rapport';
$GLOBALS['TL_LANG']['tl_isotope_prodocut']['stock_report_all'] ='Voorraad rapport (inclusief inactieve)';

0 comments on commit 96b0f7a

Please sign in to comment.