@@ -92,4 +92,12 @@ class DevelopmentController extends BackendController | |||
'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'); | |||
} | |||
} |
@@ -177,6 +177,12 @@ class ProducerController extends BackendController | |||
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() | |||
{ | |||
$producerCurrent = $this->getProducerCurrent(); | |||
@@ -193,5 +199,4 @@ class ProducerController extends BackendController | |||
$referer = strtok(Yii::$app->request->referrer, "?"); | |||
return $this->redirect($referer); | |||
} | |||
} |
@@ -22,7 +22,7 @@ class AdminSettingsForm extends Model | |||
$rulesArray = []; | |||
$typesArray = [ | |||
'string' => ['string', 'text'], | |||
'date' => ['date'], | |||
'date' => ['safe'], | |||
'boolean' => ['boolean'], | |||
'integer' => ['integer'], | |||
'double' => ['double', 'float'], |
@@ -47,6 +47,8 @@ use common\helpers\GlobalParam; | |||
$this->setTitle('Développement'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
$producer = GlobalParam::getCurrentProducer(); | |||
?> | |||
<div class="development-index"> | |||
@@ -69,6 +71,22 @@ $this->addBreadcrumb($this->getTitle()); | |||
</div> | |||
</div> | |||
<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 class="panel-heading"> | |||
<h3 class="panel-title">Participer</h3> |
@@ -44,6 +44,7 @@ use common\helpers\GlobalParam; | |||
$producerModule = $this->getProducerModule(); | |||
$adminSettingBag = $this->getSettingModule()->getAdminSettingBag(); | |||
$sharedPointSaleModule = $this->getSharedPointSaleModule(); | |||
$producer = GlobalParam::getCurrentProducer(); | |||
?> | |||
<div class="content-wrapper"> | |||
@@ -83,11 +84,12 @@ $sharedPointSaleModule = $this->getSharedPointSaleModule(); | |||
<section class="content"> | |||
<?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'), | |||
'title' => $adminSettingBag->get('adminAlertMessageTitle'), | |||
'icon' => $adminSettingBag->get('adminAlertMessageIcon'), | |||
'message' => $adminSettingBag->get('adminAlertMessage'), | |||
'buttonClose' => true | |||
]) ?> | |||
<?php $producer = GlobalParam::getCurrentProducer(); ?> |
@@ -65,6 +65,7 @@ use yii\widgets\ActiveForm; | |||
<?= $form->field($model, 'code')->label('Code d\'accès') ?> | |||
<?= $form->field($model, 'admin_comment')->textarea(['rows' => 7]) ?> | |||
<?= $form->field($model, 'is_new')->checkbox() ?> | |||
<?= $form->field($model, 'latest_version_opendistrib') ?> | |||
</div> | |||
</div> | |||
</div> |
@@ -27,5 +27,8 @@ use yii\helpers\Html; | |||
<?= nl2br($message); ?> | |||
<?php endif; ?> | |||
</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> | |||
<?php endif; ?> |
@@ -0,0 +1,26 @@ | |||
<?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() | |||
{ | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
<?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'); | |||
} | |||
} |
@@ -359,7 +359,8 @@ class Producer extends ActiveRecordCommon | |||
'option_dashboard_date_start', | |||
'option_dashboard_date_end', | |||
'option_leave_period_start', | |||
'option_leave_period_end' | |||
'option_leave_period_end', | |||
'alert_message_read_at' | |||
], 'safe'], | |||
[ | |||
['option_leave_period_start', 'option_leave_period_end'], | |||
@@ -599,6 +600,21 @@ class Producer extends ActiveRecordCommon | |||
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 | |||
*/ |
@@ -17,6 +17,12 @@ class ProducerManager extends AbstractService implements ManagerInterface | |||
$this->producerRepository = $this->loadService(ProducerRepository::class); | |||
} | |||
public function readAlertMessage(Producer $producer) | |||
{ | |||
$producer->setAlertMessageReadAt(new \DateTime()); | |||
return $producer->save(); | |||
} | |||
public function sendEmailNewProducer(Producer $producer): void | |||
{ | |||
\Yii::$app->mailerService->sendAdmin( |
@@ -14,6 +14,7 @@ class ProducerModule extends AbstractModule | |||
ProducerRepository::class, | |||
ProducerBuilder::class, | |||
ProducerNotifier::class, | |||
ProducerResolver::class, | |||
ProducerManager::class, | |||
ProducerPageSizer::class, | |||
DolibarrProducerUtils::class, | |||
@@ -46,6 +47,11 @@ class ProducerModule extends AbstractModule | |||
return ProducerNotifier::getInstance(); | |||
} | |||
public function getResolver(): ProducerResolver | |||
{ | |||
return ProducerResolver::getInstance(); | |||
} | |||
public function getUtils(): ProducerManager | |||
{ | |||
return ProducerManager::getInstance(); |
@@ -0,0 +1,25 @@ | |||
<?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; | |||
} | |||
} |
@@ -62,7 +62,7 @@ class Setting extends ActiveRecordCommon | |||
[['id_producer'], 'exist', 'skipOnError' => true, 'targetClass' => Producer::class, 'targetAttribute' => ['id_producer' => 'id']], | |||
[['name', 'string', 'text'], 'string'], | |||
[['name','string'], 'string', 'max' => 255], | |||
[['date'], 'date', 'format' => 'php:Y-m-d'], | |||
[['date'], 'safe'], | |||
[['integer'], 'integer'], | |||
[['float', 'double'], 'number'], | |||
[['boolean'], 'boolean'], |
@@ -7,6 +7,7 @@ use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageIconSettin | |||
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageSetting; | |||
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminAlertMessageTitleSetting; | |||
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\AdminSupportAlertMessageIconSetting; | |||
use domain\Setting\SettingDetails\Admin\AlertMessage\AdminSupportAlertMessageSetting; | |||
@@ -51,6 +52,7 @@ class AdminSettingDefinition extends SettingDefinition | |||
new AdminAlertMessageIconSetting(), | |||
new AdminAlertMessageTitleSetting(), | |||
new AdminAlertMessageSetting(), | |||
new AdminAlertMessageUpdatedAtSetting(), | |||
], | |||
self::SUBSECTION_ALERT_MESSAGE_SUPPORT => [ | |||
new AdminSupportAlertMessageDisplaySetting(), |
@@ -0,0 +1,17 @@ | |||
<?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(); | |||
} | |||
} |