Bladeren bron

Problème basculement branches

refactoring
keun 6 jaren geleden
bovenliggende
commit
336471206c
100 gewijzigde bestanden met toevoegingen van 6816 en 1 verwijderingen
  1. +25
    -0
      backend/web/index_1.php
  2. +21
    -0
      backend/web/main-local.php
  3. +3
    -0
      backend/web/params-local.php
  4. +1
    -1
      common/config/bootstrap.php
  5. +41
    -0
      console/config/backend/assets/AppAsset.php
  6. +2
    -0
      console/config/backend/config/.gitignore
  7. +1
    -0
      console/config/backend/config/bootstrap.php
  8. +35
    -0
      console/config/backend/config/main.php
  9. +4
    -0
      console/config/backend/config/params.php
  10. +9
    -0
      console/config/backend/controllers/BackendController.php
  11. +1240
    -0
      console/config/backend/controllers/CommandeController.php
  12. +128
    -0
      console/config/backend/controllers/CommandeautoController.php
  13. +86
    -0
      console/config/backend/controllers/CommuniquerController.php
  14. +228
    -0
      console/config/backend/controllers/CronController.php
  15. +157
    -0
      console/config/backend/controllers/DeveloppementController.php
  16. +114
    -0
      console/config/backend/controllers/EtablissementAdminController.php
  17. +110
    -0
      console/config/backend/controllers/EtablissementController.php
  18. +100
    -0
      console/config/backend/controllers/PaiementController.php
  19. +154
    -0
      console/config/backend/controllers/PointVenteController.php
  20. +196
    -0
      console/config/backend/controllers/ProduitController.php
  21. +148
    -0
      console/config/backend/controllers/SiteController.php
  22. +90
    -0
      console/config/backend/controllers/StatsController.php
  23. +243
    -0
      console/config/backend/controllers/UserController.php
  24. +195
    -0
      console/config/backend/controllers/VracController.php
  25. +1
    -0
      console/config/backend/models/.gitkeep
  26. +86
    -0
      console/config/backend/models/CreditForm.php
  27. +52
    -0
      console/config/backend/models/MailForm.php
  28. +2
    -0
      console/config/backend/runtime/.gitignore
  29. +63
    -0
      console/config/backend/views/commande/_total_commandes.php
  30. +292
    -0
      console/config/backend/views/commande/index.php
  31. +169
    -0
      console/config/backend/views/commande/report.php
  32. +79
    -0
      console/config/backend/views/commandeauto/_form.php
  33. +21
    -0
      console/config/backend/views/commandeauto/create.php
  34. +139
    -0
      console/config/backend/views/commandeauto/index.php
  35. +19
    -0
      console/config/backend/views/commandeauto/update.php
  36. +11
    -0
      console/config/backend/views/communiquer/affiche.php
  37. +20
    -0
      console/config/backend/views/communiquer/index.php
  38. +28
    -0
      console/config/backend/views/communiquer/mode_emploi.php
  39. +9
    -0
      console/config/backend/views/communiquer/mode_emploi_multi.php
  40. +42
    -0
      console/config/backend/views/developpement/_form.php
  41. +21
    -0
      console/config/backend/views/developpement/create.php
  42. +162
    -0
      console/config/backend/views/developpement/index.php
  43. +21
    -0
      console/config/backend/views/developpement/update.php
  44. +53
    -0
      console/config/backend/views/etablissement-admin/facturation.php
  45. +127
    -0
      console/config/backend/views/etablissement-admin/index.php
  46. +96
    -0
      console/config/backend/views/etablissement/facturation.php
  47. +100
    -0
      console/config/backend/views/etablissement/update.php
  48. +255
    -0
      console/config/backend/views/layouts/main.php
  49. +12
    -0
      console/config/backend/views/paiement/annuler.php
  50. +54
    -0
      console/config/backend/views/paiement/index.php
  51. +12
    -0
      console/config/backend/views/paiement/succes.php
  52. +95
    -0
      console/config/backend/views/point-vente/_form.php
  53. +22
    -0
      console/config/backend/views/point-vente/create.php
  54. +112
    -0
      console/config/backend/views/point-vente/index.php
  55. +22
    -0
      console/config/backend/views/point-vente/update.php
  56. +37
    -0
      console/config/backend/views/point-vente/view.php
  57. +63
    -0
      console/config/backend/views/produit/_form.php
  58. +21
    -0
      console/config/backend/views/produit/create.php
  59. +78
    -0
      console/config/backend/views/produit/index.php
  60. +21
    -0
      console/config/backend/views/produit/update.php
  61. +43
    -0
      console/config/backend/views/produit/view.php
  62. +27
    -0
      console/config/backend/views/site/error.php
  63. +285
    -0
      console/config/backend/views/site/index.php
  64. +34
    -0
      console/config/backend/views/site/login.php
  65. +34
    -0
      console/config/backend/views/stats/index.php
  66. +26
    -0
      console/config/backend/views/user/_form.php
  67. +44
    -0
      console/config/backend/views/user/commandes.php
  68. +22
    -0
      console/config/backend/views/user/create.php
  69. +99
    -0
      console/config/backend/views/user/credit.php
  70. +155
    -0
      console/config/backend/views/user/index.php
  71. +21
    -0
      console/config/backend/views/user/liste_mails.php
  72. +42
    -0
      console/config/backend/views/user/mail.php
  73. +21
    -0
      console/config/backend/views/user/update.php
  74. +47
    -0
      console/config/backend/views/user/view.php
  75. +36
    -0
      console/config/backend/views/vrac/_form.php
  76. +21
    -0
      console/config/backend/views/vrac/create.php
  77. +37
    -0
      console/config/backend/views/vrac/index.php
  78. +21
    -0
      console/config/backend/views/vrac/update.php
  79. +43
    -0
      console/config/backend/views/vrac/view.php
  80. +2
    -0
      console/config/backend/web/.gitignore
  81. +8
    -0
      console/config/backend/web/.htaccess
  82. +0
    -0
      console/config/backend/web/.htaccess~
  83. BIN
      console/config/backend/web/.sass-cache/04a574b9dcb788863f265d0854fa0662dfc4ec26/_base.scssc
  84. BIN
      console/config/backend/web/.sass-cache/04a574b9dcb788863f265d0854fa0662dfc4ec26/_sprite-img.scssc
  85. BIN
      console/config/backend/web/.sass-cache/05bd53ef781f54af58094c8885bd268592fc1542/_alternating-rows-and-columns.scssc
  86. BIN
      console/config/backend/web/.sass-cache/05bd53ef781f54af58094c8885bd268592fc1542/_borders.scssc
  87. BIN
      console/config/backend/web/.sass-cache/05bd53ef781f54af58094c8885bd268592fc1542/_scaffolding.scssc
  88. BIN
      console/config/backend/web/.sass-cache/06e5f5fa55abf0e37cec9d605a5a180e4f6818d3/_compass.scssc
  89. BIN
      console/config/backend/web/.sass-cache/23d5ef384c29bd24badd6f68776d8714160be6c3/_compass.scssc
  90. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_appearance.scssc
  91. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_background-clip.scssc
  92. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_background-origin.scssc
  93. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_background-size.scssc
  94. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_border-radius.scssc
  95. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_box-shadow.scssc
  96. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_box-sizing.scssc
  97. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_box.scssc
  98. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_columns.scssc
  99. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_filter.scssc
  100. BIN
      console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_font-face.scssc

+ 25
- 0
backend/web/index_1.php Bestand weergeven

@@ -0,0 +1,25 @@
<?php

date_default_timezone_set('Europe/Paris');

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php')
);

$application = new yii\web\Application($config);

date_default_timezone_set('Europe/Paris');
setlocale(LC_TIME, 'fr_FR.utf8','fra');

$application->run();

+ 21
- 0
backend/web/main-local.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '97ab1b4e420025edccf116eafc92ffd6',
],
],
];

if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module';
}

return $config;

+ 3
- 0
backend/web/params-local.php Bestand weergeven

@@ -0,0 +1,3 @@
<?php
return [
];

+ 1
- 1
common/config/bootstrap.php Bestand weergeven

@@ -7,7 +7,7 @@ Yii::setAlias('producer', dirname(dirname(__DIR__)) . '/producer');

$server_name = $_SERVER['SERVER_NAME'] ;
Yii::setAlias('@domainName', (YII_ENV === 'dev') ? (($server_name == 'localhost') ? 'localhost' : 'laboiteapain-dev.net') : 'laboiteapain.net');
Yii::setAlias('@baseUrl', ($server_name == 'localhost') ? '/reservation_pain/' : '/');
Yii::setAlias('@baseUrl', ($server_name == 'localhost') ? '/laboiteapain/' : '/');
Yii::setAlias('@baseUrlFrontend', (($server_name == 'localhost') ? '/frontend/web' : ''));
Yii::setAlias('@baseUrlBackend', (($server_name == 'localhost') ? '/backend/web' : ''));
Yii::setAlias('@baseUrlProducer', (($server_name == 'localhost') ? '/producer/web' : ''));

+ 41
- 0
console/config/backend/assets/AppAsset.php Bestand weergeven

@@ -0,0 +1,41 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

namespace backend\assets;

use yii\web\AssetBundle;
use yii ;

/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [];
public $js = [];
public $depends = [
'yii\bootstrap\BootstrapAsset',
'yii\web\YiiAsset',
];
public function __construct() {
parent::__construct() ;
// css
$this->css[] = 'js/jquery-ui-1.12.1.custom/jquery-ui.min.css?v='.filemtime(Yii::getAlias('@app/web/js/jquery-ui-1.12.1.custom/jquery-ui.min.css')) ;
$this->css[] = 'js/jquery-ui-1.12.1.custom/jquery-ui.theme.min.css?v='.filemtime(Yii::getAlias('@app/web/js/jquery-ui-1.12.1.custom/jquery-ui.theme.min.css')) ;
$this->css[] = 'css/site.css?v='.filemtime(Yii::getAlias('@app/web/css/site.css')) ;
$this->css[] = 'css/screen.css?v='.filemtime(Yii::getAlias('@app/web/css/screen.css')) ;
// js
$this->js[] = 'js/jquery-ui-1.12.1.custom/jquery-ui.min.js?v='.filemtime(Yii::getAlias('@app/web/js/jquery-ui-1.12.1.custom/jquery-ui.min.js')) ;
$this->js[] = 'js/lechatdesnoisettes.js?v='.filemtime(Yii::getAlias('@app/web/js/lechatdesnoisettes.js')) ;
}
}

+ 2
- 0
console/config/backend/config/.gitignore Bestand weergeven

@@ -0,0 +1,2 @@
main-local.php
params-local.php

+ 1
- 0
console/config/backend/config/bootstrap.php Bestand weergeven

@@ -0,0 +1 @@
<?php

+ 35
- 0
console/config/backend/config/main.php Bestand weergeven

@@ -0,0 +1,35 @@
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);

return [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'defaultRoute' => 'site/index',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
],
'params' => $params,
];

+ 4
- 0
console/config/backend/config/params.php Bestand weergeven

@@ -0,0 +1,4 @@
<?php
return [
'adminEmail' => 'contact@laboiteapain.net',
];

+ 9
- 0
console/config/backend/controllers/BackendController.php Bestand weergeven

@@ -0,0 +1,9 @@
<?php

namespace backend\controllers;

class BackendController extends \common\controllers\CommonController {
}

?>

+ 1240
- 0
console/config/backend/controllers/CommandeController.php
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 128
- 0
console/config/backend/controllers/CommandeautoController.php Bestand weergeven

@@ -0,0 +1,128 @@
<?php

namespace backend\controllers;

class CommandeautoController extends BackendController {

var $enableCsrfValidation = false;

public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN || Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

public function actionIndex() {
$dataProvider = new ActiveDataProvider([
'query' => CommandeAuto::find()
->with(['user', 'etablissement', 'pointVente', 'commandeAutoProduit'])
->joinWith(['user'])
->where(['commande_auto.id_etablissement' => Yii::$app->user->identity->id_etablissement])
->orderBy('commande_auto.id_point_vente ASC, CASE `commande_auto`.`username` WHEN "" THEN `user`.`nom` ELSE `commande_auto`.`username` END ASC'),
'pagination' => [
'pageSize' => 1000,
],
]);

return $this->render('index', [
'dataProvider' => $dataProvider
]);
}

public function actionCreate() {
// form
$model = new CommandeAutoForm;
$model->id_etablissement = Yii::$app->user->identity->id_etablissement;

// produits
$produits = Produit::find()
->where(['id_etablissement' => $model->id_etablissement])
->orderBy('order ASC')
->all();

if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->save()) {

$this->redirect(['commandeauto/index']);
}

return $this->render('create', [
'model' => $model,
'produits' => $produits
]);
}

public function actionUpdate($id) {
// form
$model = new CommandeAutoForm;
$commandeauto = CommandeAuto::findOne($id);
if ($commandeauto) {
$model->id = $id;
$model->id_etablissement = $commandeauto->id_etablissement;
$model->id_user = $commandeauto->id_user;
$model->username = $commandeauto->username;
$model->id_point_vente = $commandeauto->id_point_vente;
$model->date_debut = date('d/m/Y', strtotime($commandeauto->date_debut));
if (strlen($commandeauto->date_fin))
$model->date_fin = date('d/m/Y', strtotime($commandeauto->date_fin));
$model->lundi = $commandeauto->lundi;
$model->lundi = $commandeauto->lundi;
$model->mardi = $commandeauto->mardi;
$model->mercredi = $commandeauto->mercredi;
$model->jeudi = $commandeauto->jeudi;
$model->vendredi = $commandeauto->vendredi;
$model->samedi = $commandeauto->samedi;
$model->dimanche = $commandeauto->dimanche;
$model->paiement_automatique = $commandeauto->paiement_automatique;
$model->periodicite_semaine = $commandeauto->periodicite_semaine;


// produits
$commandeauto_produits = CommandeAutoProduit::find()->where(['id_commande_auto' => $model->id])->all();
foreach ($commandeauto_produits as $commandeauto_produit) {
$model->produits['produit_' . $commandeauto_produit->id_produit] = $commandeauto_produit->quantite;
}
} else {
throw new NotFoundHttpException('La commande récurrente est introuvable.', 404);
}

// produits
$produits = Produit::find()
->where(['id_etablissement' => $model->id_etablissement])
->orderBy('order ASC')
->all();

if ($model->load(Yii::$app->request->post()) && $model->validate()) {

if (!strlen($model->date_fin)) {
$model->date_fin = null;
}

if ($model->save()) {
$this->redirect(['commandeauto/index']);
}
}

return $this->render('update', [
'model' => $model,
'produits' => $produits
]);
}

public function actionDelete($id) {
CommandeAutoProduit::deleteAll(['id_commande_auto' => $id]);
CommandeAuto::findOne($id)->delete();
$this->redirect(['commandeauto/index']);
}

}

+ 86
- 0
console/config/backend/controllers/CommuniquerController.php Bestand weergeven

@@ -0,0 +1,86 @@
<?php

namespace backend\controllers;

/**
* UserController implements the CRUD actions for User model.
*/
class CommuniquerController extends BackendController {

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN || Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

public function actionIndex() {
$etablissement = Etablissement::findOne(['id' => Yii::$app->user->identity->id_etablissement]);

return $this->render('index', [
'etablissement' => $etablissement,
]);
}

public function actionModeemploi() {

$etablissement = Etablissement::findOne(['id' => Yii::$app->user->identity->id_etablissement]);

// get your HTML raw content without any layouts or scripts
$content = $this->renderPartial('mode_emploi_multi', [
'pdf' => true,
'etablissement' => $etablissement
]);

$pdf = new Pdf([
// set to use core fonts only
'mode' => Pdf::MODE_UTF8,
// A4 paper format
'format' => Pdf::FORMAT_A4,
// portrait orientation
'orientation' => Pdf::ORIENT_PORTRAIT,
// stream to browser inline
'destination' => Pdf::DEST_BROWSER,
// your html content input
'content' => $content,
'marginRight' => 0,
'marginLeft' => 0,
'marginTop' => 0,
'marginBottom' => 0,
// format content from your own css file if needed or use the
// enhanced bootstrap css built by Krajee for mPDF formatting
//'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
'cssFile' => '@app/web/css/screen.css',
// any css to be embedded if required
//'cssInline' => '.kv-heading-1{font-size:18px}',
// set mPDF properties on the fly
//'options' => ['title' => 'Krajee Report Title'],
// call mPDF methods on the fly

/* 'methods' => [
'SetHeader'=>['Commandes du '.$date_str],
'SetFooter'=>['{PAGENO}'],
] */
]);

// return the pdf output as per the destination setting
return $pdf->render();
}

}

+ 228
- 0
console/config/backend/controllers/CronController.php Bestand weergeven

@@ -0,0 +1,228 @@
<?php

namespace backend\controllers;

use Yii;
use common\models\User;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use kartik\mpdf\Pdf;
use common\models\Etablissement;
use common\models\Commande;
use common\models\CommandeAuto;
use common\models\Production;

/**
* UserController implements the CRUD actions for User model.
*/
class CronController extends BackendController {

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['?'],
]
],
],
];
}

