use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Distribution\Distribution\Module\DistributionModule; | use common\logic\Distribution\Distribution\Module\DistributionModule; | ||||
use common\logic\User\User\Module\UserModule; | use common\logic\User\User\Module\UserModule; | ||||
use common\logic\User\UserGroup\Module\UserGroupModule; | |||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
\backend\assets\VuejsProducerUpdateAsset::register($this); | \backend\assets\VuejsProducerUpdateAsset::register($this); | ||||
$userModule = UserModule::getInstance(); | $userModule = UserModule::getInstance(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
$userGroupModule = UserGroupModule::getInstance(); | |||||
$distributionExportManager = DistributionModule::getInstance()->getExportManager(); | $distributionExportManager = DistributionModule::getInstance()->getExportManager(); | ||||
$userCurrent = GlobalParam::getCurrentUser(); | |||||
$this->setTitle('Paramètres'); | $this->setTitle('Paramètres'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
<script> | <script> | ||||
var appInitValues = { | var appInitValues = { | ||||
isAdmin: <?= (int) $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent) ?> | |||||
isAdmin: <?= (int)$userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent) ?> | |||||
}; | }; | ||||
</script> | </script> | ||||
<div id="nav-params"> | <div id="nav-params"> | ||||
<a v-for="section in sectionsArray" v-if="!section.isAdminSection || (section.isAdminSection && isAdmin)" | <a v-for="section in sectionsArray" v-if="!section.isAdminSection || (section.isAdminSection && isAdmin)" | ||||
:class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')" | |||||
@click="changeSection(section)" :href="'#'+section.name"> | |||||
:class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')" | |||||
@click="changeSection(section)" :href="'#'+section.name"> | |||||
{{ section.nameDisplay }} | {{ section.nameDisplay }} | ||||
</a> | </a> | ||||
</div> | </div> | ||||
Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | Producer::BEHAVIOR_HOME_POINT_SALE_DAY_LIST_INCOMING_DISTRIBUTIONS => 'Distributions à venir', | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'option_point_sale_wording') ?> | <?= $form->field($model, 'option_point_sale_wording') ?> | ||||
<h4>Groupes utilisateurs</h4> | |||||
<?= $form->field($model, 'id_user_group_default') | |||||
->dropDownList($userGroupModule->getRepository()->populateUserGroupDropdownList()); ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<h4>Divers</h4> | <h4>Divers</h4> | ||||
<?php | <?php | ||||
$choicesWeeksDistributionsActivatedInAdvanceArray = [null => '--']; | |||||
for($i = 1; $i < 13; $i++) { | |||||
$choicesWeeksDistributionsActivatedInAdvanceArray[$i] = $i.' semaine'.(($i > 1) ? 's' : ''); | |||||
} | |||||
$choicesWeeksDistributionsActivatedInAdvanceArray = [null => '--']; | |||||
for ($i = 1; $i < 13; $i++) { | |||||
$choicesWeeksDistributionsActivatedInAdvanceArray[$i] = $i . ' semaine' . (($i > 1) ? 's' : ''); | |||||
} | |||||
?> | ?> | ||||
<?= $form->field($model, 'option_weeks_distributions_activated_in_advance') | <?= $form->field($model, 'option_weeks_distributions_activated_in_advance') | ||||
->dropDownList($choicesWeeksDistributionsActivatedInAdvanceArray) | ->dropDownList($choicesWeeksDistributionsActivatedInAdvanceArray) | ||||
<div v-show="currentSection == 'exports'" class="panel panel-default"> | <div v-show="currentSection == 'exports'" class="panel panel-default"> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<h4>Exports affichés dans les distributions</h4> | |||||
<?= $distributionExportManager->getProducerFormCheckboxes($form, $model) ?> | |||||
<h4>Options exports</h4> | |||||
<?= $form->field($model, 'option_csv_separator') | |||||
->dropDownList([ | |||||
';' => 'Point-virgule (;)', | |||||
',' => 'Virgule (,)' | |||||
], []); ?> | |||||
<?= $form->field($model, 'option_export_display_product_reference') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_export_display_column_delivery_note') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_csv_export_all_products') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_csv_export_by_piece') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'export_shopping_cart_labels_number_per_column') | |||||
->dropDownList(Dropdown::numberChoices(1, 20)); ?> | |||||
<h4>Exports affichés dans les distributions</h4> | |||||
<?= $distributionExportManager->getProducerFormCheckboxes($form, $model) ?> | |||||
<h4>Options exports</h4> | |||||
<?= $form->field($model, 'option_csv_separator') | |||||
->dropDownList([ | |||||
';' => 'Point-virgule (;)', | |||||
',' => 'Virgule (,)' | |||||
], []); ?> | |||||
<?= $form->field($model, 'option_export_display_product_reference') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_export_display_column_delivery_note') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_csv_export_all_products') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'option_csv_export_by_piece') | |||||
->dropDownList(Dropdown::noYesChoices()); ?> | |||||
<?= $form->field($model, 'export_shopping_cart_labels_number_per_column') | |||||
->dropDownList(Dropdown::numberChoices(1, 20)); ?> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<?= $form->field($model, 'online_payment') | <?= $form->field($model, 'online_payment') | ||||
->dropDownList(Dropdown::noYesChoices()); ?> | ->dropDownList(Dropdown::noYesChoices()); ?> | ||||
<?= $form->field($model, 'option_online_payment_minimum_amount') | <?= $form->field($model, 'option_online_payment_minimum_amount') | ||||
->hint('Valeur par défaut si non défini : '.Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT.' €') | |||||
->hint('Valeur par défaut si non défini : ' . Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT . ' €') | |||||
->textInput(); ?> | ->textInput(); ?> | ||||
<?= $form->field($model, 'option_stripe_mode_test')->dropDownList(Dropdown::noYesChoices()); ?> | <?= $form->field($model, 'option_stripe_mode_test')->dropDownList(Dropdown::noYesChoices()); ?> | ||||
<?= $form->field($model, 'option_online_payment_type') | <?= $form->field($model, 'option_online_payment_type') | ||||
<?php $urlAboutPage = Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/about']); ?> | <?php $urlAboutPage = Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/about']); ?> | ||||
<?= $form->field($model, 'option_testimony') | <?= $form->field($model, 'option_testimony') | ||||
->textarea(['rows' => 7]) | ->textarea(['rows' => 7]) | ||||
->hint("Écrivez ici votre témoignage concernant l'utilisation du logiciel. Il sera publié sur la page <a href=\"".$urlAboutPage."\" target=\"_blanck\">À propos</a> du site.") ; ?> | |||||
->hint("Écrivez ici votre témoignage concernant l'utilisation du logiciel. Il sera publié sur la page <a href=\"" . $urlAboutPage . "\" target=\"_blanck\">À propos</a> du site."); ?> | |||||
<?= $form->field($model, 'option_time_saved') | <?= $form->field($model, 'option_time_saved') | ||||
->dropDownList([ | ->dropDownList([ | ||||
null => '--', | null => '--', | ||||
7 => '7 heures', | 7 => '7 heures', | ||||
8 => '8 heures', | 8 => '8 heures', | ||||
]) | ]) | ||||
->hint("Sélectionnez le temps que vous estimez gagner chaque semaine en utilisant ce logiciel. Cette donnée sera utilisée sur la page <a href=\"".$urlAboutPage."\" target=\"_blanck\">À propos</a> du site.") ; ?> | |||||
->hint("Sélectionnez le temps que vous estimez gagner chaque semaine en utilisant ce logiciel. Cette donnée sera utilisée sur la page <a href=\"" . $urlAboutPage . "\" target=\"_blanck\">À propos</a> du site."); ?> | |||||
<?= $form->field($model, 'option_display_message_new_opendistrib_version') | <?= $form->field($model, 'option_display_message_new_opendistrib_version') | ||||
->dropDownList(Dropdown::noYesChoices()); ?> | ->dropDownList(Dropdown::noYesChoices()); ?> | ||||
</div> | </div> |
use common\logic\Config\TaxRate\Model\TaxRate; | use common\logic\Config\TaxRate\Model\TaxRate; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\UserGroup\Model\UserGroup; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
use common\components\ActiveRecordCommon; | use common\components\ActiveRecordCommon; | ||||
use yii\web\UploadedFile; | use yii\web\UploadedFile; | ||||
'dolibarr_product_id', | 'dolibarr_product_id', | ||||
'option_weeks_distributions_activated_in_advance', | 'option_weeks_distributions_activated_in_advance', | ||||
'option_document_width_logo', | 'option_document_width_logo', | ||||
'export_shopping_cart_labels_number_per_column' | |||||
'export_shopping_cart_labels_number_per_column', | |||||
'id_user_group_default' | |||||
], | ], | ||||
'integer' | 'integer' | ||||
], | ], | ||||
'option_document_width_logo' => 'Largeur du logo dans les documents', | 'option_document_width_logo' => 'Largeur du logo dans les documents', | ||||
'export_shopping_cart_labels_number_per_column' => "Étiquettes (PDF) : nombre d'étiquettes par colonne", | 'export_shopping_cart_labels_number_per_column' => "Étiquettes (PDF) : nombre d'étiquettes par colonne", | ||||
'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | 'option_document_display_price_unit_reference' => "Afficher les prix au kilogramme", | ||||
'id_user_group_default' => "Groupe utilisateur par défaut attribué à l'inscription", | |||||
]; | ]; | ||||
} | } | ||||
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate); | $this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate); | ||||
} | } | ||||
public function getUserGroupDefault() | |||||
{ | |||||
return $this->hasOne(UserGroup::class, ['id' => 'id_user_group_default']); | |||||
} | |||||
public function populateUserGroupDefault(UserGroup $userGroup) | |||||
{ | |||||
$this->populateFieldObject('id_user_group_default', 'userGroupDefault', $userGroup); | |||||
} | |||||
// --- | // --- | ||||
public static function getBillingTypePopulateDropdown() | public static function getBillingTypePopulateDropdown() |
use common\logic\User\User\Event\UserCreateEvent; | use common\logic\User\User\Event\UserCreateEvent; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\User\Repository\UserRepository; | use common\logic\User\User\Repository\UserRepository; | ||||
use common\logic\User\UserGroup\Model\UserGroup; | |||||
use common\logic\User\UserProducer\Service\UserProducerBuilder; | use common\logic\User\UserProducer\Service\UserProducerBuilder; | ||||
use common\logic\User\UserUserGroup\Service\UserUserGroupBuilder; | |||||
class UserBuilder extends AbstractBuilder | class UserBuilder extends AbstractBuilder | ||||
{ | { | ||||
protected UserRepository $userRepository; | protected UserRepository $userRepository; | ||||
protected UserNotifier $userNotifier; | protected UserNotifier $userNotifier; | ||||
protected UserProducerBuilder $userProducerBuilder; | protected UserProducerBuilder $userProducerBuilder; | ||||
protected UserUserGroupBuilder $userUserGroupBuilder; | |||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
$this->userRepository = $this->loadService(UserRepository::class); | $this->userRepository = $this->loadService(UserRepository::class); | ||||
$this->userNotifier = $this->loadService(UserNotifier::class); | $this->userNotifier = $this->loadService(UserNotifier::class); | ||||
$this->userProducerBuilder = $this->loadService(UserProducerBuilder::class); | $this->userProducerBuilder = $this->loadService(UserProducerBuilder::class); | ||||
$this->userUserGroupBuilder = $this->loadService(UserUserGroupBuilder::class); | |||||
} | } | ||||
public function instanciateUser( | public function instanciateUser( | ||||
$user->id_producer = $producer->id; | $user->id_producer = $producer->id; | ||||
$this->update($user); | $this->update($user); | ||||
} | } | ||||
public function addUserGroup(User $user, UserGroup $userGroup) | |||||
{ | |||||
$this->userUserGroupBuilder->createUserUserGroup($user, $userGroup); | |||||
} | |||||
} | } |
public function createUserGroup(): UserGroup | public function createUserGroup(): UserGroup | ||||
{ | { | ||||
$userGroup = $this->instanciateUserGroup(); | $userGroup = $this->instanciateUserGroup(); | ||||
$this->saveCreate($userGroup); | |||||
$this->create($userGroup); | |||||
return $userGroup; | return $userGroup; | ||||
} | } |
namespace common\logic\User\UserUserGroup\Model; | namespace common\logic\User\UserUserGroup\Model; | ||||
use common\logic\PointSale\PointSale\Model\PointSale; | use common\logic\PointSale\PointSale\Model\PointSale; | ||||
use common\logic\User\User\Model\User; | |||||
use common\logic\User\UserGroup\Model\UserGroup; | use common\logic\User\UserGroup\Model\UserGroup; | ||||
use Yii; | use Yii; | ||||
use common\components\ActiveRecordCommon ; | use common\components\ActiveRecordCommon ; | ||||
{ | { | ||||
return $this->hasOne(UserGroup::class, ['id' => 'id_user_group']); | return $this->hasOne(UserGroup::class, ['id' => 'id_user_group']); | ||||
} | } | ||||
public function populateUserGroup(UserGroup $userGroup): void | |||||
{ | |||||
$this->populateFieldObject('id_user_group', 'userGroup', $userGroup); | |||||
} | |||||
public function getUser() | |||||
{ | |||||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||||
} | |||||
public function populateUser(User $user): void | |||||
{ | |||||
$this->populateFieldObject('id_user', 'user', $user); | |||||
} | |||||
} | } |
namespace common\logic\User\UserUserGroup\Service; | namespace common\logic\User\UserUserGroup\Service; | ||||
use common\logic\AbstractBuilder; | use common\logic\AbstractBuilder; | ||||
use common\logic\User\User\Model\User; | |||||
use common\logic\User\UserGroup\Model\UserGroup; | |||||
use common\logic\User\UserUserGroup\Model\UserUserGroup; | use common\logic\User\UserUserGroup\Model\UserUserGroup; | ||||
class UserUserGroupBuilder extends AbstractBuilder | class UserUserGroupBuilder extends AbstractBuilder | ||||
{ | { | ||||
public function instanciateUserUserGroup(): UserUserGroup | |||||
public function instanciateUserUserGroup(User $user, UserGroup $userGroup): UserUserGroup | |||||
{ | { | ||||
$userUserGroup = new UserUserGroup(); | $userUserGroup = new UserUserGroup(); | ||||
$userUserGroup->populateUser($user); | |||||
$userUserGroup->populateUserGroup($userGroup); | |||||
return $userUserGroup; | return $userUserGroup; | ||||
} | } | ||||
public function createUserUserGroup(): UserUserGroup | |||||
public function createUserUserGroup(User $user, UserGroup $userGroup): UserUserGroup | |||||
{ | { | ||||
$userUserGroup = $this->instanciateUserUserGroup(); | |||||
$this->saveCreate($userUserGroup); | |||||
$userUserGroup = $this->instanciateUserUserGroup($user, $userGroup); | |||||
$this->create($userUserGroup); | |||||
return $userUserGroup; | return $userUserGroup; | ||||
} | } |
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m231109_090026_add_column_producer_id_user_group_default | |||||
*/ | |||||
class m231109_090026_add_column_producer_id_user_group_default extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'id_user_group_default', Schema::TYPE_INTEGER); | |||||
$this->addForeignKey('user_group_default_fk', 'producer', 'id_user_group_default', 'user_group', 'id'); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'id_user_group_default'); | |||||
$this->dropForeignKey('user_group_default_fk', 'producer'); | |||||
} | |||||
} |
use common\logic\Producer\Producer\Module\ProducerModule; | use common\logic\Producer\Producer\Module\ProducerModule; | ||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\User\Module\UserModule; | use common\logic\User\User\Module\UserModule; | ||||
use common\logic\User\UserGroup\Module\UserGroupModule; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
/** | /** | ||||
*/ | */ | ||||
public function signup() | public function signup() | ||||
{ | { | ||||
$userModule = \Yii::$app->logic->getUserModule(); | |||||
$userGroupModule = UserGroupModule::getInstance(); | |||||
$userModule = UserModule::getInstance(); | |||||
$producerModule = \Yii::$app->logic->getProducerModule(); | $producerModule = \Yii::$app->logic->getProducerModule(); | ||||
if ($this->validate()) { | if ($this->validate()) { | ||||
\Yii::$app->logic->setProducerContext($producer); | \Yii::$app->logic->setProducerContext($producer); | ||||
if(!$this->isProducer()) { | |||||
if($producer->id_user_group_default) { | |||||
$userGroupDefault = $userGroupModule->getRepository()->findOneUserGroupById($producer->id_user_group_default); | |||||
$userModule->getBuilder()->addUserGroup($user, $userGroupDefault); | |||||
} | |||||
} | |||||
$producerModule->addUser($user, $producer, true, $this->newsletter); | $producerModule->addUser($user, $producer, true, $this->newsletter); | ||||
$userModule->sendEmailSignup($user, $producer); | $userModule->sendEmailSignup($user, $producer); | ||||