return $this->redirect(['dashboard/index']); | return $this->redirect(['dashboard/index']); | ||||
} | } | ||||
public function redirectAfterSave(string $baseRoute, int $id) | |||||
public function redirectAfterSave(string $baseRoute, int $id, string $redirectUrl = null) | |||||
{ | { | ||||
$postParams = \Yii::$app->request->post(); | $postParams = \Yii::$app->request->post(); | ||||
if(isset($postParams['save-stay'])) { | if(isset($postParams['save-stay'])) { | ||||
return $this->redirect([$baseRoute.'/update', 'id' => $id]); | return $this->redirect([$baseRoute.'/update', 'id' => $id]); | ||||
} | } | ||||
else { | else { | ||||
return $this->redirect(['index']); | |||||
if($redirectUrl) { | |||||
return $this->redirect($redirectUrl); | |||||
} | |||||
else { | |||||
return $this->redirect(['index']); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
$distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray)); | $distributionJsonData['potential_revenues'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray)); | ||||
$distributionJsonData['potential_revenues_with_tax'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray, true)); | $distributionJsonData['potential_revenues_with_tax'] = Price::format($productModule->getProductDistributionPotentialRevenues($productsArray, true)); | ||||
$distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2); | $distributionJsonData['potential_weight'] = number_format($productModule->getProductDistributionPotentialWeight($productsArray), 2); | ||||
$distributionJsonData['user_create_href'] = \Yii::$app->urlManager->createUrl([ | |||||
'user/create', | |||||
'redirectUrl' => \Yii::$app->urlManager->createAbsoluteUrl([ | |||||
'distribution/index', | |||||
'date' => $distribution->date, | |||||
'displayFormOrderCreate' => 1 | |||||
]) | |||||
]); | |||||
return $distributionJsonData; | return $distributionJsonData; | ||||
} | } |
]); | ]); | ||||
} | } | ||||
public function actionCreate() | |||||
public function actionCreate(string $redirectUrl = null) | |||||
{ | { | ||||
$userModule = $this->getUserModule(); | $userModule = $this->getUserModule(); | ||||
$producerModule = $this->getProducerModule(); | $producerModule = $this->getProducerModule(); | ||||
$producerCurrent = $this->getProducerCurrent(); | $producerCurrent = $this->getProducerCurrent(); | ||||
$model = $userModule->instanciateUser(); | $model = $userModule->instanciateUser(); | ||||
$model->redirect_url = $redirectUrl; | |||||
$posts = Yii::$app->request->post(); | $posts = Yii::$app->request->post(); | ||||
$userExist = false; | $userExist = false; | ||||
$this->setFlash('success', 'Utilisateur créé.'); | $this->setFlash('success', 'Utilisateur créé.'); | ||||
return $this->redirectAfterSave('user', $userCreate->id); | |||||
return $this->redirectAfterSave('user', $userCreate->id, $model->redirect_url); | |||||
} | } | ||||
} | } | ||||
?> | ?> | ||||
<div class="form-group form-actions"> | <div class="form-group form-actions"> | ||||
<?php if(isset($form)): ?> | |||||
<?= $form->field($model, 'redirect_url', ['options' => ['class' => 'field-redirect-url']])->hiddenInput() ?> | |||||
<?php endif; ?> | |||||
<?= Html::a('Retour', ['index'], ['class' => 'btn btn-default']) ?> | <?= Html::a('Retour', ['index'], ['class' => 'btn btn-default']) ?> | ||||
<?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary', 'name' => 'save']) ?> | <?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary', 'name' => 'save']) ?> | ||||
<?= Html::submitButton($model->isNewRecord ? 'Créer et rester' : 'Modifier et rester', ['class' => 'btn btn-primary', 'name' => 'save-stay']) ?> | <?= Html::submitButton($model->isNewRecord ? 'Créer et rester' : 'Modifier et rester', ['class' => 'btn btn-primary', 'name' => 'save-stay']) ?> |
<a v-if="producer && producer.credit && order.id_user > 0 && user.id_user == order.id_user" class="btn btn-xs btn-primary btn-credit" :href="baseUrl+'/user/credit?id='+user.id_user" v-for="user in users">{{ parseFloat(user.credit).toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</a> | <a v-if="producer && producer.credit && order.id_user > 0 && user.id_user == order.id_user" class="btn btn-xs btn-primary btn-credit" :href="baseUrl+'/user/credit?id='+user.id_user" v-for="user in users">{{ parseFloat(user.credit).toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</a> | ||||
<label class="control-label" for="select-id-user"> | <label class="control-label" for="select-id-user"> | ||||
Utilisateur | Utilisateur | ||||
<a v-if="!order.id_user || order.id_user == 0" class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl('user/create'); ?>"> | |||||
<a v-if="!order.id_user || order.id_user == 0" class="btn btn-default btn-xs" :href="distribution.user_create_href"> | |||||
<span class="glyphicon glyphicon-plus"></span> | <span class="glyphicon glyphicon-plus"></span> | ||||
Créer un utilisateur | Créer un utilisateur | ||||
</a> | </a> |
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?> | ->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit pour cet utilisateur.');*/ ?> | ||||
<?= $this->render('@backend/views/_include/form_actions.php',[ | <?= $this->render('@backend/views/_include/form_actions.php',[ | ||||
'form' => $form, | |||||
'model' => $model, | 'model' => $model, | ||||
]); ?> | ]); ?> | ||||
</div> | </div> |
body.skin-black .content-wrapper .form-actions a, body.skin-black .content-wrapper .form-actions button { | body.skin-black .content-wrapper .form-actions a, body.skin-black .content-wrapper .form-actions button { | ||||
margin-left: 10px; | margin-left: 10px; | ||||
} | } | ||||
/* line 497, ../sass/_adminlte.scss */ | |||||
/* line 496, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .form-actions .field-redirect-url { | |||||
display: none; | |||||
} | |||||
/* line 501, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .form-buttons { | body.skin-black .content-wrapper .form-buttons { | ||||
margin-top: 25px; | margin-top: 25px; | ||||
text-align: right; | text-align: right; | ||||
} | } | ||||
/* line 504, ../sass/_adminlte.scss */ | |||||
/* line 508, ../sass/_adminlte.scss */ | |||||
body.skin-black .main-footer a { | body.skin-black .main-footer a { | ||||
color: #F39C12; | color: #F39C12; | ||||
} | } | ||||
/* line 509, ../sass/_adminlte.scss */ | |||||
/* line 513, ../sass/_adminlte.scss */ | |||||
body.skin-black .gridview-pagesize { | body.skin-black .gridview-pagesize { | ||||
float: right; | float: right; | ||||
margin-bottom: 8px; | margin-bottom: 8px; | ||||
} | } | ||||
/* line 514, ../sass/_adminlte.scss */ | |||||
/* line 518, ../sass/_adminlte.scss */ | |||||
body.skin-black #yii-debug-toolbar { | body.skin-black #yii-debug-toolbar { | ||||
bottom: 64px; | bottom: 64px; | ||||
} | } | ||||
/* line 519, ../sass/_adminlte.scss */ | |||||
/* line 523, ../sass/_adminlte.scss */ | |||||
body.login-page { | body.login-page { | ||||
background: none; | background: none; | ||||
background-color: white; | background-color: white; | ||||
} | } | ||||
/* line 523, ../sass/_adminlte.scss */ | |||||
/* line 527, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo { | body.login-page .login-box .login-logo { | ||||
text-align: center; | text-align: center; | ||||
font-family: 'worksans_bold'; | font-family: 'worksans_bold'; | ||||
} | } | ||||
/* line 527, ../sass/_adminlte.scss */ | |||||
/* line 531, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo img { | body.login-page .login-box .login-logo img { | ||||
width: 150px; | width: 150px; | ||||
} | } | ||||
/* line 533, ../sass/_adminlte.scss */ | |||||
/* line 537, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body, | body.login-page .login-box .login-box-body, | ||||
body.login-page .login-box .login-box-body input#loginform-email, | body.login-page .login-box .login-box-body input#loginform-email, | ||||
body.login-page .login-box .login-box-body input#loginform-password, | body.login-page .login-box .login-box-body input#loginform-password, | ||||
body.login-page .login-box .login-box-body .btn-primary { | body.login-page .login-box .login-box-body .btn-primary { | ||||
font-size: 14px; | font-size: 14px; | ||||
} | } | ||||
/* line 540, ../sass/_adminlte.scss */ | |||||
/* line 544, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary { | body.login-page .login-box .login-box-body .btn-primary { | ||||
background-color: #F39C12; | background-color: #F39C12; | ||||
border-color: #F39C12; | border-color: #F39C12; | ||||
padding: 5px 10px; | padding: 5px 10px; | ||||
margin-bottom: 15px; | margin-bottom: 15px; | ||||
} | } | ||||
/* line 546, ../sass/_adminlte.scss */ | |||||
/* line 550, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary:active { | body.login-page .login-box .login-box-body .btn-primary:active { | ||||
background-color: #f4a62a; | background-color: #f4a62a; | ||||
border-color: #F39C12; | border-color: #F39C12; | ||||
} | } | ||||
/* line 552, ../sass/_adminlte.scss */ | |||||
/* line 556, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a { | body.login-page .login-box .login-box-body a { | ||||
color: #F39C12; | color: #F39C12; | ||||
} | } | ||||
/* line 554, ../sass/_adminlte.scss */ | |||||
/* line 558, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a:hover { | body.login-page .login-box .login-box-body a:hover { | ||||
color: #f4a62a; | color: #f4a62a; | ||||
} | } | ||||
/* line 559, ../sass/_adminlte.scss */ | |||||
/* line 563, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .checkbox label input { | body.login-page .login-box .login-box-body .checkbox label input { | ||||
position: relative; | position: relative; | ||||
top: 0px; | top: 0px; |
+ ('0' + (this.date.getMonth() + 1)).slice(-2) + '/' | + ('0' + (this.date.getMonth() + 1)).slice(-2) + '/' | ||||
+ this.date.getFullYear(); | + this.date.getFullYear(); | ||||
} | } | ||||
this.init(); | |||||
this.init(false, true); | |||||
this.loading = false; | this.loading = false; | ||||
}, | }, | ||||
methods: { | methods: { | ||||
&& today.getMonth() == this.date.getMonth() | && today.getMonth() == this.date.getMonth() | ||||
&& today.getDay() == this.date.getDay(); | && today.getDay() == this.date.getDay(); | ||||
}, | }, | ||||
init: function (idActivePointSale) { | |||||
init: function (idActivePointSale, displayFormOrderCreate) { | |||||
var app = this; | var app = this; | ||||
this.showLoading = true; | this.showLoading = true; | ||||
highlight: highlightStyle, | highlight: highlightStyle, | ||||
dates: app.date | dates: app.date | ||||
}); | }); | ||||
if(displayFormOrderCreate && searchParams.has('displayFormOrderCreate')) { | |||||
app.openModalFormOrderCreate(); | |||||
} | |||||
}); | }); | ||||
}, | }, | ||||
initCountActiveProducts: function () { | initCountActiveProducts: function () { |
a, button { | a, button { | ||||
margin-left: 10px; | margin-left: 10px; | ||||
} | } | ||||
.field-redirect-url { | |||||
display: none; | |||||
} | |||||
} | } | ||||
.form-buttons { | .form-buttons { |
const SEARCH_ONE = 'one'; | const SEARCH_ONE = 'one'; | ||||
const SEARCH_COUNT = 'count'; | const SEARCH_COUNT = 'count'; | ||||
public ?string $redirect_url = ''; | |||||
public function populateFieldObject($fieldIdentifier, $fieldObject, $object) | public function populateFieldObject($fieldIdentifier, $fieldObject, $object) | ||||
{ | { | ||||
$this->{$fieldIdentifier} = $object->id; | $this->{$fieldIdentifier} = $object->id; |
['password_old', 'verifyPasswordOld'], | ['password_old', 'verifyPasswordOld'], | ||||
['password_new', 'verifyPasswordNew'], | ['password_new', 'verifyPasswordNew'], | ||||
['password_new_confirm', 'verifyPasswordNewConfirm'], | ['password_new_confirm', 'verifyPasswordNewConfirm'], | ||||
[['date_last_connection', 'password_old', 'password_new', 'password_new_confirm', 'password_hash', 'points_sale', 'product_price_percent', 'user_groups'], 'safe'], | |||||
[['date_last_connection', 'password_old', 'password_new', 'password_new_confirm', 'password_hash', 'points_sale', 'product_price_percent', 'user_groups', 'redirect_url'], 'safe'], | |||||
]; | ]; | ||||
} | } | ||||