public function actionInitBddDemo($key = '') {
if ($key == '45432df6e842ac71aa0b5bb6b9f25d44' && YII_ENV == 'demo') {

$arr_noms = [
'Martin', 'Bernard', 'Thomas', 'Petit', 'Robert', 'Richard', 'Durand', 'Dubois',
'Moreau', 'Laurent', 'Simon', 'Michel', 'Lefebvre', 'Leroy', 'Roux', 'David',
'Bertrand', 'Morel', 'Fournier', 'Girard', 'Bonnet', 'Dupont', 'Lambert', 'Fontaine',
'Rousseau', 'Vincent', 'Muller', 'Lefevre', 'Faure', 'Andre', 'Mercier', 'Blanc', 'Guerin',
'Boyer', 'Garnier', 'Chevalier', 'François', 'Legrand', 'Gauthier', 'Garcia', 'Perrin',
'Robin', 'Clement', 'Morin', 'Nicolas', 'Henry', 'Roussel', 'Mathieu', 'Gautier', 'Masson',
'Marchand', 'Duval', 'Denis', 'Dumont', 'Marie', 'Lemaire', 'Noël', 'Meyer', 'Dufour',
'Meunier', 'Brun', 'Blanchard', 'Giraud', 'Joly', 'Rivière', 'Lucas', 'Brunet', 'Gaillard', 'Barbier',
'Arnaud', 'Martinez', 'Gerard', 'Roche', 'Renard', 'Schmitt', 'Roy', 'Leroux', 'Colin', 'Vidal',
'Caron', 'Picard', 'Roger', 'Fabre', 'Aubert', 'Lemoine', 'Renaud', 'Dumas', 'Lacroix', 'Olivier',
'Philippe', 'Bourgeois', 'Pierre', 'Benoit', 'Rey', 'Leclerc', 'Payet', 'Rolland', 'Lecomte', 'Lopez',
'Jean', 'Dupuis', 'Guillot', 'Hubert', 'Berger', 'Carpentier', 'Sanchez', 'Dupuis', 'Moulin',
'Louis', 'Deschamps', 'Huet', 'Vasseur', 'Perez', 'Trouillot', 'Fusillier', 'Massenot', 'Boucher', 'Fleury',
'Royer', 'Klein', 'Jacquet', 'Jaquin', 'Adam', 'Paris', 'Poirier', 'Aubry', 'Guyot', 'Carré', 'Charles',
'Charpentier', 'Menard', 'Bailly', 'Bertin', 'Le Gall', 'Collet', 'Leger', 'Bouvier', 'Millet', 'Daniel',
'Langlois', 'Pelletier', 'Perrier', 'Leblanc', 'Lebrun', 'Monnier', 'Michaud', 'Laporte', 'Carlier',
'Pasquier', 'Delaunay', 'Lamy', 'Gilbert', 'Lejeune', 'Pichon', 'Cordier', 'Barthelemy', 'Perret', 'Reynaud',
'Humbert', 'Marechal', 'Bernard', 'Lemaitre', 'Gay', 'Bouchet', 'Da Silva', 'Chauvin', 'Chevalier', 'Tessier',
'Poulain', 'Girondin', 'Gillet', 'Guichard'
];

$arr_prenoms = [
'Adel', 'Antonin', 'Armand', 'Arnaud', 'Aymeric', 'Baptiste', 'Barnabé', 'Bernard', 'Brice', 'Baudouin',
'Camille', 'Cassandre', 'Célestin', 'Christian', 'Clément', 'Cyril', 'Claude', 'Damien', 'Daniel', 'David',
'Delphin', 'Denis', 'Didier', 'Dimitri', 'Dorothée', 'Désiré', 'Edgard', 'Etienne', 'Eugène', 'Eudes', 'Eric',
'Fabien', 'Fabrice', 'Flavien', 'Florent', 'Francois', 'Frédéric', 'Gabin', 'Gabriel', 'Gautier', 'Gilles', 'Guy',
'Hervé', 'Huvert', 'Hugues', 'Hector', 'Jacques', 'Jason', 'Jean', 'Jeannot', 'Johan', 'Julien', 'Léon', 'Lionel', 'Loïc',
'Lucas', 'Luc', 'Lucien', 'Maurice', 'Maxence', 'Maxime', 'Michel', 'Morgan', 'Nicolas', 'Normand', 'Norbert', 'Olivier,',
'Pascal', 'Patrice', 'Pierrick', 'Raphael', 'Roland', 'Stéphane', 'Sylvain', 'Sylvestre', 'Timothée', 'Thomas', 'Tristan',
'Ulysse', 'Vincent', 'Victor', 'Vivien',
'Adeline', 'Albane', 'Alix', 'Amélie', 'Arielle', 'Aurelle', 'Blandine', 'Blanche', 'Brigitte', 'Berthe', 'Camille', 'Capucine',
'Catherine', 'Cécile', 'Charlotte', 'Chloé', 'Claudine', 'Clémenence', 'Constance', 'Cyrielle', 'Corinne', 'Danielle',
'Delphine', 'Denise', 'Dominique', 'Diane', 'Édith', 'Éliane', 'Éléonore', 'Émilie', 'Emmanuelle', 'Ève', 'Évelyne',
'Fanny', 'Flavie', 'Flore', 'Françoise', 'Gabrielle', 'Gaëlle', 'Geneviève', 'Georgette', 'Germaine', 'Gertrude', 'Gisèle',
'Gwenaëlle', 'Hélène', 'Héloïse', 'Henriette', 'Huguette', 'Inès', 'Isabelle', 'Jacqueline', 'Jeanne', 'Joëlle', 'Joséphine',
'Juliette', 'Justine', 'Julie', 'Laura', 'Laure', 'Léa', 'Léonie', 'Lucie', 'Lucienne', 'Lorraine', 'Lucille', 'Ludivine', 'Lydie',
'Margot', 'Marion', 'Marlène', 'Marthe', 'Mélodie', 'Monique', 'Noémie', 'Nadine', 'Nadège', 'Océane', 'Odette', 'Odile', 'Paulette',
'Rose', 'Roseline', 'Renée', 'Sabine', 'Sophie', 'Suzanne', 'Sylvie', 'Thérèse',
];

$arr_noms_checked = [];
$arr_prenoms_checked = [];

$users = User::find()
->joinWith('userEtablissement')
->where('user_etablissement.id_etablissement = 1')
->all();

foreach ($users as $u) {
if ($u->email != 'boulanger@laboiteapain.net') {
do {
$i_nom = rand(0, count($arr_noms) - 1);
$i_prenom = rand(0, count($arr_prenoms) - 1);
} while (isset($arr_noms_checked[$i_nom]) || isset($arr_prenoms_checked[$i_prenom]));

$arr_noms_checked[$i_nom] = true;
$arr_prenoms_checked[$i_prenom] = true;

$nom = $arr_noms[$i_nom];
$prenom = $arr_prenoms[$i_prenom];

$u->nom = $nom;
$u->prenom = $prenom;

$email = strtolower($prenom) . '.' . strtolower($nom) . '@yopmail.com';
$email = htmlentities($email, ENT_NOQUOTES, 'utf-8');
$email = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $email);
$email = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $email); // pour les ligatures e.g. '&oelig;'
$email = preg_replace('#&[^;]+;#', '', $email); // supprime les autres caractères
$email = str_replace(' ', '', $email);
$u->email = $email;

$u->telephone = '0600000000';
} else {
/*
* Le hash du mot de passe en production est volontairement corrompu
* pour empêcher la connexion des utilisateurs via ce compte en prod.
* Lors de l'initialisation des utilisateurs sur l'espace de démo,
* on remet le bon hash pour que ce compte soit disponible.
*/
$u->password_hash = '$2y$13$2D5T3Eo0pySmtlAuEGcfmOdTR5mleog8Y6YPGhop/ych6pbj6aN2y';
}

$u->save();
}

$commandes = Commande::find()
->where('username IS NOT NULL')
->all();

foreach ($commandes as $c) {
$nom = $arr_noms[rand(0, count($arr_noms) - 1)];
$prenom = $arr_prenoms[rand(0, count($arr_prenoms) - 1)];

$c->username = $prenom . ' ' . $nom;

$c->save();
}

$commandes_auto = CommandeAuto::find()
->where('username IS NOT NULL')
->all();

foreach ($commandes_auto as $c) {
$nom = $arr_noms[rand(0, count($arr_noms) - 1)];
$prenom = $arr_prenoms[rand(0, count($arr_prenoms) - 1)];

$c->username = $prenom . ' ' . $nom;

$c->save();
}
}
}

public function actionSendCommandes($key = '') {
if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') {
$heure = date('H');

if ($heure == '00') {
$date = date('Y-m-d');
} else {
$date = date('Y-m-d', time() + 24 * 60 * 60);
}

$etablissements = Etablissement::find()->all();

foreach ($etablissements as $e) {
$production = Production::findOne([
'date' => $date,
'actif' => 1,
'id_etablissement' => $e['id'],
]);

if ($production && $heure == $e['heure_limite_commande']) {
$commandes = Commande::find()
->with('commandeProduits', 'user')
->joinWith('production')
->where(['production.date' => $date])
->andWhere(['production.id_etablissement' => $e['id']])
->orderBy('date ASC')
->all();

$user = User::findOne([
'id_etablissement' => $e['id'],
'status' => User::STATUS_BOULANGER
]);

$mail = Yii::$app->mailer->compose(
[
'html' => 'cronRecapCommandes-html',
'text' => 'cronRecapCommandes-text',
], [
'date' => $date,
'commandes' => $commandes
]
)
->setTo($user->email)
->setFrom([Yii::$app->params['adminEmail'] => 'La boîte à pain']);

if (count($commandes)) {
$sujet = '[La boîte à pain] Commandes du ' . date('d/m', strtotime($date));

// génération du pdf de commande
Yii::$app->runAction('commande/report-cron', [
'date' => $date,
'save' => true,
'id_etablissement' => $e['id'],
'key' => '64ac0bdab7e9f5e48c4d991ec5201d57'
]);
$mail->attach(Yii::getAlias('@app/web/pdf/Commandes-' . $date . '-' . $e['id'] . '.pdf'));
} else {
$sujet = '[La boîte à pain] Aucune commande';
}

$mail->setSubject($sujet)
->send();
}
}
}
}

}

+ 157
- 0
console/config/backend/controllers/DeveloppementController.php Bestand weergeven

@@ -0,0 +1,157 @@
<?php

namespace backend\controllers;

use Yii;
use common\models\User;
use common\models\Developpement;
use common\models\DeveloppementPriorite;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;

/**
* DeveloppementController implements the CRUD actions for Developpement model.
*/
class DeveloppementController extends Controller {

/**
* @inheritdoc
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN || Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

/**
* Lists all Developpement models.
* @return mixed
*/
public function actionIndex($statut = Developpement::STATUT_OPEN) {
$dataProvider = new ActiveDataProvider([
'query' => Developpement::find()->with(['developpementPriorite', 'developpementPrioriteCurrentEtablissement'])->where(['statut' => $statut])->orderBy('date DESC'),
]);

return $this->render('index', [
'dataProvider' => $dataProvider,
'statut' => $statut
]);
}

/**
* Creates a new Developpement model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
$model = new Developpement();

if ($model->load(Yii::$app->request->post())) {
$model->date = date('Y-m-d H:i:s');
$model->setDateLivraison();
if ($model->save()) {
Yii::$app->getSession()->setFlash('success', 'Développement ajouté');
return $this->redirect(['index']);
}
} else {
return $this->render('create', [
'model' => $model,
]);
}
}

/**
* Updates an existing Developpement model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = $this->findModel($id);

if ($model->load(Yii::$app->request->post())) {
$model->setDateLivraison();
if ($model->save()) {
Yii::$app->getSession()->setFlash('success', 'Développement modifié');
return $this->redirect(['index']);
}
} else {
return $this->render('update', [
'model' => $model,
]);
}
}

/**
* Deletes an existing Developpement model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
$this->findModel($id)->delete();
Yii::$app->getSession()->setFlash('success', 'Développement supprimé');

return $this->redirect(['index']);
}

public function actionPriorite($id_developpement, $priorite = null) {

$developpement_priorite = DeveloppementPriorite::find()
->where(['id_developpement' => $id_developpement, 'id_etablissement' => Yii::$app->user->identity->id_etablissement])
->one();

if (in_array($priorite, [DeveloppementPriorite::PRIORITE_HAUTE,
DeveloppementPriorite::PRIORITE_NORMALE,
DeveloppementPriorite::PRIORITE_BASSE])) {

if ($developpement_priorite) {
$developpement_priorite->priorite = $priorite;
$developpement_priorite->id_etablissement = Yii::$app->user->identity->id_etablissement;
} else {
$developpement_priorite = new DeveloppementPriorite;
$developpement_priorite->id_developpement = $id_developpement;
$developpement_priorite->priorite = $priorite;
$developpement_priorite->id_etablissement = Yii::$app->user->identity->id_etablissement;
}

$developpement_priorite->save();
} else {
if ($developpement_priorite) {
$developpement_priorite->delete();
}
}

$this->redirect(['index']);
}

/**
* Finds the Developpement model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Developpement the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = Developpement::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 114
- 0
console/config/backend/controllers/EtablissementAdminController.php Bestand weergeven

@@ -0,0 +1,114 @@
<?php

namespace backend\controllers;

use Yii;
use common\models\User;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\helpers\Upload;
use common\models\Etablissement;
use yii\data\ActiveDataProvider;
use common\models\Facture;

/**
* UserController implements the CRUD actions for User model.
*/
class EtablissementAdminController extends BackendController {

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN;
}
]
],
],
];
}

public function actionIndex() {
$datas_etablissements = new ActiveDataProvider([
'query' => Etablissement::find()
->with('userEtablissement', 'user')
->orderBy('date_creation DESC'),
'pagination' => [
'pageSize' => 1000,
],
]);

return $this->render('index', [
'datas_etablissements' => $datas_etablissements,
]);
}

public function actionFacturer($id_etablissement) {

$etablissement = Etablissement::findOne($id_etablissement);

if ($etablissement) {
$periode = date('Y-m', strtotime('-1 month'));

$last_facture = Facture::getLastFacture();
if (!$last_facture) {
$reference = 'BAP000001';
} else {
$reference = str_replace('BAP', '', $last_facture->reference);
$reference ++;
$reference = 'BAP' . $reference;
}

$facture = new Facture;
$facture->id_etablissement = $id_etablissement;
$facture->date = date('Y-m-d H:i:s');
$facture->reference = $reference;
$facture->ca = $etablissement->getCA($periode);
$facture->montant_ht = $etablissement->getMontantFacturer($periode);
$facture->libelle = 'Facture ' . date('m/Y', strtotime('-1 month'));
$facture->texte = 'Utilisation de la plateforme <strong>La boîte à pain</strong> pour le mois : ' . date('m/Y', strtotime('-1 month')) . '<br />'
. 'Chiffre d\'affaire réalisé sur la plateforme : <strong>' . number_format($facture->ca, 2) . ' €</strong> commissionné à <strong>1%</strong>.';
$facture->paye = 0;
$facture->periode = $periode;
$facture->save();
}

$this->redirect(['etablissement-admin/index']);
}

public function actionFacturation() {
$datas_factures = new ActiveDataProvider([
'query' => Facture::find()
->with('etablissement')
->orderBy('reference DESC'),
'pagination' => [
'pageSize' => 1000,
],
]);

return $this->render('facturation', [
'datas_factures' => $datas_factures,
]);
}

protected function findModel($id) {
if (($model = Etablissement::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 110
- 0
console/config/backend/controllers/EtablissementController.php Bestand weergeven

@@ -0,0 +1,110 @@
<?php

namespace backend\controllers;

use Yii;
use common\models\User;
use backend\models\MailForm;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\helpers\Upload;
use common\models\Etablissement;
use common\models\Facture;

/**
* UserController implements the CRUD actions for User model.
*/
class EtablissementController extends BackendController {

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

public function actionUpdate() {
$request = Yii::$app->request;
$model = $this->findModel(Yii::$app->user->identity->id_etablissement);
$logo_filename_old = $model->logo;
$photo_filename_old = $model->photo;

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Upload::uploadFile($model, 'logo', $logo_filename_old);
Upload::uploadFile($model, 'photo', $photo_filename_old);

$delete_logo = $request->post('delete_logo', 0);
if ($delete_logo) {
$model->logo = '';
$model->save();
}

$delete_photo = $request->post('delete_photo', 0);
if ($delete_photo) {
$model->photo = '';
$model->save();
}

return $this->redirect(['update', 'id' => $model->id, 'edit_ok' => true]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}

public function actionFacturation() {
$datas_factures = new ActiveDataProvider([
'query' => Facture::find()
->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])
->orderBy('reference DESC'),
'pagination' => [
'pageSize' => 1000,
],
]);

$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement);

if ($etablissement->load(Yii::$app->request->post())) {
$etablissement->save();

if (!is_null($etablissement->prix_libre))
$alert_prix_libre = true;
}

return $this->render('facturation', [
'datas_factures' => $datas_factures,
'etablissement' => $etablissement,
'alert_prix_libre' => (isset($alert_prix_libre)) ? true : false
]);
}

protected function findModel($id) {
if (($model = Etablissement::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 100
- 0
console/config/backend/controllers/PaiementController.php Bestand weergeven

@@ -0,0 +1,100 @@
<?php

namespace backend\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\User;
use common\models\Etablissement;
use c006\paypal_ipn\PayPal_Ipn;

/**
* ProduitController implements the CRUD actions for Produit model.
*/
class PaiementController extends BackendController {

var $enableCsrfValidation = false;

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['ipn'],
'allow' => true,
'roles' => ['?'],
],
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

/**
* Lists all Produit models.
* @return mixed
*/
public function actionIndex() {

return $this->render('index', [
]);
}

public function actionAnnuler() {

return $this->render('annuler', [
]);
}

public function actionSucces() {
return $this->render('succes', [
]);
}

public function beforeAction($action) {
if (Yii::$app->controller->action->id == "ipn")
$this->enableCsrfValidation = false;
return parent::beforeAction($action);
}

public function actionIpn() {
if (isset($_POST)) {
$ipn = new PayPal_Ipn(false);
if ($ipn->init()) {
$custom = $ipn->getKeyValue('custom');
$txn_type = $ipn->getKeyValue('txn_type');

if ($txn_type == 'subscr_payment' && $custom) {
$user = User::findOne($custom);
if ($user) {
$etablissement = Etablissement::findOne($user->id_etablissement);
if ($etablissement) {
$etablissement->date_paiement = date('Y-m-d H:i:s', time());
$etablissement->save();
}
}
}
}
}
/* Enable again if you use it */
Yii::$app->request->enableCsrfValidation = true;
}

}

+ 154
- 0
console/config/backend/controllers/PointVenteController.php Bestand weergeven

@@ -0,0 +1,154 @@
<?php

namespace backend\controllers;

use Yii;
use yii\filters\AccessControl;
use common\models\PointVente;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\User;
use common\models\PointVenteUser;

/**
* PointVenteController implements the CRUD actions for PointVente model.
*/
class PointVenteController extends BackendController {

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
],
],
],
];
}

