Finish version/v.0.0.49
This commit is contained in:
commit
a3bec37b7f
@ -59,6 +59,7 @@ class ContractSearch extends Contract
|
|||||||
'contract.part_count as contract_part_count',
|
'contract.part_count as contract_part_count',
|
||||||
'contract.created_at as contract_created_at',
|
'contract.created_at as contract_created_at',
|
||||||
'contract.expired_at as contract_expired_at',
|
'contract.expired_at as contract_expired_at',
|
||||||
|
'contract.started_at as contract_started_at',
|
||||||
|
|
||||||
]);
|
]);
|
||||||
$query->from('contract');
|
$query->from('contract');
|
||||||
@ -117,6 +118,10 @@ class ContractSearch extends Contract
|
|||||||
'asc' => ['contract.expired_at' => SORT_ASC ],
|
'asc' => ['contract.expired_at' => SORT_ASC ],
|
||||||
'desc' => ['contract.expired_at' => SORT_DESC],
|
'desc' => ['contract.expired_at' => SORT_DESC],
|
||||||
],
|
],
|
||||||
|
'contract_started_at' => [
|
||||||
|
'asc' => ['contract.started_at' => SORT_ASC ],
|
||||||
|
'desc' => ['contract.started_at' => SORT_DESC],
|
||||||
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -75,6 +75,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'label' =>'Létrehozva',
|
'label' =>'Létrehozva',
|
||||||
'format' => 'date'
|
'format' => 'date'
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'contract_started_at' ,
|
||||||
|
'label' =>'Érvényes tól',
|
||||||
|
'format' => 'date'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'contract_expired_at' ,
|
'attribute' => 'contract_expired_at' ,
|
||||||
'label' =>'Lejárat',
|
'label' =>'Lejárat',
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
-0.0.49
|
||||||
|
- contract - add started_at
|
||||||
|
- receptions/account-state/mixed
|
||||||
-0.0.48
|
-0.0.48
|
||||||
- add payment method display to backend/transfer/index
|
- add payment method display to backend/transfer/index
|
||||||
- add footer money display to backend/transfer/index
|
- add footer money display to backend/transfer/index
|
||||||
|
|||||||
@ -135,6 +135,17 @@ class DailyListing
|
|||||||
return $days_between > $days_visiblity;
|
return $days_between > $days_visiblity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cutler győr-ben a nap záráshoz ezt nyomtatjuk ki
|
||||||
|
* Ez a metódus csak akkor használható, ha csak ez a statisztika kell
|
||||||
|
* */
|
||||||
|
public function readMixed(){
|
||||||
|
$this->readProductsByCategory();
|
||||||
|
$this->readTicketStas();
|
||||||
|
$this->readMoneyMovements();
|
||||||
|
}
|
||||||
|
|
||||||
public function readTotalEasy(){
|
public function readTotalEasy(){
|
||||||
$this->readTicketMoney();
|
$this->readTicketMoney();
|
||||||
$this->readProductsMoney();
|
$this->readProductsMoney();
|
||||||
|
|||||||
@ -254,6 +254,13 @@ class Helper {
|
|||||||
public static function fixAsciiChars($in) {
|
public static function fixAsciiChars($in) {
|
||||||
$out = str_replace ( "ö", "0", $in );
|
$out = str_replace ( "ö", "0", $in );
|
||||||
$out = str_replace ( "Ö", "0", $out );
|
$out = str_replace ( "Ö", "0", $out );
|
||||||
|
/*
|
||||||
|
$out = str_replace ( "Y", "%", $out );
|
||||||
|
$out = str_replace ( "y", "%", $out );
|
||||||
|
$out = str_replace ( "Z", "y", $out );
|
||||||
|
$out = str_replace ( "z", "y", $out );
|
||||||
|
$out = str_replace ( "%", "y", $out );
|
||||||
|
*/
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
public static function isUserCartVisibilityUser() {
|
public static function isUserCartVisibilityUser() {
|
||||||
@ -361,7 +368,7 @@ class Helper {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateRandomString($length = 6,$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ) {
|
public static function generateRandomString($length = 6,$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWX' ) {
|
||||||
$charactersLength = strlen($characters);
|
$charactersLength = strlen($characters);
|
||||||
$randomString = '';
|
$randomString = '';
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
|||||||
@ -40,7 +40,8 @@ class AccountStateWidget extends Widget{
|
|||||||
'user.username',
|
'user.username',
|
||||||
[
|
[
|
||||||
'attribute' => 'created_at',
|
'attribute' => 'created_at',
|
||||||
'label' => 'Nyitás ideje'
|
'label' => 'Nyitás ideje',
|
||||||
|
'format' => 'datetime'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}else{
|
}else{
|
||||||
@ -61,11 +62,13 @@ class AccountStateWidget extends Widget{
|
|||||||
'user.username',
|
'user.username',
|
||||||
[
|
[
|
||||||
'attribute' => 'start_date',
|
'attribute' => 'start_date',
|
||||||
'label' => 'Előző nyitás ideje'
|
'label' => 'Előző nyitás ideje' ,
|
||||||
|
'format' => 'datetime'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'created_at',
|
'attribute' => 'created_at',
|
||||||
'label' => 'Zárás ideje'
|
'label' => 'Zárás ideje',
|
||||||
|
'format' => 'datetime'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -74,6 +77,7 @@ class AccountStateWidget extends Widget{
|
|||||||
|
|
||||||
|
|
||||||
echo DetailView::widget([
|
echo DetailView::widget([
|
||||||
|
'options' => ['class' => 'table table-striped table-bordered detail-view table-account-view'] ,
|
||||||
'model' => $this->model,
|
'model' => $this->model,
|
||||||
'attributes' =>$attributes,
|
'attributes' =>$attributes,
|
||||||
]) ;
|
]) ;
|
||||||
|
|||||||
@ -27,6 +27,7 @@ class TotalDifferenceWidget extends Widget{
|
|||||||
|
|
||||||
$ft = " Ft";
|
$ft = " Ft";
|
||||||
$s .= DetailView::widget([
|
$s .= DetailView::widget([
|
||||||
|
'options' => ['class' => 'table table-striped table-bordered detail-view table-account-diff'],
|
||||||
'model' => $this->model,
|
'model' => $this->model,
|
||||||
'template' =>"<tr><th>{label}</th><td style='text-align: right;'>{value} </td></tr>",
|
'template' =>"<tr><th>{label}</th><td style='text-align: right;'>{value} </td></tr>",
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace common\components\total;
|
||||||
|
|
||||||
|
class TotalProductsByCategoryWidget extends TotalBaseWidget{
|
||||||
|
|
||||||
|
public $viewFile = 'total_product_by_category.php';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.48',
|
'version' => 'v0.0.49',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
|
|||||||
@ -22,6 +22,7 @@ use common\components\Helper;
|
|||||||
* @property string $expired_at
|
* @property string $expired_at
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
|
* @property string $started_at
|
||||||
*/
|
*/
|
||||||
class Contract extends \yii\db\ActiveRecord
|
class Contract extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@ -82,6 +83,7 @@ class Contract extends \yii\db\ActiveRecord
|
|||||||
'expired_at' => Yii::t('common/contract', 'Lejárati dátum'),
|
'expired_at' => Yii::t('common/contract', 'Lejárati dátum'),
|
||||||
'created_at' => Yii::t('common/contract', 'Létrehozva'),
|
'created_at' => Yii::t('common/contract', 'Létrehozva'),
|
||||||
'updated_at' => Yii::t('common/contract', 'Módosítva'),
|
'updated_at' => Yii::t('common/contract', 'Módosítva'),
|
||||||
|
'started_at' => Yii::t('common/contract', 'Érvényesség kezdete'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -123,7 +123,12 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getTicketExpirationDate(){
|
public function getTicketExpirationDate(){
|
||||||
return strtotime( $this->request_target_time_at . " +1 month -1 day") ;
|
$date = \DateTime::createFromFormat("Y-m-d H:i:s", $this->request_target_time_at, new \DateTimeZone( 'UTC'));
|
||||||
|
$date->modify("+1 month");
|
||||||
|
$date->modify("-1 day");
|
||||||
|
$date->setTime(0, 0, 0);
|
||||||
|
|
||||||
|
return $date->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,9 +251,11 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
if ( isset( $discount ) ){
|
if ( isset( $discount ) ){
|
||||||
$money = Discount::applyDiscount( $money, $discount );
|
$money = Discount::applyDiscount( $money, $discount );
|
||||||
}
|
}
|
||||||
$ticketCreatedAt = time();
|
|
||||||
|
|
||||||
|
|
||||||
for ( $i = 1; $i <= $count; $i++){
|
for ( $i = 1; $i <= $count; $i++){
|
||||||
$request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $contract, $money, $ticketCreatedAt, $i);
|
$request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $contract, $money, null, $i);
|
||||||
$result[] = $request;
|
$result[] = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +269,11 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
$request->id_customer = $customer->id_customer;
|
$request->id_customer = $customer->id_customer;
|
||||||
$request->status = TicketInstallmentRequest::$STATUS_PENDING;
|
$request->status = TicketInstallmentRequest::$STATUS_PENDING;
|
||||||
$request->priority = $index;
|
$request->priority = $index;
|
||||||
$request->request_target_time_at = date('Y-m-d H:i:s', strtotime("+".$index." month" ));
|
$date = \DateTime::createFromFormat("Y.m.d", $contract->started_at, new \DateTimeZone( 'UTC'));
|
||||||
|
$date->modify("+$index month");
|
||||||
|
// $date->modify("-1 day");
|
||||||
|
$date->setTime(0, 0, 0);
|
||||||
|
$request->request_target_time_at = $date->format ( 'Y-m-d H:i:s' );
|
||||||
$request->request_processed_at = null;
|
$request->request_processed_at = null;
|
||||||
$request->request_sent_at = null;
|
$request->request_sent_at = null;
|
||||||
$request->money = $money;
|
$request->money = $money;
|
||||||
|
|||||||
@ -672,8 +672,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
self::notInInterval ( $query, 'transfer.created_at', $start, $end );
|
self::notInInterval ( $query, 'transfer.created_at', $start, $end );
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "start date is: ". $start;
|
// echo "start date is: ". $start;
|
||||||
echo "start date is: " . gettype( $start );
|
// echo "start date is: " . gettype( $start );
|
||||||
|
|
||||||
if ( !RoleDefinition::isAdmin() ){
|
if ( !RoleDefinition::isAdmin() ){
|
||||||
Helper::restrictIfNotAdminTheStartDate($query, $start);
|
Helper::restrictIfNotAdminTheStartDate($query, $start);
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<h3>Pénzmozgások</h3>
|
<table class="table table-bordered table-striped table-summary table-money-movements-detailed">
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Dátum</th>
|
<th>Dátum</th>
|
||||||
@ -7,20 +6,20 @@
|
|||||||
<th>Felhasználó</th>
|
<th>Felhasználó</th>
|
||||||
<th>Név</th>
|
<th>Név</th>
|
||||||
<th>Típus</th>
|
<th>Típus</th>
|
||||||
<th>Összeg</th>
|
|
||||||
<th>Megjegyzés</th>
|
<th>Megjegyzés</th>
|
||||||
|
<th>Összeg</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($model->moneyMovements as $p ){?>
|
<?php foreach ($model->moneyMovements as $p ){?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $p['money_movement_created_at']?> </td>
|
<td class="created-at"><?php echo $p['money_movement_created_at']?> </td>
|
||||||
<td><?php echo $p['account_name']?> </td>
|
<td class="account"><?php echo $p['account_name']?> </td>
|
||||||
<td><?php echo $p['user_name']?> </td>
|
<td class="username"><?php echo $p['user_name']?> </td>
|
||||||
<td><?php echo $p['money_movement_name'] ?></td>
|
<td class="name"><?php echo $p['money_movement_name'] ?></td>
|
||||||
<td><?php echo $p['money_movement_type_name'] ?></td>
|
<td class="type"><?php echo $p['money_movement_type_name'] ?></td>
|
||||||
|
<td class="comment"><?php echo $p['money_movement_comment'] ?></td>
|
||||||
<td class='money'><?php echo \Yii::$app->formatter->asInteger( $p['signed_money'])?> Ft</td>
|
<td class='money'><?php echo \Yii::$app->formatter->asInteger( $p['signed_money'])?> Ft</td>
|
||||||
<td><?php echo $p['money_movement_comment'] ?></td>
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<table class="table table-bordered table-striped table-summary">
|
<table class="table table-bordered table-striped table-summary total-medium-ticket">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Bérlet típus</th>
|
<th>Bérlet típus</th>
|
||||||
|
|||||||
37
common/views/total/total_product_by_category.php
Normal file
37
common/views/total/total_product_by_category.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
$categories = $model->productMoneies;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<table
|
||||||
|
class="table table-bordered table-striped table-summary total-product-by-category">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Kategória</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ( $categories as $p){?>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class='name'><?php echo $p['category_name'] ?></td>
|
||||||
|
<td class='count'><?php echo $p['category_count'] ?> Db</td>
|
||||||
|
<td class='money'><?php echo \Yii::$app->formatter->asInteger( $p['product_money'])?> FT</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php }?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen:
|
||||||
|
<?php
|
||||||
|
echo \Yii::$app->formatter->asInteger( $model->productsByCategory ['total']);
|
||||||
|
?> Ft
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160302_171507_alter__table__contract__add__column__started_at extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("contract", "started_at", "datetime");
|
||||||
|
$this->execute("update contract set started_at = created_at");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160302_171507_alter__table__contract__add__column__started_at cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
29
frontend/assets/ContractMakeAsset.php
Normal file
29
frontend/assets/ContractMakeAsset.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace frontend\assets;
|
||||||
|
|
||||||
|
use yii\web\AssetBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
class ContractMakeAsset extends AssetBundle
|
||||||
|
{
|
||||||
|
public $basePath = '@webroot';
|
||||||
|
public $baseUrl = '@web';
|
||||||
|
public $css = [
|
||||||
|
];
|
||||||
|
public $js = [
|
||||||
|
'js/contract.make.js',
|
||||||
|
];
|
||||||
|
public $depends = [
|
||||||
|
'frontend\assets\AppAsset',
|
||||||
|
'yii\jui\JuiAsset',
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -59,6 +59,14 @@ class AccountStateBanknoteCountWidget extends Widget{
|
|||||||
|
|
||||||
$s .= Html::a( Html::tag("span","",['class' =>'glyphicon glyphicon-download-alt']) ." Pdf", Url::to([ 'view', 'id' =>$this->model->id_account_state, 'output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf','style' =>'margin-bottom: 12px; margin-right: 6px;']);
|
$s .= Html::a( Html::tag("span","",['class' =>'glyphicon glyphicon-download-alt']) ." Pdf", Url::to([ 'view', 'id' =>$this->model->id_account_state, 'output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf','style' =>'margin-bottom: 12px; margin-right: 6px;']);
|
||||||
|
|
||||||
|
if ( $this->model->isTypeClose() ){
|
||||||
|
$s .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> Napi összefoglaló', Url::toRoute(['mixed','id' =>$this->model->id_account_state]), [
|
||||||
|
'title' => 'Napi összefoglaló',
|
||||||
|
'class' => 'btn btn-success',
|
||||||
|
'style' =>'margin-bottom: 12px; margin-right: 6px;'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$s .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> Részletek', Url::toRoute(['view','id' =>$this->model->id_account_state]), [
|
$s .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> Részletek', Url::toRoute(['view','id' =>$this->model->id_account_state]), [
|
||||||
'title' => 'Részletek',
|
'title' => 'Részletek',
|
||||||
'class' => 'btn btn-success',
|
'class' => 'btn btn-success',
|
||||||
|
|||||||
@ -27,7 +27,8 @@ class AccountStateController extends Controller {
|
|||||||
'index',
|
'index',
|
||||||
'open',
|
'open',
|
||||||
'close',
|
'close',
|
||||||
'view'
|
'view' ,
|
||||||
|
'mixed'
|
||||||
],
|
],
|
||||||
'rules' => [
|
'rules' => [
|
||||||
// allow authenticated users
|
// allow authenticated users
|
||||||
@ -301,4 +302,63 @@ class AccountStateController extends Controller {
|
|||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function actionMixed($id){
|
||||||
|
$accountState = $this->findModel ( $id );
|
||||||
|
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
|
||||||
|
$details = null;
|
||||||
|
|
||||||
|
if ($accountState->isTypeClose ()) {
|
||||||
|
|
||||||
|
$prev;
|
||||||
|
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||||
|
if (isset ( $accountState->prev_state )) {
|
||||||
|
$prev = AccountState::findOne ( $accountState->prev_state );
|
||||||
|
}
|
||||||
|
if (isset ( $prev )) {
|
||||||
|
$accountState->start_date = $prev->created_at;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$details = new DailyListing ();
|
||||||
|
$details->loadAccountState ( $accountState );
|
||||||
|
|
||||||
|
$details->readTotalEasy ();
|
||||||
|
$details->readTotalDetailed ();
|
||||||
|
$details->readTotalMedium ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($output == 'pdf') {
|
||||||
|
$user = User::findOne(\Yii::$app->user->id);
|
||||||
|
$mpdf=new \mPDF('utf-8', 'A4');
|
||||||
|
$mpdf->useSubstitutions=false;
|
||||||
|
$mpdf->simpleTables = true;
|
||||||
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
|
|
||||||
|
$stylesheet = file_get_contents( \Yii::getAlias('@frontend'.'/web/css/account_close.css')); // external css
|
||||||
|
$mpdf->WriteHTML($stylesheet,1);
|
||||||
|
|
||||||
|
|
||||||
|
$mpdf->WriteHTML($this->renderPartial("@frontend/views/account-state/mixed_pdf", [
|
||||||
|
'model' => $accountState,
|
||||||
|
'details' => $details
|
||||||
|
]));
|
||||||
|
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
|
||||||
|
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
||||||
|
$fn= $type .$dt.".pdf";
|
||||||
|
$mpdf->Output($fn, 'D');
|
||||||
|
exit();
|
||||||
|
|
||||||
|
}
|
||||||
|
return $this->render ( 'mixed', [
|
||||||
|
'model' => $accountState,
|
||||||
|
'details' => $details
|
||||||
|
] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -284,9 +284,14 @@ class ContractController extends Controller {
|
|||||||
throw new Exception ( "Az oldal nem található" );
|
throw new Exception ( "Az oldal nem található" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$model = new ContractForm ( [
|
$model = new ContractForm ( [
|
||||||
'customer' => $customer
|
'customer' => $customer
|
||||||
] );
|
] );
|
||||||
|
|
||||||
|
$model->started_at = date(date('Y.m.d'));
|
||||||
|
|
||||||
|
|
||||||
$model->fillOut ();
|
$model->fillOut ();
|
||||||
|
|
||||||
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||||
|
|||||||
@ -39,6 +39,8 @@ class ContractForm extends Model {
|
|||||||
private $ticketType;
|
private $ticketType;
|
||||||
private $money;
|
private $money;
|
||||||
private $discount;
|
private $discount;
|
||||||
|
public $started_at;
|
||||||
|
public $timestampStart;
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -59,7 +61,9 @@ class ContractForm extends Model {
|
|||||||
"bank_name",
|
"bank_name",
|
||||||
'phone',
|
'phone',
|
||||||
'email',
|
'email',
|
||||||
'payment_method'
|
'payment_method' ,
|
||||||
|
'started_at',
|
||||||
|
'started_at'
|
||||||
],
|
],
|
||||||
'required'
|
'required'
|
||||||
],
|
],
|
||||||
@ -124,7 +128,8 @@ class ContractForm extends Model {
|
|||||||
'ticket_type'
|
'ticket_type'
|
||||||
],
|
],
|
||||||
'validateTicketType'
|
'validateTicketType'
|
||||||
]
|
] ,
|
||||||
|
[[ 'started_at', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public function validateTicketType($attribute, $params) {
|
public function validateTicketType($attribute, $params) {
|
||||||
@ -162,6 +167,7 @@ class ContractForm extends Model {
|
|||||||
'ticket_type' => 'Bérlet típus' ,
|
'ticket_type' => 'Bérlet típus' ,
|
||||||
'payment_method' => 'Fizetési mód (első bérlet)' ,
|
'payment_method' => 'Fizetési mód (első bérlet)' ,
|
||||||
'id_discount' => 'Kedvezmény' ,
|
'id_discount' => 'Kedvezmény' ,
|
||||||
|
'started_at' => 'Érvényesség kezdete' ,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public function fillOut() {
|
public function fillOut() {
|
||||||
@ -223,8 +229,8 @@ class ContractForm extends Model {
|
|||||||
$ticket->id_user = \Yii::$app->user->id;
|
$ticket->id_user = \Yii::$app->user->id;
|
||||||
$ticket->id_account = Account::readDefault ();
|
$ticket->id_account = Account::readDefault ();
|
||||||
$ticket->id_discount = $this->id_discount;
|
$ticket->id_discount = $this->id_discount;
|
||||||
$ticket->start = date ( 'Y-m-d' );
|
$ticket->start = $this->started_at;
|
||||||
$date = new \DateTime ();
|
$date = new \DateTime ( $this->timestampStart);
|
||||||
$date->modify ( '+1 month' );
|
$date->modify ( '+1 month' );
|
||||||
$date->modify ( '-1 day' );
|
$date->modify ( '-1 day' );
|
||||||
$ticket->end = $date->format ( 'Y-m-d H:i:s' );
|
$ticket->end = $date->format ( 'Y-m-d H:i:s' );
|
||||||
@ -283,7 +289,12 @@ class ContractForm extends Model {
|
|||||||
$contract->part_count = $this->ticketType->installment_count;
|
$contract->part_count = $this->ticketType->installment_count;
|
||||||
$contract->part_paid = 0;
|
$contract->part_paid = 0;
|
||||||
$contract->part_required = 0;
|
$contract->part_required = 0;
|
||||||
$contract->expired_at = date ( 'Y-m-d', strtotime ( "today +12 month -1 day" ) );
|
$contract->started_at = $this->started_at;
|
||||||
|
$date = new \DateTime( $this->timestampStart );
|
||||||
|
$date->modify ( '+1 year' );
|
||||||
|
$date->modify ( '-1 day' );
|
||||||
|
$date->setTime(0, 0, 0);
|
||||||
|
$contract->expired_at = $date->format ( 'Y-m-d H:i:s' );
|
||||||
$contract->id_ticket_type = $this->ticketType->id_ticket_type;
|
$contract->id_ticket_type = $this->ticketType->id_ticket_type;
|
||||||
|
|
||||||
if (! $contract->save ( false )) {
|
if (! $contract->save ( false )) {
|
||||||
|
|||||||
21
frontend/views/account-state/_mixed.php
Normal file
21
frontend/views/account-state/_mixed.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php use common\components\total\TotalMediumTicketsWidget;
|
||||||
|
use common\components\total\TotalProductsByCategoryWidget;
|
||||||
|
use common\components\total\TotalDetailedMoneyMovementWidget;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p>Bérletek típus szerint</p>
|
||||||
|
<?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<p>Termékek kategória szerint</p>
|
||||||
|
<?php echo TotalProductsByCategoryWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<p>Pénzmozgások</p>
|
||||||
|
<?php echo TotalDetailedMoneyMovementWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
|
||||||
|
<p>Összesen </p>
|
||||||
|
<table class="table table-bordered table-striped table-summary table-total">
|
||||||
|
<tr>
|
||||||
|
<th>Végösszeg bruttó</th>
|
||||||
|
<td class="money"><span style='border-bottom: 1px solid black'><?php echo \Yii::$app->formatter->asInteger( $model->money)?> FT</span></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
61
frontend/views/account-state/mixed.php
Normal file
61
frontend/views/account-state/mixed.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
use common\components\accountstate\AccountStateWidget;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use common\components\total\TotalDifferenceWidget;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.btn-pdf{
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
p{
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="account-state-view">
|
||||||
|
|
||||||
|
<h1>Napi összefoglaló</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ( $model->hasDifferenceToPrevState() ){
|
||||||
|
if ( $model->hasMinus()){
|
||||||
|
?>
|
||||||
|
<div class="alert alert-danger" role="alert">Negatív különbözet</div>
|
||||||
|
<?php
|
||||||
|
}else{
|
||||||
|
?>
|
||||||
|
<div class="alert alert-success" role="alert">Pozitív különbözet</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php echo AccountStateWidget::widget(['model' =>$model]) ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo Html::a( Html::tag("span","",['class' =>'glyphicon glyphicon-download-alt'])." Pdf", Url::current(['output' =>'pdf']) ,['class' => 'btn btn-primary btn-pdf']);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if ( $model->hasDifferenceToPrevState() ){
|
||||||
|
?>
|
||||||
|
<h2>Különbözet</h2>
|
||||||
|
<?php
|
||||||
|
echo TotalDifferenceWidget::widget(['model' => $model] );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php echo $this->render('_mixed', [
|
||||||
|
'model' => $model,
|
||||||
|
'details' => $details
|
||||||
|
] ); ?>
|
||||||
|
|
||||||
45
frontend/views/account-state/mixed_pdf.php
Normal file
45
frontend/views/account-state/mixed_pdf.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
use common\components\accountstate\AccountStateWidget;
|
||||||
|
use common\components\total\TotalDifferenceWidget;
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="account-state-view ">
|
||||||
|
|
||||||
|
<table class="table-top">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="top-cell first">
|
||||||
|
<p class="p">Zárás összefoglaló</p>
|
||||||
|
<?php echo AccountStateWidget::widget(['model' =>$model]) ?>
|
||||||
|
</td>
|
||||||
|
<td class="top-cell last">
|
||||||
|
<?php if ( $model->hasDifferenceToPrevState() ){
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
if ( $model->hasMinus()){
|
||||||
|
?>
|
||||||
|
<p class="p">Negatív különbözet</p>
|
||||||
|
<?php
|
||||||
|
}else{
|
||||||
|
?>
|
||||||
|
<p class="p">Pozitív különbözet</p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
echo TotalDifferenceWidget::widget(['model' => $model] );
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php echo $this->render('_mixed', [
|
||||||
|
'model' => $model,
|
||||||
|
'details' => $details
|
||||||
|
] ); ?>
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ use yii\base\Widget;
|
|||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
use common\components\accountstate\AccountStateWidget;
|
use common\components\accountstate\AccountStateWidget;
|
||||||
|
use common\components\total\TotalProductsByCategoryWidget;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\AccountState */
|
/* @var $model common\models\AccountState */
|
||||||
@ -81,6 +82,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
role="tab" data-toggle="tab">Részletes összesítő</a></li>
|
role="tab" data-toggle="tab">Részletes összesítő</a></li>
|
||||||
<li role="presentation" class=""><a href="#banknotes"
|
<li role="presentation" class=""><a href="#banknotes"
|
||||||
aria-controls="banknotes" role="tab" data-toggle="tab">Címletek</a></li>
|
aria-controls="banknotes" role="tab" data-toggle="tab">Címletek</a></li>
|
||||||
|
<li role="presentation" class=""><a href="#printing"
|
||||||
|
aria-controls="printing" role="tab" data-toggle="tab">Nyomtatni</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
@ -107,6 +110,12 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<h2>Címletek</h2>
|
<h2>Címletek</h2>
|
||||||
<?php echo BankNotesWidget::widget(['model' => $model]);?>
|
<?php echo BankNotesWidget::widget(['model' => $model]);?>
|
||||||
</div>
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane " id="printing">
|
||||||
|
<h2>Részletek</h2>
|
||||||
|
<?php echo TotalMediumTicketsWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<?php echo TotalProductsByCategoryWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
<?php echo TotalDetailedMoneyMovementWidget::widget(['dailyListing' => $details]);?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -14,6 +14,11 @@ use common\components\Azaz;
|
|||||||
$customerBankAccount = $customer->bank_account;
|
$customerBankAccount = $customer->bank_account;
|
||||||
$customerIdCustomer = $customer->id_customer;
|
$customerIdCustomer = $customer->id_customer;
|
||||||
|
|
||||||
|
// $dt = \DateTime::createFromFormat("Y-m-d H:i:s", $model->started_at);
|
||||||
|
// $contractStartAtDate = $dt->format("Y.m.d");
|
||||||
|
$contractStartAtDate = \Yii::$app->formatter->asDate($model->started_at);
|
||||||
|
|
||||||
|
|
||||||
$contractDate = date('Y.m.d');
|
$contractDate = date('Y.m.d');
|
||||||
|
|
||||||
$azaz = new Azaz();
|
$azaz = new Azaz();
|
||||||
@ -27,7 +32,6 @@ use common\components\Azaz;
|
|||||||
$img = "<img height='20px' src='" . \Yii::getAlias("@webroot") . DIRECTORY_SEPARATOR. "images" . DIRECTORY_SEPARATOR . "alairas.jpg'>";
|
$img = "<img height='20px' src='" . \Yii::getAlias("@webroot") . DIRECTORY_SEPARATOR. "images" . DIRECTORY_SEPARATOR . "alairas.jpg'>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h1 style='text-align: center'>
|
<h1 style='text-align: center'>
|
||||||
@ -241,7 +245,7 @@ másrészről:
|
|||||||
Teljesítés adatai:
|
Teljesítés adatai:
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Érvényesség kezdete: <?php echo $contractDate?> lejárata:
|
Érvényesség kezdete: <?php echo $contractStartAtDate?> lejárata:
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Teljesítés felső értékhatára:
|
Teljesítés felső értékhatára:
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use frontend\components\HtmlHelper;
|
|||||||
use kartik\widgets\DatePicker;
|
use kartik\widgets\DatePicker;
|
||||||
use common\models\Transfer;
|
use common\models\Transfer;
|
||||||
use common\models\Discount;
|
use common\models\Discount;
|
||||||
|
use frontend\assets\ContractMakeAsset;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\Contract */
|
/* @var $model common\models\Contract */
|
||||||
@ -17,12 +18,26 @@ use common\models\Discount;
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
ContractMakeAsset::register($this);
|
||||||
|
|
||||||
$types = TicketType::findAll(['status' => TicketType::STATUS_ACTIVE ,'installment_enabled' => '1']);
|
$types = TicketType::findAll(['status' => TicketType::STATUS_ACTIVE ,'installment_enabled' => '1']);
|
||||||
|
|
||||||
|
$typeOptions = TicketType::modelsToArray($types);
|
||||||
|
|
||||||
|
|
||||||
$types = HtmlHelper::mkTicketTypeOptions($types);
|
$types = HtmlHelper::mkTicketTypeOptions($types);
|
||||||
|
|
||||||
$discounts = Discount::readTicketDiscounts();
|
$discounts = Discount::readTicketDiscounts();
|
||||||
|
$discountOptions = Discount::modelsToArray($discounts,[]);
|
||||||
|
|
||||||
$discounts = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts);
|
$discounts = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts);
|
||||||
|
|
||||||
|
$options = [];
|
||||||
|
$options['ticket_types'] = $typeOptions;
|
||||||
|
$options['discounts'] = $discountOptions;
|
||||||
|
|
||||||
|
$this->registerJs(' contract_make.init( '. json_encode($options) .' );');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<h1>Szerződés létrehozása</h1>
|
<h1>Szerződés létrehozása</h1>
|
||||||
<div class="contract-form">
|
<div class="contract-form">
|
||||||
@ -92,7 +107,12 @@ use common\models\Discount;
|
|||||||
<?= $form->field($model, 'ticket_type')->dropDownList($types) ?>
|
<?= $form->field($model, 'ticket_type')->dropDownList($types) ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
<?= $form->field($model, 'started_at')->widget(\kartik\date\DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -106,8 +126,19 @@ use common\models\Discount;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Figyelem: A szerződés létrehozásakor a szerződés első bérlete bekerül a vásálró kosarába.
|
||||||
|
</p>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tr>
|
||||||
|
<td>Bérlet ára</td>
|
||||||
|
<td class="ticket-price"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Összesen</td>
|
||||||
|
<td class="ticket-total"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@ -41,6 +41,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'part_paid',
|
'part_paid',
|
||||||
'part_required',
|
'part_required',
|
||||||
'part_count',
|
'part_count',
|
||||||
|
'started_at:datetime',
|
||||||
'expired_at:datetime',
|
'expired_at:datetime',
|
||||||
'created_at:datetime',
|
'created_at:datetime',
|
||||||
'updated_at:datetime',
|
'updated_at:datetime',
|
||||||
|
|||||||
69
frontend/web/css/account_close.css
Normal file
69
frontend/web/css/account_close.css
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
h1{
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table td,
|
||||||
|
.table th{
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-pdf{
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
p{
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.total-medium-ticket td.name,
|
||||||
|
.total-product-by-category td.name
|
||||||
|
{
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
.total-medium-ticket td.count,
|
||||||
|
.total-product-by-category td.count
|
||||||
|
{
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-total td.money{
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
.table-account-view td{
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
.table-account-diff td{
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-money-movements-detailed td.created-at{ width: 120px;}
|
||||||
|
.table-money-movements-detailed td.account{ width: 80px;}
|
||||||
|
.table-money-movements-detailed td.username{ width: 80px;}
|
||||||
|
.table-money-movements-detailed td.name{ width: 80px;}
|
||||||
|
.table-money-movements-detailed td.type{ width: 80px;}
|
||||||
|
.table-money-movements-detailed td.money{ width: 70px;}
|
||||||
|
|
||||||
|
|
||||||
|
table.table-top {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.table-top td.top-cell {
|
||||||
|
width: 48%;
|
||||||
|
vertical-align: top;
|
||||||
|
|
||||||
|
}
|
||||||
|
table.table-top td.top-cell .table {
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.table-top td.first {
|
||||||
|
padding-right: 3px;
|
||||||
|
}
|
||||||
|
table.table-top td.last {
|
||||||
|
padding-left: 3px;
|
||||||
|
}
|
||||||
70
frontend/web/js/contract.make.js
Normal file
70
frontend/web/js/contract.make.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var contract_make ={
|
||||||
|
|
||||||
|
defaults :{
|
||||||
|
ticket_types : [],
|
||||||
|
discounts: [],
|
||||||
|
dd_types: '#contractform-ticket_type',
|
||||||
|
dd_discounts: '#contractform-id_discount',
|
||||||
|
},
|
||||||
|
init: function(o){
|
||||||
|
contract_make.defaults = $.extend(contract_make.defaults, o);
|
||||||
|
contract_make.update();
|
||||||
|
contract_make.getDDTypes().change(contract_make.update);
|
||||||
|
contract_make.getDDDiscounts().change(contract_make.update);
|
||||||
|
},
|
||||||
|
getDDTypes: function(){
|
||||||
|
return $(contract_make.defaults.dd_types);
|
||||||
|
},
|
||||||
|
|
||||||
|
getDDDiscounts: function(){
|
||||||
|
return $(contract_make.defaults.dd_discounts);
|
||||||
|
},
|
||||||
|
findType: function(id){
|
||||||
|
var type ;
|
||||||
|
var i;
|
||||||
|
type = null;
|
||||||
|
for ( i = 0; i<contract_make.defaults.ticket_types.length; i++ ){
|
||||||
|
if ( contract_make.defaults.ticket_types[i]['id_ticket_type'] == id ){
|
||||||
|
type = contract_make.defaults.ticket_types[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
},
|
||||||
|
findDiscount: function(id){
|
||||||
|
var type ;
|
||||||
|
var i;
|
||||||
|
type = null;
|
||||||
|
if ( id && !isNaN(id) ){
|
||||||
|
for ( i = 0; i < contract_make.defaults.discounts.length; i++ ){
|
||||||
|
if ( contract_make.defaults.discounts[i]['id_discount'] == id ){
|
||||||
|
type = contract_make.defaults.discounts[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
},
|
||||||
|
update: function(){
|
||||||
|
var type = contract_make.findType( +contract_make.getDDTypes().val());
|
||||||
|
var discount = contract_make.findDiscount( +contract_make.getDDDiscounts().val() );
|
||||||
|
var total = contract_make.calcPriceBrutto(type,discount);
|
||||||
|
$('.ticket-price').html(type.price_brutto);
|
||||||
|
$('.ticket-total').html(total);
|
||||||
|
},
|
||||||
|
calcPriceBrutto: function(type,discount){
|
||||||
|
var result;
|
||||||
|
result = type.price_brutto;
|
||||||
|
if ( discount!= null ){
|
||||||
|
var d = result* discount.value /100;
|
||||||
|
d = Math.floor( d );
|
||||||
|
result = result - d;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user