add rest application and discount-status rest method

This commit is contained in:
Roland Schneider
2018-08-31 07:50:14 +02:00
parent 017bf0f9e4
commit 767211d6c7
33 changed files with 805 additions and 16 deletions

View File

@@ -3,7 +3,6 @@
namespace common\models;
use Yii;
use yii\db\ActiveRecord;
use yii\db\Query;
use yii\db\Expression;
use common\components\Helper;
@@ -241,18 +240,23 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
}
/**
* @param \common\models\Card $card the card to which we are looking for
*
* @return array|\yii\db\ActiveRecord[]
*/
public static function readActive($card){
/**
* @param \common\models\Card $card the card to which we are looking for
*
* @param \DateTime $validOnDay on which day must be the ticket valid
* @return array|\yii\db\ActiveRecord[]
*/
public static function readActive($card, $validOnDay = null){
if ( $card == null )
return [];
$query = Ticket::find();
$today = date('Y-m-d');
if (!isset( $validOnDay ) ){
$today = date('Y-m-d');
}else{
$today = $validOnDay->format('Y-m-d');
}
$query->andWhere(['ticket.id_card' => $card->id_card]);
$query->andWhere( 'ticket.start <= :today' ,[ 'today' => $today] );