/**
* Lists all PointVente models.
* @return mixed
*/
public function actionIndex() {

$dataProvider = new ActiveDataProvider([
'query' => PointVente::find()->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement])
]);

return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}

/**
* Displays a single PointVente model.
* @param integer $id
* @return mixed
*/
public function actionView($id) {
return $this->render('view', [
'model' => $this->findModel($id),
]);
}

/**
* Creates a new PointVente model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
$model = new PointVente();

if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->gestionPointFabrication();
$model->gestionAccesRestreint();
return $this->redirect(['index']);
} else {
return $this->render('update', array_merge($this->initForm(), [
'model' => $model,
]));
}
}

/**
* Updates an existing PointVente model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = PointVente::find()
->with('pointVenteUser')
->where(['id' => $id])
->one();

foreach ($model->pointVenteUser as $u) {
$model->users[] = $u->id_user;
$model->users_commentaire[$u->id_user] = $u->commentaire;
}

if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->gestionPointFabrication();
$model->gestionAccesRestreint();
return $this->redirect(['index']);
} else {
return $this->render('update', array_merge($this->initForm($id), [
'model' => $model,
]));
}
}

public function initForm($id = 0) {
$users = User::findBy()
->orderBy('nom ASC')
->all();

return [
'users' => $users
];
}

/**
* Deletes an existing PointVente model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
$this->findModel($id)->delete();
PointVenteUser::deleteAll(['id_point_vente' => $id]);

return $this->redirect(['index']);
}

/**
* Finds the PointVente model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return PointVente the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = PointVente::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 196
- 0
console/config/backend/controllers/ProduitController.php Bestand weergeven

@@ -0,0 +1,196 @@
<?php

namespace backend\controllers;

use common\models\ProductionProduit;
use Yii;
use yii\filters\AccessControl;
use common\models\Produit;
use common\models\Production;
use common\models\User;
use common\models\UserBoulangerie;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\UploadedFile;
use common\helpers\Upload;

/**
* ProduitController implements the CRUD actions for Produit model.
*/
class ProduitController extends BackendController {

var $enableCsrfValidation = false;

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

/**
* Lists all Produit models.
* @return mixed
*/
public function actionIndex() {
$dataProvider = new ActiveDataProvider([
'query' => Produit::find()
->where('(vrac IS NULL OR vrac = 0)')
->andWhere(['id_etablissement' => Yii::$app->user->identity->id_etablissement])
->orderBy('order ASC'),
'pagination' => [
'pageSize' => 1000,
],
]);

return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}

/**
* Displays a single Produit model.
* @param integer $id
* @return mixed
*/
public function actionView($id) {
return $this->render('view', [
'model' => $this->findModel($id),
]);
}

/**
* Creates a new Produit model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
$model = new Produit();
$model->actif = 1;
$model->id_etablissement = Yii::$app->user->identity->id_etablissement;
$model->saison = 'all';

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Upload::uploadFile($model, 'illustration');
Upload::uploadFile($model, 'photo');
$model->save();

// on ajoute un enregistrement ProductionProduit pour chaque production
$productions = Production::find()
->where('date > ' . date('Y-m-d'))
->andWhere(['id_etablissement' => Yii::$app->user->identity->id_etablissement])
->all();
foreach ($productions as $prod) {
$production_produit = new ProductionProduit;
$production_produit->id_production = $prod->id;
$production_produit->id_produit = $model->id;
$production_produit->actif = 0;
$production_produit->save();
}

return $this->redirect(['index']);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}

/**
* Updates an existing Produit model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$request = Yii::$app->request;

$model = $this->findModel($id);
$illustration_filename_old = $model->illustration;
$photo_filename_old = $model->photo;

if ($model->load(Yii::$app->request->post()) && $model->save()) {
Upload::uploadFile($model, 'illustration', $illustration_filename_old);
Upload::uploadFile($model, 'photo', $photo_filename_old);

$delete_illustration = $request->post('delete_illustration', 0);
if ($delete_illustration) {
$model->illustration = '';
$model->save();
}

$delete_photo = $request->post('delete_photo', 0);
if ($delete_photo) {
$model->photo = '';
$model->save();
}

return $this->redirect(['index']);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}

/**
* Deletes an existing Produit model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
$this->findModel($id)->delete();

$productions_produits = ProductionProduit::find()->where(['id_produit' => $id])->all();
foreach ($productions_produits as $pp) {
$pp->delete();
}

return $this->redirect(['index']);
}

public function actionOrdre($tab) {
$tab_ordre = json_decode(stripslashes($tab));

foreach ($tab_ordre as $id => $o) {
$produit = $this->findModel($id);
$produit->order = $o;
$produit->save();
}
}

/**
* Finds the Produit model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Produit the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = Produit::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 148
- 0
console/config/backend/controllers/SiteController.php Bestand weergeven

@@ -0,0 +1,148 @@
<?php

namespace backend\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use common\models\User;
use yii\filters\VerbFilter;
use common\models\Produit;
use common\models\PointVente;
use common\models\Etablissement;
use common\models\Production;
use common\models\Commande;

/**
* Site controller
*/
class SiteController extends BackendController {

/**
* @inheritdoc
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
],
[
'actions' => ['change-etablissement'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN;
}
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}

/**
* @inheritdoc
*/
public function actions() {
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}

public function actionIndex() {
// commandes
$productions = Production::find()
->with('commande')
->where(['>=', 'production.date', date('Y-m-d')])
->andWhere([
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement,
'production.actif' => 1
])
->orderBy('date ASC')
->limit(5)
->all();

// dernières commandes
$commandes = Commande::findBy([
'orderby' => 'date DESC',
'limit' => 15,
'condition' => 'production.date > \'' . date('Y-m-d 00:00:00') . '\' AND (type = \'' . Commande::TYPE_USER . '\' OR type = \'' . Commande::TYPE_ADMIN . '\')'
]);

foreach ($commandes as $c)
$c->init();

// clients
$nb_clients = User::findBy()->count();

$clients = User::findBy()
->orderBy('created_at DESC')
->limit(5)
->all();

$clients_credit_pain_negatif = User::findBy(['id_etablissement' => Yii::$app->user->identity->id_etablissement])
->andWhere('user_etablissement.credit < 0')
->all();

// paramètres
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement);

return $this->render('index', [
'productions' => $productions,
'commandes' => $commandes,
'clients' => $clients,
'nb_clients' => $nb_clients,
'clients_credit_pain_negatif' => $clients_credit_pain_negatif,
'etablissement' => $etablissement,
]);
}

public function actionLogin() {
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}

$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}

public function actionLogout() {
Yii::$app->user->logout();

return $this->goHome();
}

public function actionChangeEtablissement($id) {
Yii::$app->user->identity->id_etablissement = $id;
Yii::$app->user->identity->save();
$this->redirect(['site/index']);
}

}

+ 90
- 0
console/config/backend/controllers/StatsController.php Bestand weergeven

@@ -0,0 +1,90 @@
<?php

namespace backend\controllers;

use yii\web\Controller;
use yii\filters\AccessControl;
use Yii;
use common\models\User;
use common\models\Commande;
use DateTime;
use DateInterval;
use DatePeriod;

class StatsController extends BackendController {

public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

public function actionIndex() {

/*
* Volume de commande de l'année passée (par mois)
*/

$date_start = date('Y-m-d', time() - 60 * 60 * 24 * 365);
$date_end = date('Y-m-d');

$data_pain = [];

// labels
$data_labels = [];

$start = new DateTime($date_start);
$interval = new DateInterval('P1M');
$end = new DateTime($date_end);

$period = new DatePeriod($start, $interval, $end);

foreach ($period as $date) {
$mois = date('m/Y', $date->getTimestamp());
$data_labels[] = $mois;
$data_pain[$mois] = 0;
}

// commandes
$commandes = Commande::find()
->with('commandeProduits')
->joinWith('production')
->where('production.date > ' . $date_start)
->andWhere('production.id_etablissement = ' . Yii::$app->user->identity->id_etablissement)
->all();

foreach ($commandes as $c) {
$c->init();
$mois = date('m/Y', strtotime($c->production->date));
if (isset($data_pain[$mois])) {
$data_pain[$mois] += $c->montant_pain;
}
}

// création d'un tableau sans index car chart.js n'accepte pas les index
$data_pain_noindex = [];
foreach ($data_pain as $key => $val) {
$data_pain_noindex[] = $val;
}

return $this->render('index', [
'data_labels' => $data_labels,
'data_pain' => $data_pain_noindex,
]);
}

}

?>

+ 243
- 0
console/config/backend/controllers/UserController.php Bestand weergeven

@@ -0,0 +1,243 @@
<?php

namespace backend\controllers;

/**
* UserController implements the CRUD actions for User model.
*/
class UserController extends BackendController {

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
if ($action->actionMethod == 'actionIndex' ||
$action->actionMethod == 'actionCreate' ||
$action->actionMethod == 'actionUpdate' ||
$action->actionMethod == 'actionCredit' ||
$action->actionMethod == 'actionMail' ||
$action->actionMethod == 'actionCommandes') {
return Yii::$app->user->identity->status == User::STATUS_ADMIN
|| Yii::$app->user->identity->status == User::STATUS_BOULANGER;
} else {
return Yii::$app->user->identity->status == User::STATUS_ADMIN;
}
}
]
],
],
];
}

/**
* Lists all User models.
* @return mixed
*/
public function actionIndex() {
$params = Yii::$app->request->queryParams;
$query = User::findBy($params);

$dataProvider = new ActiveDataProvider([
'query' => $query
]);

$etablissement = Etablissement::find()
->where(['id' => Yii::$app->user->identity->id_etablissement])
->one();

return $this->render('index', [
'dataProvider' => $dataProvider,
'etablissement' => $etablissement
]);
}

/**
* Displays a single User model.
* @param integer $id
* @return mixed
*/
public function actionView($id) {
return $this->render('view', [
'model' => $this->findModel($id),
]);
}

/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
$model = new User();

if ($model->load(Yii::$app->request->post()) && $model->validate() && YII_ENV != 'demo') {

// save use
$password = Password::generate();
$model->setPassword($password);
$model->generateAuthKey();
$model->username = $model->email;
$model->confiance = 1;
if (!strlen($model->email))
$model->username = 'inconnu@laboiteapain.net';

$model->save();

// liaison etablissement / user
$user_etablissement = new UserEtablissement();
$user_etablissement->id_user = $model->id;
$user_etablissement->id_etablissement = Yii::$app->user->identity->id_etablissement;
$user_etablissement->credit = 0;
$user_etablissement->actif = 1;
$user_etablissement->save();

// send mail
if (strlen($model->email)) {
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement);
Yii::$app->mailer->compose();
$mail = Yii::$app->mailer->compose(
['html' => 'createUserAdmin-html', 'text' => 'createUserAdmin-text'], ['user' => $model, 'etablissement' => $etablissement, 'password' => $password])
->setTo($model->email)
->setFrom(['contact@laboiteapain.net' => 'La boîte à pain'])
->setSubject('[La boîte à pain] Inscription')
->send();
}

return $this->redirect(['index']);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}

/**
* Updates an existing User model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = $this->findModel($id);

$user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one();
$user_appartient_etablissement = UserEtablissement::findOne(['id_user' => $id, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]);
if (($user_appartient_etablissement && count($user->userEtablissement) == 1) || Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
} else {
return $this->render('update', [
'model' => $model,
]);
}
} else {
throw new UserException("Vous ne pouvez pas modifier cet utilisateur, soit parce qu'il appartient à plusieurs boulangeries, soit parce qu'il n'est pas lié à la votre.");
}
}

public function actionMail() {

$users = (new \yii\db\Query())
->select('*')
->from('user, user_etablissement')
->where('user.id = user_etablissement.id_user')
->andWhere('user_etablissement.actif = 1')
->andWhere('user_etablissement.id_etablissement = ' . Yii::$app->user->identity->id_etablissement)
->all();

$arr_users = [];
foreach ($users as $u) {
if (isset($u['email']))
$arr_users[] = $u['email'];
}

return $this->render('liste_mails', [
//'model' => $model,
'users' => $arr_users
]);
}

public function actionCredit($id) {
$user = User::find()->with('userEtablissement')->where(['id' => $id])->one();
$user_etablissement = UserEtablissement::findOne(['id_user' => $id, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]);
if (($user_etablissement) || Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
$credit_form = new CreditForm;
if ($credit_form->load(Yii::$app->request->post()) && $credit_form->validate()) {
$credit_form->id_user = $id ;
$credit_form->save();
$credit_form = new CreditForm;
}

$historique = CreditHistorique::find()
->with(['commande', 'userAction'])
->where([
'id_user' => $user->id,
'id_etablissement' => Yii::$app->user->identity->id_etablissement,
])
->orderBy('date DESC')
->all();

return $this->render('credit', [
'user' => $user,
'credit_form' => $credit_form,
'historique' => $historique
]);
}
else {
throw new UserException("Vous ne pouvez pas créditer un utilisateur qui n'est pas associé à votre boulangerie.");
}
}

public function actionCommandes($id) {

$user = User::findOne($id);

$commandes = Commande::find()
->with('commandeProduits', 'pointVente', 'creditHistorique')
->joinWith('production', 'production.etablissement')
->where([
'id_user' => $id,
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement
])
->orderBy('production.date DESC')
->all();

foreach ($commandes as $c)
$c->init();

return $this->render('commandes', [
'commandes' => $commandes,
'user' => $user
]);
}

/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = User::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 195
- 0
console/config/backend/controllers/VracController.php Bestand weergeven

@@ -0,0 +1,195 @@
<?php

namespace backend\controllers;

use common\models\ProductionProduit;
use Yii;
use yii\filters\AccessControl;
use common\models\Produit;
use common\models\Production;
use common\models\User;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\UploadedFile;

/**
* ProduitController implements the CRUD actions for Produit model.
*/
class VracController extends BackendController {

var $enableCsrfValidation = false;

public function behaviors() {
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
],
],
];
}

/**
* Lists all Produit models.
* @return mixed
*/
public function actionIndex() {
$dataProvider = new ActiveDataProvider([
'query' => Produit::find()->where('vrac = 1')->orderBy('order ASC'),
]);

return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}

/**
* Displays a single Produit model.
* @param integer $id
* @return mixed
*/
public function actionView($id) {
return $this->render('view', [
'model' => $this->findModel($id),
]);
}

/**
* Creates a new Produit model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
$model = new Produit();

if ($model->load(Yii::$app->request->post()) && $model->save()) {
self::uploadFile($model, 'illustration');
self::uploadFile($model, 'photo');

$model->vrac = 1;
$model->lundi = 1;
$model->mardi = 1;
$model->mercredi = 1;
$model->jeudi = 1;
$model->vendredi = 1;
$model->samedi = 1;
$model->dimanche = 1;
$model->save();

// on ajoute un enregistrement ProductionProduit pour chaque production
$productions = Production::find()->where('date > ' . date('Y-m-d'))->all();
foreach ($productions as $prod) {
$production_produit = new ProductionProduit;
$production_produit->id_production = $prod->id;
$production_produit->id_produit = $model->id;
$production_produit->actif = 0;
$production_produit->save();
}

return $this->redirect(['index']);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}

/**
* Updates an existing Produit model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$request = Yii::$app->request;

$model = $this->findModel($id);
$illustration_filename_old = $model->illustration;
$photo_filename_old = $model->photo;

if ($model->load(Yii::$app->request->post()) && $model->save()) {
self::uploadFile($model, 'illustration', $illustration_filename_old);
self::uploadFile($model, 'photo', $photo_filename_old);

$delete_illustration = $request->post('delete_illustration', 0);
if ($delete_illustration) {
$model->illustration = '';
$model->save();
}

$delete_photo = $request->post('delete_photo', 0);
if ($delete_photo) {
$model->photo = '';
$model->save();
}

return $this->redirect(['index']);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}

public static function uploadFile($model, $champs, $filename_old = '') {
$file = UploadedFile::getInstance($model, $champs);
if ($file) {
$file_name = $file->baseName . '-' . uniqid() . '.' . $file->extension;
$file->saveAs('../../frontend/web/uploads/' . $file_name);
$model->$champs = $file_name;
} else {
$model->$champs = $filename_old;
}

$model->save();
}

/**
* Deletes an existing Produit model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
$this->findModel($id)->delete();

$productions_produits = ProductionProduit::find()->where(['id_produit' => $id])->all();
foreach ($productions_produits as $pp) {
$pp->delete();
}

return $this->redirect(['index']);
}

/**
* Finds the Produit model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Produit the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = Produit::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}

}

+ 1
- 0
console/config/backend/models/.gitkeep Bestand weergeven

@@ -0,0 +1 @@
*

+ 86
- 0
console/config/backend/models/CreditForm.php Bestand weergeven

@@ -0,0 +1,86 @@
<?php

namespace backend\models;

use Yii;
use yii\base\Model;
use common\models\CreditHistorique ;
use common\models\User ;
use common\models\Etablissement ;
use common\models\UserEtablissement ;
use common\helpers\Mail ;

/**
* ContactForm is the model behind the contact form.
*/
class CreditForm extends Model {

public $id_user ;
public $id_user_action ;
public $id_etablissement ;
public $type ;
public $montant ;
public $moyen_paiement ;
public $commentaire ;
public $send_mail ;

/**
* @inheritdoc
*/
public function rules() {
return [
[['montant'], 'required'],
[['id_user', 'id_user_action', 'id_etablissement'], 'integer'],
[['date','send_mail'], 'safe'],
[['montant'], 'double'],
[['type', 'moyen_paiement', 'commentaire'], 'string', 'max' => 255],
];
}

/**
* @inheritdoc
*/
public function attributeLabels() {
return [
'id_user' => 'Utilisateur',
'id_user_action' => 'Utilisateur',
'date' => 'Date',
'montant' => 'Montant',
'type' => 'Type',
'id_etablissement' => 'Établissement',
'moyen_paiement' => 'Moyen de paiement',
'commentaire' => 'Commentaire',
'send_mail' => 'Prévenir l\'utilisateur',
];
}
public function save() {
if ($this->validate()) {
$credit_historique = new CreditHistorique ;
$credit_historique->id_user = $this->id_user;
$credit_historique->id_user_action = Yii::$app->user->identity->id;
$credit_historique->id_etablissement = Yii::$app->user->identity->id_etablissement;
$credit_historique->type = $this->type ;
$credit_historique->commentaire = $this->commentaire ;
$credit_historique->montant = $this->montant ;
$credit_historique->moyen_paiement = $this->moyen_paiement ;
$credit_historique->save();
// on prévient l'utilisateur que son compte vient d'être crédité
if($this->send_mail) {
$user = User::findOne($this->id_user) ;
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement) ;
$user_etablissement = UserEtablissement::findOne(['id_user' => $this->id_user, 'id_etablissement' => Yii::$app->user->identity->id_etablissement]);
Mail::send($user->email, 'Votre compte vient d\'être crédité','creditUser', [
'user' => $user,
'etablissement' => $etablissement,
'user_etablissement' => $user_etablissement,
'credit_form' => $this
]) ;
}
}
}

}

