<?php | |||||
/** | |||||
* Copyright distrib (2018) | |||||
* | |||||
* contact@opendistrib.net | |||||
* | |||||
* Ce logiciel est un programme informatique servant à aider les producteurs | |||||
* à distribuer leur production en circuits courts. | |||||
* | |||||
* Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
* respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
* utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
* sur le site "http://www.cecill.info". | |||||
* | |||||
* En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
* de modification et de redistribution accordés par cette licence, il n'est | |||||
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
* seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
* titulaire des droits patrimoniaux et les concédants successifs. | |||||
* | |||||
* A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
* associés au chargement, à l'utilisation, à la modification et/ou au | |||||
* développement et à la reproduction du logiciel par l'utilisateur étant | |||||
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
* manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
* avertis possédant des connaissances informatiques approfondies. Les | |||||
* utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
* logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
* sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
* | |||||
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
* pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
* termes. | |||||
*/ | |||||
namespace backend\controllers; | |||||
use common\helpers\Price; | |||||
use yii\filters\AccessControl; | |||||
use yii\filters\VerbFilter; | |||||
class DashboardAdminController extends BackendController | |||||
{ | |||||
/** | |||||
* @inheritdoc | |||||
*/ | |||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'access' => [ | |||||
'class' => AccessControl::class, | |||||
'rules' => [ | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return $this->getUserModule() | |||||
->getAuthorizationChecker() | |||||
->isGrantedAsAdministrator($this->getUserCurrent()); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
public function actionIndex() | |||||
{ | |||||
return $this->render('index', [ | |||||
'supportOnline' => $this->getSettingModule()->getAdminSettingBag()->get('supportOnline'), | |||||
'countUsersOnline' => $this->getUserModule()->getRepository()->countUsersOnline(), | |||||
'countTicketsAdminOpen' => $this->getTicketModule()->getRepository()->countTicketsAdminStatusOpen(), | |||||
'countTicketsAdminUnread' => $this->getTicketModule()->getRepository()->countTicketsAdminUnreadByUser($this->getUserCurrent()), | |||||
'statisticsCacheHtml' => \Yii::$app->cache->get('dashboard_statistics') ?: '' | |||||
]); | |||||
} | |||||
public function actionSupportOnlineToggle(int $active) | |||||
{ | |||||
$this->getSettingModule()->getAdminSettingBag()->set('supportOnline', $active); | |||||
return $this->redirect('index'); | |||||
} | |||||
public function actionAjaxStatisticsHtml() | |||||
{ | |||||
return \Yii::$app->cache->getOrSet('dashboard_statistics', function () { | |||||
$producerModule = $this->getProducerModule(); | |||||
$pointSaleModule = $this->getPointSaleModule(); | |||||
$userModule = $this->getUserModule(); | |||||
$orderModule = $this->getOrderModule(); | |||||
$countProducersActive = $producerModule->getRepository()->countProducersActiveWithTurnover(); | |||||
$countPointSalesActive = $pointSaleModule->countPointSalesActiveLastThreeMonths(); | |||||
$countUsersActive = $userModule->countUsersActiveLastThreeMonths(); | |||||
$averageOrdersPerDay = $orderModule->countGlobalUserOrdersAverageLastSevenDays(); | |||||
$turnoverLastThirtyDays = $orderModule->getRepository()->getTurnoverLastThirtyDays(); | |||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(\Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | |||||
$numberVisitsDay = $resultMatomoApiVisitSummary->nb_uniq_visitors / 30; | |||||
$amountBilledLastMonth = $producerModule->getRepository()->getAmountBilledLastMonth(); | |||||
$amountToBillCurrentMonth = $producerModule->getRepository()->getAmountToBillCurrentMonth(); | |||||
$amountProducerUnpaidInvoices = $producerModule->getDolibarrUtils()->getAmountProducerInvoicesUnpaid(); | |||||
return $this->renderPartial('_statistics', [ | |||||
'amountBilledLastMonth' => $amountBilledLastMonth, | |||||
'amountToBillCurrentMonth' => $amountToBillCurrentMonth, | |||||
'amountProducerUnpaidInvoices' => $amountProducerUnpaidInvoices, | |||||
'countProducersActive' => $countProducersActive, | |||||
'countPointSalesActive' => $countPointSalesActive, | |||||
'countUsersActive' => $countUsersActive, | |||||
'averageOrdersPerDay' => $averageOrdersPerDay, | |||||
'turnoverLastThirtyDays' => $turnoverLastThirtyDays, | |||||
'numberVisitsDay' => $numberVisitsDay | |||||
]); | |||||
}, 60 * 60 * 24); | |||||
} | |||||
} |
$producersArray = $producerModule->findProducersActive(); | $producersArray = $producerModule->findProducersActive(); | ||||
$sumPrices = 0; | $sumPrices = 0; | ||||
foreach ($producersArray as $producer) { | foreach ($producersArray as $producer) { | ||||
$sumPrices += $producerModule->getAmountBilledLastMonth($producer); | |||||
$sumPrices += $producerModule->getAmountBilledLastMonthByProducer($producer); | |||||
} | } | ||||
return $this->render('index', [ | return $this->render('index', [ |
<div class="small-box bg-<?= $backgroundColor ?>"> | |||||
<div class="inner"> | |||||
<h3><?= $title ?></h3> | |||||
<p><?= $description ?></p> | |||||
</div> | |||||
<div class="icon"> | |||||
<i class="fa fa-<?= $icon ?>"></i> | |||||
</div> | |||||
<?php if(isset($footerLinkUrl) && $footerLinkUrl): ?> | |||||
<a href="<?= $footerLinkUrl ?>" class="small-box-footer"> | |||||
<?= $footerLinkLabel ?> <i class="fa fa-<?= $footerLinkIcon ?>"></i> | |||||
</a> | |||||
<?php else: ?> | |||||
<div class="small-box-footer"> </div> | |||||
<?php endif; ?> | |||||
</div> |
<?php | |||||
use common\helpers\AdminLTE; | |||||
use common\helpers\Price; | |||||
?> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
Price::format($turnoverLastThirtyDays, 0), | |||||
'CA producteurs sur les 30 derniers jours', | |||||
'aqua', | |||||
'line-chart', | |||||
Yii::$app->urlManager->createUrl('stats-admin/turnover') | |||||
) ?> | |||||
</div> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$averageOrdersPerDay, | |||||
'Commandes clients / jour sur les 7 derniers jours', | |||||
'aqua', | |||||
'shopping-cart', | |||||
Yii::$app->urlManager->createUrl('stats-admin/turnover') | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$countProducersActive, | |||||
'Producteurs actifs sur les 3 derniers mois', | |||||
'aqua', | |||||
'user' | |||||
) ?> | |||||
</div> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$countUsersActive, | |||||
'Clients actifs sur les 3 derniers mois', | |||||
'aqua', | |||||
'users' | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$countPointSalesActive, | |||||
'Points de vente actifs sur les 3 derniers mois', | |||||
'aqua', | |||||
'map-marker' | |||||
) ?> | |||||
</div> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$numberVisitsDay, | |||||
'Visites / jour en moyenne sur les 30 derniers jours', | |||||
'aqua', | |||||
'eye' | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
Price::format($amountToBillCurrentMonth, 0), | |||||
'Total factures producteurs mois en cours', | |||||
'green', | |||||
'euro', | |||||
Yii::$app->urlManager->createUrl('producer-admin/index') | |||||
) ?> | |||||
</div> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
Price::format($amountBilledLastMonth, 0), | |||||
'Total factures producteurs du mois dernier', | |||||
'green', | |||||
'euro', | |||||
Yii::$app->urlManager->createUrl('producer-admin/index') | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
Price::format($amountProducerUnpaidInvoices, 0), | |||||
'Montant factures producteurs impayées', | |||||
'red', | |||||
'euro', | |||||
Yii::$app->parameterBag->get('dolibarrUrl') . 'compta/facture/list.php?leftmenu=customers_bills_notpaid&search_status=1' | |||||
) ?> | |||||
</div> | |||||
</div> |
<?php | |||||
use common\helpers\AdminLTE; | |||||
$this->setTitle('Tableau de bord'); | |||||
?> | |||||
<div class="dashboard-admin-index"> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$countUsersOnline, | |||||
'En ligne', | |||||
$countUsersOnline ? 'green' : 'blue', | |||||
'wifi', | |||||
Yii::$app->urlManager->createUrl('online-admin/index') | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div class="row"> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$supportOnline ? 'Oui' : 'Non', | |||||
'Support activé', | |||||
$supportOnline ? 'green' : 'blue', | |||||
'phone', | |||||
Yii::$app->urlManager->createUrl(['dashboard-admin/support-online-toggle', 'active' => $supportOnline ? 0 : 1]), | |||||
$supportOnline ? 'Désactiver' : 'Activer' | |||||
) ?> | |||||
</div> | |||||
<div class="col-lg-6 col-xs-6"> | |||||
<?= AdminLTE::smallBox( | |||||
$countTicketsAdminOpen, | |||||
'Tickets', | |||||
$countTicketsAdminUnread ? 'green' : 'blue', | |||||
'comments', | |||||
Yii::$app->urlManager->createUrl('support-admin/index') | |||||
) ?> | |||||
</div> | |||||
</div> | |||||
<div id="dashboard-admin-statistics-html"> | |||||
<?= $statisticsCacheHtml ?> | |||||
</div> | |||||
</div> |
<header class="main-header"> | <header class="main-header"> | ||||
<!-- <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>--> | <!-- <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>--> | ||||
<?= Html::a('Opendistrib', Yii::$app->homeUrl, ['class' => 'logo']); ?> | |||||
<?= Html::a( | |||||
'Opendistrib', | |||||
$userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent) | |||||
? Yii::$app->urlManager->createUrl('dashboard-admin/index') | |||||
: Yii::$app->homeUrl, | |||||
['class' => 'logo'] | |||||
); ?> | |||||
<nav class="navbar navbar-static-top" role="navigation"> | <nav class="navbar navbar-static-top" role="navigation"> | ||||
// Administration | // Administration | ||||
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator], | ['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator], | ||||
[ | |||||
'label' => 'Tableau de bord', | |||||
'icon' => 'dashboard', | |||||
'url' => ['dashboard-admin/index'], | |||||
'visible' => $isUserCurrentGrantedAsAdministrator, | |||||
], | |||||
[ | [ | ||||
'label' => 'En ligne', | 'label' => 'En ligne', | ||||
'icon' => 'wifi', | 'icon' => 'wifi', |
opacity: 1; | opacity: 1; | ||||
} | } | ||||
/* line 301, ../sass/_adminlte.scss */ | /* line 301, ../sass/_adminlte.scss */ | ||||
body.skin-black .content-wrapper .small-box h3 { | |||||
font-size: 28px; | |||||
font-family: 'Source Sans Pro',sans-serif; | |||||
} | |||||
/* line 306, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .small-box .icon { | |||||
top: -2px; | |||||
} | |||||
/* line 310, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .small-box .small-box-footer { | |||||
color: white; | |||||
padding-top: 6px; | |||||
padding-bottom: 2px; | |||||
} | |||||
/* line 319, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .callout h4 .fa { | body.skin-black .content-wrapper .callout h4 .fa { | ||||
margin-right: 7px; | margin-right: 7px; | ||||
} | } | ||||
/* line 304, ../sass/_adminlte.scss */ | |||||
/* line 322, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .callout a { | body.skin-black .content-wrapper .callout a { | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 307, ../sass/_adminlte.scss */ | |||||
/* line 325, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .callout .btn { | body.skin-black .content-wrapper .callout .btn { | ||||
color: #333; | color: #333; | ||||
text-decoration: none; | text-decoration: none; | ||||
} | } | ||||
/* line 314, ../sass/_adminlte.scss */ | |||||
/* line 332, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .table th { | body.skin-black .content-wrapper .table th { | ||||
font-size: 13px; | font-size: 13px; | ||||
} | } | ||||
/* line 317, ../sass/_adminlte.scss */ | |||||
/* line 335, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .table th.column-actions, body.skin-black .content-wrapper .table td.column-actions { | body.skin-black .content-wrapper .table th.column-actions, body.skin-black .content-wrapper .table td.column-actions { | ||||
width: 172px; | width: 172px; | ||||
text-align: right; | text-align: right; | ||||
} | } | ||||
/* line 321, ../sass/_adminlte.scss */ | |||||
/* line 339, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .table td.text-small, body.skin-black .content-wrapper .table th.text-small { | body.skin-black .content-wrapper .table td.text-small, body.skin-black .content-wrapper .table th.text-small { | ||||
font-size: 12px; | font-size: 12px; | ||||
} | } | ||||
/* line 326, ../sass/_adminlte.scss */ | |||||
/* line 344, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .pagination > .active > a, body.skin-black .content-wrapper .pagination > .active > span, body.skin-black .content-wrapper .pagination > .active > a:hover, body.skin-black .content-wrapper .pagination > .active > span:hover, body.skin-black .content-wrapper .pagination > .active > a:focus, body.skin-black .content-wrapper .pagination > .active > span:focus { | body.skin-black .content-wrapper .pagination > .active > a, body.skin-black .content-wrapper .pagination > .active > span, body.skin-black .content-wrapper .pagination > .active > a:hover, body.skin-black .content-wrapper .pagination > .active > span:hover, body.skin-black .content-wrapper .pagination > .active > a:focus, body.skin-black .content-wrapper .pagination > .active > span:focus { | ||||
background-color: #F39C12; | background-color: #F39C12; | ||||
border: solid 1px #F39C12; | border: solid 1px #F39C12; | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 332, ../sass/_adminlte.scss */ | |||||
/* line 350, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .pagination > li > a, body.skin-black .content-wrapper .pagination > li > span { | body.skin-black .content-wrapper .pagination > li > a, body.skin-black .content-wrapper .pagination > li > span { | ||||
color: #F39C12; | color: #F39C12; | ||||
} | } | ||||
/* line 334, ../sass/_adminlte.scss */ | |||||
/* line 352, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .pagination > li > a:hover, body.skin-black .content-wrapper .pagination > li > span:hover { | body.skin-black .content-wrapper .pagination > li > a:hover, body.skin-black .content-wrapper .pagination > li > span:hover { | ||||
color: #c87f0a; | color: #c87f0a; | ||||
} | } | ||||
/* line 339, ../sass/_adminlte.scss */ | |||||
/* line 357, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .submenu { | body.skin-black .content-wrapper .submenu { | ||||
margin-bottom: 25px; | margin-bottom: 25px; | ||||
} | } | ||||
/* line 343, ../sass/_adminlte.scss */ | |||||
/* line 361, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .form-actions { | body.skin-black .content-wrapper .form-actions { | ||||
position: fixed; | position: fixed; | ||||
bottom: 0; | bottom: 0; | ||||
z-index: 10; | z-index: 10; | ||||
border-top: solid 1px #e0e0e0; | border-top: solid 1px #e0e0e0; | ||||
} | } | ||||
/* line 356, ../sass/_adminlte.scss */ | |||||
/* line 374, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .form-actions a, body.skin-black .content-wrapper .form-actions button { | body.skin-black .content-wrapper .form-actions a, body.skin-black .content-wrapper .form-actions button { | ||||
margin-left: 10px; | margin-left: 10px; | ||||
} | } | ||||
/* line 361, ../sass/_adminlte.scss */ | |||||
/* line 379, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .form-buttons { | body.skin-black .content-wrapper .form-buttons { | ||||
margin-top: 25px; | margin-top: 25px; | ||||
text-align: right; | text-align: right; | ||||
} | } | ||||
/* line 368, ../sass/_adminlte.scss */ | |||||
/* line 386, ../sass/_adminlte.scss */ | |||||
body.skin-black .main-footer a { | body.skin-black .main-footer a { | ||||
color: #F39C12; | color: #F39C12; | ||||
} | } | ||||
/* line 373, ../sass/_adminlte.scss */ | |||||
/* line 391, ../sass/_adminlte.scss */ | |||||
body.skin-black .gridview-pagesize { | body.skin-black .gridview-pagesize { | ||||
float: right; | float: right; | ||||
margin-bottom: 8px; | margin-bottom: 8px; | ||||
} | } | ||||
/* line 378, ../sass/_adminlte.scss */ | |||||
/* line 396, ../sass/_adminlte.scss */ | |||||
body.skin-black #yii-debug-toolbar { | body.skin-black #yii-debug-toolbar { | ||||
bottom: 64px; | bottom: 64px; | ||||
} | } | ||||
/* line 383, ../sass/_adminlte.scss */ | |||||
/* line 401, ../sass/_adminlte.scss */ | |||||
body.login-page { | body.login-page { | ||||
background: none; | background: none; | ||||
background-color: white; | background-color: white; | ||||
} | } | ||||
/* line 387, ../sass/_adminlte.scss */ | |||||
/* line 405, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo { | body.login-page .login-box .login-logo { | ||||
text-align: center; | text-align: center; | ||||
font-family: 'highvoltageregular'; | font-family: 'highvoltageregular'; | ||||
} | } | ||||
/* line 391, ../sass/_adminlte.scss */ | |||||
/* line 409, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo img { | body.login-page .login-box .login-logo img { | ||||
width: 50px; | width: 50px; | ||||
} | } | ||||
/* line 396, ../sass/_adminlte.scss */ | |||||
/* line 414, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary { | body.login-page .login-box .login-box-body .btn-primary { | ||||
background-color: #F39C12; | background-color: #F39C12; | ||||
border-color: #F39C12; | border-color: #F39C12; | ||||
padding: 5px 10px; | padding: 5px 10px; | ||||
} | } | ||||
/* line 401, ../sass/_adminlte.scss */ | |||||
/* line 419, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary:active { | body.login-page .login-box .login-box-body .btn-primary:active { | ||||
background-color: #f4a62a; | background-color: #f4a62a; | ||||
border-color: #F39C12; | border-color: #F39C12; | ||||
} | } | ||||
/* line 407, ../sass/_adminlte.scss */ | |||||
/* line 425, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a { | body.login-page .login-box .login-box-body a { | ||||
color: #F39C12; | color: #F39C12; | ||||
} | } | ||||
/* line 409, ../sass/_adminlte.scss */ | |||||
/* line 427, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a:hover { | body.login-page .login-box .login-box-body a:hover { | ||||
color: #f4a62a; | color: #f4a62a; | ||||
} | } |
opendistrib_features_index(); | opendistrib_features_index(); | ||||
opendistrib_point_sale_form(); | opendistrib_point_sale_form(); | ||||
opendistrib_check_all_checkboxes(); | opendistrib_check_all_checkboxes(); | ||||
opendistrib_dashboard_admin_statistics(); | |||||
}); | }); | ||||
var UrlManager = { | var UrlManager = { | ||||
getBaseUrl: function () { | getBaseUrl: function () { | ||||
return $('meta[name=baseurl]').attr('content') + '/'; | return $('meta[name=baseurl]').attr('content') + '/'; | ||||
}, | }, | ||||
getBaseUrlAbsolute: function () { | getBaseUrlAbsolute: function () { | ||||
return $('meta[name=baseurl-absolute]').attr('content') + '/'; | return $('meta[name=baseurl-absolute]').attr('content') + '/'; | ||||
} | } | ||||
}; | }; | ||||
function opendistrib_dashboard_admin_statistics() { | |||||
$.get(UrlManager.getBaseUrl() + 'dashboard-admin/ajax-statistics-html', {}, function(result) { | |||||
$('#dashboard-admin-statistics-html').html(result); | |||||
}); | |||||
} | |||||
function opendistrib_check_all_checkboxes() { | function opendistrib_check_all_checkboxes() { | ||||
$('.check-all-checkboxes').change(function() { | $('.check-all-checkboxes').change(function() { | ||||
var selector = $(this).data('selector'); | var selector = $(this).data('selector'); |
} | } | ||||
} | } | ||||
} | } | ||||
.small-box { | |||||
h3 { | |||||
font-size: 28px; | |||||
font-family: 'Source Sans Pro',sans-serif; | |||||
} | |||||
.icon { | |||||
top: -2px; | |||||
} | |||||
.small-box-footer { | |||||
color: white; | |||||
padding-top: 6px; | |||||
padding-bottom: 2px; | |||||
} | |||||
} | |||||
.callout { | .callout { | ||||
h4 .fa { | h4 .fa { |
.dashboard-admin-index { | |||||
} |
@import "online-admin/_index.scss"; | @import "online-admin/_index.scss"; | ||||
@import "feature-admin/_index.scss"; | @import "feature-admin/_index.scss"; | ||||
@import "setting/_form.scss"; | @import "setting/_form.scss"; | ||||
@import "dashboard-admin/_index.scss" ; | |||||
@import "_responsive.scss" ; | @import "_responsive.scss" ; |
<?php | |||||
namespace common\helpers; | |||||
class AdminLTE | |||||
{ | |||||
public static function smallBox( | |||||
string $title, | |||||
string $description, | |||||
string $backgroundColor, | |||||
string $icon, | |||||
string $footerLinkUrl = null, | |||||
string $footerLinkLabel = 'Voir', | |||||
string $footerLinkIcon = 'arrow-circle-right' | |||||
) | |||||
{ | |||||
return \Yii::$app->getView()->renderFile('@backend/views/_include/small_box.php', [ | |||||
'title' => $title, | |||||
'description' => $description, | |||||
'backgroundColor' => $backgroundColor, | |||||
'icon' => $icon, | |||||
'footerLinkUrl' => $footerLinkUrl, | |||||
'footerLinkLabel' => $footerLinkLabel, | |||||
'footerLinkIcon' => $footerLinkIcon | |||||
]); | |||||
} | |||||
} |
} | } | ||||
public function getTurnoverByDate(\DateTime $date) | public function getTurnoverByDate(\DateTime $date) | ||||
{ | |||||
return $this->getTurnoverByDateStartEnd( | |||||
$date->modify('first day of this month'), | |||||
$date->modify('last day of this month') | |||||
); | |||||
} | |||||
public function getTurnoverLastThirtyDays() | |||||
{ | |||||
$now = new \DateTime(); | |||||
return $this->getTurnoverByDateStartEnd( | |||||
$now, | |||||
$now->modify('-30 days') | |||||
); | |||||
} | |||||
public function getTurnoverByDateStartEnd(\DateTime $dateStart, \DateTime $dateEnd) | |||||
{ | { | ||||
$res = \Yii::$app->db->createCommand("SELECT SUM(product_order.price * product_order.quantity) AS total | $res = \Yii::$app->db->createCommand("SELECT SUM(product_order.price * product_order.quantity) AS total | ||||
FROM `order`, product_order, distribution | FROM `order`, product_order, distribution | ||||
AND distribution.date >= :date_start | AND distribution.date >= :date_start | ||||
AND distribution.date <= :date_end | AND distribution.date <= :date_end | ||||
") | ") | ||||
->bindValue(':date_start', date('Y-m-', $date->getTimestamp()) . '01') | |||||
->bindValue(':date_end', date('Y-m-', $date->getTimestamp()) . '31') | |||||
->bindValue(':date_start', $dateStart->format('Y-m-d')) | |||||
->bindValue(':date_end', $dateEnd->format('Y-m-d')) | |||||
->queryOne(); | ->queryOne(); | ||||
if ($res['total']) { | if ($res['total']) { |
return $invoicesArray; | return $invoicesArray; | ||||
} | } | ||||
public function countDolibarrProducerInvoicesUnpaid(Producer $producer): int | |||||
public function getDolibarrProducerInvoicesUnpaid(Producer $producer): array | |||||
{ | { | ||||
$count = 0; | |||||
$unpaidInvoicesArray = []; | |||||
$invoicesArray = $this->getDolibarrProducerInvoices($producer); | $invoicesArray = $this->getDolibarrProducerInvoices($producer); | ||||
foreach($invoicesArray as $invoice) { | foreach($invoicesArray as $invoice) { | ||||
if($invoice['remaintopay'] > 0) { | if($invoice['remaintopay'] > 0) { | ||||
$count ++; | |||||
$unpaidInvoicesArray[] = $invoice; | |||||
} | } | ||||
} | } | ||||
return $count; | |||||
return $unpaidInvoicesArray; | |||||
} | |||||
public function countDolibarrProducerInvoicesUnpaid(Producer $producer): int | |||||
{ | |||||
return count($this->getDolibarrProducerInvoicesUnpaid($producer)); | |||||
} | |||||
public function getDolibarrInvoicesUnpaid() | |||||
{ | |||||
$unpaidInvoicesArray = []; | |||||
$producersArray = $this->producerRepository->findProducersActive(); | |||||
foreach($producersArray as $producer) { | |||||
$unpaidInvoicesArray = array_merge( | |||||
$unpaidInvoicesArray, | |||||
$this->getDolibarrProducerInvoicesUnpaid($producer) | |||||
); | |||||
} | |||||
//die('test : '.count($unpaidInvoicesArray)); | |||||
return $unpaidInvoicesArray; | |||||
} | |||||
public function getAmountProducerInvoicesUnpaid() | |||||
{ | |||||
$amount = 0; | |||||
$unpaidInvoicesArray = $this->getDolibarrInvoicesUnpaid(); | |||||
foreach($unpaidInvoicesArray as $unpaidInvoice) { | |||||
$amount += $unpaidInvoice['remaintopay']; | |||||
} | |||||
return $amount; | |||||
} | } | ||||
public function generateDolibarrProducerInvoice(Producer $producer) | public function generateDolibarrProducerInvoice(Producer $producer) |
return $text; | return $text; | ||||
} | } | ||||
public function getAmountBilledLastMonth(Producer $producer): float | |||||
public function getAmountToBillCurrentMonth() | |||||
{ | { | ||||
if ($this->producerSolver->isBillingTypeClassic($producer)) { | |||||
$month = date('Y-m', strtotime('-1 month')); | |||||
return $this->getAmountToBeBilledByMonth($producer, $month); | |||||
} elseif ($this->producerSolver->isBillingTypeFreePrice($producer)) { | |||||
return $producer->free_price; | |||||
$amountToBill = 0; | |||||
$producersArray = $this->findProducersActive(); | |||||
foreach ($producersArray as $producer) { | |||||
$amountToBill += $this->getAmountToBillCurrentMonthByProducer($producer); | |||||
} | } | ||||
return $amountToBill; | |||||
} | |||||
return 0; | |||||
public function getAmountBilledLastMonth() | |||||
{ | |||||
$amountBilled = 0; | |||||
$producersArray = $this->findProducersActive(); | |||||
foreach ($producersArray as $producer) { | |||||
$amountBilled += $this->getAmountBilledLastMonthByProducer($producer); | |||||
} | |||||
return $amountBilled; | |||||
} | |||||
public function getAmountToBillCurrentMonthByProducer(Producer $producer): float | |||||
{ | |||||
return $this->getAmountToBeBilledByMonth($producer, date('Y-m')); | |||||
} | |||||
public function getAmountBilledLastMonthByProducer(Producer $producer): float | |||||
{ | |||||
return $this->getAmountToBeBilledByMonth($producer, date('Y-m', strtotime('-1 month'))); | |||||
} | } | ||||
public function getOnlinePaymentMinimumAmount(): float | public function getOnlinePaymentMinimumAmount(): float |
{ | { | ||||
return count($this->findUsersWithStatusUserAndOnline()); | return count($this->findUsersWithStatusUserAndOnline()); | ||||
} | } | ||||
public function countUsersOnline(): int | |||||
{ | |||||
return $this->countUsersStatusUserOnline() + $this->countUsersStatusProducerOnline(); | |||||
} | |||||
} | } |