add collection changes
This commit is contained in:
@@ -73,24 +73,26 @@ class CollectionController extends Controller
|
||||
|
||||
$user = User::findOne(Yii::$app->user->id);
|
||||
|
||||
// $accounts = Account::find()->orderBy("name asc")->all();
|
||||
|
||||
$model->accounts = Account::read();
|
||||
$model->lastCollection = Collection::readLast($user);
|
||||
$model->id_user = $user->id;
|
||||
$model->id_account = Account::readDefault();
|
||||
$model->id_account = $id_account;
|
||||
$model->account = Account::readOne($model->id_account);
|
||||
$accountMap = ArrayHelper::map( $model->accounts ,'id_account','name' );
|
||||
$model->accountMap = ArrayHelper::map( $model->accounts ,'id_account','name' );
|
||||
|
||||
$model->start = isset($model->lastCollection) ? $model->lastCollection->end :null;
|
||||
$model->end = date("Y-m-d H:i:s");
|
||||
$model->timestampStart = isset($model->lastCollection) ? $model->lastCollection->end :null;
|
||||
$model->timestampEnd = date("Y-m-d H:i:s");
|
||||
|
||||
$model->start = isset($model->timestampStart) ? Yii::$app->formatter->asDatetime( $model->timestampStart ) : '';
|
||||
$model->end = isset($model->timestampEnd) ? Yii::$app->formatter->asDatetime( $model->timestampEnd ): '';
|
||||
|
||||
$model->type = Collection::TYPE_RECEPTION;
|
||||
|
||||
|
||||
$model->totals = Transfer::mkTotals($model->start, $model->end, $model->user->id, null, $model->account->id_account, $model->accounts, $accountMap);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
if ( $model->load(Yii::$app->request->post()) && $model->save() ) {
|
||||
return $this->redirect(['view', 'id' => $model->id_collection]);
|
||||
} else {
|
||||
$model->totals = Transfer::mkTotals($model->timestampStart, $model->timestampEnd, $model->user->id, null, $model->account->id_account, $model->accounts, $model->accountMap);
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user