+ 52
- 0
console/config/backend/models/MailForm.php Bestand weergeven

@@ -0,0 +1,52 @@
<?php

namespace backend\models;

use Yii;
use yii\base\Model;

/**
* ContactForm is the model behind the contact form.
*/
class MailForm extends Model {

public $subject;
public $body;

/**
* @inheritdoc
*/
public function rules() {
return [
// name, email, subject and body are required
[['subject', 'body'], 'required', 'message' => 'Champs obligatoire'],
];
}

/**
* @inheritdoc
*/
public function attributeLabels() {
return [
'subject' => 'Sujet',
'body' => 'Message',
];
}

/**
* Sends an email to the specified email address using the information collected by this model.
*
* @param string $email the target email address
* @return boolean whether the email was sent
*/
public function sendEmail($email) {

return Yii::$app->mailer->compose()
->setTo($email)
->setFrom(['matthieu@lechatdesnoisettes.com' => 'Le Chat des Noisettes'])
->setSubject($this->subject)
->setTextBody($this->body)
->send();
}

}

+ 2
- 0
console/config/backend/runtime/.gitignore Bestand weergeven

@@ -0,0 +1,2 @@
*
!.gitignore

+ 63
- 0
console/config/backend/views/commande/_total_commandes.php Bestand weergeven

@@ -0,0 +1,63 @@
<?php

use common\models\Commande ;
use yii\helpers\Html ;

?>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Global
</h3>
</div>
<div class="panel-body">
<div class="alert alert-warning">
<strong>Potentiel :</strong> <?= number_format($ca_potentiel,2); ?> € (<?= $poids_total ?> kg) &bull;
<strong>Commandé :</strong> <?= number_format($recettes_pain,2); ?> € (<?= $poids_pain ?> kg)
</div>

<table class="table table-bordered tab-content table-produits table-header-rotated">
<tbody>
<tr>
<?php
foreach ($produits as $p) {
if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif'])
{
echo '<th class="rotate-45"><div><span>'.Html::encode($p->getLibelleAdmin()).'</span></div></th>' ;
}
}
?>
</tr>
<tr>
<?php
foreach ($produits as $p) {
if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif'])
{

$quantite = Commande::getQuantiteProduit($p->id, $commandes);
$str_quantite = '';
if ($quantite)
$str_quantite = $quantite;

$classe = 'total';
if ($str_quantite > $produits_selec[$p->id]['quantite_max'] && !$produits_selec[$p->id]['vrac'])
{
$classe .= ' depasse';
}
echo '<td class="' . $classe . '"><strong>' . $str_quantite . '</strong> ';

if ($produits_selec[$p->id]['quantite_max'] && $str_quantite)
echo '<br /><span>' . $produits_selec[$p->id]['quantite_max'] . '</span>';
echo '</td>' ;
}
}
?>
</tr>
</tbody>
</table>
</div>
</div>


+ 292
- 0
console/config/backend/views/commande/index.php Bestand weergeven

@@ -0,0 +1,292 @@
<?php

use yii\helpers\Html;
use common\models\Commande;
use common\models\User ;
use yii\helpers\ArrayHelper ;
use yii\widgets\ActiveForm;

$this->title = 'Commande';

$cpt_non_vrac = 0;
foreach ($produits as $p) {
if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
if (!$p->vrac) {
$cpt_non_vrac ++;
}
}
}
?>

<div id="page-commande">
<div class="col-md-3" id="col-left">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Calendrier</h3>
</div>
<div class="panel-body">
<?php
// chargement assets
common\components\fullcalendar\FullcalendarWidget::widget();
// --> lancement du js en manuel (via lechatdesnoisettes.js)
?>
<div id="calendar"></div>
<?php if (!$date): ?>
<br />
<div class="alert alert-info">
<span class="glyphicon glyphicon-share-alt"></span> Choisissez une date pour initier ou
éditer un jour de production.
</div>
<?php endif; ?>
</div>
</div>
<?php if ($date != ''): ?>
<div id="bloc-production">
<input type="hidden" id="date-production" value="<?= $date ?>" />
<input type="hidden" id="id-production" value="<?= $production->id ?>" />
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Production du <strong><?php echo date('d/m/Y', strtotime($date)); ?></strong></h3>
</div>
<div class="panel-body">
<strong>Production</strong><br />
<div class="btn-group" role="group">
<a class="btn btn-default<?php if ($production->actif): ?> btn-success<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['commande/change-state', 'date' => $date, 'actif' => 1]); ?>">Activé</a>
<a class="btn btn-default<?php if (!$production->actif): ?> btn-danger<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['commande/change-state', 'date' => $date, 'actif' => 0]); ?>">Désactivé</a>
</div>
<br />
<br />
<?php if (!$production->actif): ?>
<div class="alert alert-info">
<span class="glyphicon glyphicon-share-alt"></span> Activez ici la production pour qu'elle soit visible au client.
</div>
<?php endif; ?>

<?php if ($production->actif): ?>
<?php if($production->livraison && count($arr_productions_point_vente)): ?>
<div id="productions-point-vente">
<strong>Points de vente : </strong>
<div class="checkbox-list">
<?= Html::activeCheckboxList(
$production_point_vente,
'productions_point_vente',
$arr_productions_point_vente ,
['encode' => false, 'class' => '']) ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ($production): ?>
<div id="bloc-produits">

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Produits</h3>
</div>
<div class="panel-body">
<!-- produits sélectionnés -->
<form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['commande/index', 'date' => $date]); ?>" method="post">
<div class="overflow">
<table class="table table-condensed">
<thead>
<tr>
<th class="td-actif">Actif</th>
<th class="td-produit">Produit</th>
<th class="td-max">Max. <span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="Quantité disponible à la commande. Laisser vide si vous ne souhaitez pas avoir de limite de commande. La valeur par défaut est configurable dans vos produits."></span></th>
</tr>
</thead>
<tbody>
<?php foreach ($produits as $p): ?>
<tr<?php if ($p->vrac): ?> style="display:none;"<?php endif; ?> <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>class="active"<?php endif; ?>>
<td class="td-actif"><input id="produit-<?php echo $p->id; ?>" name="Produit[<?php echo $p->id; ?>][actif]" type="checkbox" <?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>checked="checked"<?php endif; ?> /></td>
<td class="td-produit"><label for="produit-<?php echo $p->id; ?>"><?= Html::encode($p->nom) ?></label></td>
<td class="td-max"><input class="quantite-max" name="Produit[<?php echo $p->id; ?>][quantite_max]" type="text" value="<?php if (isset($produits_selec[$p->id])) echo $produits_selec[$p->id]['quantite_max']; ?>" /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" />
</form>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-md-9" id="col-right">
<input type="hidden" value="<?php echo $date; ?>" id="current-date" />
<ul id="jours-production">
<?php foreach ($jours_production as $j) : ?>
<li><?php echo $j->date; ?></li>
<?php endforeach; ?>
</ul>
<?php if ($date != ''): ?>
<div id="bloc-totaux">
<?= $this->render('_total_commandes.php',[
'produits' => $produits,
'commandes' => $commandes,
'produits_selec' => $produits_selec,
'recettes_pain' => $recettes_pain,
'poids_pain' => $poids_pain,
'ca_potentiel' => $ca_potentiel,
'poids_total' => $poids_total,
]); ?>
</div>

<?php
$num_jour_semaine = date('w', strtotime($date));
$arr_jour_semaine = [0 => 'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi'];
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];
?>
<div class="panel panel-default" id="panel-commandes">
<div class="panel-heading">
<h3 class="panel-title">
Commandes
<?php if (!count($commandes)): ?><span class="label label-danger">0</span>
<?php else: ?><span class="label label-success"><?= count($commandes) ?></span>
<?php endif; ?>
<?php if (count($commandes)): ?>
<a id="btn-export-commandes" class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['commande/report', 'date' => $date, 'id_point_vente' => 0, 'global' => 1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Exporter</a>
<?php endif; ?>
<div id="btn-commandes-auto" class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-repeat"></span> Commandes récurrentes <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="<?= Yii::$app->urlManager->createUrl(['commande/add-commandes-auto', 'date' => $date]); ?>">Importer toutes les commandes</a></li>
</ul>
</div>
</h3>
</div>
<div class="panel-body">
<div class="col-md-12">
<div class="alert alert-danger" style="display:none;">Aucun point de vente activé</div>
<!-- Nav tabs -->
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist">
<?php foreach($points_vente as $pv): ?>
<li role="presentation" class="<?php if($pv->point_fabrication): ?>active<?php endif; ?>">
<a href="#point-vente-<?= $pv->id ?>" id="btn-point-vente-<?= $pv->id ?>" aria-controls="point-vente-<?= $pv->id ?>" role="tab" data-toggle="tab"><?= Html::encode($pv->nom) ?> <span class="badge badge-<?php if(count($pv->commandes)): ?>success<?php else: ?>danger<?php endif; ?>"><?php echo count($pv->commandes); ?></span></a>
</li>
<?php endforeach; ?>
</ul>

<!-- Tab panes -->
<div class="tab-content" id="commandes-points-vente">
<?php foreach($points_vente as $pv): ?>
<div role="tabpanel" data-id-pv="<?= $pv->id ?>" class="bloc-point-vente tab-pane <?php if($pv->point_fabrication): ?> active<?php endif; ?>" id="point-vente-<?= $pv->id ?>">
<div class="col-md-12">
<div class="alert alert-warning recap-pv <?php if(!count($pv->commandes)): ?>no-commande<?php endif; ?>">
<?php if(count($pv->commandes)): ?>
<strong class="commandes"><?= count($pv->commandes) ?> commande<?php if(count($pv->commandes) > 1): ?>s<?php endif; ?></strong>
<span class="recettes"><?= number_format($pv->recettes, 2) ?> €</span>
<?php else: ?>
<strong class="commandes">Aucune commande</strong>
<span class="recettes"></span>
<?php endif; ?>
</div>
<ul class="liste-commandes btn-group-vertical<?php if(!count($pv->commandes)): ?> no-commande<?php endif; ?>">
<?php foreach($pv->commandes as $c): ?>
<li>
<a href="javascript:void(0);" class="btn btn-default" data-pv-id="<?= $pv->id ?>" data-id-commande="<?= $c->id ?>" data-commande='<?= $pv->data_options_commandes[$c->id]['data-commande'] ?>' data-commentaire="<?= Html::encode($c->commentaire) ?>" data-date="<?= date('d/m à H:i',strtotime($c->date)); ?>">
<span class="montant <?php if(number_format($c->montant_paye,2) >= number_format($c->montant,2)): ?>paye<?php endif; ?>">
<?= Html::encode(number_format($c->montant, 2)); ?> €
<?php if($c->montant_paye - $c->montant > 0.01): ?><span class="glyphicon glyphicon-warning-sign"></span><?php endif; ?>
</span>
<span class="user">
<?php if($c->type): ?>
<?php if($c->type == Commande::TYPE_ADMIN): ?>
<span class="label label-warning">vous</span>
<?php elseif($c->type == Commande::TYPE_AUTO): ?>
<span class="label label-default">auto</span>
<?php elseif($c->type == Commande::TYPE_USER): ?>
<span class="label label-success">client</span>
<?php endif; ?>
<?php endif; ?>
<?php if(isset($c->user)): ?>
<?= Html::encode($c->user->nom.' '.$c->user->prenom); ?>
<?php else: ?>
<?= Html::encode($c->username); ?>
<?php endif; ?>
</span>
<?php if (strlen($c->commentaire)): ?>
<span class="glyphicon glyphicon-comment"></span>
<?php endif; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?= Html::a('<span class="glyphicon glyphicon-plus"></span> Créer une commande', 'javascript:void(0);', ['class' => 'btn btn-default creer-commande', 'data-pv-id' => $pv->id]) ?>
</div>
<div class="col-md-12 bloc-commande">
<h2 class="title-user">
<span class="buttons-edit-remove">
<?= Html::a('<span class="glyphicon glyphicon-trash"></span> Supprimer', 'javascript:void(0);', ['class' => 'btn btn-default btn-remove']) ?>
<?= Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', 'javascript:void(0);', ['class' => 'btn btn-default btn-edit']) ?>
</span>
<span class="buttons-save-cancel">
<?= Html::a('<span class="glyphicon glyphicon-ok"></span> Sauvegarder', 'javascript:void(0);', ['class' => 'btn btn-primary btn-save']) ?>
<?= Html::a('<span class="glyphicon glyphicon-remove"></span> Annuler', 'javascript:void(0);', ['class' => 'btn btn-default btn-cancel']) ?>
</span>
<span class="the-title"></span>
<span class="choix-user">
<?= Html::activeDropDownList(new User, 'id', ArrayHelper::map(User::find()->joinWith('userEtablissement')->where('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement)->andWhere('user_etablissement.actif = 1')->orderBy('user.nom ASC, user.prenom ASC')->all(), 'id', function($model, $defaultValue) {
return $model['nom'].' '.$model['prenom'];
}), ['prompt' => '--','class' => 'form-control user-id']) ?>
OU <input type="text" class="form-control username" placeholder="Choisissez un nom" />
</span>
</h2>
<div class="commentaire alert alert-info">
</div>
<textarea name="commentaire" class="form-control textarea-commentaire" placeholder="Commentaire"></textarea>
<table class="table table-bordered table-condensed tab-content table-produits">
<tbody>
<?php foreach ($produits as $p): ?>
<?php if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?>
<tr class="produit-<?= $p->id ?>" data-id-produit="<?= $p->id ?>">
<td class="td-commande"></td>
<td class="td-produit"><?php echo Html::encode($p->getLibelleAdmin()); ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<tr class="tr-total">
<td class="td-total"></td>
<td class="td-paiement"></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>

+ 169
- 0
console/config/backend/views/commande/report.php Bestand weergeven

@@ -0,0 +1,169 @@

<?php

use common\models\Commande ;

$num_jour_semaine = date('w', strtotime($date));
$arr_jour_semaine = [0 => 'dimanche', 1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi'];
$champs_horaires_point_vente = 'horaires_' . $arr_jour_semaine[$num_jour_semaine];

$html = '' ;

// par point de vente
foreach ($points_vente as $pv) {
if (count($pv->commandes) && strlen($pv->$champs_horaires_point_vente)) {
$html .= '<h3>'.$pv->nom.'</h3>' ;

$html .= '<table class="table table-bordered">'
. '<thead>'
. '<tr>'
. '<th>Client</th>'
. '<th>Produits</th>'
. '<th>Commentaire</th>'
. '<th>Montant</th>'
. '</tr>'
. '<tbody>';
foreach ($pv->commandes as $c) {
$html .= '<tr>' ;
$str_user = '';

// username
if ($c->user) {
$str_user = $c->user->prenom . " " . $c->user->nom; //.' - '.date('d/m', strtotime($c->date)) ;
} else {
$str_user = $c->username; //.' - '.date('d/m', strtotime($c->date)) ;
}
if(strlen($c->commentaire_point_vente))
{
$str_user .= '<br /><em>'.$c->commentaire_point_vente.'</em>' ;
}
// téléphone
if (isset($c->user) && strlen($c->user->telephone)) {
$str_user .= '<br />' . $c->user->telephone . '';
}

$html .= '<td>'.$str_user.'</td>';
// produits
$str_produits = '';
foreach ($produits as $p) {
if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
$add = false;
foreach ($c->commandeProduits as $cp) {
if ($p->id == $cp->id_produit) {
$str_produits .= $cp->quantite . '&nbsp;' . $p->nom . ', ';
$add = true;
}
}
}
}
$html .= '<td>'.substr($str_produits, 0, strlen($str_produits) - 2).'</td>';
$html .= '<td>'.$c->commentaire.'</td>';
$html .= '<td>'.number_format($c->montant, 2) . ' € ';

if($c->getStatutPaiement() == Commande::STATUT_PAYEE)
{
$html .= '(payé)' ;
}
elseif($c->getStatutPaiement() == Commande::STATUT_IMPAYEE && $c->getMontantPaye())
{
$html .= '(reste '.$c->getMontantRestant(true).' à payer)' ;
}
elseif($c->getStatutPaiement() == Commande::STATUT_SURPLUS)
{
$html .= '(surplus : '.$c->getMontantSurplus(true).' à rembourser)' ;
}
$html .= '</td>' ;
$html .= '</tr>' ;
}

$html .= '<tr><td><strong>Total</strong></td>' ;
$str_produits = '';
foreach ($produits as $p) {
if (!$p->vrac && isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
$quantite = Commande::getQuantiteProduit($p->id, $pv->commandes);
$str_quantite = '';
if ($quantite) {
$str_quantite = $quantite;
$str_produits .= $str_quantite .'&nbsp;'. $p->nom . ', ';
}
}
}
$str_produits = substr($str_produits, 0, strlen($str_produits) - 2) ;
$html .= '<td>'.$str_produits.'</td><td></td>' ;
$html .= '<td><strong>'.number_format($pv->recettes_pain, 2) . ' €</strong></td>';
$html .= '</tbody></table><pagebreak>' ;
}
}

// par point de vente
$html .= '<h3>Points de vente</h3>' ;
$html .= '<table class="table table-bordered">'
. '<thead>'
. '<tr>'
. '<th>Point de vente</th>'
. '<th>Produits</th>'
. '<th>Montant</th>'
. '</tr>'
. '<tbody>';

$recettes = 0 ;
foreach ($points_vente as $pv)
{
if (count($pv->commandes) && strlen($pv->$champs_horaires_point_vente))
{
$html .= '<tr><td>'.$pv->nom.'</td><td>' ;
foreach ($produits as $p) {
if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
$quantite = Commande::getQuantiteProduit($p->id, $pv->commandes);
$str_quantite = '';

if (!$p->vrac) {
if ($quantite)
$str_quantite = $quantite;
}

if(strlen($str_quantite))
$html .= $str_quantite . '&nbsp;'.$p->nom.', ' ;
}
}
$html = substr($html, 0, strlen($html) - 2) ;
$html .= '</td><td>'.number_format($pv->recettes_pain, 2).' €</td></tr>' ;
$recettes += $pv->recettes_pain ;
}
}

