add ticket original end and original price
add helper links to related object in admin
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace common\components;
|
||||
|
||||
use common\models\TicketType;
|
||||
use common\models\Transfer;
|
||||
use \Yii;
|
||||
|
||||
@@ -493,5 +494,40 @@ class Helper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $start \DateTime datetime
|
||||
* @param $ticketType \common\models\TicketType the ticket type
|
||||
*/
|
||||
public static function getTicketExpirationDate($start,$ticketType){
|
||||
$result = new \DateTime();
|
||||
$result->setTimezone(new \DateTimeZone("UTC") );
|
||||
$result->setTimestamp($start->getTimestamp());
|
||||
|
||||
|
||||
$unitCount = $ticketType->time_unit_count;
|
||||
$unitType = $ticketType->time_unit_type;
|
||||
|
||||
switch ($unitType){
|
||||
case TicketType::TIME_UNIT_DAY:
|
||||
$result->add(new \DateInterval("P".$unitCount."D"));
|
||||
$result->sub(new \DateInterval("P1D"));
|
||||
break;
|
||||
case TicketType::TIME_UNIT_MONTH:
|
||||
$result->add(new \DateInterval("P".$unitCount."M"));
|
||||
$result->sub(new \DateInterval("P1D"));
|
||||
break;
|
||||
case TicketType::TIME_UNIT_MONTH_REFERENCE:
|
||||
if ( $unitCount > 1 ){
|
||||
$result->add(new \DateInterval("P". ($unitCount -1 )."M"));
|
||||
}
|
||||
$result->sub(new \DateInterval("P1D"));
|
||||
break;
|
||||
}
|
||||
|
||||
$result->setTime(0, 0, 0);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user