add feature payout_later
This commit is contained in:
parent
b84ebf0177
commit
51b28134c1
@ -69,7 +69,6 @@ class AccountStateController extends \backend\controllers\BackendController
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id) {
|
||||
echo "view";
|
||||
$accountState = $this->findModel ( $id );
|
||||
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
|
||||
$details = null;
|
||||
|
||||
@ -16,6 +16,7 @@ use common\models\ProductCategory;
|
||||
use common\models\Product;
|
||||
use backend\models\TransferListUserGroupedSearch;
|
||||
use backend\models\TransferLaterSearch;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* TransferController implements the CRUD actions for Transfer model.
|
||||
@ -50,6 +51,15 @@ class TransferController extends \backend\controllers\BackendController
|
||||
|
||||
public function actionPaymentLater(){
|
||||
$searchModel = new TransferLaterSearch();
|
||||
|
||||
|
||||
if ( \Yii::$app->request->isPost){
|
||||
$searchModel->load(Yii::$app->request->post());
|
||||
if ( $searchModel->doPayout()) {
|
||||
return $this->redirect(['transfer/payment-later' ]);
|
||||
}
|
||||
}
|
||||
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
$accounts = Account::read();
|
||||
@ -57,6 +67,8 @@ class TransferController extends \backend\controllers\BackendController
|
||||
|
||||
$users = User::read();
|
||||
|
||||
Url::remember("payment_later",Url::current());
|
||||
|
||||
return $this->render('payment_later', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
|
||||
@ -25,16 +25,21 @@ class TransferLaterSearch extends Transfer
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
public $id_ticket_type;
|
||||
|
||||
|
||||
public $ticket_type;
|
||||
public $selected = [];
|
||||
|
||||
public $total_money;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[[ 'id_account','id_user', 'type','status','payment_method'], 'integer'],
|
||||
[[ 'id_ticket_type','id_user'], 'integer'],
|
||||
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
['selected', 'each', 'rule' => ['integer']],
|
||||
@ -118,23 +123,21 @@ class TransferLaterSearch extends Transfer
|
||||
}
|
||||
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.type' => $this->type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
'transfer.status' => $this->status,
|
||||
'transfer.payment_method' => $this->payment_method,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere([
|
||||
'ticket_type.id_ticket_type' => $this->id_ticket_type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
]);
|
||||
|
||||
$created_condition = ['and',[ '>=', 'transfer.created_at', $this->timestampStart ] ,[ '<', 'transfer.created_at', $this->timestampEnd ] ];
|
||||
$paid_condition = ['and',[ '>=', 'transfer.paid_at', $this->timestampStart ] ,[ '<', 'transfer.paid_at', $this->timestampEnd ] ];
|
||||
|
||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||
|
||||
if (!RoleDefinition::isAdmin()){
|
||||
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['transfer.created_at','transfer.paid_at']);
|
||||
}
|
||||
$qtotal = Query::create($query);
|
||||
$qtotal->select([ new Expression("coalesce(sum(transfer.money),0) as transfer_money" )]);
|
||||
$this->total_money = $qtotal->scalar();
|
||||
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
@ -148,6 +151,45 @@ class TransferLaterSearch extends Transfer
|
||||
}
|
||||
|
||||
|
||||
public function doPayout(){
|
||||
|
||||
if ( !isset($this->selected) || count($this->selected) == 0){
|
||||
Helper::flash("error", "Nincs kiválasztott tranzakció");
|
||||
return false;
|
||||
}
|
||||
|
||||
$transfers = Transfer::find()
|
||||
->andWhere(['status' => Transfer::STATUS_NOT_PAID ])
|
||||
->andWhere(['payment_method' => Transfer::PAYMENT_METHOD_TRANSFER_LATER])
|
||||
->andWhere(['in','transfer.id_transfer',$this->selected])
|
||||
->all();
|
||||
|
||||
if ( count($transfers) != count($this->selected)){
|
||||
Helper::flash("warning", "A kiválasztott tranzakciókban időközben változás történt");
|
||||
return false;
|
||||
}
|
||||
|
||||
$db = \Yii::$app->db;
|
||||
$tx = $db->beginTransaction();
|
||||
try{
|
||||
foreach ($transfers as $transfer){
|
||||
if ( !$transfer->payout($transfer->id_account) ){
|
||||
\Yii::error("Failed to payout transaction: " .$transfer->id_transfer);
|
||||
throw new \Exception("Nem sikerült mententi a tranzakciókat");
|
||||
}
|
||||
}
|
||||
$tx->commit();
|
||||
Helper::flash("success", "Tranzakciók fizetettnek jelölve: " .count($transfers) . " db");
|
||||
}catch (\Exception $e){
|
||||
$tx->rollBack();
|
||||
Helper::flash("error", "Hiba történt a művelet közben");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -143,7 +143,6 @@ class TransferSearch extends Transfer
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
echo "start date:" .$this->timestampStart;
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
|
||||
@ -7,6 +7,7 @@ use yii\base\Widget;
|
||||
<?php
|
||||
echo AccountStateBanknoteCountWidget::widget([
|
||||
'model' => $model,
|
||||
'showDailyDownload' =>false
|
||||
]);
|
||||
?>
|
||||
|
||||
|
||||
65
backend/views/transfer/_search_payment_later.php
Normal file
65
backend/views/transfer/_search_payment_later.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use kartik\widgets\DatePicker;
|
||||
use frontend\components\HtmlHelper;
|
||||
use common\models\Transfer;
|
||||
use kartik\widgets\DateTimePicker;
|
||||
use common\models\TicketType;
|
||||
use common\models\User;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\TransferSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<?php
|
||||
$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions(User::find()->all(),'id','username');
|
||||
$ticketTypeOptions = ['' => 'Mind'] + HtmlHelper::mkTicketTypeOptions(TicketType::find()->all());
|
||||
?>
|
||||
|
||||
<div class="transfer-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
// 'action' => ['list'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd hh:ii'
|
||||
]
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd hh:ii'
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions)->label("Bérlet típus") ?>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'id_user')->dropDownList($userOptions) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
@ -18,7 +18,7 @@ use yii\helpers\Url;
|
||||
/* @var $searchModel backend\models\TransferSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('frontend/transfer', 'Transfers');
|
||||
$this->title = "Tranzakciók későbbi utalás fizetés típussal";
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
?>
|
||||
@ -34,14 +34,29 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
<div class="transfer-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel, 'accounts' => $accounts,'users' => $users,]); ?>
|
||||
<?php echo $this->render('_search_payment_later', ['model' => $searchModel, ]); ?>
|
||||
|
||||
|
||||
<div style="margin-bottom: 6px;">
|
||||
<?php
|
||||
echo Html::a("Összes kiválasztása",null, ['class' => 'btn btn-primary select-all' ,'style' => 'margin-right: 6px;',
|
||||
'onclick' => "$('.table-transfer').find(\"input[type='checkbox']\").prop('checked',true);"
|
||||
]);
|
||||
echo Html::a("Egyiket sem",null, ['class' => 'btn btn-primary deselect-all',
|
||||
'onclick' => "$('.table-transfer').find(\"input[type='checkbox']\").prop('checked',false);"
|
||||
|
||||
]);
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div class="transfer-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(
|
||||
[ 'action' => Url::current() ]
|
||||
); ?>
|
||||
|
||||
<p>
|
||||
Összesen: <?php echo $searchModel->total_money;?> Ft
|
||||
</p>
|
||||
<?= GridView::widget([
|
||||
'tableOptions' => ['class' => 'table table-striped table-bordered table-transfer'],
|
||||
'dataProvider' => $dataProvider,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<b>Felhasználó:</b> <?php echo $model->username ;?><br>
|
||||
<b>Idő:</b> <?php echo \Yii::$app->formatter->asDatetime(time());?><br>
|
||||
<?php
|
||||
if ( isset($geoip->city)){
|
||||
if ( isset($geoip) && isset($geoip->city)){
|
||||
?>
|
||||
<b>Ip cím:</b> <?php echo $geoip->ip?><br>
|
||||
<b>Város:</b> <?php echo $geoip->city?><br>
|
||||
|
||||
@ -960,7 +960,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]);
|
||||
UserSoldItem::deleteAll(['id_transfer' => $this->id_transfer]);
|
||||
}
|
||||
public function payout() {
|
||||
public function payout($id_account = null) {
|
||||
|
||||
if ($this->status != Transfer::STATUS_NOT_PAID) {
|
||||
return false;
|
||||
@ -970,14 +970,18 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$this->paid_at = Helper::getDateTimeString ();
|
||||
$this->paid_by = \Yii::$app->user->id;
|
||||
|
||||
if ( isset($id_account)){
|
||||
$this->id_account = $id_account;
|
||||
}else{
|
||||
if( Helper::isUserCartVisibilityAll() ){
|
||||
$this->id_account = Account::readDefault();
|
||||
}
|
||||
}
|
||||
|
||||
ShoppingCart::deleteAll ( [ 'id_transfer' => $this->id_transfer ] );
|
||||
UserSoldItem::deleteAll ( [ 'id_transfer' => $this->id_transfer
|
||||
] );
|
||||
return $this->save ();
|
||||
return $this->save (false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,18 +23,24 @@
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if ( count($model->moneyMovements ) == 0 ) {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="7" style="text-align: right; padding: 3px;">
|
||||
Nincs találat
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}else{?>
|
||||
}?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if ( count($model->moneyMovements ) > 0 ) {
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||
Összesen: <?php echo \Yii::$app->formatter->asInteger( $model->moneyMovementMoneis); ?> Ft
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@ -22,6 +22,7 @@ class AccountStateBanknoteCountWidget extends Widget{
|
||||
public $model;
|
||||
public $layout;
|
||||
public $index;
|
||||
public $showDailyDownload = true;
|
||||
|
||||
public function run(){
|
||||
|
||||
@ -60,12 +61,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;']);
|
||||
|
||||
if ( $this->model->isTypeClose() ){
|
||||
if ( $this->showDailyDownload ){
|
||||
$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]), [
|
||||
'title' => 'Részletek',
|
||||
|
||||
@ -94,8 +94,11 @@ class SiteController extends Controller
|
||||
|
||||
$geoip = Helper::getGeoIp();
|
||||
|
||||
$message = "";
|
||||
$user = User::findOne(\Yii::$app->user->id);
|
||||
if ( isset($geoip)){
|
||||
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $geoip->ip . " Város: " . $geoip->city;
|
||||
}
|
||||
|
||||
Log::log([
|
||||
'type' =>Log::$TYPE_LOGIN,
|
||||
|
||||
@ -4,6 +4,8 @@ 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>
|
||||
|
||||
@ -3,7 +3,14 @@ use common\components\accountstate\AccountStateWidget;
|
||||
use common\components\total\TotalDifferenceWidget;
|
||||
?>
|
||||
|
||||
|
||||
<style>
|
||||
.table td{
|
||||
padding: 2px;
|
||||
}
|
||||
.table th{
|
||||
padding: 2px;
|
||||
}
|
||||
</style>
|
||||
<div class="account-state-view ">
|
||||
|
||||
<table class="table-top">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user