// total
$html .= '<tr><td><strong>Total</strong></td><td>' ;
foreach ($produits as $p) {
if (isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) {
$quantite = Commande::getQuantiteProduit($p->id, $commandes);
if(!$p->vrac && $quantite)
$html .= $quantite . '&nbsp;'.$p->nom.', ' ;
}
}

$html = substr($html, 0, strlen($html) - 2) ;

$html .= '</td><td><strong>'.number_format($recettes, 2).' €</strong></td></tr>' ;

$html .= '</tbody></table>' ;

echo $html ;

?>

+ 79
- 0
console/config/backend/views/commandeauto/_form.php Bestand weergeven

@@ -0,0 +1,79 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper ;
use common\models\User ;
use common\models\PointVente ;

?>

<div class="commandeauto-form">
<?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?>
<div class="col-md-5" id="bloc-select-user">
<?= $form->field($model, 'id_user')->dropDownList( ArrayHelper::map(User::find()->joinWith('userEtablissement')->where('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement)->andWhere('user_etablissement.actif = 1')->orderBy('nom ASC, prenom ASC')->all(), 'id', function($model, $defaultValue) {
return $model['nom'].' '.$model['prenom'];
}), ['prompt' => '--','class' => 'form-control user-id', ]) ?>
</div>
<div class="col-md-1" id="or-user">
<span>OU</span>
</div>
<div class="col-md-6">
<?= $form->field($model, 'username')->textInput() ?>
</div>
<div class="clr"></div>
<?= $form->field($model, 'id_etablissement')->hiddenInput() ?>
<?= $form->field($model, 'id_point_vente')->dropDownList( ArrayHelper::map(PointVente::find()->where('id_etablissement = '.Yii::$app->user->identity->id_etablissement)->all(), 'id', function($model, $defaultValue) {
return $model['nom'];
}), ['prompt' => '--','class' => 'form-control user-id']) ?>
<?= $form->field($model, 'date_debut') ?>
<?= $form->field($model, 'date_fin')->hint('Laisser vide pour une durée indéterminée') ?>
<div class="jours">
<h2>Jours</h2>
<?= $form->field($model, 'lundi')->checkbox() ?>
<?= $form->field($model, 'mardi')->checkbox() ?>
<?= $form->field($model, 'mercredi')->checkbox() ?>
<?= $form->field($model, 'jeudi')->checkbox() ?>
<?= $form->field($model, 'vendredi')->checkbox() ?>
<?= $form->field($model, 'samedi')->checkbox() ?>
<?= $form->field($model, 'dimanche')->checkbox() ?>
</div>
<div class="clr"></div>
<?= $form->field($model, 'periodicite_semaine')->dropDownList([1=>1, 2=>2, 3=>3, 4=>4]) ?>

<?= $form->field($model, 'paiement_automatique')
->checkbox()
->hint('Cochez cette case si vous souhaitez que le crédit pain du client soit automatiquement débité lors de la création de la commande.<br />'
. 'Attention, un compte client existant doit être spécifié en haut de ce formulaire.') ?>
<div class="produits">
<h2>Produits</h2>
<?php if(isset($model->errors['produits']) && count($model->errors['produits']))
{
echo '<div class="alert alert-danger">'.$model->errors['produits'][0].'</div>' ;
}
?>
<table class="table table-bordered table-condensed table-hover">
<?php foreach ($produits as $p) : ?>
<tr>
<td><?= Html::encode($p->nom) ?></td>
<td>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default btn-moins" type="button"><span class="glyphicon glyphicon-minus"></span></button>
</span>
<?= Html::input('text', 'CommandeAutoForm[produits][produit_'.$p->id.']', (isset($model->produits['produit_'.$p->id])) ? $model->produits['produit_'.$p->id] : '', ['class' => 'form-control quantite']) ?>
<span class="input-group-btn">
<button class="btn btn-default btn-plus" type="button"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<?= Html::submitButton('Enregistrer' , ['class' => 'btn btn-primary']) ?>
<?php ActiveForm::end(); ?>
</div>

+ 21
- 0
console/config/backend/views/commandeauto/create.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = 'Ajouter une commande automatique';
$this->params['breadcrumbs'][] = ['label' => 'Commandes automatiques', 'url' => ['index']];
$this->params['breadcrumbs'][] = 'Ajouter';
?>
<div class="commandeauto-create">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
'produits' => $produits
]) ?>

</div>

+ 139
- 0
console/config/backend/views/commandeauto/index.php Bestand weergeven

@@ -0,0 +1,139 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Commandes récurrentes';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="commande-auto-index">

<h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>

<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'id_user',
'format' => 'raw',
'value' => function($model) {
if(strlen($model->username))
{
return Html::encode($model->username) ;
}
else {
if(isset($model->user))
return Html::encode($model->user->nom.' '.$model->user->prenom) ;
}
}
],
[
'attribute' => 'id_point_vente',
'format' => 'raw',
'value' => function($model) {
return Html::encode($model->pointVente->nom) ;
}
],
[
'attribute' => 'produits',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
foreach($model->commandeAutoProduit as $commande_produit)
{
$html .= $commande_produit->quantite . ' x '.Html::encode($commande_produit->produit->nom).'<br />' ;
}
// aucun produit
if(!count($model->commandeAutoProduit))
{
$html .= '<span class="glyphicon glyphicon-warning-sign"></span> Aucun produit' ;
}
return $html ;
}
],
[
'attribute' => 'date_debut',
'value' => function($model) {
return date('d/m/Y',strtotime($model->date_debut)) ;
}
],
[
'attribute' => 'date_fin',
'value' => function($model) {
if($model->date_fin)
return date('d/m/Y',strtotime($model->date_fin)) ;
else
return 'indéterminée' ;
}
],
[
'attribute' => 'lundi',
'label' => 'Jours',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
if($model->lundi)
$html .= 'lundi, ' ;
if($model->mardi)
$html .= 'mardi, ' ;
if($model->mercredi)
$html .= 'mercredi, ' ;
if($model->jeudi)
$html .= 'jeudi, ' ;
if($model->vendredi)
$html .= 'vendredi, ' ;
if($model->samedi)
$html .= 'samedi, ' ;
if($model->dimanche)
$html .= 'dimanche, ' ;
if(strlen($html))
return substr ($html, 0, strlen($html) - 2) ;
else
return '<span class="glyphicon glyphicon-warning-sign"></span> Aucun jour' ;
}
],
[
'attribute' => 'periodicite_semaine',
'value' => function($model) {
if($model->periodicite_semaine == 1)
return 'Toutes les semaines' ;
else
return 'Toutes les '.$model->periodicite_semaine.' semaines' ;
}
],
[
'attribute' => 'paiement_automatique',
'format' => 'raw',
'value' => function($model) {
if($model->paiement_automatique)
return '<span class="label label-success">Oui</span>' ;
else
return '<span class="label label-danger">Non</span>' ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'update' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
]);
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]);
}
],
],
],
]); ?>
</div>

+ 19
- 0
console/config/backend/views/commandeauto/update.php Bestand weergeven

@@ -0,0 +1,19 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = 'Modifier une commande récurrente';
$this->params['breadcrumbs'][] = ['label' => 'Commandes récurrentes', 'url' => ['index']];
$this->params['breadcrumbs'][] = 'Modifier';
?>
<div class="commandeauto-update">
<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
'produits' => $produits
]) ?>
</div>

+ 11
- 0
console/config/backend/views/communiquer/affiche.php Bestand weergeven

@@ -0,0 +1,11 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

?>

<h1>Affiche</h1>

+ 20
- 0
console/config/backend/views/communiquer/index.php Bestand weergeven

@@ -0,0 +1,20 @@
<?php

use yii\helpers\Html ;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

$this->title = 'Communiquer' ;

?>

<h1><?= Html::encode($this->title) ; ?></h1>

<p>Imprimez ce petit encart pour expliquer à vos clients comment passer leurs commandes.</p>
<?php echo $this->render('mode_emploi', ['etablissement' => $etablissement]) ; ?>
<p><?php echo Html::a('<span class="glyphicon glyphicon-download-alt"></span> Télécharger', ['communiquer/modeemploi'], ['class'=>'btn btn-primary']) ?></p>


+ 28
- 0
console/config/backend/views/communiquer/mode_emploi.php Bestand weergeven

@@ -0,0 +1,28 @@
<?php

use yii\helpers\Html ;

?>

<div class="communiquer-mode-emploi<?php if(isset($pdf) && $pdf): ?> communiquer-mode-emploi-pdf<?php endif; ?><?php if(!isset($pdf)): ?> communiquer-mode-emploi-encart<?php endif; ?>">
<div class="header">
<div class="logo">
<img src="./img/laboulange4.png" alt="Logo" />
</div>
<h1>La boîte à pain</h1>
<h2>Plateforme de réservation de pain</h2>
</div>
<div class="clr"></div>
<h3>Pour réserver votre pain en ligne</h3>
<ol>
<li>Inscrivez-vous sur <strong>www.laboiteapain.net</strong></li>
<?php if(strlen($etablissement->code)): ?>
<li>Ajoutez le producteur <strong><?= Html::encode($etablissement->nom); ?></strong><br />grâce au code : <span class="code"><strong><?= Html::encode($etablissement->code) ?></strong> <?php if(!isset($pdf)): echo Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['etablissement/update'], ['class'=> 'btn btn-default btn-xs']); endif; ?></span></li>
<?php else: ?>
<li>Ajoutez la producteur <strong><?= Html::encode($etablissement->nom); ?></strong></li>
<?php endif; ?>
<li>Passez votre commande</li>
</ol>
</div>

+ 9
- 0
console/config/backend/views/communiquer/mode_emploi_multi.php Bestand weergeven

@@ -0,0 +1,9 @@
<?php

?>

<?php for($i = 0; $i < 8; $i++): ?>
<div class="bloc-mode-emploi-pdf<?php if($i%2 == 0): ?> bloc-mode-emploi-border<?php endif; ?><?php if($i == 6 || $i == 7): ?> bloc-mode-emploi-bottom<?php endif; ?>">
<?php echo $this->render('mode_emploi',['pdf' => true, 'etablissement' => $etablissement]) ; ?>
</div>
<?php endfor; ?>

+ 42
- 0
console/config/backend/views/developpement/_form.php Bestand weergeven

@@ -0,0 +1,42 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Developpement ;

/* @var $this yii\web\View */
/* @var $model common\models\Developpement */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="developpement-form">

<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'type')->dropDownList([
Developpement::TYPE_EVOLUTION => 'Évolution',
Developpement::TYPE_BUG => 'Anomalie',
]) ?>
<?= $form->field($model, 'statut')->dropDownList([
Developpement::STATUT_OPEN => 'Ouvert',
Developpement::STATUT_CLOSED => 'Fermé',
]) ?>
<?= $form->field($model, 'objet')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>

<?= $form->field($model, 'estimation_temps')->textInput() ?>

<?= $form->field($model, 'avancement')->textInput() ?>
<?= $form->field($model, 'date_livraison')->textInput() ?>

<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>

</div>

+ 21
- 0
console/config/backend/views/developpement/create.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;


/* @var $this yii\web\View */
/* @var $model common\models\Developpement */

$this->title = 'Ajouter un développement';
$this->params['breadcrumbs'][] = ['label' => 'Développement', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="developpement-create">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 162
- 0
console/config/backend/views/developpement/index.php Bestand weergeven

@@ -0,0 +1,162 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Developpement;
use common\models\DeveloppementPriorite;
use common\models\User;
use common\helpers\Url;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Développement';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="developpement-index">

<h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
<div class="well">
Cette page liste les besoins recencés auprès des producteurs utilisant la plateforme. N'hésitez pas à me <a href="<?= Url::frontend('site/contact') ?>">contacter</a> pour la faire évoluer. Les remontées de bugs sont également bienvenues.<br />
Afin d'orienter de manière pertinente le développement de la plateforme, je vous invite à définir la priorité des évolutions qui vous intéressent.
</div>
<?php
foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
}
?>
<ul id="tabs-statuts-developpements" class="nav nav-tabs" role="tablist">
<li role="presentation" class="<?php if($statut == Developpement::STATUT_OPEN): ?>active<?php endif; ?>"><a href="<?= Yii::$app->urlManager->createUrl(['developpement/index','statut' => Developpement::STATUT_OPEN]); ?>" id="" aria-controls="" role="tab">Ouvert</a></li>
<li role="presentation" class="<?php if($statut == Developpement::STATUT_CLOSED): ?>active<?php endif; ?>"><a href="<?= Yii::$app->urlManager->createUrl(['developpement/index','statut' => Developpement::STATUT_CLOSED]); ?>" id="" aria-controls="" role="tab">Fermé</a></li>
</ul>
<?php
$columns = [
[
'header' => '#',
'value' => function($model) {
return '#'.$model->id ;
}
],
[
'attribute' => 'type',
'header' => 'Type',
'format' => 'raw',
'value' => function($model) {
if($model->type == Developpement::TYPE_EVOLUTION) {
return '<span class="label label-success">Évolution</span>' ;
}
else {
return '<span class="label label-danger">Anomalie</span>' ;
}
}
],
[ 'attribute' => 'sujet',
'format' => 'raw',
'value' => function($model) {
$html = '<strong>'.Html::encode($model->objet).'</strong>' ;
if(strlen($model->description))
$html .= '<br />'.nl2br(Html::encode($model->description)) ;
return $html ;
}],
[ 'attribute' => 'estimation_temps',
'header' => 'Estimation',
'format' => 'raw',
'value' => function($model) {
return intval($model->estimation_temps).' h' ;
}],
[ 'attribute' => 'avancement',
'format' => 'raw',
'value' => function($model) {
if($model->avancement)
return '<div class="progress">
<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="'.intval($model->avancement).'" aria-valuemin="0" aria-valuemax="100" style="width: '.intval($model->avancement).'%;">
<span class="sr-only">'.intval($model->avancement).'% effectué</span>
</div>
</div> ' ;
else
return '' ;
}],
[ 'attribute' => 'date_livraison',
'format' => 'raw',
'value' => function($model) {
if(strlen($model->date_livraison))
return date('d/m/Y',strtotime($model->date_livraison)) ;
else
return '' ;
}],
] ;
if(Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER) {
$columns[] = [
'header' => 'Priorité',
'format' => 'raw',
'value' => function($model) {

$current_priorite = (isset($model->developpementPrioriteCurrentEtablissement)) ? $model->developpementPrioriteCurrentEtablissement->getStrPriorite() : 'Non' ;
$style_bouton = (isset($model->developpementPrioriteCurrentEtablissement)) ? $model->developpementPrioriteCurrentEtablissement->getClassCssStyleBouton() : 'default' ;
$html = '<div class="btn-group btn-group-priorite">
<button type="button" class="btn btn-priorite btn-sm btn-'.$style_bouton.' dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
'.$current_priorite.' <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id]).'">Non</a></li>
<li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_BASSE]).'">Basse</a></li>
<li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_NORMALE]).'">Normale</a></li>
<li><a href="'.Yii::$app->urlManager->createUrl(['developpement/priorite','id_developpement'=>$model->id, 'priorite' => DeveloppementPriorite::PRIORITE_HAUTE]).'">Haute</a></li>
</ul>
</div><br />' ;
if(isset($model->developpementPriorite) && count($model->developpementPriorite)) {
foreach($model->developpementPriorite as $developpement_priorite) {
if($developpement_priorite->id_etablissement != Yii::$app->user->identity->id_etablissement)
$html .= '<div class="label label-priorite label-sm label-'.$developpement_priorite->getClassCssStyleBouton().'">'.Html::encode($developpement_priorite->etablissement->nom).'</div> ' ;
}
}
return $html ;
}
] ;
}
if(Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
$columns[] = [
'class' => 'yii\grid\ActionColumn',
'template' => '{update}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'update' => function ($url, $model) {
return '<div class="btn-group">
<a href="'.$url.'" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="'.Yii::$app->urlManager->createUrl(['developpement/delete','id' => $model->id]).'" class=""><span class="glyphicon glyphicon-trash"></span> Supprimer</a></li>
</ul>
</div>' ;
},
],
] ;
}
?>
<?=
GridView::widget([
'id' => 'tab-developpements',
'dataProvider' => $dataProvider,
'columns' => $columns
]);
?>
</div>

