Browse Source

Correctif option allow_order_guest

refactoring
Guillaume 3 years ago
parent
commit
fb809c7156
7 changed files with 97 additions and 79 deletions
  1. +2
    -1
      backend/views/user/_form.php
  2. +1
    -0
      common/models/User.php
  3. +13
    -13
      producer/controllers/OrderController.php
  4. +1
    -1
      producer/views/order/order.php
  5. +67
    -63
      producer/web/css/screen.css
  6. +7
    -1
      producer/web/js/vuejs/order-order.js
  7. +6
    -0
      producer/web/sass/_layout.scss

+ 2
- 1
backend/views/user/_form.php View File

@@ -54,7 +54,8 @@ use common\models\ProductPrice ;
<?= $form->field($model, 'type')
->dropDownList([
User::TYPE_INDIVIDUAL => 'Particulier',
User::TYPE_LEGAL_PERSON => 'Personne morale'
User::TYPE_LEGAL_PERSON => 'Personne morale',
User::TYPE_GUEST => 'Visiteur'
], [
'v-model' => 'type'
]) ; ?>

+ 1
- 0
common/models/User.php View File

@@ -63,6 +63,7 @@ class User extends ActiveRecordCommon implements IdentityInterface

const TYPE_INDIVIDUAL = 'individual' ;
const TYPE_LEGAL_PERSON = 'legal-person' ;
const TYPE_GUEST = 'guest' ;
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;

+ 13
- 13
producer/controllers/OrderController.php View File

@@ -204,19 +204,26 @@ class OrderController extends ProducerBaseController
// gestion user : option_allow_order_guest
if(isset($posts['user']) && $posts['user']) {

$user = User::searchOne([
'email' => $posts['user']['email']
$userIndividualExist = User::searchOne([
'email' => $posts['user']['email'],
'type' => User::TYPE_INDIVIDUAL
]) ;

if($user) {
$producer->addUser($user->id, $idProducer) ;
if($userIndividualExist) {
$errorUserGuest = 'Cette adresse email est déjà utilisée, veuillez vous <a href="'.Yii::$app->urlManagerFrontend->createUrl(['site/producer', 'id' => $idProducer]).'">connecter à votre compte</a> ou en utiliser une autre.' ;
return ['status' => 'error', 'errors' => [$errorUserGuest]];
}

$user = User::searchOne([
'email' => $posts['user']['email'],
'type' => User::TYPE_GUEST
]) ;

if(!$user) {
$user = new User ;
$user->id_producer = 0;
$user->type = User::TYPE_GUEST;
$password = Password::generate() ;
//$password = $posts['user']['password'] ;
$user->setPassword($password);
$user->generateAuthKey();
$user->username = $posts['user']['email'];
@@ -225,15 +232,8 @@ class OrderController extends ProducerBaseController
$user->lastname = $posts['user']['lastname'];
$user->phone = $posts['user']['phone'];
$user->save() ;

// liaison producer / user
$producer->addUser($user->id, $idProducer) ;

// mail bienvenue
$user->sendMailWelcome($password);
}
else {
$producer->addUser($user->id, $idProducer) ;
}
}

@@ -816,4 +816,4 @@ class OrderController extends ProducerBaseController
}

}

+ 1
- 1
producer/views/order/order.php View File

@@ -98,7 +98,7 @@ $producer = GlobalParam::getCurrentProducer() ;
<div v-if="errors.length" class="alert alert-danger">
<ul>
<li v-for="error in errors">
{{ error }}
<div v-html="error"></div>
</li>
</ul>
</div>

+ 67
- 63
producer/web/css/screen.css View File

@@ -186,30 +186,34 @@ body {
.alert.alert-warning a {
color: #8a6d3b;
}
/* line 95, ../sass/_layout.scss */
.alert.alert-danger a {
color: #a94442;
}

/* line 98, ../sass/_layout.scss */
/* line 104, ../sass/_layout.scss */
ul.pagination li.active a {
background-color: #FF7F00;
border: solid 1px #FF7F00;
}
/* line 102, ../sass/_layout.scss */
/* line 108, ../sass/_layout.scss */
ul.pagination li.active a:hover {
background-color: white;
border: solid 1px white;
color: #FF7F00;
}
/* line 109, ../sass/_layout.scss */
/* line 115, ../sass/_layout.scss */
ul.pagination li a {
color: #FF7F00;
}
/* line 112, ../sass/_layout.scss */
/* line 118, ../sass/_layout.scss */
ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
background-color: white;
border: solid 1px white;
color: #FF7F00;
}

/* line 121, ../sass/_layout.scss */
/* line 127, ../sass/_layout.scss */
#header-bap {
position: absolute;
right: 0px;
@@ -221,39 +225,39 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
text-align: center;
z-index: 1000;
}
/* line 132, ../sass/_layout.scss */
/* line 138, ../sass/_layout.scss */
#header-bap .container {
padding-left: 0px;
padding-right: 0px;
}
/* line 137, ../sass/_layout.scss */
/* line 143, ../sass/_layout.scss */
#header-bap a#logo {
color: black;
text-decoration: none;
position: relative;
top: 3px;
}
/* line 143, ../sass/_layout.scss */
/* line 149, ../sass/_layout.scss */
#header-bap a#logo img {
width: 45px;
}
/* line 148, ../sass/_layout.scss */
/* line 154, ../sass/_layout.scss */
#header-bap ul#nav-bap {
float: right;
}
/* line 152, ../sass/_layout.scss */
/* line 158, ../sass/_layout.scss */
#header-bap ul#nav-bap li a {
color: black;
font-size: 15px;
color: #FF7F00;
}
/* line 157, ../sass/_layout.scss */
/* line 163, ../sass/_layout.scss */
#header-bap ul#nav-bap li a:hover, #header-bap ul#nav-bap li a:focus {
color: #333;
color: #FF7F00;
background: none;
}
/* line 164, ../sass/_layout.scss */
/* line 170, ../sass/_layout.scss */
#header-bap ul#nav-bap li ul {
background-color: white;
border-top: solid 2px #FF7F00;
@@ -261,23 +265,23 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
top: 50px;
width: 200px;
}
/* line 172, ../sass/_layout.scss */
/* line 178, ../sass/_layout.scss */
#header-bap ul#nav-bap li ul li a {
text-transform: uppercase;
font-size: 13px;
}
/* line 176, ../sass/_layout.scss */
/* line 182, ../sass/_layout.scss */
#header-bap ul#nav-bap li ul li a:hover {
color: #ff9933;
}
/* line 180, ../sass/_layout.scss */
/* line 186, ../sass/_layout.scss */
#header-bap ul#nav-bap li ul li a small {
font-size: 10px;
line-height: 13px;
margin-left: 18px;
}

