Browse Source

Merge branch 'develop'

master
Guillaume Bourgeois 5 months ago
parent
commit
d9b0962e3e
16 changed files with 166 additions and 5 deletions
  1. +8
    -0
      backend/controllers/DevelopmentController.php
  2. +6
    -1
      backend/controllers/ProducerController.php
  3. +1
    -1
      backend/forms/AdminSettingsForm.php
  4. +18
    -0
      backend/views/development/index.php
  5. +3
    -1
      backend/views/layouts/content.php
  6. +1
    -0
      backend/views/producer-admin/_form.php
  7. +3
    -0
      common/views/alert_message.php
  8. +26
    -0
      console/migrations/m240617_090650_alter_column_producer_option_display_message_new_opendistrib_version.php
  9. +26
    -0
      console/migrations/m240617_092952_add_colmun_producer_alert_message_read_at.php
  10. +17
    -1
      domain/Producer/Producer/Producer.php
  11. +6
    -0
      domain/Producer/Producer/ProducerManager.php
  12. +6
    -0
      domain/Producer/Producer/ProducerModule.php
  13. +25
    -0
      domain/Producer/Producer/ProducerResolver.php
  14. +1
    -1
      domain/Setting/Setting.php
  15. +2
    -0
      domain/Setting/SettingDetails/Admin/AdminSettingDefinition.php
  16. +17
    -0
      domain/Setting/SettingDetails/Admin/AlertMessage/AdminAlertMessageUpdatedAtSetting.php

+ 8
- 0
backend/controllers/DevelopmentController.php View File

'versionsArray' => $versionsRenderArray 'versionsArray' => $versionsRenderArray
]); ]);
} }

public function actionUpdateDisplayMessageNewSoukeVersion(int $displayMessage)
{
$producer = $this->getProducerCurrent();
$producer->option_display_message_new_opendistrib_version = (bool) $displayMessage;
$producer->save();
return $this->redirect('index');
}
} }

+ 6
- 1
backend/controllers/ProducerController.php View File

return $this->redirect(\Yii::$app->request->referrer); return $this->redirect(\Yii::$app->request->referrer);
} }


public function actionUpdateAlertMessageReadAt()
{
$this->getProducerModule()->getManager()->readAlertMessage($this->getProducerCurrent());
return $this->redirect(\Yii::$app->request->referrer);
}

public function actionPagesize() public function actionPagesize()
{ {
$producerCurrent = $this->getProducerCurrent(); $producerCurrent = $this->getProducerCurrent();
$referer = strtok(Yii::$app->request->referrer, "?"); $referer = strtok(Yii::$app->request->referrer, "?");
return $this->redirect($referer); return $this->redirect($referer);
} }

} }

+ 1
- 1
backend/forms/AdminSettingsForm.php View File

