Browse Source

Forum

feature/souke
Guillaume Bourgeois 10 months ago
parent
commit
6bc483f3cc
9 changed files with 173 additions and 77 deletions
  1. +2
    -1
      backend/controllers/DashboardController.php
  2. +106
    -66
      backend/views/dashboard/index.php
  3. +10
    -0
      backend/views/support/index.php
  4. +6
    -2
      common/components/AbstractApi.php
  5. +11
    -0
      common/components/ForumFlarumClient.php
  6. +11
    -6
      common/config/main.php
  7. +4
    -2
      common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php
  8. +17
    -0
      common/logic/Setting/SettingDetails/Admin/General/ForumFlarumUrlAdminSetting.php
  9. +6
    -0
      frontend/views/layouts/main.php

+ 2
- 1
backend/controllers/DashboardController.php View File

'pointsSaleCount' => $this->getPointSaleModule()->getRepository()->countPointSales(), 'pointsSaleCount' => $this->getPointSaleModule()->getRepository()->countPointSales(),
'distributionsArray' => $this->getDistributionModule()->getRepository()->findDistributionsDashboard(), 'distributionsArray' => $this->getDistributionModule()->getRepository()->findDistributionsDashboard(),
'ordersArray' => $this->getOrderModule()->getRepository()->findOrdersDashboard(), 'ordersArray' => $this->getOrderModule()->getRepository()->findOrdersDashboard(),
'subscriptionsLatestAddedArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsLatestAdded()
'subscriptionsLatestAddedArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsLatestAdded(),
'forumDiscussionsArray' => \Yii::$app->forumFlarumClient->getLastDiscussions()
]); ]);
} }
} }

+ 106
- 66
backend/views/dashboard/index.php View File

use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Module\OrderModule; use common\logic\Order\Order\Module\OrderModule;
use common\logic\Producer\Producer\Module\ProducerModule; use common\logic\Producer\Producer\Module\ProducerModule;
use common\logic\Setting\SettingModule;
use common\logic\Subscription\Subscription\Module\SubscriptionModule; use common\logic\Subscription\Subscription\Module\SubscriptionModule;
use common\logic\User\User\Module\UserModule; use common\logic\User\User\Module\UserModule;
use yii\helpers\Html ; use yii\helpers\Html ;
$orderModule = OrderModule::getInstance(); $orderModule = OrderModule::getInstance();
$subscriptionModule = SubscriptionModule::getInstance(); $subscriptionModule = SubscriptionModule::getInstance();
$producerModule = ProducerModule::getInstance(); $producerModule = ProducerModule::getInstance();
$settingModule = SettingModule::getInstance();
$adminSettingBag = $settingModule->getAdminSettingBag();


$this->setTitle('Tableau de bord'); $this->setTitle('Tableau de bord');


?> ?>
<div class="dashboard-index"> <div class="dashboard-index">


<?php if(Yii::$app->request->get('error_products_points_sale')): ?>
<div class="alert alert-warning">
Vous devez ajouter <?php if(!$productsCount): ?> des produits<?php endif; ?>
<?php if(!$productsCount && !$pointsSaleCount): ?> et<?php endif; ?>
<?php if(!$pointsSaleCount): ?> un ou des points de vente <?php endif; ?>
avant d'effectuer cette action.
</div>
<?php endif; ?>
<div <?php if($adminSettingBag->get('forumFlarumUrl')): ?>class="col-md-8"<?php endif; ?>>
<?php if(Yii::$app->request->get('error_products_points_sale')): ?>
<div class="alert alert-warning">
Vous devez ajouter <?php if(!$productsCount): ?> des produits<?php endif; ?>
<?php if(!$productsCount && !$pointsSaleCount): ?> et<?php endif; ?>
<?php if(!$pointsSaleCount): ?> un ou des points de vente <?php endif; ?>
avant d'effectuer cette action.
</div>
<?php endif; ?>


