Browse Source

Forum

feature/souke
Guillaume Bourgeois 11 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

@@ -80,7 +80,8 @@ class DashboardController extends BackendController
'pointsSaleCount' => $this->getPointSaleModule()->getRepository()->countPointSales(),
'distributionsArray' => $this->getDistributionModule()->getRepository()->findDistributionsDashboard(),
'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

@@ -41,6 +41,7 @@ use common\logic\Distribution\Distribution\Module\DistributionModule;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Module\OrderModule;
use common\logic\Producer\Producer\Module\ProducerModule;
use common\logic\Setting\SettingModule;
use common\logic\Subscription\Subscription\Module\SubscriptionModule;
use common\logic\User\User\Module\UserModule;
use yii\helpers\Html ;
@@ -50,90 +51,129 @@ $userModule = UserModule::getInstance();
$orderModule = OrderModule::getInstance();
$subscriptionModule = SubscriptionModule::getInstance();
$producerModule = ProducerModule::getInstance();
$settingModule = SettingModule::getInstance();
$adminSettingBag = $settingModule->getAdminSettingBag();

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

?>
<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>
<?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>
<?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>
<?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-heading">
<h3 class="panel-title">
Prochaines distributions
</h3>
<h3 class="panel-title">
Derniers sujets sur le forum
</h3>
</div>
<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>

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

@@ -98,6 +98,16 @@ $this->addBreadcrumb($this->getTitle());
</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 class="clr"></div>
<?php endif; ?>

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

@@ -11,7 +11,7 @@ abstract class AbstractApi
public string $url;
public array $auth;

public function __construct(string $url, array $auth)
public function __construct(string $url, array $auth = [])
{
$this->url = $url;
$this->auth = $auth;
@@ -41,7 +41,11 @@ abstract class AbstractApi
private function getClient()
{
$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;
}


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

@@ -0,0 +1,11 @@
<?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

@@ -38,6 +38,7 @@

use common\components\BusinessLogic;
use common\components\DolibarrApi;
use common\components\ForumFlarumClient;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Order\Order\Model\Order;
@@ -83,6 +84,16 @@ return [
'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' => [
'linkAssets' => YII_ENV == "dev" ? 'true' : false,
],
@@ -167,12 +178,6 @@ return [
'enableStrictParsing' => false,
'rules' => [],
],
'dolibarrApi' => function() {
return new DolibarrApi(
Yii::$app->parameterBag->get('dolibarrApiUrl'),
['DOLAPIKEY', \Yii::$app->parameterBag->get('dolibarrApiKey')]
);
},
'logic' => function () {
return new BusinessLogic();
},

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

@@ -5,6 +5,7 @@ namespace common\logic\Setting\SettingDetails\Admin;
use common\logic\Setting\SettingDefinition;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorEmailAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\AdministratorPhoneNumberAdminSetting;
use common\logic\Setting\SettingDetails\Admin\General\ForumFlarumUrlAdminSetting;

class AdminSettingDefinition extends SettingDefinition
{
@@ -16,8 +17,9 @@ class AdminSettingDefinition extends SettingDefinition
return [
self::SECTION_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

@@ -0,0 +1,17 @@
<?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

@@ -37,6 +37,7 @@
*/

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

?>
<?php $this->beginPage() ?>
@@ -173,6 +176,9 @@ if ($isUserCurrentGrantedAsProducer) {
<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/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/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>

Loading…
Cancel
Save