+ 21
- 0
console/config/backend/views/developpement/update.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model common\models\Developpement */

$this->title = 'Modifier un développement';
$this->params['breadcrumbs'][] = ['label' => 'Développement', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '#'.$model->id, 'url' => ['update', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Modifier';
?>
<div class="developpement-update">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 53
- 0
console/config/backend/views/etablissement-admin/facturation.php Bestand weergeven

@@ -0,0 +1,53 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;
use common\models\Etablissement ;

$this->title = 'Facturation';
$this->params['breadcrumbs'][] = 'Administration' ;
$this->params['breadcrumbs'][] = $this->title;

?>

<h1>Facturation</h1>

<?= GridView::widget([
'dataProvider' => $datas_factures,
'columns' => [
[
'attribute' => 'reference',
'label' => 'Référence',
],
[
'attribute' => 'id_etablissement',
'label' => 'Établissement',
'value' => function($model) {
return Html::encode($model->etablissement->nom) ;
}
],
'libelle',
[
'attribute' => 'montant_ht',
'label' => 'Montant',
'value' => function($model) {
return number_format($model->montant_ht,2).' €' ;
}
],
[
'attribute' => 'paye',
'label' => 'Payé',
'format' => 'raw',
'value' => function($model) {
if($model->paye)
{
return '<span class="label label-success">Oui</span>' ;
}
else {
return '<span class="label label-danger">Non</span>' ;
}
}
]
],
]); ?>

+ 127
- 0
console/config/backend/views/etablissement-admin/index.php Bestand weergeven

@@ -0,0 +1,127 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;
use common\models\Etablissement ;

$this->title = 'Producteurs';
$this->params['breadcrumbs'][] = 'Administration' ;
$this->params['breadcrumbs'][] = $this->title;

?>

<h1>Producteurs</h1>

<?= GridView::widget([
'dataProvider' => $datas_etablissements,
'columns' => [
'nom',
[
'attribute' => 'date_creation',
'format' => 'raw',
'value' => function($model) {
return date('d/m/Y', strtotime($model->date_creation)) ;
}
],
[
'attribute' => 'Lieu',
'format' => 'raw',
'value' => function($model) {
return Html::encode($model->ville.' ('.$model->code_postal.')') ;
}
],
[
'attribute' => 'Clients',
'format' => 'raw',
'value' => function($model) {
if(!$model->userEtablissement || !count($model->userEtablissement))
{
return 'Aucun client' ;
}
else {
$clients = count($model->userEtablissement).' client' ;
if(count($model->userEtablissement) > 1)
$clients .= 's' ;
return $clients ;
}
}
],
[
'attribute' => 'Contact',
'format' => 'raw',
'value' => function($model) {
if(!isset($model->user) || (isset($model->user) && count($model->user) == 0))
{
return 'Aucun contact' ;
}
else {
foreach($model->user as $u)
{
if($u->status == User::STATUS_BOULANGER)
{
return Html::encode($u->prenom.' '.$u->nom)
.'<br />'.Html::encode($u->email)
.'<br />'.Html::encode($u->telephone) ;
}
}
}
}
],
[
'attribute' => 'actif',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
if($model->actif)
$html .= '<span class="label label-success">En ligne</span>' ;
else
$html .= '<span class="label label-danger">Hors-ligne</span>' ;
if(strlen($model->code))
{
$html .= ' <span class="glyphicon glyphicon-lock" data-toggle="tooltip" data-placement="bottom" data-original-title="'.Html::encode($model->code).'"></span>' ;
}
return $html ;
}
],
[
'attribute' => 'Gratuit',
'format' => 'raw',
'value' => function($model) {
if($model->gratuit)
return '<span class="label label-success">Compte gratuit</span>' ;
else
return '' ;
}
],
[
'attribute' => 'Prix libre',
'label' => 'Prix libre',
'format' => 'raw',
'value' => function($model) {
if(is_null($model->prix_libre))
return '' ;
else
return $model->getPrixLibre() ;
}
],
[
'attribute' => 'Cours',
'label' => 'CA mois en cours',
'format' => 'raw',
'value' => function($model) {
$ca = $model->getCA(date('Y-m')) ;
$html = '' ;
$html .= 'CA : '.number_format($ca,2).' €<br />' ;
return $html ;
}
],
],
]); ?>

+ 96
- 0
console/config/backend/views/etablissement/facturation.php Bestand weergeven

@@ -0,0 +1,96 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;
use common\models\Etablissement ;
use yii\bootstrap\ActiveForm;

$this->title = 'Facturation';
$this->params['breadcrumbs'][] = 'Administration' ;
$this->params['breadcrumbs'][] = $this->title;

?>

<h1>Facturation</h1>

<p class="">
Vous seuls savez ce que vous apporte cet outil et dans quelle mesure vous souhaitez le soutenir.<br />
C'est pourquoi le modèle économique est basé sur un prix libre facturé mensuellement.<br />
</p>

<div id="estimation-facture" class="">
<?php if($alert_prix_libre): ?>
<div class="alert alert-success">
Le prix libre a bien été mis à jour.
<?php if($etablissement->prix_libre != 0): ?>
Vos prochaines factures mensuelles auront un montant de <strong><?= number_format(Html::encode($etablissement->prix_libre),2).' € TTC' ; ?></strong>.
<?php endif; ?>
</div>
<?php endif; ?>
<?php $form = ActiveForm::begin([
'layout' => 'horizontal',
'fieldConfig' => [
'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
'horizontalCssClasses' => [
'label' => 'col-sm-2',
],
],
]); ?>
<?= $form->field($etablissement, 'prix_libre')->textInput()->label('Prix libre<br /><span>€ TTC / mois</span>') ?>
<div class="form-group field-user-prix_libre">
<label class="control-label col-sm-2" for=""></label>
<div class="col-sm-6">
<?= Html::submitButton('Valider', ['class' => 'btn btn-primary']) ?>
</div>
</div>

<?php ActiveForm::end(); ?>
<div class="clr"></div>
</div>


<h2>Dernières factures</h2>
<?= GridView::widget([
'dataProvider' => $datas_factures,
'columns' => [
[
'attribute' => 'reference',
'label' => 'Référence',
],
[
'attribute' => 'date',
'value' => function($model) {
return date('d/m/Y', strtotime($model->date)) ;
}
],
'libelle',
[
'attribute' => 'montant_ht',
'label' => 'Montant',
'value' => function($model) {
return number_format($model->montant_ht,2).' €' ;
}
],
[
'attribute' => 'paye',
'label' => 'Payé',
'format' => 'raw',
'value' => function($model) {
if($model->paye)
{
return '<span class="label label-success">Oui</span>' ;
}
else {
return '<span class="label label-danger">Non</span>' ;
}
}
]
],
]); ?>

+ 100
- 0
console/config/backend/views/etablissement/update.php Bestand weergeven

@@ -0,0 +1,100 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\helpers\Url ;

/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = 'Paramètres';
$this->params['breadcrumbs'][] = 'Paramètres';
?>
<div class="user-update">
<h1><?= Html::encode($this->title) ?></h1>
<div class="user-form">
<?php $form = ActiveForm::begin(); ?>
<div class="">
<?= $form->field($model, 'actif')
->dropDownList([
0 => 'Non',
1 => 'Oui'
], [])
->label('Activer le producteur')
->hint('Activez cette option pour rendre votre établissement visible à vos clients.') ; ?>
<?= $form->field($model, 'code_postal') ?>
<?= $form->field($model, 'ville') ?>
<?= $form->field($model, 'code')->hint("Saisissez ce champs si vous souhaitez protéger l'accès à votre boutique par un code, sinon laissez-le vide.<br />"
. "Ce code est à communiquer à vos client pour qu'ils puissent ajouter votre établissement à leur tableau de bord.<br />"
. "<a href=\"".Yii::$app->urlManager->createUrl(['communiquer/index'])."\">Cliquez ici</a> pour télécharger un mode d'emploi comprenant ce code à distribuer à vos clients.") ?>

<?= $form->field($model, 'delai_commande')
->dropDownList([
1 => '1 jour',
2 => '2 jours',
3 => '3 jours',
4 => '4 jours',
5 => '5 jours',
6 => '6 jours',
7 => '7 jours',
], [])
->hint('Si <strong>1 jour</strong> est sélectionné, le client pourra commander jusqu\'à la veille de la production.<br />'
. 'Si <strong>2 jours</strong> est sélectionné, le client pourra commander jusqu\'à l\'avant-veille de la production, etc.') ; ?>
<?= $form->field($model, 'heure_limite_commande')
->dropDownList([
24 => 'Minuit',
23 => '23h',
22 => '22h',
21 => '21h',
20 => '20h',
19 => '19h',
18 => '18h',
17 => '17h',
16 => '16h',
15 => '15h',
14 => '14h',
13 => '13h',
12 => '12h',
11 => '11h',
10 => '10h',
9 => '9h',
8 => '8h',
], [])
->hint('Heure limite jusqu\'à laquelle les clients peuvent commander pour satisfaire le délai de commande.<br />'
. 'Par exemple, si <strong>2 jours</strong> est sélectionné dans le délai de commande, le client devra commander l\'avant-veille de la production avant l\'heure précisée ici.') ; ?>
<?= $form->field($model, 'credit_pain')
->dropDownList([
0 => 'Non',
1 => 'Oui',
], [])
->label('Activer le système de Crédit Pain')
->hint('Le système de Crédit Pain permet à vos clients d\'avoir un compte prépayé sur le site <em>La boîte à pain</em>.<br />'
. 'Ils créditent leur compte en vous donnant la somme de leur choix et c\'est ensuite à vous de '.Html::a('mettre à jour', ['user/index']).' leur compte Crédit Pain en ligne.<br />'
. 'Ceci fait, les clients paient leur commande directement via leur compte Crédit Pain.') ; ?>
<?= $form->field($model, 'photo')->fileInput() ?>
<?php
if (strlen($model->photo)) {
$base_url = Url::frontend() ;
echo '<img src="'.$base_url.'uploads/' . $model->photo . '" width="400px" /><br />';
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />';
}
?>
<?= $form->field($model, 'infos_commande')
->textarea(['rows' => 6])
->hint('Affichées au client lors de sa commande')?>
<div class="form-group">
<?= Html::submitButton('Mettre à jour', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>




+ 255
- 0
console/config/backend/views/layouts/main.php Bestand weergeven

@@ -0,0 +1,255 @@
<?php

use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\models\Etablissement;
use common\models\User;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\helpers\Url;

/* @var $this \yii\web\View */
/* @var $content string */

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon3.png" />
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?> - La boîte à pain</title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => '<img class="logo" src="' . Yii::$app->urlManager->getBaseUrl() . '/img/laboulange3.png" />',
'brandUrl' => Yii::$app->homeUrl,
'innerContainerOptions' => ['class' => 'container-fluid'],
'options' => [
'class' => 'navbar-inverse navbar-fixed-top nav-header',
],
]);

$menuItems = [
[
'label' => '<span class="glyphicon glyphicon-home"></span> Tableau de bord',
'url' => ['/site/index'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-calendar"></span> Commandes',
'url' => ['/commande/index'],
'visible' => !Yii::$app->user->isGuest,
'items' => [
[
'label' => '<span class="glyphicon glyphicon-calendar"></span> Toutes les commandes',
'url' => ['/commande/index'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-repeat"></span> Commandes récurrentes',
'url' => ['/commandeauto/index'],
'visible' => !Yii::$app->user->isGuest
],
]
],
[
'label' => '<span class="glyphicon glyphicon-grain"></span> Produits',
'url' => ['/produit/index'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-map-marker"></span> Points de vente',
'url' => ['/point-vente/index'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-user"></span> Clients',
'url' => ['/user/index'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-plus"></span>',
'url' => ['/etablissement/update'],
'visible' => !Yii::$app->user->isGuest,
'items' => [
[
'label' => '<span class="glyphicon glyphicon-cog"></span> Paramètres',
'url' => ['/etablissement/update'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-bullhorn"></span> Communiquer',
'url' => ['/communiquer/index'],
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation',
'url' => ['/etablissement/facturation'],
'visible' => !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-stats"></span> Statistiques',
'url' => ['/stats/index'],
'visible' => !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-wrench"></span> Développement',
'url' => ['/developpement/index'],
'visible' => !Yii::$app->user->isGuest
],
],
]
];

if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Connexion', 'url' => ['/site/login']];
} else {

if (Yii::$app->user->identity->status == USER::STATUS_ADMIN) {
$menuItems[] = [
'label' => '<span class="glyphicon glyphicon-asterisk"></span>',
'url' => '#',
'items' => [
[
'label' => '<span class="glyphicon glyphicon-th-list"></span> Producteurs',
'url' => ['etablissement-admin/index'],
'visible' => !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation',
'url' => ['etablissement-admin/facturation'],
'visible' => !Yii::$app->user->isGuest,
],
]
];
}

$menuItems[] = [
'label' => '<span class="glyphicon glyphicon-off"></span>',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post', 'title' => 'Déconnexion']
];

$menuItems[] = [
'label' => '<span class="retour-site">Retour sur le site</span>',
'url' => Url::frontend(),
];
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
'encodeLabels' => false
]);
NavBar::end();
?>

<div class="container-fluid container-body">
<?php if (YII_ENV == 'dev' || YII_ENV == 'demo'): ?>
<div id="env-dev"><?php if (YII_ENV == 'dev'): ?>Dév.<?php elseif (YII_ENV == 'demo'): ?>Démo<?php endif; ?></div>
<?php endif; ?>
<?php if (!Yii::$app->user->isGuest): ?>
<div class="nom-boulange">
<?php if (Yii::$app->user->identity->status == User::STATUS_BOULANGER): ?>
<span><?= Html::encode(Yii::$app->user->identity->getNomMagasin()); ?></span>
<?php elseif (Yii::$app->user->identity->status == User::STATUS_ADMIN): ?>
<?php $form = ActiveForm::begin(['id' => 'select-etablissement']); ?>
<?=
Html::dropDownList('select_etablissement', Yii::$app->user->identity->id_etablissement, ArrayHelper::map(Etablissement::find()->orderBy('nom ASC')->all(), 'id', function($model, $defaultValue) {
return $model->nom;
}));
?>
<?php ActiveForm::end(); ?>
<?php endif; ?>

<?php
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement);
if (!$etablissement->actif):
?>
<span class="label label-danger" data-toggle="tooltip" data-placement="bottom" data-original-title="Activez votre établissement quand vous le souhaitez afin de la rendre visible à vos clients.">
<?= Html::a('Hors-ligne', ['etablissement/update']); ?>
</span>
<?php endif; ?>

<div class="clr"></div>

<?php $etat_paiement_etablissement = Yii::$app->user->identity->etatPaiementEtablissement(); ?>
<?php if ($etat_paiement_etablissement == 'essai'): ?>
<span id="etat-paiement-etablissement">Période d'essai gratuite
<span class="strong"><?php echo Yii::$app->user->identity->periodeEssai(); ?> jours</span> <a class="btn btn-success" href="<?php echo Yii::$app->urlManager->createUrl(['paiement/index']) ?>">S'abonner</a>
</span>
<?php elseif ($etat_paiement_etablissement == Etablissement::PAIEMENT_ESSAI_TERMINE || $etat_paiement_etablissement == Etablissement::PAIEMENT_RETARD): ?>
<span id="etat-paiement-etablissement">
<span class="strong">
<?php if ($etat_paiement_etablissement == Etablissement::PAIEMENT_ESSAI_TERMINE): ?>Période d'essai gratuite terminée
<?php elseif ($etat_paiement_etablissement == Etablissement::PAIEMENT_RETARD): ?>Retard de paiement
<?php endif; ?>
</span>
</span>
<?php endif; ?>
</div>
<?php endif; ?>

<?php if (YII_ENV == 'demo'): ?>
<div id="block-demo">
<div class="container-fluid">
<span class="glyphicon glyphicon-eye-open"></span> <strong>Espace de démonstration</strong> :
Testez la plateforme sans avoir à vous inscrire. Les données sont réinitialisées quotidiennement &bull; <?= Html::a('Retour', Url::env('prod', 'frontend')) ?>
</div>
</div>
<?php endif; ?>

<?=
Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
])
?>
<?= $content ?>
</div>
</div>

<div id="alerts-fixed"></div>

<footer class="footer">
<div class="container-fluid">
<p class="pull-left">
<a href="<?php echo Url::frontend('site/contact'); ?>">Contact</a> &bull;
<a href="<?php echo Url::frontend('site/mentions'); ?>">Mentions légales</a> &bull;
<a href="<?php echo Url::frontend('site/cgv'); ?>">CGS</a>
</p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>

<?php $this->endBody() ?>

<!-- analytics -->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-86917043-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
<?php $this->endPage() ?>

+ 12
- 0
console/config/backend/views/paiement/annuler.php Bestand weergeven

@@ -0,0 +1,12 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

?>

<h1>Paiement annulé</h1>


+ 54
- 0
console/config/backend/views/paiement/index.php Bestand weergeven

@@ -0,0 +1,54 @@
<?php

use common\models\Etablissement ;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

$this->title = 'Paiement';

$etat_paiement = Yii::$app->user->identity->etatPaiementEtablissement() ;

?>

<h1>Paiement</h1>

<div class="alert alert-warning">
<?php if($etat_paiement == Etablissement::PAIEMENT_ESSAI_TERMINE): ?>
Votre période d'essai gratuite est terminée.<br />
Vous pouvez continuer à bénéficier de ce service en vous abonnant à <strong>La boîte à pain</strong>
pour <strong>30 € / mois</strong>
<?php elseif($etat_paiement == Etablissement::PAIEMENT_RETARD): ?>
Nous constatons un retard de paiement sur votre compte.<br />
Nous vous invitons à vérifier que tout est en ordre au niveau de votre compte Paypal ou à vous
abonner à nouveau en utilisant le bouton ci-dessous (<strong>30 € / mois</strong>).
<?php elseif($etat_paiement == Etablissement::PAIEMENT_ESSAI): ?>
Si vous souhaitez profiter de ce service au-delà de la période d'essai gratuite,
abonnez-vous à <strong>La boîte à pain</strong> pour <strong>30 € / mois</strong>.
<?php endif; ?>
</div>
<div class="alert alert-info">Si vous rencontrez des difficultés, n'hésitez pas à nous contacter.</div>


<!--<h2>Prod</h2>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="K96K2WLBSBDSA">
<input name="custom" value="<?php echo Yii::$app->user->identity->id; ?>" type="hidden" />
<input type="image" src="https://www.paypalobjects.com/fr_FR/FR/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal, le réflexe sécurité pour payer en ligne">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>-->

<!--<h2>Test</h2>-->
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="USASPWAC39S4N">
<input name="custom" value="<?php echo Yii::$app->user->identity->id; ?>" type="hidden" />
<input type="image" src="https://www.sandbox.paypal.com/fr_FR/FR/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal, le réflexe sécurité pour payer en ligne">
<img alt="" border="0" src="https://www.sandbox.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>


+ 12
- 0
console/config/backend/views/paiement/succes.php Bestand weergeven

@@ -0,0 +1,12 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

?>

<h1>Paiement validé</h1>


+ 95
- 0
console/config/backend/views/point-vente/_form.php Bestand weergeven

@@ -0,0 +1,95 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper ;
use common\models\Etablissement ;

/* @var $this yii\web\View */
/* @var $model backend\models\PointVente */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="point-vente-form">

<?php $form = ActiveForm::begin(); ?>

<div class="col-md-8">
<?= $form->field($model, 'nom')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'localite')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'adresse')->textarea(['rows' => 6]) ?>