$rulesArray = []; $rulesArray = [];
$typesArray = [ $typesArray = [
'string' => ['string', 'text'], 'string' => ['string', 'text'],
'date' => ['date'],
'date' => ['safe'],
'boolean' => ['boolean'], 'boolean' => ['boolean'],
'integer' => ['integer'], 'integer' => ['integer'],
'double' => ['double', 'float'], 'double' => ['double', 'float'],

+ 18
- 0
backend/views/development/index.php View File

$this->setTitle('Développement'); $this->setTitle('Développement');
$this->addBreadcrumb($this->getTitle()); $this->addBreadcrumb($this->getTitle());


$producer = GlobalParam::getCurrentProducer();

?> ?>


<div class="development-index"> <div class="development-index">
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">

<div id="panel-participate" class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Être prévenu des mises à jour</h3>
</div>
<div class="panel-body">
<p>
Afficher un message d'alerte quand une nouvelle version de <em>Souke</em> est mise en ligne.
</p>
<div class="btn-group" role="group">
<a href="<?= Yii::$app->urlManager->createUrl(['development/update-display-message-new-souke-version', 'displayMessage' => 1]) ?>" class="btn <?= $producer->option_display_message_new_opendistrib_version ? 'btn-success' : 'btn-default' ?>">Oui</a>
<a href="<?= Yii::$app->urlManager->createUrl(['development/update-display-message-new-souke-version', 'displayMessage' => 0]) ?>" class="btn <?= $producer->option_display_message_new_opendistrib_version ? 'btn-default' : 'btn-danger' ?>">Non</a>
</div>
</div>
</div>

<div id="panel-participate" class="panel panel-default"> <div id="panel-participate" class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">Participer</h3> <h3 class="panel-title">Participer</h3>

+ 3
- 1
backend/views/layouts/content.php View File

$producerModule = $this->getProducerModule(); $producerModule = $this->getProducerModule();
$adminSettingBag = $this->getSettingModule()->getAdminSettingBag(); $adminSettingBag = $this->getSettingModule()->getAdminSettingBag();
$sharedPointSaleModule = $this->getSharedPointSaleModule(); $sharedPointSaleModule = $this->getSharedPointSaleModule();
$producer = GlobalParam::getCurrentProducer();


?> ?>
<div class="content-wrapper"> <div class="content-wrapper">
<section class="content"> <section class="content">


<?php echo $this->renderFile('@common/views/alert_message.php', [ <?php echo $this->renderFile('@common/views/alert_message.php', [
'display' => $adminSettingBag->get('adminAlertMessageDisplay'),
'display' => $adminSettingBag->get('adminAlertMessageDisplay') && $producerModule->getResolver()->isAlertMessageDisplayed($producer),
'type' => $adminSettingBag->get('adminAlertMessageType'), 'type' => $adminSettingBag->get('adminAlertMessageType'),
'title' => $adminSettingBag->get('adminAlertMessageTitle'), 'title' => $adminSettingBag->get('adminAlertMessageTitle'),
'icon' => $adminSettingBag->get('adminAlertMessageIcon'), 'icon' => $adminSettingBag->get('adminAlertMessageIcon'),
'message' => $adminSettingBag->get('adminAlertMessage'), 'message' => $adminSettingBag->get('adminAlertMessage'),
'buttonClose' => true
]) ?> ]) ?>


<?php $producer = GlobalParam::getCurrentProducer(); ?> <?php $producer = GlobalParam::getCurrentProducer(); ?>

+ 1
- 0
backend/views/producer-admin/_form.php View File

<?= $form->field($model, 'code')->label('Code d\'accès') ?> <?= $form->field($model, 'code')->label('Code d\'accès') ?>
<?= $form->field($model, 'admin_comment')->textarea(['rows' => 7]) ?> <?= $form->field($model, 'admin_comment')->textarea(['rows' => 7]) ?>
<?= $form->field($model, 'is_new')->checkbox() ?> <?= $form->field($model, 'is_new')->checkbox() ?>
<?= $form->field($model, 'latest_version_opendistrib') ?>
</div> </div>
</div> </div>
</div> </div>

+ 3
- 0
common/views/alert_message.php View File

<?= nl2br($message); ?> <?= nl2br($message); ?>
<?php endif; ?> <?php endif; ?>
</p> </p>
<?php if(isset($buttonClose) && $buttonClose): ?>
<a href="<?= Yii::$app->urlManager->createUrl(['producer/update-alert-message-read-at']) ?>" class="close"><span aria-hidden="true">×</span></a>
<?php endif; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>

+ 26
- 0
console/migrations/m240617_090650_alter_column_producer_option_display_message_new_opendistrib_version.php View File

<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m240617_090650_alter_column_producer_option_display_message_new_opendistrib_version
*/
class m240617_090650_alter_column_producer_option_display_message_new_opendistrib_version extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->alterColumn('producer', 'option_display_message_new_opendistrib_version', Schema::TYPE_BOOLEAN.' DEFAULT 1');
}

/**
* {@inheritdoc}
*/
public function safeDown()
{

}
}

+ 26
- 0
console/migrations/m240617_092952_add_colmun_producer_alert_message_read_at.php View File

<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m240617_092952_add_colmun_producer_alert_message_read_at
*/
class m240617_092952_add_colmun_producer_alert_message_read_at extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('producer', 'alert_message_read_at', Schema::TYPE_DATETIME);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('producer', 'alert_message_read_at');
}
}

+ 17
- 1
domain/Producer/Producer/Producer.php View File

'option_dashboard_date_start', 'option_dashboard_date_start',
'option_dashboard_date_end', 'option_dashboard_date_end',
'option_leave_period_start', 'option_leave_period_start',
'option_leave_period_end'
'option_leave_period_end',
'alert_message_read_at'
], 'safe'], ], 'safe'],
[ [
['option_leave_period_start', 'option_leave_period_end'], ['option_leave_period_start', 'option_leave_period_end'],
return $this; return $this;
} }


public function getAlertMessageReadAt(): ?\DateTime
{
if($this->alert_message_read_at) {
return new \DateTime($this->alert_message_read_at);
}

return null;
}

public function setAlertMessageReadAt(\DateTime $alertMessageReadAt): self
{
$this->alert_message_read_at = $alertMessageReadAt->format('Y-m-d H:i:s');
return $this;
}

/* /*
* Relations * Relations
*/ */

