add daily listing by paid_by, add customer cart details

This commit is contained in:
2016-01-27 09:01:02 +01:00
parent 9fb349ee64
commit 2291ca5ff4
28 changed files with 577 additions and 81 deletions

View File

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