<?= $form->field($model, 'point_fabrication')
->checkbox()
->hint('Cochez cette case si ce point de vente correspond à votre lieu de production.') ?>

<?php
$add_hint_credit_pain = '' ;
if(!Etablissement::getConfig('credit_pain')):
$add_hint_credit_pain = '<br /><strong>Attention, le système de Crédit Pain est désactivé au niveau des '.Html::a('paramètres globaux',['etablissement/update']).'.</strong>' ;
endif;
echo $form->field($model, 'credit_pain')
->checkbox()
->hint('Cochez cette case si le client peut régler ses commandes via son compte Crédit Pain pour ce point de vente.'
.$add_hint_credit_pain);
?>

<div id="jours-livraison">
<h2>Jours de livraison</h2>
<?= $form->field($model, 'livraison_lundi')->checkbox() ?>
<?= $form->field($model, 'livraison_mardi')->checkbox() ?>
<?= $form->field($model, 'livraison_mercredi')->checkbox() ?>
<?= $form->field($model, 'livraison_jeudi')->checkbox() ?>
<?= $form->field($model, 'livraison_vendredi')->checkbox() ?>
<?= $form->field($model, 'livraison_samedi')->checkbox() ?>
<?= $form->field($model, 'livraison_dimanche')->checkbox() ?>
</div>
<div class="clr"></div>
<h2>Horaires</h2>
<?= $form->field($model, 'horaires_lundi')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'horaires_mardi')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'horaires_mercredi')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'horaires_jeudi')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'horaires_vendredi')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'horaires_samedi')->textarea(['rows' => 3]) ?>
<?= $form->field($model, 'horaires_dimanche')->textarea(['rows' => 3]) ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'code')
->label('Code d\'accès')
->hint('Renseignez ce champs si vous souhaitez protéger ce point de vente par un code.')
?>
<?= $form->field($model, 'acces_restreint')
->checkbox()
->hint('Cochez cette case si seulement un groupe restreint d\'utilisateurs peuvent accéder à ce point de vente.<br />'
. 'Dans le cas des boîtes à pain, il vous est possible de spécifier un commentaire pour chaque utilisateur sélectionné afin de lui renseigner son numéro de boîte ou son code.') ?>
<div id="users">
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function($model_user, $defaultValue) use ($model) {
return Html::encode($model_user['nom'].' '.$model_user['prenom']).'<br />'
.Html::activeTextInput(
$model,
'users_commentaire['.$model_user['user_id'].']',
[
'class' => 'form-control commentaire',
'placeholder' => 'Commentaire',
'value' => (isset($model->users_commentaire[$model_user['user_id']])) ? Html::encode($model->users_commentaire[$model_user['user_id']]) : ''
]);
} ), ['encode' => false, 'class' => '']) ?>
</div>
</div>
<div class="clr"></div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>

</div>

+ 22
- 0
console/config/backend/views/point-vente/create.php Bestand weergeven

@@ -0,0 +1,22 @@
<?php

use yii\helpers\Html;


/* @var $this yii\web\View */
/* @var $model backend\models\PointVente */

$this->title = 'Ajouter un point de vente';
$this->params['breadcrumbs'][] = ['label' => 'Points de vente', 'url' => ['index']];
$this->params['breadcrumbs'][] = 'Ajouter';
?>
<div class="point-vente-create">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
'users' => $users,
]) ?>

</div>

+ 112
- 0
console/config/backend/views/point-vente/index.php Bestand weergeven

@@ -0,0 +1,112 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\PointVenteUser ;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Points de vente';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="point-vente-index">

<h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>

<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'nom',
'localite',
[
'attribute' => 'point_fabrication',
'format' => 'raw',
'value' => function($model) {
if($model->point_fabrication)
{
return '<span class="label label-success">Oui</span>' ;
}
else {
return '<span class="label label-danger">Non</span>' ;
}
}
],
[
'label' => 'Livraison',
'value' => function($model) {
$html = '' ;
if($model->livraison_lundi) $html .= 'lundi, ' ;
if($model->livraison_mardi) $html .= 'mardi, ' ;
if($model->livraison_mercredi) $html .= 'mercredi, ' ;
if($model->livraison_jeudi) $html .= 'jeudi, ' ;
if($model->livraison_vendredi) $html .= 'vendredi, ' ;
if($model->livraison_samedi) $html .= 'samedi, ' ;
if($model->livraison_dimanche) $html .= 'dimanche, ' ;
if(strlen($html))
return substr ($html, 0, strlen($html)-2) ;
else
return '' ;
}
],
[
'attribute' => 'acces_restreint',
'format' => 'raw',
'value' => function($model) {
$count = PointVenteUser::find()->where(['id_point_vente' => $model->id])->count();
$html = '' ;
if($model->acces_restreint)
{
$html .= '<span class="glyphicon glyphicon-lock"></span> ' ;
if($count == 1)
{
$html .= '1 utilisateur' ;
}
else {
$html .= $count.' utilisateurs' ;
}
}
if(strlen($model->code))
{
if(strlen($html)) $html .= '<br />' ;
$html .= 'Code : <strong>'.Html::encode($model->code).'</strong>' ;
}
return $html ;
}
],
[
'attribute' => 'credit_pain',
'label' => 'Crédit pain',
'format' => 'raw',
'value' => function($model) {
if($model->credit_pain)
return '<span class="glyphicon glyphicon-euro"></span>' ;
return '' ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'update' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
]);
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]);
}
],
],
],
]); ?>

</div>

+ 22
- 0
console/config/backend/views/point-vente/update.php Bestand weergeven

@@ -0,0 +1,22 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model backend\models\PointVente */

$this->title = 'Modifier un point de vente';
$this->params['breadcrumbs'][] = ['label' => 'Points de vente', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($model->nom), 'url' => ['update', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Modifier';
?>
<div class="point-vente-update">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
'users' => $users
]) ?>

</div>

+ 37
- 0
console/config/backend/views/point-vente/view.php Bestand weergeven

@@ -0,0 +1,37 @@
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\models\PointVente */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Point Ventes', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="point-vente-view">

<h1><?= Html::encode($this->title) ?></h1>

<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>

<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'nom',
'adresse:ntext',
],
]) ?>

</div>

+ 63
- 0
console/config/backend/views/produit/_form.php Bestand weergeven

@@ -0,0 +1,63 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="produit-form">

<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>

<?= $form->field($model, 'actif')->radioList([1 => 'Oui',0 => 'Non' ]) ?>
<?= $form->field($model, 'nom')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'recette')->textarea() ?>
<?= $form->field($model, 'prix')->textInput() ?>
<?= $form->field($model, 'poids')->textInput() ?>
<?= $form->field($model, 'quantite_max')
->hint('Renseignez ce champs si vous souhaitez limiter la quantité commandable pour ce produit.')
->textInput() ?>
<?= $form->field($model, 'photo')->fileInput() ?>
<?php
if(strlen($model->photo)) {
echo '<img src="../../frontend/web/uploads/'.$model->photo.'" width="200px" /><br />' ;
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />' ;
}
?>
<?php if(Yii::$app->user->identity->id_etablissement == 1): ?>
<?= $form->field($model, 'illustration')->fileInput() ?>
<?php
if(strlen($model->illustration)) {
echo '<img src="../../frontend/web/uploads/'.$model->illustration.'" width="200px" /><br />' ;
echo '<input type="checkbox" name="delete_illustration" id="delete_illustration" /> <label for="delete_illustration">Supprimer l\'illustration</label><br /><br />' ;
}
?>
<?php endif; ?>
<h2>Jours de production</h2>
<div id="jours-production">
<?= $form->field($model, 'lundi')->checkbox() ?>
<?= $form->field($model, 'mardi')->checkbox() ?>
<?= $form->field($model, 'mercredi')->checkbox() ?>
<?= $form->field($model, 'jeudi')->checkbox() ?>
<?= $form->field($model, 'vendredi')->checkbox() ?>
<?= $form->field($model, 'samedi')->checkbox() ?>
<?= $form->field($model, 'dimanche')->checkbox() ?>
</div>
<div class="clr"></div>
<?= $form->field($model, 'id_etablissement')->hiddenInput()->label('') ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>

</div>

+ 21
- 0
console/config/backend/views/produit/create.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;


/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = 'Ajouter un produit';
$this->params['breadcrumbs'][] = ['label' => 'Produits', 'url' => ['index']];
$this->params['breadcrumbs'][] = 'Ajouter';
?>
<div class="produit-create">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 78
- 0
console/config/backend/views/produit/index.php Bestand weergeven

@@ -0,0 +1,78 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\helpers\Url ;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Produits';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="produit-index">

<h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>

<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'order',
'headerOptions' => ['class' => 'order'],
'format' => 'raw',
'value' => function($model) {
return '<a class="btn-order btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>' ;
}
],
[
'attribute' => 'photo',
'format' => 'raw',
'headerOptions' => ['class' => 'td-photo'],
'value' => function($model) {
if(strlen($model->photo)) {
$url = Url::frontend() ;
return '<img class="photo-produit" src="'.$url.'uploads/'.$model->photo.'" />' ;
}
return '' ;
}
],
'nom',
'description',
[
'attribute' => 'actif',
'headerOptions' => ['class' => 'actif'],
'contentOptions' => ['class' => 'center'],
'format' => 'raw',
'value' => function($model) {
if($model->actif)
{
return '<span class="label label-success">oui</span>' ;
}
else {
return '<span class="label label-danger">non</span>' ;
}
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'update' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
]);
},
'delete' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]);
}
],
],
],
]); ?>

</div>

+ 21
- 0
console/config/backend/views/produit/update.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = 'Modifier un produit';
$this->params['breadcrumbs'][] = ['label' => 'Produits', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->nom, 'url' => ['update', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Modifier';
?>
<div class="produit-update">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 43
- 0
console/config/backend/views/produit/view.php Bestand weergeven

@@ -0,0 +1,43 @@
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Produits', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="produit-view">

<h1><?= Html::encode($this->title) ?></h1>

<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>

<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'nom',
'description',
'actif',
'illustration',
'photo',
'saison',
'prix',
'poids',
],
]) ?>

</div>

+ 27
- 0
console/config/backend/views/site/error.php Bestand weergeven

@@ -0,0 +1,27 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */

$this->title = $name;
?>
<div class="site-error">

<h1><?= Html::encode($this->title) ?></h1>

<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>

<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>

</div>

+ 285
- 0
console/config/backend/views/site/index.php Bestand weergeven

@@ -0,0 +1,285 @@
<?php
/* @var $this yii\web\View */

use yii\helpers\Html ;

