Add unpaid tickets display

Add unpaid tickets display to reception
This commit is contained in:
Roland Schneider 2016-05-30 08:18:25 +02:00
parent afa58973ae
commit 410e74a61c
5 changed files with 70 additions and 1 deletions

View File

@ -1,3 +1,5 @@
-0.0.75
- add unpaid tickets display
-0.0.74
- add newsletter changes
-0.0.73

View File

@ -5,7 +5,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.74',
'version' => 'v0.0.75',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global

View File

@ -124,6 +124,11 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
public function getCard(){
return $this->hasOne( Card::className(), ["id_card" =>"id_card" ] );
}
public function getContract(){
return $this->hasOne( Contract::className(), ["id_contract" =>"id_contract" ] );
}
public function getCardNumber(){
$result = "";
$card = $this->card;
@ -217,6 +222,31 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
return $result;
}
/**
* @param common\models\Card $card the card to which we are looking for
* */
public static function readUnpaid($card){
if ( $card == null )
return [];
$query = Ticket::find();
$query->innerJoin("transfer", "transfer.id_object = ticket.id_ticket ");
$today = date('Y-m-d');
$query->andWhere(['ticket.id_card' => $card->id_card]);
$query->andWhere( 'ticket.start <= :today' ,[ 'today' => $today] );
$query->andWhere( 'ticket.end >= :today' ,[ 'today' => $today] );
$query->andWhere( ['in' ,'ticket.status' ,[ Ticket::STATUS_INACTIVE, Ticket::STATUS_ACTIVE] ]);
$query->andWhere( ["transfer.type" => Transfer::TYPE_TICKET] );
$query->andWhere( [ "transfer.status" => Transfer::STATUS_NOT_PAID ]);
$query->orderBy([ "ticket.created_at" =>SORT_DESC] );
$result = $query->all();
return $result;
}
public static function mkStatisticQuery($start,$end,$id_card = null){

View File

@ -26,6 +26,7 @@ class ReceptionForm extends Model
public $card;
public $customer;
public $tickets;
public $unpaidTickets;
public $defaultAccount;
public $cardSearchModel;
public $lastCassaState;
@ -77,6 +78,7 @@ class ReceptionForm extends Model
if ( $this->card != null ){
$this->customer = $this->card->customer;
$this->readValidTickets();
$this->readUnpaidTicket();
$this->readAssignedKeys();
$this->readContract();
}
@ -183,6 +185,10 @@ class ReceptionForm extends Model
$this->tickets = Ticket::readActive($this->card);
}
public function readUnpaidTicket(){
$this->unpaidTickets = Ticket::readUnpaid($this->card);
}
/**
* @return true , if card found without customer
* */

View File

@ -105,4 +105,35 @@ if ( isset($model->contract)){
}
}
if ( isset( $model->unpaidTickets ) ) {
if ( count($model->unpaidTickets) > 0){
echo Html::beginTag("div",['class'=>"alert alert-warning", "role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
echo "Fizetetlen bérletek";
echo Html::endTag("strong");
echo "<ul>";
$formatter = \Yii::$app->formatter;
foreach ($model->unpaidTickets as $t ){
echo Html::beginTag("li",[ ]);
$c = $t->contract;
if (isset($c)){
echo "<b>Szerződéses</b>";
}
echo $t->getTicketTypeName();
echo ": ";
echo $formatter->asDate($t->start);
echo " - " ;
echo $formatter->asDate($t->end);
echo " (";
echo $t->price_brutto;
echo " Ft)";
echo Html::endTag("li");
}
echo "</ul>";
echo Html::endTag("div");
}
}
?>