+ 6
- 0
domain/Producer/Producer/ProducerManager.php View File

$this->producerRepository = $this->loadService(ProducerRepository::class); $this->producerRepository = $this->loadService(ProducerRepository::class);
} }


public function readAlertMessage(Producer $producer)
{
$producer->setAlertMessageReadAt(new \DateTime());
return $producer->save();
}

public function sendEmailNewProducer(Producer $producer): void public function sendEmailNewProducer(Producer $producer): void
{ {
\Yii::$app->mailerService->sendAdmin( \Yii::$app->mailerService->sendAdmin(

+ 6
- 0
domain/Producer/Producer/ProducerModule.php View File

ProducerRepository::class, ProducerRepository::class,
ProducerBuilder::class, ProducerBuilder::class,
ProducerNotifier::class, ProducerNotifier::class,
ProducerResolver::class,
ProducerManager::class, ProducerManager::class,
ProducerPageSizer::class, ProducerPageSizer::class,
DolibarrProducerUtils::class, DolibarrProducerUtils::class,
return ProducerNotifier::getInstance(); return ProducerNotifier::getInstance();
} }


public function getResolver(): ProducerResolver
{
return ProducerResolver::getInstance();
}

public function getUtils(): ProducerManager public function getUtils(): ProducerManager
{ {
return ProducerManager::getInstance(); return ProducerManager::getInstance();

+ 25
- 0
domain/Producer/Producer/ProducerResolver.php View File

<?php

namespace domain\Producer\Producer;

use domain\_\AbstractResolver;
use domain\Setting\AdminSettingBag;

class ProducerResolver extends AbstractResolver
{
public function isAlertMessageDisplayed(Producer $producer): bool
{
// @TODO : modifier le chargement de cette classe quand la hiérarchie des services sera revue
$alertMessageUpdatedAt = AdminSettingBag::getInstance()->get('adminAlertMessageUpdatedAt');
$alertMessageReadAt = $producer->getAlertMessageReadAt();

if($alertMessageUpdatedAt) {
$alertMessageUpdatedAt = new \DateTime($alertMessageUpdatedAt);
if($alertMessageReadAt && $alertMessageReadAt >= $alertMessageUpdatedAt) {
return false;
}
}

return true;
}
}

+ 1
- 1
domain/Setting/Setting.php View File

[['id_producer'], 'exist', 'skipOnError' => true, 'targetClass' => Producer::class, 'targetAttribute' => ['id_producer' => 'id']], [['id_producer'], 'exist', 'skipOnError' => true, 'targetClass' => Producer::class, 'targetAttribute' => ['id_producer' => 'id']],
[['name', 'string', 'text'], 'string'], [['name', 'string', 'text'], 'string'],
[['name','string'], 'string', 'max' => 255], [['name','string'], 'string', 'max' => 255],
[['date'], 'date', 'format' => 'php:Y-m-d'],
[['date'], 'safe'],
[['integer'], 'integer'], [['integer'], 'integer'],
[['float', 'double'], 'number'], [['float', 'double'], 'number'],
[['boolean'], 'boolean'], [['boolean'], 'boolean'],

+ 2
- 0
domain/Setting/SettingDetails/Admin/AdminSettingDefinition.php View File

use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageSetting; use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageSetting;
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTitleSetting; use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTitleSetting;
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTypeSetting; use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTypeSetting;
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageUpdatedAtSetting;
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageDisplaySetting; use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageDisplaySetting;
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageIconSetting; use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageIconSetting;
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageSetting; use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageSetting;
new AdminAlertMessageIconSetting(), new AdminAlertMessageIconSetting(),
new AdminAlertMessageTitleSetting(), new AdminAlertMessageTitleSetting(),
new AdminAlertMessageSetting(), new AdminAlertMessageSetting(),
new AdminAlertMessageUpdatedAtSetting(),
], ],
self::SUBSECTION_ALERT_MESSAGE_SUPPORT => [ self::SUBSECTION_ALERT_MESSAGE_SUPPORT => [
new AdminSupportAlertMessageDisplaySetting(), new AdminSupportAlertMessageDisplaySetting(),

+ 17
- 0
domain/Setting/SettingDetails/Admin/AlertMessage/AdminAlertMessageUpdatedAtSetting.php View File

<?php

namespace domain\Setting\SettingDetails\Admin\AlertMessage;

use domain\Setting\SettingDetails\AbstractSettingDetail;

class AdminAlertMessageUpdatedAtSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('adminAlertMessageUpdatedAt')
->setLabel("Date de mise à jour")
->setTypeString()
->setFormTypeInput();
}
}

Loading…
Cancel
Save