'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'); | |||||
} | |||||
} | } |
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); | ||||
} | } | ||||
} | } |
$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'], |
$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> |
$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(); ?> |
<?= $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> |
<?= 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; ?> |
<?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() | |||||
{ | |||||
} | |||||
} |
<?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'); | |||||
} | |||||
} |
'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 | ||||
*/ | */ |
$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( |
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(); |
<?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; | |||||
} | |||||
} |
[['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'], |
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(), |
<?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(); | |||||
} | |||||
} |