$this->title = 'Tableau de bord';
?>
<div class="site-index">
<?php if(Yii::$app->request->get('erreur_produits_points_vente')): ?>
<div class="alert alert-danger">Vous devez saisir vos produits et vos points de vente
avant d'initialiser vos jours de production.</div>
<?php endif; ?>
<div class="col-md-4">
<!-- commandes -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Commandes
<?= Html::a('Voir', ['commande/index'], ['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<?php if(count($productions)): ?>
<p>Prochaines productions : </p>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Date</th>
<th>Commandes</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($productions as $p): ?>
<tr>
<td><?= date('d/m/Y',strtotime($p['date'])); ?></td>
<td><?= count($p->commande); ?></td>
<td>
<?= Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['commande/index','date' => $p['date']], ['class' => 'btn btn-default btn-xs']) ; ?>
<?php if(count($p->commande)): ?><?= Html::a('<span class="glyphicon glyphicon-download-alt"></span>', ['commande/report','date' => $p['date'],'global' => 1], ['class' => 'btn btn-default btn-xs']) ; ?><?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucune production de programmée.</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- Clients -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<?= $nb_clients; ?> client<?php if($nb_clients > 1): ?>s<?php endif; ?>
<?= Html::a('Ajouter',['user/create'],['class' => 'btn btn-success btn-xs margin-left']) ; ?>
<?= Html::a('Liste', ['user/index'], ['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<?php if($nb_clients): ?>
<p>Dernières inscriptions :</p>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Prénom, nom</th>
<th>Inscription</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($clients as $c): ?>
<tr>
<td><?= Html::encode($c['prenom'].' '.$c['nom']) ?></td>
<td><?= date('d/m/Y', $c['created_at']); ?></td>
<td><?= Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['user/update','id' => $c['user_id']], ['class' => 'btn btn-default btn-xs']) ; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucun client.</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- Clients crédit pain négatif -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Clients au crédit pain négatif
</h3>
</div>
<div class="panel-body">
<?php if(count($clients_credit_pain_negatif)): ?>
<p>Dernières inscriptions :</p>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Prénom, nom</th>
<th>Crédit pain</th>
</tr>
</thead>
<tbody>
<?php foreach($clients_credit_pain_negatif as $c): ?>
<tr>
<td><?= Html::encode($c['prenom'].' '.$c['nom']) ?></td>
<td><?= number_format($c['credit'],2) ?></td>
<td><?= Html::a('<span class="glyphicon glyphicon-euro"></span>', ['user/credit','id' => $c['user_id']], ['class' => 'btn btn-default btn-xs']) ; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucun client.</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- Paramètres -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Paramètres
<?= Html::a('Configurer',['etablissement/update'],['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Configuration</th>
<th>Valeur</th>
</tr>
</thead>
<tbody>
<tr>
<td>Établissement activé</td>
<td>
<?php if($etablissement->actif): ?>
<span class="label label-success">Active</span>
<?php else: ?>
<span class="label label-danger">Hors-ligne</span>
<?php endif; ?>
</td>
</tr>
<tr>
<td>Établissement protégé par un code</td>
<td>
<?php if(strlen($etablissement->code)): ?>
<span class="label label-success">Oui</span><br />
<strong><?= Html::encode($etablissement->code) ?></strong>
<?php else: ?>
<span class="label label-danger">Non</span>
<?php endif; ?>
</td>
</tr>
<tr>
<td>Délai de commande</td>
<td><?= $etablissement->delai_commande ?> jour<?php if($etablissement->delai_commande > 1): ?>s<?php endif; ?></td>
</tr>
<tr>
<td>Heure limite de commande</td>
<td><?= $etablissement->heure_limite_commande ?>h</td>
</tr>
<tr>
<td>Système de Crédit Pain activé</td>
<td>
<?php if($etablissement->credit_pain): ?>
<span class="label label-success">Oui</span><br />
<?php else: ?>
<span class="label label-danger">Non</span>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

<!-- Facturation -->
<div class="" id="facturation">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Facturation
<?= Html::a('Voir',['etablissement/facturation'],['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<div class="col-md-12">
<?php if(is_null($etablissement->prix_libre)): ?>
<h2>Prix libre</h2>
<p>Le modèle économique de <em>La boîte à pain</em> est basé sur un système de prix libre. <?= Html::a('En savoir plus',['etablissement/facturation']); ?></p>
<?php else: ?>
<h2><?= $etablissement->getPrixLibre() ?> / mois <?= Html::a('Modifier',['etablissement/facturation'],['class' => 'btn btn-xs btn-primary']) ?></h2>
<?php endif; ?>
</div>
<!--<div class="col-md-6 mois-en-cours">
<h2>Chiffre d'affaire<br />du mois en cours</h2>
<div class="montant"><span><?= number_format($etablissement->getCA(date('Y-m')), 2); ?> €</span></div>
</div>

<div class="col-md-6">
<?php $montant = $etablissement->getMontantFacturer(date('Y-m'), 0); ?>
<h2>Participation<br /><em>La boîte à pain</em> (2%)</h2>
<div class="montant"><span><?php if($montant): echo number_format($montant,2).' €' ; else: echo 'Gratuit' ; endif; ?></span></div>
</div>
<div class="clr"></div>-->
</div>
</div>
</div>
</div>
<div class="col-md-8">
<!-- dernières commandes -->
<div id="dernieres-commandes" class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Dernières commandes clients
</h3>
</div>
<div class="panel-body">
<?php if(count($commandes)): ?>
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Client</th>
<th>Produits</th>
<th>Point de vente</th>
<th>Montant</th>
</tr>
</thead>
<tbody>
<?php foreach($commandes as $c): ?>
<tr>
<td><?= $c->getStrType(true); ?></td>
<td class="date">
<div class="bloc-date">
<div class="jour"><?= strftime('%A', strtotime($c->production->date)) ?></div>
<div class="num"><?= date('d', strtotime($c->production->date)) ?></div>
<div class="mois"><?= strftime('%B', strtotime($c->production->date)) ?></div>
</div>
</td>
<td>
<?= $c->getStrUser(); ?><br />
<span class="small">Le <?= date('d/m/Y à G\hi', strtotime($c->date)) ?></span>
</td>
<td><?= $c->getResumePanier() ; ?></td>
<td><?= $c->getResumePointVente() ; ?></td>
<td><?= $c->getStrMontant() ; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucune commande</div>
<?php endif; ?>
</div>
</div>
</div>

</div>
</div>

+ 34
- 0
console/config/backend/views/site/login.php Bestand weergeven

@@ -0,0 +1,34 @@
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */

$this->title = 'Connexion';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-login">
<h1><?= Html::encode($this->title) ?></h1>

<div class="row">
<div class="col-lg-5">
<?php if(YII_ENV == 'demo') : ?>
<div class="alert alert-warning">
Identifiant : <strong>boulanger@laboiteapain.net</strong><br />
Mot de passe : <strong>laboiteapain</strong>
</div>
<?php endif; ?>
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton('Connexion', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>

+ 34
- 0
console/config/backend/views/stats/index.php Bestand weergeven

@@ -0,0 +1,34 @@
<?php

$this->title = 'Statistiques' ;

use dosamigos\chartjs\ChartJs;

$this->params['breadcrumbs'][] = 'Statistiques';

?>

<h1>Statistiques</h1>

<?= ChartJs::widget([
'type' => 'line',
'options' => [
'height' => 400,
'width' => 1100
],
'data' => [
'labels' => $data_labels,
'datasets' => [
[
'label' => 'Recettes commandes',
'backgroundColor' => "rgb(187,135,87,0.5)",
'borderColor' => "rgb(187,135,87,1)",
'pointBackgroundColor' => "rgb(187,135,87,1)",
'pointStrokeColor' => "#fff",
'data' => $data_pain
]
]
]
]);

?>

+ 26
- 0
console/config/backend/views/user/_form.php Bestand weergeven

@@ -0,0 +1,26 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\User */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="user-form">

<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'nom')->textInput() ?>
<?= $form->field($model, 'prenom')->textInput() ?>
<?= $form->field($model, 'telephone')->textInput() ?>
<?= $form->field($model, 'email')->textInput() ?>
<?= $form->field($model, 'adresse')->textarea() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>
</div>

+ 44
- 0
console/config/backend/views/user/commandes.php Bestand weergeven

@@ -0,0 +1,44 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\CreditHistorique;
use common\models\Etablissement;
use common\models\Commande;

$this->title = 'Commandes <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->nom.' '.$user->prenom)];
$this->params['breadcrumbs'][] = 'Créditer';

?>

<div class="user-commandes">
<h1><?= $this->title ?> </h1>
<?php if(count($commandes)): ?>
<table id="historique-commandes" class="table table-striped table-bordered">
<thead>
<tr>
<th>Date livraison</th>
<th>Résumé</th>
<th>Point de vente</th>
<th class="montant">Montant</th>
</tr>
</thead>
<tbody>
<?php foreach($commandes as $c): ?>
<tr>
<td><?php echo date('d/m/Y',strtotime($c->production->date)); ?></td>
<td class="resume"><?= $c->getResumePanier() ; ?></td>
<td><?= $c->getResumePointVente(); ?></td>
<td class="montant"><?= $c->getResumeMontant(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucune commande passée par ce client.</div>
<?php endif; ?>
</div>

+ 22
- 0
console/config/backend/views/user/create.php Bestand weergeven

@@ -0,0 +1,22 @@
<?php

use yii\helpers\Html;


/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = 'Ajouter un client';
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = 'Ajouter' ;
?>
<div class="user-create">
<?php if(YII_ENV == 'demo'): ?>
<div class="alert alert-warning">Vous ne pouvez pas ajouter de client dans l'espace Démo.</div>
<?php else: ?>
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
<?php endif; ?>
</div>

+ 99
- 0
console/config/backend/views/user/credit.php Bestand weergeven

@@ -0,0 +1,99 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\CreditHistorique;
use common\models\Etablissement;

$this->title = 'Créditer <small>'.Html::encode($user->nom.' '.$user->prenom).'</small>';
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($user->nom.' '.$user->prenom)];
$this->params['breadcrumbs'][] = 'Créditer';

?>

<div class="user-credit">
<?php
$etablissement = Etablissement::find()
->where(['id' => Yii::$app->user->identity->id_etablissement])
->one() ;
if(!$etablissement->credit_pain)
{
echo '<div class="alert alert-warning">Attention, la fonctionnalité <strong>Crédit Pain</strong> est désactivée dans vos <a href="'.Yii::$app->urlManager->createurl(['etablissement/update']).'">paramètres</a>.'
. ' Pensez à l\'activer si vous souhaitez qu\'elle soit visible de vos clients.</div>' ;
}
?>
<div class="col-md-12">
<h1><?= $this->title ?></h1>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($credit_form, 'type')->dropDownList([
CreditHistorique::TYPE_CREDIT => 'Crédit',
CreditHistorique::TYPE_DEBIT => 'Débit',
]) ?>
<?= $form->field($credit_form, 'montant')->textInput() ?>
<?= $form->field($credit_form, 'moyen_paiement')->dropDownList([
CreditHistorique::MOYEN_ESPECES => 'Espèces',
CreditHistorique::MOYEN_CB => 'Carte bancaire',
CreditHistorique::MOYEN_CHEQUE => 'Chèque',
CreditHistorique::MOYEN_AUTRE => 'Autre',
]) ?>
<?= $form->field($credit_form, 'commentaire')->textarea() ?>
<?= $form->field($credit_form, 'send_mail')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton( 'Créditer', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<div class="col-md-12">
<h2>Historique <span class="the-credit"><?= number_format($user->getCredit($etablissement->id), 2); ?> €</span></h2>
<table class="table table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Utilisateur</th>
<th>Type</th>
<th>- Débit</th>
<th>+ Crédit</th>
<th>Paiement</th>
<th>Commentaire</th>
</tr>
</thead>
<tbody>
<?php if(count($historique)): ?>
<?php foreach($historique as $ch): ?>
<tr>
<td><?= $ch->getDate(true) ; ?></td>
<td><?php if(isset($ch->userAction)): echo Html::encode($ch->userAction->nom. ' '.$ch->userAction->prenom) ; else: echo 'Administrateur' ;endif; ?></td>
<td><?= $ch->getStrLibelle(); ?></td>
<td>
<?php if($ch->isTypeDebit()): ?>
- <?= $ch->getMontant(true); ?>
<?php endif; ?>
</td>
<td>
<?php if($ch->isTypeCredit()): ?>
+ <?= $ch->getMontant(true); ?>
<?php endif; ?>
</td>
<td>
<?= $ch->getStrMoyenPaiement() ?>
</td>
<td>
<?php if(strlen($ch->commentaire)): ?>
<?= nl2br($ch->commentaire) ; ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td colspan="4">Aucun résultat</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>

+ 155
- 0
console/config/backend/views/user/index.php Bestand weergeven

@@ -0,0 +1,155 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;
use common\models\Commande ;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Clients';
$this->params['breadcrumbs'][] = $this->title;
?>


<div class="user-index">
<h1>
<?= Html::encode($this->title) ?>
<?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?>
</h1>

<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => true,
'columns' => [
[
'attribute' => 'nom',
'filter' => Html::input(
'string',
'nom',
isset(Yii::$app->request->queryParams['nom']) ? Html::encode(Yii::$app->request->queryParams['nom']) : '',
[ 'class' => 'form-control']
)
],
[
'attribute' => 'prenom',
'filter' => Html::input(
'string',
'prenom',
isset(Yii::$app->request->queryParams['prenom']) ? Html::encode(Yii::$app->request->queryParams['prenom']) : '',
['class' => 'form-control']
)
],
[
'attribute' => 'telephone',
'filter' => Html::input(
'string',
'telephone',
isset(Yii::$app->request->queryParams['telephone']) ? Html::encode(Yii::$app->request->queryParams['telephone']) : '',
['class' => 'form-control']
)
],
[
'attribute' => 'email',
'filter' => Html::input(
'string',
'email',
isset(Yii::$app->request->queryParams['email']) ? Html::encode(Yii::$app->request->queryParams['email']) : '',
['class' => 'form-control']
)
],
[
'attribute' => 'created_at',
'label' => 'Date d\'inscription',
'value' => function($model) {
if(isset($model['created_at']))
return date('m/d/Y à H:i', $model['created_at']);
}
],
[
'attribute' => 'date_derniere_connexion',
'label' => 'Dernière connexion',
'value' => function($model) {
if(isset($model['date_derniere_connexion']))
return date('d/m/Y à H:i', strtotime($model['date_derniere_connexion']));
else
return '' ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{commandes}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'commandes' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/commandes','id' => $model['user_id']]) ;
$count_commandes = Commande::find()
->joinWith('production')
->where([
'id_user' => $model['user_id'],
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement])
->count() ;
$html = '' ;
if($count_commandes)
{
$s = '' ;
if($count_commandes > 1) $s = 's' ;
$html .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> '.$count_commandes.' commande'.$s, $url, [
'title' => Yii::t('app', 'Commandes'), 'class' => 'btn btn-default '
]); ;
}
else {
$html .= 'Aucune commande' ;
}

return $html ;
},
],
],
[
'attribute' => 'credit',
'format' => 'raw',
'value' => function($model) use($etablissement) {
if(!isset($model['credit'])) $model['credit'] = 0 ;
$user = User::findOne($model['user_id']) ;
$html = '<div class="input-group">
<input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($user->getCredit($etablissement->id),2).' €" placeholder="">
<span class="input-group-btn">
'.Html::a(
'<span class="glyphicon glyphicon-euro"></span> Crédit',
Yii::$app->urlManager->createUrl(['user/credit','id' => $model['user_id']]),
[
'title' => 'Crédit',
'class' => 'btn btn-default'
]
).'
</span>
</div>' ;
return $html ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['user_id']]) ;
$user = User::find()->with('userEtablissement')->where(['id' => $model['user_id']])->one() ;
if(count($user->userEtablissement) <= 1)
{
return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
]);
}
else {
return '<span data-toggle="tooltip" data-placement="top" title="Vous ne pouvez pas modifier les clients qui sont liés à plusieurs producteurs."><span class="glyphicon glyphicon-remove-sign"></span> Non modifiable</span>' ;
}
},
],
],
],
]); ?>
</div>

+ 21
- 0
console/config/backend/views/user/liste_mails.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

use yii\helpers\Html ;

$this->title = 'Liste des emails';
$this->params['breadcrumbs'][] = ['label' => 'Clients',
'url' => ['user/index']] ;
$this->params['breadcrumbs'][] = $this->title;

?>

<h1><?= count($users); ?> clients</h1>

<?= implode(', ', $users); ?>


+ 42
- 0
console/config/backend/views/user/mail.php Bestand weergeven

@@ -0,0 +1,42 @@
<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

$this->title = 'Envoi d\'un email à tous les utilisateurs';

?>

<h1><?= Html::encode($this->title) ?></h1>

<?php

$form = ActiveForm::begin(['id' => 'email-masse-form','enableClientValidation' => false]); ?>
<?= $form->field($model, 'subject') ?>
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>

<div class="form-group">
<label class="control-label">Envoyer à</label>
<p>Cliquer sur les utilisateurs pour modifier leur état.<br />
Légende : <span class="label label-default">à envoyer</span> <span class="label label-danger">ne pas envoyer</span> <span class="label label-success">envoyé</span></p>
<div id="ids-users">
<?php foreach($users as $u): ?>
<a href="javascript:void(0);" class="label <?php if($u->no_mail): ?>label-danger<?php else: ?>label-default<?php endif; ?>" data-send="0" data-id="<?php echo $u->id; ?>"><?php echo Html::encode($u->prenom.' '.$u->nom); ?></a>
<?php endforeach; ?>
</div>
<input name="id_user" type="hidden" value="" />
</div>
<br />

<div class="form-group">
<?= Html::submitButton('Envoyer', ['class' => 'btn btn-default', 'name' => 'email-masse-button']) ?>
</div>
<?php ActiveForm::end(); ?>



+ 21
- 0
console/config/backend/views/user/update.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = 'Modifier un client' ;
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($model->nom.' '.$model->prenom)];
$this->params['breadcrumbs'][] = 'Modifier';
?>
<div class="user-update">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 47
- 0
console/config/backend/views/user/view.php Bestand weergeven

@@ -0,0 +1,47 @@
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Clients', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-view">

<h1><?= Html::encode($this->title) ?></h1>

<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>

<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'username',
'auth_key',
'password_hash',
'password_reset_token',
'email:email',
'status',
'created_at',
'updated_at',
'nom',
'prenom',
'telephone',
'confiance',
],
]) ?>

</div>

+ 36
- 0
console/config/backend/views/vrac/_form.php Bestand weergeven

@@ -0,0 +1,36 @@
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="produit-form">

<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>

<?= $form->field($model, 'actif')->radioList([1 => 'Oui',0 => 'Non' ]) ?>
<?= $form->field($model, 'order')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'nom')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'diminutif')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
<?= $form->field($model, 'prix')->textInput() ?>
<?= $form->field($model, 'epuise')->checkbox() ?>
<?= $form->field($model, 'photo')->fileInput() ?>
<?php
if(strlen($model->photo)) {
echo '<img src="../../frontend/web/uploads/'.$model->photo.'" width="200px" /><br />' ;
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />' ;
}
?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>
</div>

+ 21
- 0
console/config/backend/views/vrac/create.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;


/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = 'Ajouter vrac';
$this->params['breadcrumbs'][] = ['label' => 'Produits', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="produit-create">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 37
- 0
console/config/backend/views/vrac/index.php Bestand weergeven

@@ -0,0 +1,37 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Vrac';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="produit-index">

<h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>

<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
//['class' => 'yii\grid\SerialColumn'],

//'id',
'order',
'diminutif',
'nom',
'epuise',
'actif',
//'illustration',
// 'photo',
// 'saison',
// 'prix',
// 'poids',

['class' => 'yii\grid\ActionColumn'],
],
]); ?>

</div>

+ 21
- 0
console/config/backend/views/vrac/update.php Bestand weergeven

@@ -0,0 +1,21 @@
<?php

use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = 'Modifier vrac #'. $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Produits', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="produit-update">

<h1><?= Html::encode($this->title) ?></h1>

<?= $this->render('_form', [
'model' => $model,
]) ?>

</div>

+ 43
- 0
console/config/backend/views/vrac/view.php Bestand weergeven

@@ -0,0 +1,43 @@
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\models\Produit */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Produits', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="produit-view">

<h1><?= Html::encode($this->title) ?></h1>

<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>

<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'nom',
'description',
'actif',
'illustration',
'photo',
'saison',
'prix',
'poids',
],
]) ?>

</div>

+ 2
- 0
console/config/backend/web/.gitignore Bestand weergeven

@@ -0,0 +1,2 @@
/index.php
/index-test.php

+ 8
- 0
console/config/backend/web/.htaccess Bestand weergeven

@@ -0,0 +1,8 @@
RewriteEngine on

# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward the request to index.php
RewriteRule . index.php

+ 0
- 0
console/config/backend/web/.htaccess~ Bestand weergeven


BIN
console/config/backend/web/.sass-cache/04a574b9dcb788863f265d0854fa0662dfc4ec26/_base.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/04a574b9dcb788863f265d0854fa0662dfc4ec26/_sprite-img.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/05bd53ef781f54af58094c8885bd268592fc1542/_alternating-rows-and-columns.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/05bd53ef781f54af58094c8885bd268592fc1542/_borders.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/05bd53ef781f54af58094c8885bd268592fc1542/_scaffolding.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/06e5f5fa55abf0e37cec9d605a5a180e4f6818d3/_compass.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/23d5ef384c29bd24badd6f68776d8714160be6c3/_compass.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_appearance.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_background-clip.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_background-origin.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_background-size.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_border-radius.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_box-shadow.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_box-sizing.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_box.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_columns.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_filter.scssc Bestand weergeven


BIN
console/config/backend/web/.sass-cache/2ab931e314902320f054d93b6c55c4185e894dd6/_font-face.scssc Bestand weergeven


Some files were not shown because too many files changed in this diff

Laden…
Annuleren
Opslaan