/* line 192, ../sass/_layout.scss */
/* line 198, ../sass/_layout.scss */
#left {
background-color: #FFF8DC;
text-align: center;
@@ -285,12 +289,12 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
padding: 0px;
position: relative;
}
/* line 199, ../sass/_layout.scss */
/* line 205, ../sass/_layout.scss */
#left .fixed {
position: fixed;
display: none;
}
/* line 205, ../sass/_layout.scss */
/* line 211, ../sass/_layout.scss */
#left #logo {
position: relative;
background-color: white;
@@ -305,7 +309,7 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
text-align: center;
overflow: hidden;
}
/* line 217, ../sass/_layout.scss */
/* line 223, ../sass/_layout.scss */
#left #logo img {
position: absolute;
top: 50%;
@@ -314,11 +318,11 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
max-width: 90px;
max-height: 90px;
}
/* line 227, ../sass/_layout.scss */
/* line 233, ../sass/_layout.scss */
#left h1, #left h2, #left #infos, #left #infos a {
color: #323232;
}
/* line 231, ../sass/_layout.scss */
/* line 237, ../sass/_layout.scss */
#left h1 {
text-transform: uppercase;
font-family: "highvoltageregular";
@@ -329,37 +333,37 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
text-align: center;
font-weight: normal;
}
/* line 242, ../sass/_layout.scss */
/* line 248, ../sass/_layout.scss */
#left h2 {
font-family: "capsuularegular";
font-size: 15px;
font-weight: normal;
text-align: center;
}
/* line 248, ../sass/_layout.scss */
/* line 254, ../sass/_layout.scss */
#left h2 .favorite {
padding-left: 0px;
}
/* line 251, ../sass/_layout.scss */
/* line 257, ../sass/_layout.scss */
#left h2 .favorite .glyphicon {
font-size: 14px;
}
/* line 256, ../sass/_layout.scss */
/* line 262, ../sass/_layout.scss */
#left h2 a {
color: #323232;
}
/* line 262, ../sass/_layout.scss */
/* line 268, ../sass/_layout.scss */
#left nav#main-nav {
background-color: white;
border: solid 1px #e0e0e0;
border-bottom: 0px none;
margin-top: 20px;
}
/* line 269, ../sass/_layout.scss */
/* line 275, ../sass/_layout.scss */
#left nav#main-nav ul li {
display: block;
}
/* line 272, ../sass/_layout.scss */
/* line 278, ../sass/_layout.scss */
#left nav#main-nav ul li a {
color: #323232;
color: black;
@@ -369,23 +373,23 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
display: block;
text-align: left;
}
/* line 281, ../sass/_layout.scss */
/* line 287, ../sass/_layout.scss */
#left nav#main-nav ul li a .glyphicon {
font-size: 15px;
margin-right: 3px;
}
/* line 286, ../sass/_layout.scss */
/* line 292, ../sass/_layout.scss */
#left nav#main-nav ul li a span.label {
padding-bottom: 3px;
font-family: "Arial";
float: right;
}
/* line 294, ../sass/_layout.scss */
/* line 300, ../sass/_layout.scss */
#left nav#main-nav ul li.active span.label, #left nav#main-nav ul li a:hover span.label {
background-color: #e67200;
color: white;
}
/* line 300, ../sass/_layout.scss */
/* line 306, ../sass/_layout.scss */
#left nav#main-nav ul li a:hover, #left nav#main-nav ul li.active a {
background: #FF7F00;
color: white;
@@ -393,22 +397,22 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
-webkit-border-radius: 0px;
border-radius: 0px;
}
/* line 309, ../sass/_layout.scss */
/* line 315, ../sass/_layout.scss */
#left nav#main-nav ul li#btn-administration a {
color: #FF7F00;
}
/* line 312, ../sass/_layout.scss */
/* line 318, ../sass/_layout.scss */
#left nav#main-nav ul li#btn-administration a:hover {
color: white;
}
/* line 320, ../sass/_layout.scss */
/* line 326, ../sass/_layout.scss */
#left nav#main-nav #user {
color: #FF7F00;
float: right;
padding: 10px;
}

