add daily listing by paid_by, add customer cart details
This commit is contained in:
@@ -155,15 +155,15 @@ class ProductController extends Controller {
|
||||
}
|
||||
public function actionPayoutUserCart() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
$result = [ ];
|
||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
// $result = [ ];
|
||||
// \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
|
||||
$user = User::findOne ( Yii::$app->user->id );
|
||||
UserSoldItem::payout ( $user );
|
||||
// $user = User::findOne ( Yii::$app->user->id );
|
||||
// UserSoldItem::payout ( $user );
|
||||
|
||||
$userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
|
||||
$result ['transfers'] = $userTransfers;
|
||||
$result ['code'] = 'success';
|
||||
// $userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
|
||||
// $result ['transfers'] = $userTransfers;
|
||||
// $result ['code'] = 'success';
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
@@ -175,7 +175,7 @@ class ProductController extends Controller {
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
UserSoldItem::payout ( $user, $model->transfers );
|
||||
UserSoldItem::payout ( $user, $model->transfers , Account::readDefault() );
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', 'Recepicó kosár fizetve' );
|
||||
} catch ( Exception $e ) {
|
||||
@@ -231,7 +231,7 @@ class ProductController extends Controller {
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
ShoppingCart::payout ( $this->customer, $model->transfers );
|
||||
ShoppingCart::payout ( $this->customer, $model->transfers , Account::readDefault());
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', 'Vendég kosár kifizetve' );
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
@@ -20,6 +20,9 @@ use common\models\Product;
|
||||
use common\models\TransferTicketSearch;
|
||||
use common\models\TicketType;
|
||||
use frontend\models\UserCartForm;
|
||||
use common\models\Customer;
|
||||
use frontend\models\CustomerCartForm;
|
||||
use common\models\Card;
|
||||
|
||||
/**
|
||||
* TransferController implements the CRUD actions for Transfer model.
|
||||
@@ -191,10 +194,11 @@ class TransferController extends Controller
|
||||
$transfer->status = Transfer::STATUS_PAID;
|
||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||
$transfer->paid_by = \Yii::$app->user->id;
|
||||
$transfer->id_account = Account::readDefault();
|
||||
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
if ( $transfer->save() ){
|
||||
\Yii::$app->session->setFlash( 'success','Tranzakció kifizetve' );
|
||||
\Yii::$app->session->setFlash( 'success','Tranzakció kifizetve!' );
|
||||
$transaction->commit();
|
||||
}else{
|
||||
throw new \Exception("Failed to save");
|
||||
@@ -342,6 +346,12 @@ class TransferController extends Controller
|
||||
|
||||
public function actionUserCart(){
|
||||
|
||||
$defaultAccount = Account::readDefault();
|
||||
|
||||
if ( !isset($defaultAccount)){
|
||||
return $this->redirect(['account/select']);
|
||||
}
|
||||
|
||||
$model = new UserCartForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->payout()) {
|
||||
return $this->redirect(['user-cart']);
|
||||
@@ -349,4 +359,30 @@ class TransferController extends Controller
|
||||
$model->run();
|
||||
return $this->render("usercart",[ 'model' => $model]);
|
||||
}
|
||||
public function actionCustomerCart($id_card){
|
||||
|
||||
$defaultAccount = Account::readDefault();
|
||||
|
||||
if ( !isset($defaultAccount)){
|
||||
return $this->redirect(['account/select']);
|
||||
}
|
||||
|
||||
$customer = null;
|
||||
$card = Card::findOne($id_card);
|
||||
if ($card != null )
|
||||
$customer = $card->customer;
|
||||
|
||||
|
||||
if ( !isset($customer) ){
|
||||
throw new NotFoundHttpException ( 'Az oldal nem található' );
|
||||
}
|
||||
|
||||
$model = new CustomerCartForm();
|
||||
$model->customer = $customer;
|
||||
if ($model->load(Yii::$app->request->post()) && $model->payout()) {
|
||||
return $this->redirect(['customer-cart','id_card' => $model->customer->card->id_card]);
|
||||
}
|
||||
$model->run();
|
||||
return $this->render("customercart",[ 'model' => $model]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user