<?php if(!$productsCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des produits', ['product/create'], ['class' => 'btn btn-default']); ?></span>
<?php if(!$productsCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des produits', ['product/create'], ['class' => 'btn btn-default']); ?></span>
</div>
</div> </div>
</div>
<?php endif; ?>
<?php endif; ?>


<?php if(!$pointsSaleCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des points de vente', ['point-sale/create'], ['class' => 'btn btn-default']); ?></span>
<?php if(!$pointsSaleCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des points de vente', ['point-sale/create'], ['class' => 'btn btn-default']); ?></span>
</div>
</div> </div>
</div>
<?php endif; ?>
<?php endif; ?>


<?php if($productsCount && $pointsSaleCount && !count($distributionsArray)): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des jours de distribution', ['distribution/index'], ['class' => 'btn btn-default']); ?></span>
<?php if($productsCount && $pointsSaleCount && !count($distributionsArray)): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des jours de distribution', ['distribution/index'], ['class' => 'btn btn-default']); ?></span>
</div>
</div>
<?php endif; ?>

<?php if(count($distributionsArray)): ?>
<div id="distributions">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Prochaines distributions
</h3>
</div>
<div class="panel-body">
<!-- distributions -->
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-6 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
</span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['distribution/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?>
<?php
$exportsEnabledArray = $distributionModule->getExportManager()->getAllEnabled();
foreach($exportsEnabledArray as $name => $export) {
echo Html::a('<span class="fa fa-download"></span>', ['distribution/export', 'name' => $name, 'date' => $distribution->date], ['class' => 'btn btn-default', 'title' => $export[0]]).' ';
}
?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div> </div>
</div> </div>
<?php endif; ?>
<?php endif; ?>
</div>


<?php if(count($distributionsArray)): ?>
<div id="distributions">
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-4">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">
Prochaines distributions
</h3>
<h3 class="panel-title">
Derniers sujets sur le forum
</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<!-- distributions -->
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
</span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['distribution/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?>
<?php
$exportsEnabledArray = $distributionModule->getExportManager()->getAllEnabled();
foreach($exportsEnabledArray as $name => $export) {
echo Html::a('<span class="fa fa-download"></span>', ['distribution/export', 'name' => $name, 'date' => $distribution->date], ['class' => 'btn btn-default', 'title' => $export[0]]).' ';
}
?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php //echo print_r($forumDiscussionsArray); ?>
<?php if($forumDiscussionsArray && count($forumDiscussionsArray['data'])): ?>
<table class="table">
<?php $forumDiscussionsLimitedArray = array_slice($forumDiscussionsArray['data'], 0, min(3, count($forumDiscussionsArray['data']))); ?>
<?php foreach($forumDiscussionsLimitedArray as $forumDiscussion): ?>
<tr>
<?php //echo print_r($forumDiscussion); ?>
<td><?= $forumDiscussion['attributes']['title']; ?></td>
<td><?= date('d/m à H:i', strtotime($forumDiscussion['attributes']['lastPostedAt'])); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>Aucun sujet sur le forum.</p>
<?php endif; ?>
<p>
<a href="<?= $settingModule->getAdminSettingBag()->get('forumFlarumUrl'); ?>" class="btn btn-default">
<span class="fa fa-comments"></span>
Consulter le forum
</a>
</p>
</div> </div>
</div> </div>
</div> </div>

+ 10
- 0
backend/views/support/index.php View File

</div> </div>
</div> </div>
</div> </div>
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<div class="col-md-6 col-left">
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-users"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br/><?= Html::a("Ouvrir une discussion sur le forum", $adminSettingBag->get('forumFlarumUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?></span>
</div>
</div>
</div>
<?php endif; ?>
</div> </div>
<div class="clr"></div> <div class="clr"></div>
<?php endif; ?> <?php endif; ?>

+ 6
- 2
common/components/AbstractApi.php View File

public string $url; public string $url;
public array $auth; public array $auth;


public function __construct(string $url, array $auth)
public function __construct(string $url, array $auth = [])
{ {
$this->url = $url; $this->url = $url;
$this->auth = $auth; $this->auth = $auth;
private function getClient() private function getClient()
{ {
$curl = new Curl(); $curl = new Curl();
$curl->setHeader($this->auth[0], $this->auth[1]);

if(count($this->auth)) {
$curl->setHeader($this->auth[0], $this->auth[1]);
}

return $curl; return $curl;
} }



+ 11
- 0
common/components/ForumFlarumClient.php View File

<?php

namespace common\components;

class ForumFlarumClient extends AbstractApi
{
public function getLastDiscussions()
{
return $this->get('discussions', ['offset' => 1]);
}
}

+ 11
- 6
common/config/main.php View File



use common\components\BusinessLogic; use common\components\BusinessLogic;
use common\components\DolibarrApi; use common\components\DolibarrApi;
use common\components\ForumFlarumClient;
use common\logic\Distribution\Distribution\Model\Distribution; use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Document\DeliveryNote\Model\DeliveryNote; use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Order\Order\Model\Order; use common\logic\Order\Order\Model\Order;
'alwaysdataClient' => [ 'alwaysdataClient' => [
'class' => 'common\components\AlwaysdataClient' 'class' => 'common\components\AlwaysdataClient'
], ],
'forumFlarumClient' => function() {

return new ForumFlarumClient(Yii::$app->logic->getSettingModule()->getAdminSettingBag()->get('forumFlarumUrl').'api/');
},
'dolibarrApi' => function() {
return new DolibarrApi(
Yii::$app->parameterBag->get('dolibarrApiUrl'),
['DOLAPIKEY', \Yii::$app->parameterBag->get('dolibarrApiKey')]
);
},
'assetManager' => [ 'assetManager' => [
'linkAssets' => YII_ENV == "dev" ? 'true' : false, 'linkAssets' => YII_ENV == "dev" ? 'true' : false,
], ],
'enableStrictParsing' => false, 'enableStrictParsing' => false,
'rules' => [], 'rules' => [],
], ],
'dolibarrApi' => function() {
return new DolibarrApi(
Yii::$app->parameterBag->get('dolibarrApiUrl'),
['DOLAPIKEY', \Yii::$app->parameterBag->get('dolibarrApiKey')]
);
},
'logic' => function () { 'logic' => function () {
return new BusinessLogic(); return new BusinessLogic();
}, },

+ 4
- 2
common/logic/Setting/SettingDetails/Admin/AdminSettingDefinition.php View File

use common\logic\Setting\SettingDefinition; use common\logic\Setting\SettingDefinition;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting; use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting; use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\ForumFlarumUrlAdminSetting;


class AdminSettingDefinition extends SettingDefinition class AdminSettingDefinition extends SettingDefinition
{ {
return [ return [
self::SECTION_GENERAL => [ self::SECTION_GENERAL => [
self::SUBSECTION_GENERAL => [ self::SUBSECTION_GENERAL => [
new AdministratorEmailAdminSetting,
new AdministratorPhoneNumberAdminSetting,
new AdministratorEmailAdminSetting(),
new AdministratorPhoneNumberAdminSetting(),
new ForumFlarumUrlAdminSetting(),
] ]
], ],
]; ];

+ 17
- 0
common/logic/Setting/SettingDetails/Admin/General/ForumFlarumUrlAdminSetting.php View File

<?php

namespace common\logic\Setting\SettingDetails\Admin\General;

use common\logic\Setting\SettingDetails\AbstractSettingDetail;

class ForumFlarumUrlAdminSetting extends AbstractSettingDetail
{
public function __construct()
{
$this
->setName('forumFlarumUrl')
->setLabel("Url du forum Flarum")
->setTypeString()
->setFormTypeInput();
}
}

+ 6
- 0
frontend/views/layouts/main.php View File

*/ */


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Setting\SettingModule;
use common\logic\User\User\Module\UserModule; use common\logic\User\User\Module\UserModule;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
if ($isUserCurrentGrantedAsProducer) { if ($isUserCurrentGrantedAsProducer) {
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); $producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]);
} }
$settingModule = SettingModule::getInstance();
$adminSettingBag = $settingModule->getAdminSettingBag();


?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<div class="container"> <div class="container">
<a href="<?php echo $this->getUrlManager()->createUrl('site/service'); ?>">Fonctionnalités, services & tarifs</a> <span class="bull">&bull;</span> <a href="<?php echo $this->getUrlManager()->createUrl('site/service'); ?>">Fonctionnalités, services & tarifs</a> <span class="bull">&bull;</span>
<a href="<?php echo $this->getUrlManager()->createUrl('site/opinion'); ?>">Avis & suggestions</a> <span class="bull">&bull;</span> <a href="<?php echo $this->getUrlManager()->createUrl('site/opinion'); ?>">Avis & suggestions</a> <span class="bull">&bull;</span>
<?php if($adminSettingBag->get('forumFlarumUrl')): ?>
<!--<a href="<?php echo $adminSettingBag->get('forumFlarumUrl'); ?>">Forum</a> <span class="bull">&bull;</span>-->
<?php endif; ?>
<a href="<?php echo $this->getUrlManager()->createUrl('site/mentions'); ?>">Mentions légales</a> <span class="bull">&bull;</span> <a href="<?php echo $this->getUrlManager()->createUrl('site/mentions'); ?>">Mentions légales</a> <span class="bull">&bull;</span>
<a href="<?php echo $this->getUrlManager()->createUrl('site/cgv'); ?>">Conditions générales de service</a> <span class="bull">&bull;</span> <a href="<?php echo $this->getUrlManager()->createUrl('site/cgv'); ?>">Conditions générales de service</a> <span class="bull">&bull;</span>
<a href="<?php echo $this->getUrlManager()->createUrl('site/source-code'); ?>">Code source</a> <a href="<?php echo $this->getUrlManager()->createUrl('site/source-code'); ?>">Code source</a>

Loading…
Cancel
Save