Skip to content

Commit

Permalink
update removed grey line
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapjansma committed Nov 15, 2022
1 parent c8f11c3 commit 5901d89
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Cron/UpdateTstamp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright (C) 2022 Jaap Jansma ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

namespace Krabo\IsotopeStockBundle\Cron;

use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\ServiceAnnotation\CronJob;
use Krabo\IsotopePackagingSlipBundle\Helper\PackagingSlipCheckAvailability;

/**
* @CronJob("hourly")
*/
class UpdateTstamp {

/**
* @param \Contao\CoreBundle\Framework\ContaoFramework $contaoFramework
*/
public function __construct(ContaoFramework $contaoFramework) {
$contaoFramework->initialize();
}

public function __invoke(): void
{
$db = \Contao\Database::getInstance();
$db->prepare("UPDATE `tl_isotope_stock_booking` SET `tstamp` = `date` WHERE `tstamp` = 0")->execute();
}

}
13 changes: 13 additions & 0 deletions src/Model/BookingModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public static function doesBookingExistsForOrderAndProduct(Order $objOrder, $pro
->count();
}

/**
* Modify the current row before it is stored in the database
*
* @param array $arrSet The data array
*
* @return array The modified data array
*/
protected function preSave(array $arrSet)
{
$arrSet['tstamp'] = time();
return $arrSet;
}

/**
* @param \Isotope\Model\ProductCollection\Order $objOrder
* @param int $type
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
Krabo\IsotopeStockBundle\Controller\ProductController: ~
Krabo\IsotopeStockBundle\Controller\BookingController: ~
Krabo\IsotopeStockBundle\Controller\OverviewController: ~
Krabo\IsotopeStockBundle\Cron\UpdateTstamp: ~
Krabo\IsotopeStockBundle\EventListener\ProductListener:
public: true
Krabo\IsotopeStockBundle\EventListener\ProductCollectionListener:
Expand Down

0 comments on commit 5901d89

Please sign in to comment.