add ticket original end and original price

add helper links to related object in admin
This commit is contained in:
2017-09-06 12:14:12 +02:00
parent bacfc36487
commit 90d19d17b6
19 changed files with 481 additions and 81 deletions

View File

@@ -101,4 +101,11 @@ class DateUtil
return $formatter->asDatetime($dateTimeObject);
}
public static function parseDate($dateString){
$date = \DateTime::createFromFormat("Y.m.d", $dateString, new \DateTimeZone( 'UTC'));
$date->setTime(0, 0, 0);
return $date;
}
}

View File

@@ -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;
}
}