/* line 328, ../sass/_layout.scss */
/* line 334, ../sass/_layout.scss */
#main {
background-color: #FFF8DC;
border: solid 1px #e0e0e0;
@@ -416,13 +420,13 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
padding: 0px;
background-color: white;
}
/* line 335, ../sass/_layout.scss */
/* line 341, ../sass/_layout.scss */
#main #img-big {
height: 130px;
overflow: hidden;
position: relative;
}
/* line 340, ../sass/_layout.scss */
/* line 346, ../sass/_layout.scss */
#main #img-big img.img-photo {
width: 100%;
position: absolute;
@@ -430,7 +434,7 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
left: 50%;
transform: translate(-50%, -50%);
}
/* line 350, ../sass/_layout.scss */
/* line 356, ../sass/_layout.scss */
#main #infos-producer {
padding: 5px 10px;
margin-bottom: 0px;
@@ -440,20 +444,20 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
border-bottom: solid 1px #e0e0e0;
color: gray;
}
/* line 359, ../sass/_layout.scss */
/* line 365, ../sass/_layout.scss */
#main #infos-producer strong {
font-weight: bold;
}
/* line 363, ../sass/_layout.scss */
/* line 369, ../sass/_layout.scss */
#main #infos-producer .favorite {
float: right;
color: gray;
}
/* line 366, ../sass/_layout.scss */
/* line 372, ../sass/_layout.scss */
#main #infos-producer .favorite a {
color: black;
}
/* line 372, ../sass/_layout.scss */
/* line 378, ../sass/_layout.scss */
#main h2#page-title {
padding-left: 15px;
padding-right: 15px;
@@ -468,36 +472,36 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
top: -10px;
text-align: left;
}
/* line 386, ../sass/_layout.scss */
/* line 392, ../sass/_layout.scss */
#main h2#page-title #buttons {
margin-bottom: 15px;
font-family: "Arial";
}
/* line 393, ../sass/_layout.scss */
/* line 399, ../sass/_layout.scss */
#main #content {
padding: 0px 20px 20px 20px;
padding-bottom: 40px;
min-height: 300px;
}
/* line 398, ../sass/_layout.scss */
/* line 404, ../sass/_layout.scss */
#main #content h1, #main #content h2, #main #content h3, #main #content h4, #main #content h5, #main #content h6 {
font-family: "highvoltageregular";
margin-top: 30px;
margin-bottom: 20px;
}
/* line 403, ../sass/_layout.scss */
/* line 409, ../sass/_layout.scss */
#main #content h1.first, #main #content h2.first, #main #content h3.first, #main #content h4.first, #main #content h5.first, #main #content h6.first {
margin-top: 0px;
}
/* line 408, ../sass/_layout.scss */
/* line 414, ../sass/_layout.scss */
#main #content h1 {
font-size: 30px;
}
/* line 412, ../sass/_layout.scss */
/* line 418, ../sass/_layout.scss */
#main #content h2 {
font-size: 25px;
}
/* line 417, ../sass/_layout.scss */
/* line 423, ../sass/_layout.scss */
#main #content h3 {
font-family: "capsuularegular";
text-transform: uppercase;
@@ -506,29 +510,29 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
margin-bottom: 30px;
margin-top: 45px;
}
/* line 425, ../sass/_layout.scss */
/* line 431, ../sass/_layout.scss */
#main #content h3 span {
padding-top: 14px;
color: #323232;
}
/* line 431, ../sass/_layout.scss */
/* line 437, ../sass/_layout.scss */
#main #content h4 {
font-size: 20px;
}
/* line 435, ../sass/_layout.scss */
/* line 441, ../sass/_layout.scss */
#main #content h5 {
font-size: 18px;
}
/* line 439, ../sass/_layout.scss */
/* line 445, ../sass/_layout.scss */
#main #content h6 {
font-size: 16px;
}
/* line 445, ../sass/_layout.scss */
/* line 451, ../sass/_layout.scss */
#main #content form .form-group .hint-block {
color: gray;
}

