add frontend changes

This commit is contained in:
2015-10-30 09:28:58 +01:00
parent 4a04c9efa2
commit e34b150d74
41 changed files with 1083 additions and 254 deletions

View File

@@ -43,6 +43,7 @@ class AccountController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->writeToSession()) {
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Default account is set!') );
return $this->redirect(['product/sale']);
}
return $this->render('select', [
'model' => $model,

View File

@@ -141,8 +141,7 @@ class ProductController extends Controller
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$user = User::findOne(Yii::$app->user->id );
UserSoldItem::deleteAll(['id_user' => Yii::$app->user->id]);
UserSoldItem::payout($user);
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
$result['transfers'] = $userTransfers;

View File

@@ -88,11 +88,10 @@ class SiteController extends Controller
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
// return $this->goBack();
return $this->redirect(['account/select']);
} else {
return $this->render('login', [
'model' => $model,
]);
return $this->render('login', ['model' => $model,]);
}
}

View File

@@ -16,11 +16,14 @@ use common\models\Account;
use yii\base\Object;
use common\models\Transfer;
use common\models\User;
use common\models\ShoppingCart;
use common\models\UserSoldItem;
use frontend\components\FrontendController;
/**
* TicketController implements the CRUD actions for Ticket model.
*/
class TicketController extends Controller
class TicketController extends FrontendController
{
public function behaviors()
{
@@ -52,9 +55,7 @@ class TicketController extends Controller
*/
public function actionIndex($number = null)
{
$receptionForm = new ReceptionForm();
$receptionForm->number = $number;
$receptionForm->readCard();
$receptionForm = $this->mkReceptionForm($number);
if ( !isset($receptionForm->card ) ){
@@ -79,14 +80,19 @@ class TicketController extends Controller
public function actionCreate($number = null)
{
$receptionForm = new ReceptionForm();
$receptionForm->number = $number;
$receptionForm->readCard();
$receptionForm =$this->mkReceptionForm($number);
if ( !isset($receptionForm->card ) ){
throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.'));
}
if ( isset($_POST['payout_customer_cart']) && $this->payoutCustomerCart($receptionForm) ){
return $this->redirect(['customer/reception' ]);
}else if ( isset($_POST['payout_user_cart']) && $this->payoutUserCart($receptionForm)){
return $this->redirect(['customer/reception' ]);
}
$model = new TicketCreate();
$discounts = Discount::read();
@@ -97,7 +103,7 @@ class TicketController extends Controller
$user = User::findOne( [ 'id' => Yii::$app->user->id ] );
$model->customer = $receptionForm->customer;
$model->id_user = \Yii::$app->user->id;
$model->status = Ticket::STATUS_ACTIVE;
$model->usage_count = 0;
@@ -107,9 +113,10 @@ class TicketController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') );
return $this->redirect(['product/sale', 'number' => $receptionForm->card->number]);
} else {
}
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
$model->userCart = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
$model->customerCart = Transfer::modelsToArray( Transfer::readCustomerCart( $receptionForm->customer ) );
return $this->render('create', [
'model' => $model,
@@ -117,71 +124,7 @@ class TicketController extends Controller
'ticketTypes' => $ticketTypes,
'accounts' => $accounts,
'receptionForm' => $receptionForm,
'userTransfers' => $userTransfers,
]);
}
}
/**
* Finds the Ticket model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Ticket the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Ticket::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Displays a single Ticket model.
* @param integer $id
* @return mixed
*/
/*
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
*/
/**
* Deletes an existing Ticket model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
/*
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
*/
/**
* Updates an existing Ticket model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
/*
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_ticket]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
*/
}

View File

@@ -9,6 +9,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use frontend\models\TransferMoneyMovementSearch;
use common\models\Account;
/**
* TransferController implements the CRUD actions for Transfer model.
@@ -41,6 +42,27 @@ class TransferController extends Controller
'dataProvider' => $dataProvider,
]);
}
/**
* Lists all Transfer models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TransferSearch();
$searchModel->accounts = Account::read();
$searchModel->load(Yii::$app->request->queryParams);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$searchModel->totalsTransfers(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Transfer model.