]; | ]; | ||||
// Items du menu | // Items du menu | ||||
/*$itemHome = [ | |||||
'label' => '<span class="glyphicon glyphicon-home"></span> Accueil', | |||||
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']), | |||||
'linkOptions' => ['class' => 'btn btn-default navbar-btn'] | |||||
];*/ | |||||
$itemAdministration = [ | $itemAdministration = [ | ||||
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | 'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', | ||||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']), | ||||
if ($context == 'producer') { | if ($context == 'producer') { | ||||
$itemsUserArray = [ | $itemsUserArray = [ | ||||
[ | [ | ||||
'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil', | |||||
'label' => '<span class="glyphicon glyphicon-home"></span> Retour à l\'accueil', | |||||
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']), | 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']), | ||||
] | ] | ||||
]; | ]; |
return [ | return [ | ||||
'access' => [ | 'access' => [ | ||||
'class' => AccessControl::class, | 'class' => AccessControl::class, | ||||
'only' => ['logout', 'signup'], | |||||
'only' => ['logout', 'signup', 'signup-producer'], | |||||
'rules' => [ | 'rules' => [ | ||||
[ | [ | ||||
'actions' => ['signup'], | 'actions' => ['signup'], | ||||
'allow' => true, | 'allow' => true, | ||||
'roles' => ['?'], | 'roles' => ['?'], | ||||
], | ], | ||||
[ | |||||
'actions' => ['signup-producer'], | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
], | |||||
[ | [ | ||||
'actions' => ['logout'], | 'actions' => ['logout'], | ||||
'allow' => true, | 'allow' => true, | ||||
]); | ]); | ||||
} | } | ||||
public function actionSignupProducer() | |||||
{ | |||||
$model = new SignupForm(); | |||||
$model->signup_producer_only = 'producer'; | |||||
$model->option_user_producer = 'producer'; | |||||
if ($model->load(Yii::$app->request->post())) { | |||||
$user = $model->signup($this->getUserCurrent()); | |||||
if($user) { | |||||
$this->redirect(['site/signup-confirm']); | |||||
} | |||||
} | |||||
return $this->render('signup_producer', [ | |||||
'model' => $model, | |||||
'dataProviderPrices' => $this->getDataProviderPrices(), | |||||
'paidFeaturesArray' => $this->getFeatureModule()->getRepository()->findPaidFeatures() | |||||
]); | |||||
} | |||||
public function actionSignupConfirm($idProducerRedirect = null) | public function actionSignupConfirm($idProducerRedirect = null) | ||||
{ | { | ||||
$producerModule = $this->getProducerModule(); | $producerModule = $this->getProducerModule(); |
*/ | */ | ||||
class SignupForm extends Model | class SignupForm extends Model | ||||
{ | { | ||||
public $signup_producer_only = false; | |||||
public $username; | public $username; | ||||
public $email; | public $email; | ||||
public $password; | public $password; | ||||
{ | { | ||||
return [ | return [ | ||||
['email', 'filter', 'filter' => 'trim'], | ['email', 'filter', 'filter' => 'trim'], | ||||
['email', 'required', 'message' => 'Champs obligatoire'], | |||||
['email', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { | |||||
return !$model->signup_producer_only; | |||||
}], | |||||
['email', 'email'], | ['email', 'email'], | ||||
['email', function ($attribute, $params) { | ['email', function ($attribute, $params) { | ||||
$email = $this->$attribute; | $email = $this->$attribute; | ||||
$this->addError($attribute, 'Cet email est déjà utilisé.'); | $this->addError($attribute, 'Cet email est déjà utilisé.'); | ||||
} | } | ||||
}], | }], | ||||
[['name', 'lastname', 'phone'], 'required', 'message' => 'Champs obligatoire'], | |||||
[['name', 'lastname', 'phone'], 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { | |||||
return !$model->signup_producer_only; | |||||
}], | |||||
[['name', 'lastname', 'phone', 'option_user_producer'], 'string', 'min' => 2, 'max' => 255], | [['name', 'lastname', 'phone', 'option_user_producer'], 'string', 'min' => 2, 'max' => 255], | ||||
['password', 'required', 'message' => 'Champs obligatoire'], | |||||
['password', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { | |||||
return !$model->signup_producer_only; | |||||
}], | |||||
['password', 'string', 'min' => 6, 'tooShort' => 'Votre mot de passe doit contenir au moins 6 caractères'], | ['password', 'string', 'min' => 6, 'tooShort' => 'Votre mot de passe doit contenir au moins 6 caractères'], | ||||
[['is_producer', 'newsletter'], 'boolean'], | [['is_producer', 'newsletter'], 'boolean'], | ||||
['cgv', 'boolean'], | ['cgv', 'boolean'], | ||||
}], | }], | ||||
['postcode', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ['postcode', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ||||
return $model->option_user_producer == 'producer'; | return $model->option_user_producer == 'producer'; | ||||
}, 'whenClient' => "function (attribute, value) { | |||||
return $('#option-producer').prop('checked') ; | |||||
}"], | |||||
}], | |||||
['id_tax_rate_default', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ['id_tax_rate_default', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ||||
return $model->option_user_producer == 'producer'; | return $model->option_user_producer == 'producer'; | ||||
}, 'whenClient' => "function (attribute, value) { | |||||
return $('#option-producer').prop('checked') ; | |||||
}"], | |||||
}], | |||||
['city', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ['city', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ||||
return $model->option_user_producer == 'producer'; | return $model->option_user_producer == 'producer'; | ||||
}, 'whenClient' => "function (attribute, value) { | |||||
return $('#option-producer').prop('checked') ; | |||||
}"], | |||||
}], | |||||
[['name_producer', 'type', 'siret', 'is_test'], 'string'], | [['name_producer', 'type', 'siret', 'is_test'], 'string'], | ||||
['name_producer', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ['name_producer', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ||||
return $model->option_user_producer == 'producer'; | return $model->option_user_producer == 'producer'; | ||||
}, 'whenClient' => "function (attribute, value) { | |||||
return $('#option-producer').prop('checked') ; | |||||
}"], | |||||
}], | |||||
['type', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ['type', 'required', 'message' => 'Champs obligatoire', 'when' => function ($model) { | ||||
return $model->option_user_producer == 'producer'; | return $model->option_user_producer == 'producer'; | ||||
}, 'whenClient' => "function (attribute, value) { | |||||
return $('#option-producer').prop('checked') ; | |||||
}"], | |||||
}], | |||||
['siret', function ($attribute, $params) { | ['siret', function ($attribute, $params) { | ||||
$siret = $this->$attribute; | $siret = $this->$attribute; | ||||
$siret = str_replace(' ', '', $siret); | $siret = str_replace(' ', '', $siret); | ||||
* | * | ||||
* @return User|null the saved model or null if saving fails | * @return User|null the saved model or null if saving fails | ||||
*/ | */ | ||||
public function signup() | |||||
public function signup($user = null) | |||||
{ | { | ||||
$userGroupModule = UserGroupModule::getInstance(); | $userGroupModule = UserGroupModule::getInstance(); | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
if ($this->validate()) { | if ($this->validate()) { | ||||
$user = $userModule->instanciateUser(User::TYPE_INDIVIDUAL); | |||||
$this->populateUser($user); | |||||
$sendEmailSignup = false; | |||||
if(!$user) { | |||||
$sendEmailSignup = true; | |||||
$user = $userModule->instanciateUser(User::TYPE_INDIVIDUAL); | |||||
$this->populateUser($user); | |||||
} | |||||
if ($this->isProducer()) { | if ($this->isProducer()) { | ||||
$producer = $this->processFormProducer($user); | $producer = $this->processFormProducer($user); | ||||
$producer = $producerModule->findOneProducerById($idProducer); | $producer = $producerModule->findOneProducerById($idProducer); | ||||
if ($user->save() && $producer) { | if ($user->save() && $producer) { | ||||
\Yii::$app->logic->setProducerContext($producer); | \Yii::$app->logic->setProducerContext($producer); | ||||
if(!$this->isProducer()) { | if(!$this->isProducer()) { | ||||
} | } | ||||
} | } | ||||
$producerModule->addUser($user, $producer, true, $this->newsletter); | $producerModule->addUser($user, $producer, true, $this->newsletter); | ||||
$userModule->sendEmailSignup($user, $producer); | |||||
if($sendEmailSignup) { | |||||
$userModule->sendEmailSignup($user, $producer); | |||||
} | |||||
return $user; | return $user; | ||||
} | } |
<?php | <?php | ||||
$userModule = $this->getUserModule(); | |||||
$producerManager = $this->getProducerModule()->getManager(); | $producerManager = $this->getProducerModule()->getManager(); | ||||
$producerSignupRemainingPlaces = $producerManager->getProducerSignupRemainingPlaces(); | $producerSignupRemainingPlaces = $producerManager->getProducerSignupRemainingPlaces(); | ||||
$userCurrent = $this->getUserCurrent(); | |||||
if (Yii::$app->user->isGuest): ?> | |||||
<?php if($producerManager->isProducerSignupOpen()): ?> | |||||
?> | |||||
<?php if($producerManager->isProducerSignupOpen()): ?> | |||||
<?php if(Yii::$app->user->isGuest || $userModule->getSolver()->isStatusUser($userCurrent)): ?> | |||||
<a class="btn btn-primary" | <a class="btn btn-primary" | ||||
href="<?= \Yii::$app->urlManagerFrontend->createUrl(['site/signup']); ?>"> | |||||
href="<?= Yii::$app->user->isGuest ? \Yii::$app->urlManagerFrontend->createUrl(['site/signup']) : \Yii::$app->urlManagerFrontend->createUrl(['site/signup-producer']); ?>"> | |||||
<span class="glyphicon glyphicon-user"></span> Je crée mon espace producteur | <span class="glyphicon glyphicon-user"></span> Je crée mon espace producteur | ||||
</a><br /> | </a><br /> | ||||
<?php if($producerManager->getMaximumNumberProducers()): ?> | <?php if($producerManager->getMaximumNumberProducers()): ?> | ||||
<strong><?= ($producerSignupRemainingPlaces); ?></strong> | <strong><?= ($producerSignupRemainingPlaces); ?></strong> | ||||
place<?php if($producerSignupRemainingPlaces > 1): ?>s<?php endif; ?> restante<?php if($producerSignupRemainingPlaces > 1): ?>s<?php endif; ?> | place<?php if($producerSignupRemainingPlaces > 1): ?>s<?php endif; ?> restante<?php if($producerSignupRemainingPlaces > 1): ?>s<?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php else: ?> | |||||
<div class="label label-warning label-producer-signup-closed"> | |||||
La plateforme n'accueille pas de nouveaux producteurs pour le moment | |||||
</div> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
<br /> | |||||
<br /> | |||||
<?php else: ?> | |||||
<div class="label label-warning label-producer-signup-closed"> | |||||
La plateforme n'accueille pas de nouveaux producteurs pour le moment | |||||
</div> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
<br /> | |||||
<br /> |
<p> | <p> | ||||
Si vous avez oublié votre mot de passe, vous pouvez le <?= Html::a('réinitialiser', ['site/request-password-reset']) ?>. | Si vous avez oublié votre mot de passe, vous pouvez le <?= Html::a('réinitialiser', ['site/request-password-reset']) ?>. | ||||
</p> | </p> | ||||
<div class="form-group"> | |||||
<div class="form-group form-buttons"> | |||||
<?= Html::submitButton('Connexion', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> | <?= Html::submitButton('Connexion', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> | ||||
</div> | </div> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> |
<?= Html::a('<span class="glyphicon glyphicon-star-empty"></span>', ['bookmark/add', 'idProducer' => $producer->id], ['class'=>'btn btn-default', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom', 'data-original-title' => 'Ajouter à ma liste de producteurs']) ; ?> | <?= Html::a('<span class="glyphicon glyphicon-star-empty"></span>', ['bookmark/add', 'idProducer' => $producer->id], ['class'=>'btn btn-default', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom', 'data-original-title' => 'Ajouter à ma liste de producteurs']) ; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="clr"></div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<?php endforeach; ?> | <?php endforeach; ?> |
]) ?> | ]) ?> | ||||
<?= $form->field($model, 'is_test')->hiddenInput() ?> | <?= $form->field($model, 'is_test')->hiddenInput() ?> | ||||
<div class="form-group" id="buttons-signup"> | |||||
<div class="form-group form-buttons" id="buttons-signup"> | |||||
<?= Html::submitButton("S'inscrire", ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?> | <?= Html::submitButton("S'inscrire", ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?> | ||||
</div> | </div> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> |
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
$this->setTitle('Inscription') ; | |||||
$this->setTitle('Inscription confirmée') ; | |||||
$this->setIcon('check'); | |||||
$this->setMeta('description', 'Inscrivez-vous afin de profiter des fonctionnalités de la plateforme.'); | $this->setMeta('description', 'Inscrivez-vous afin de profiter des fonctionnalités de la plateforme.'); | ||||
$this->params['breadcrumbs'][] = $this->title; | $this->params['breadcrumbs'][] = $this->title; | ||||
?> | ?> | ||||
<div class="site-signup-confirm"> | <div class="site-signup-confirm"> | ||||
<h1 class="title-system-order"><span class="glyphicon glyphicon-check"></span> Inscription confirmée</h1> | |||||
<div class="alert alert-success"> | <div class="alert alert-success"> | ||||
Votre inscription a bien été prise en compte. | Votre inscription a bien été prise en compte. | ||||
</div> | </div> |
<?php | |||||
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
use common\logic\Config\TaxRate\Model\TaxRate; | |||||
use yii\helpers\Html; | |||||
use yii\bootstrap\ActiveForm; | |||||
use yii\helpers\ArrayHelper; | |||||
$this->setTitle('Créer un espace producteur') ; | |||||
$this->setIcon('grain'); | |||||
$this->setMeta('description', 'Créer un espace producteur sur Opendistrib.'); | |||||
$this->params['breadcrumbs'][] = $this->title; | |||||
?> | |||||
<div class="site-signup"> | |||||
<div class="row"> | |||||
<div class="col-lg-5"> | |||||
<?php $form = ActiveForm::begin(['id' => 'form-signup','enableClientValidation'=> false]); ?> | |||||
<?= $form->field($model, 'name_producer') ?> | |||||
<?= $form->field($model, 'type')->textInput(['placeholder' => 'Boulangerie, brasserie, ferme ...']); ?> | |||||
<?= $form->field($model, 'postcode') ?> | |||||
<?= $form->field($model, 'city') ?> | |||||
<?= $form->field($model, 'id_tax_rate_default') | |||||
->dropDownList(ArrayHelper::map(TaxRate::find()->all(), 'id', function($model) { return $model->name; }), [ | |||||
'prompt' => '--', | |||||
]) | |||||
->label('TVA à appliquer par défaut'); ?> | |||||
<?= $form->field($model, 'cgv')->checkbox()->label('J\'accepte les <button type="button" class="btn btn-xs btn-default btn-modal-cgv" data-toggle="modal" data-target="#modal-cgv">conditions générales de service</button> et les <button type="button" class="btn btn-xs btn-default btn-modal-prices" data-toggle="modal" data-target="#modal-prices">conditions tarifaires</button>.') ?> | |||||
<?= $form->field($model, 'verifyCode')->widget(\yii\captcha\Captcha::className(), [ | |||||
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', | |||||
]) ?> | |||||
<?= $form->field($model, 'is_test')->hiddenInput() ?> | |||||
<div class="form-group" id="buttons-signup"> | |||||
<?= Html::submitButton("S'inscrire", ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<!-- CGV --> | |||||
<div class="modal fade" id="modal-cgv" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |||||
<div class="modal-dialog modal-lg" role="document"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |||||
<h4 class="modal-title" id="myModalLabel">Conditions générales de service</h4> | |||||
</div> | |||||
<div class="modal-body"> | |||||
<?= $this->render('_cgv_content.php'); ?> | |||||
</div> | |||||
<div class="modal-footer"> | |||||
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<!-- Tarifs --> | |||||
<div class="modal fade" id="modal-prices" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |||||
<div class="modal-dialog modal-lg" role="document"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |||||
<h4 class="modal-title" id="myModalLabel">Tarifs</h4> | |||||
</div> | |||||
<div class="modal-body"> | |||||
<?= $this->render('../site/_prices_producer', ['dataProviderPrices' => $dataProviderPrices, 'paidFeaturesArray' => $paidFeaturesArray]); ?> | |||||
</div> | |||||
<div class="modal-footer"> | |||||
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> |
color: #505050; | color: #505050; | ||||
font-family: 'Arial'; | font-family: 'Arial'; | ||||
background-attachment: fixed; | background-attachment: fixed; | ||||
//min-height: 100%; | |||||
margin: 0; | margin: 0; | ||||
padding: 0; | padding: 0; | ||||
background-color: #333; | background-color: #333; | ||||
//background-color: #F5DE83; | |||||
} | } | ||||
strong { | strong { | ||||
border: solid 1px $color1; | border: solid 1px $color1; | ||||
} | } | ||||
.form-buttons { | |||||
text-align: center | |||||
} | |||||
p { | p { | ||||
padding-bottom: 20px; | padding-bottom: 20px; | ||||
line-height: 21px; | line-height: 21px; |