/* line 453, ../sass/_layout.scss */
/* line 459, ../sass/_layout.scss */
#footer-producer {
text-align: center;
position: absolute;
@@ -536,28 +540,28 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
left: 0px;
width: 100%;
}
/* line 460, ../sass/_layout.scss */
/* line 466, ../sass/_layout.scss */
#footer-producer a {
color: #FF7F00;
}
/* line 462, ../sass/_layout.scss */
/* line 468, ../sass/_layout.scss */
#footer-producer a:active {
text-decoration: underline;
}

/* line 468, ../sass/_layout.scss */
/* line 474, ../sass/_layout.scss */
#footer {
background-color: #FFF8DC;
height: 100px;
float: right;
text-align: center;
}
/* line 474, ../sass/_layout.scss */
/* line 480, ../sass/_layout.scss */
#footer .content {
padding-top: 20px;
color: black;
}
/* line 478, ../sass/_layout.scss */
/* line 484, ../sass/_layout.scss */
#footer .content a {
color: black;
font-family: "capsuularegular";
@@ -565,11 +569,11 @@ ul.pagination li a:hover, ul.pagination li a:focus, ul.pagination li a:active {
padding-left: 10px;
padding-right: 10px;
}
/* line 485, ../sass/_layout.scss */
/* line 491, ../sass/_layout.scss */
#footer .content a:hover {
text-decoration: underline;
}
/* line 492, ../sass/_layout.scss */
/* line 498, ../sass/_layout.scss */
#footer #code-source img {
height: 20px;
}

+ 7
- 1
producer/web/js/vuejs/order-order.js View File

@@ -332,13 +332,14 @@ var app = new Vue({
},
confirmClick: function() {

var app = this ;
var $signupGuestForm = $('#signup-guest form') ;
if($signupGuestForm.length > 0 && !$signupGuestForm.valid()) {
$signupGuestForm.submit() ;
return false ;
}

this.disableConfirmButton = true ;
app.disableConfirmButton = true ;
var productsArray = {} ;
for(var key in this.products) {
@@ -371,8 +372,13 @@ var app = new Vue({
user: user
}).then(function(response) {
if(response.data.status == 'success') {
app.errors = [] ;
window.location.href = opendistrib_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ;
}
else {
app.errors = response.data.errors ;
app.disableConfirmButton = false ;
}
});
},
checkProducts: function() {

+ 6
- 0
producer/web/sass/_layout.scss View File

@@ -90,6 +90,12 @@ body {
color: #8a6d3b ;
}
}

&.alert-danger {
a {
color: #a94442 ;
}
}
}

ul.pagination {

Loading…
Cancel
Save