{ | |||||
"directory" : "vendor/bower" | |||||
} |
# yii console command | |||||
# /yii | |||||
# phpstorm project files | |||||
.idea | |||||
# netbeans project files | |||||
nbproject | |||||
# zend studio for eclipse project files | |||||
.buildpath | |||||
.project | |||||
.settings | |||||
# windows thumbnail cache | |||||
Thumbs.db | |||||
# composer itself is not needed | |||||
composer.phar | |||||
# Mac DS_Store Files | |||||
.DS_Store | |||||
# phpunit itself is not needed | |||||
phpunit.phar | |||||
# local phpunit config | |||||
/phpunit.xml |
Options -Indexes | |||||
#<IfModule mod_rewrite.c> | |||||
# RewriteEngine on | |||||
# RewriteCond %{REQUEST_URI} !^public | |||||
# RewriteRule ^(.*)$ frontend/web/$1 [L] | |||||
#</IfModule> | |||||
<IfModule mod_rewrite.c> | |||||
RewriteEngine on | |||||
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/ | |||||
RewriteCond %{REQUEST_URI} admin | |||||
RewriteRule .* backend/web/index.php [L] | |||||
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/ | |||||
RewriteCond %{REQUEST_FILENAME} !-f | |||||
RewriteCond %{REQUEST_URI} !admin | |||||
RewriteRule .* frontend/web/index.php [L] | |||||
</IfModule> | |||||
# Deny accessing below extensions | |||||
<Files ~ "(.json|.lock|.git)"> | |||||
Order allow,deny | |||||
Deny from all | |||||
</Files> | |||||
# Deny accessing dot files | |||||
RewriteRule (^\.|/\.) - [F] |
The Yii framework is free software. It is released under the terms of | |||||
the following BSD License. | |||||
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) | |||||
All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without | |||||
modification, are permitted provided that the following conditions | |||||
are met: | |||||
* Redistributions of source code must retain the above copyright | |||||
notice, this list of conditions and the following disclaimer. | |||||
* Redistributions in binary form must reproduce the above copyright | |||||
notice, this list of conditions and the following disclaimer in | |||||
the documentation and/or other materials provided with the | |||||
distribution. | |||||
* Neither the name of Yii Software LLC nor the names of its | |||||
contributors may be used to endorse or promote products derived | |||||
from this software without specific prior written permission. | |||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||||
POSSIBILITY OF SUCH DAMAGE. |
Yii 2 Advanced Application Template | |||||
=================================== | |||||
Yii 2 Advanced Application Template is a skeleton Yii 2 application best for | |||||
developing complex Web applications with multiple tiers. | |||||
The template includes three tiers: front end, back end, and console, each of which | |||||
is a separate Yii application. | |||||
The template is designed to work in a team development environment. It supports | |||||
deploying the application in different environments. | |||||
DIRECTORY STRUCTURE | |||||
------------------- | |||||
``` | |||||
common | |||||
config/ contains shared configurations | |||||
mail/ contains view files for e-mails | |||||
models/ contains model classes used in both backend and frontend | |||||
console | |||||
config/ contains console configurations | |||||
controllers/ contains console controllers (commands) | |||||
migrations/ contains database migrations | |||||
models/ contains console-specific model classes | |||||
runtime/ contains files generated during runtime | |||||
backend | |||||
assets/ contains application assets such as JavaScript and CSS | |||||
config/ contains backend configurations | |||||
controllers/ contains Web controller classes | |||||
models/ contains backend-specific model classes | |||||
runtime/ contains files generated during runtime | |||||
views/ contains view files for the Web application | |||||
web/ contains the entry script and Web resources | |||||
frontend | |||||
assets/ contains application assets such as JavaScript and CSS | |||||
config/ contains frontend configurations | |||||
controllers/ contains Web controller classes | |||||
models/ contains frontend-specific model classes | |||||
runtime/ contains files generated during runtime | |||||
views/ contains view files for the Web application | |||||
web/ contains the entry script and Web resources | |||||
widgets/ contains frontend widgets | |||||
vendor/ contains dependent 3rd-party packages | |||||
environments/ contains environment-based overrides | |||||
tests contains various tests for the advanced application | |||||
codeception/ contains tests developed with Codeception PHP Testing Framework | |||||
``` | |||||
REQUIREMENTS | |||||
------------ | |||||
The minimum requirement by this application template that your Web server supports PHP 5.4.0. | |||||
INSTALLATION | |||||
------------ | |||||
### Install from an Archive File | |||||
Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to | |||||
a directory named `advanced` that is directly under the Web root. | |||||
Then follow the instructions given in "GETTING STARTED". | |||||
### Install via Composer | |||||
If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions | |||||
at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). | |||||
You can then install the application using the following command: | |||||
~~~ | |||||
php composer.phar global require "fxp/composer-asset-plugin:1.0.0" | |||||
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced advanced | |||||
~~~ | |||||
GETTING STARTED | |||||
--------------- | |||||
After you install the application, you have to conduct the following steps to initialize | |||||
the installed application. You only need to do these once for all. | |||||
1. Run command `init` to initialize the application with a specific environment. | |||||
2. Create a new database and adjust the `components['db']` configuration in `common/config/main-local.php` accordingly. | |||||
3. Apply migrations with console command `yii migrate`. This will create tables needed for the application to work. | |||||
4. Set document roots of your Web server: | |||||
- for frontend `/path/to/yii-application/frontend/web/` and using the URL `http://frontend/` | |||||
- for backend `/path/to/yii-application/backend/web/` and using the URL `http://backend/` | |||||
To login into the application, you need to first sign up, with any of your email address, username and password. | |||||
Then, you can login into the application with same email address and password at any time. |
<?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; | |||||
/** | |||||
* @author Qiang Xue <qiang.xue@gmail.com> | |||||
* @since 2.0 | |||||
*/ | |||||
class AppAsset extends AssetBundle | |||||
{ | |||||
public $basePath = '@webroot'; | |||||
public $baseUrl = '@web'; | |||||
public $css = [ | |||||
'css/site.css', | |||||
'../../frontend/web/js/jquery-ui-1.11.4.custom/jquery-ui.min.css', | |||||
'../../frontend/web/js/jquery-ui-1.11.4.custom/jquery-ui.theme.css', | |||||
'css/screen.css?v=2', | |||||
]; | |||||
public $js = [ | |||||
'../../frontend/web/js/jquery-ui-1.11.4.custom/jquery-ui.min.js', | |||||
'js/lechatdesnoisettes.js?v=2', | |||||
]; | |||||
public $depends = [ | |||||
'yii\bootstrap\BootstrapAsset', | |||||
'yii\web\YiiAsset', | |||||
]; | |||||
} |
main-local.php | |||||
params-local.php |
<?php |
<?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' => 'commande/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, | |||||
]; |
<?php | |||||
return [ | |||||
'adminEmail' => 'admin@example.com', | |||||
]; |
<?php | |||||
namespace backend\controllers; | |||||
use common\models\ProductionProduit; | |||||
use Yii; | |||||
use common\models\Production ; | |||||
use yii\filters\AccessControl; | |||||
use yii\web\Controller; | |||||
use common\models\LoginForm; | |||||
use yii\filters\VerbFilter; | |||||
use common\models\Commande; | |||||
use common\models\PointVente; | |||||
use common\models\Produit; | |||||
use common\helpers\CSV ; | |||||
use common\models\User ; | |||||
use common\models\CommandeProduit; | |||||
class CommandeController extends \yii\web\Controller | |||||
{ | |||||
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 ; | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
public function actionDeleteCommande($date, $id_commande) { | |||||
$commande = Commande::find()->where(['id'=>$id_commande])->one(); | |||||
if($commande) { | |||||
$commande->delete() ; | |||||
CommandeProduit::deleteAll(['id_commande'=>$id_commande]) ; | |||||
} | |||||
$this->redirect(['index','date'=>$date]) ; | |||||
} | |||||
public function gestionFormCommandes($production, $date, $points_vente, $produits, $users) { | |||||
if($date != '') { | |||||
// commandes | |||||
$commandes = Commande::find() | |||||
->with('commandeProduits','user') | |||||
->joinWith('production') | |||||
->where(['production.date'=>$date]) | |||||
->all() ; | |||||
foreach($commandes as $c) | |||||
$c->init() ; | |||||
foreach($points_vente as $pv) { | |||||
$pv->initCommandes($commandes) ; | |||||
if(isset($_POST['submit_pv']) && $_POST['submit_pv']) { | |||||
// modifs | |||||
foreach($pv->commandes as $c) { | |||||
// suppression des commande_produit | |||||
$commande_produits = CommandeProduit::find()->where(['id_commande'=>$c->id])->all() ; | |||||
foreach($commande_produits as $cp) $cp->delete() ; | |||||
// création des commande_produit modifiés | |||||
foreach($produits as $p) { | |||||
$quantite = Yii::$app->getRequest()->post('produit_'.$c->id.'_'.$p->id, 0) ; | |||||
if($quantite) { | |||||
$commande_produit = new CommandeProduit ; | |||||
$commande_produit->id_commande = $c->id ; | |||||
$commande_produit->id_produit = $p->id ; | |||||
$commande_produit->quantite = $quantite ; | |||||
$commande_produit->prix = $p->prix ; | |||||
$commande_produit->save() ; | |||||
} | |||||
} | |||||
} | |||||
// ajout | |||||
//$id_client = Yii::$app->getRequest()->post('user_pv_'.$pv->id, 0) ; | |||||
$username = Yii::$app->getRequest()->post('username_pv_'.$pv->id, 0) ; | |||||
$date = Yii::$app->getRequest()->post('date_commande_pv_'.$pv->id, 0) ; | |||||
$one_product = false ; | |||||
foreach($produits as $p) { | |||||
$quantite = Yii::$app->getRequest()->post('produit_pv_'.$pv->id.'_'.$p->id, 0) ; | |||||
if($quantite) { | |||||
$one_product = true ; | |||||
} | |||||
} | |||||
if(strlen($username) && $date && $one_product) { | |||||
$commande = new Commande ; | |||||
$commande->id_point_vente = $pv->id ; | |||||
$commande->id_production = $production->id ; | |||||
$commande->id_user = 0 ; | |||||
$commande->username = $username ; | |||||
$tab_date = explode('/', $date) ; | |||||
$commande->date = $tab_date[2].'-'.$tab_date[1].'-'.$tab_date[0].' 00:00:00' ; | |||||
$commande->save() ; | |||||
foreach($produits as $p) { | |||||
$quantite = Yii::$app->getRequest()->post('produit_pv_'.$pv->id.'_'.$p->id, 0) ; | |||||
if($quantite) { | |||||
$commande_produit = new CommandeProduit ; | |||||
$commande_produit->id_commande = $commande->id ; | |||||
$commande_produit->id_produit = $p->id ; | |||||
$commande_produit->quantite = $quantite ; | |||||
$commande_produit->prix = $p->prix ; | |||||
$commande_produit->save() ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public function actionIndex($date = '', $return_data = false) | |||||
{ | |||||
$commandes = [] ; | |||||
// points de vente | |||||
$points_vente = PointVente::find()->all() ; | |||||
// produits | |||||
$produits = Produit::find()->orderBy('order ASC')->all() ; | |||||
// users | |||||
$arr_users = [0 => '--'] ; | |||||
$users = User::find()->orderBy('prenom, nom ASC')->all() ; | |||||
foreach($users as $u) { | |||||
$arr_users[$u->id] = $u->prenom. ' '. $u->nom ; | |||||
} | |||||
// création du jour de production | |||||
$production = null ; | |||||
if($date != '') { | |||||
$production = Production::find()->where(['date' => $date])->one() ; | |||||
if(!$production) { | |||||
$production = new Production ; | |||||
$production->date = $date ; | |||||
$production->livraison = 1 ; | |||||
$production->save() ; | |||||
} | |||||
} | |||||
// gestion des commandes | |||||
$this->gestionFormCommandes($production, $date, $points_vente, $produits, $users) ; | |||||
// commandes | |||||
$commandes = Commande::find() | |||||
->with('commandeProduits','user') | |||||
->joinWith('production') | |||||
->where(['production.date'=>$date]) | |||||
->orderBy('date ASC') | |||||
->all() ; | |||||
$recettes = 0 ; | |||||
$recettes_pain = 0 ; | |||||
$recettes_vrac = 0 ; | |||||
$recettes_pain_livre = 0 ; | |||||
$poids_pain = 0 ; | |||||
$poids_vrac = 0 ; | |||||
foreach($commandes as $c) { | |||||
$c->init() ; | |||||
$recettes += $c->montant ; | |||||
$recettes_pain += $c->montant_pain ; | |||||
$recettes_vrac += $c->montant_vrac ; | |||||
if($c->id_point_vente != 1) | |||||
$recettes_pain_livre += $c->montant_pain ; | |||||
$poids_pain += $c->poids_pain ; | |||||
$poids_vrac += $c->poids_vrac ; | |||||
} | |||||
$recettes = number_format($recettes, 2) ; | |||||
$recettes_pain = number_format($recettes_pain, 2) ; | |||||
$recettes_vrac = number_format($recettes_vrac, 2) ; | |||||
// init commandes point de vente | |||||
foreach($points_vente as $pv) { | |||||
$pv->initCommandes($commandes) ; | |||||
} | |||||
// gestion produits selec | |||||
if(isset($_POST['valider_produit_selec'])) { | |||||
if(isset($_POST['Produit'])) { | |||||
foreach($produits as $p) { | |||||
$produit_production = ProductionProduit::find()->where(['id_production'=>$production->id,'id_produit'=>$p->id])->one() ; | |||||
if(!$produit_production) { | |||||
$produit_production = new ProductionProduit() ; | |||||
$produit_production->id_production = $production->id ; | |||||
$produit_production->id_produit = $p->id ; | |||||
$produit_production->actif = 0 ; | |||||
if(isset($p->quantite_max)) | |||||
$produit_production->quantite_max = $p->quantite_max ; | |||||
$produit_production->save() ; | |||||
} | |||||
if(isset($_POST['Produit'][$p->id]['actif'])) | |||||
{ | |||||
$produit_production->actif = 1 ; | |||||
} | |||||
else { | |||||
$produit_production->actif = 0 ; | |||||
} | |||||
if((isset($_POST['Produit'][$p->id]['quantite_max']) && $_POST['Produit'][$p->id]['quantite_max'] != '')) | |||||
{ | |||||
$produit_production->quantite_max = (int) $_POST['Produit'][$p->id]['quantite_max'] ; | |||||
} | |||||
else { | |||||
if(isset($p->quantite_max) && is_numeric($p->quantite_max) && $p->quantite_max > 0) | |||||
{ | |||||
$produit_production->quantite_max = $p->quantite_max ; | |||||
} | |||||
} | |||||
$produit_production->save() ; | |||||
} | |||||
} | |||||
} | |||||
// init produits sélectionnés pour cette production | |||||
$produits_selec = [] ; | |||||
if($production) { | |||||
$day_production = date('N',strtotime($production->date)) ; | |||||
$produits_production = ProductionProduit::find()->where(['id_production'=>$production->id])->all() ; | |||||
if(!count($produits_production)) { | |||||
foreach($produits as $p) { | |||||
$pp = new ProductionProduit() ; | |||||
$pp->id_production = $production->id ; | |||||
$pp->id_produit = $p->id ; | |||||
$pp->actif = 0 ; | |||||
if($day_production == 1 && $p->lundi) $pp->actif = 1 ; | |||||
if($day_production == 2 && $p->mardi) $pp->actif = 1 ; | |||||
if($day_production == 3 && $p->mercredi) $pp->actif = 1 ; | |||||
if($day_production == 4 && $p->jeudi) $pp->actif = 1 ; | |||||
if($day_production == 5 && $p->vendredi) $pp->actif = 1 ; | |||||
if($day_production == 6 && $p->samedi) $pp->actif = 1 ; | |||||
if($day_production == 7 && $p->dimanche) $pp->actif = 1 ; | |||||
$pp->quantite_max = $p->quantite_max ; | |||||
$pp->save() ; | |||||
} | |||||
} | |||||
// produits selec pour production | |||||
$produits_selec = ProductionProduit::findProduits($production->id) ; | |||||
} | |||||
// produit en vrac forcément activé | |||||
if($date != '') { | |||||
foreach($produits as $p) { | |||||
$produit_production = ProductionProduit::find()->where(['id_production'=>$production->id,'id_produit'=>$p->id])->one() ; | |||||
if($p->vrac) { | |||||
if(!$produit_production) { | |||||
$produit_production = new ProductionProduit() ; | |||||
$produit_production->id_production = $production->id ; | |||||
$produit_production->id_produit = $p->id ; | |||||
$produit_production->quantite_max = 0 ; | |||||
$produit_production->actif = 1 ; | |||||
$produit_production->save() ; | |||||
} | |||||
else { | |||||
$produit_production->actif = 1 ; | |||||
$produit_production->save() ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// poids total de la production et CA potentiel | |||||
$ca_potentiel = 0 ; | |||||
$poids_total = 0 ; | |||||
foreach($produits_selec as $id_produit_selec => $produit_selec) | |||||
{ | |||||
if($produit_selec['actif']) | |||||
{ | |||||
foreach($produits as $produit) | |||||
{ | |||||
if($produit->id == $id_produit_selec) | |||||
{ | |||||
//echo $produit->nom.' : '.$produit_selec['quantite_max'].'<br />' ; | |||||
$ca_potentiel += $produit_selec['quantite_max'] * $produit->prix ; | |||||
$poids_total += $produit_selec['quantite_max'] * $produit->poids ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// jours de production | |||||
$jours_production = Production::find()->where(['actif'=>1])->all() ; | |||||
$datas = [ | |||||
'produits' => $produits, | |||||
'points_vente' => $points_vente, | |||||
'commandes' => $commandes, | |||||
'date' => $date, | |||||
'production' => $production, | |||||
'jours_production' => $jours_production, | |||||
'produits_selec' => $produits_selec, | |||||
'users' => $arr_users, | |||||
'recettes' => $recettes, | |||||
'recettes_pain' => $recettes_pain, | |||||
'recettes_vrac' => $recettes_vrac, | |||||
'recettes_pain_livre' => $recettes_pain_livre, | |||||
'poids_pain' => $poids_pain, | |||||
'poids_vrac' => $poids_vrac, | |||||
'ca_potentiel' => $ca_potentiel, | |||||
'poids_total' => $poids_total, | |||||
] ; | |||||
if($return_data) | |||||
{ | |||||
return $datas ; | |||||
} | |||||
else { | |||||
return $this->render('index', $datas); | |||||
} | |||||
} | |||||
public function actionDownload($date = '', $id_point_vente = 0, $global = 0) { | |||||
// commandes | |||||
$commandes = Commande::find() | |||||
->with('commandeProduits','user') | |||||
->joinWith('production') | |||||
->where(['production.date'=>$date]) | |||||
->orderBy('date ASC') | |||||
->all() ; | |||||
foreach($commandes as $c) | |||||
$c->init() ; | |||||
// points de vente | |||||
$points_vente = PointVente::find()->all() ; | |||||
foreach($points_vente as $pv) | |||||
$pv->initCommandes($commandes) ; | |||||
// produits | |||||
$produits = Produit::find()->orderBy('order ASC')->all() ; | |||||
$production = Production::find()->where('date LIKE \''.$date.'\'')->one(); | |||||
$produits_selec = ProductionProduit::findProduits($production->id) ; | |||||
/* | |||||
* export global | |||||
*/ | |||||
if($global) { | |||||
$data = [] ; | |||||
$filename = 'export_'.$date.'_global' ; | |||||
$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] ; | |||||
// header | |||||
/*$line = [''] ; | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$line[] = $p->getLibelleAdmin() ; | |||||
} | |||||
} | |||||
$data[] = $line ;*/ | |||||
// par point de vente | |||||
foreach($points_vente as $pv) { | |||||
if(count($pv->commandes) && strlen($pv->$champs_horaires_point_vente)) { | |||||
//$data[] = [$pv->nom] ; | |||||
$line = [$pv->nom, 'Produits', 'Montant', 'Commentaire'] ; | |||||
/*foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$line[] = $p->getLibelleAdmin() ; | |||||
} | |||||
}*/ | |||||
$data[] = $line ; | |||||
$res = $this->contentPointVenteCSV($date, $produits, $points_vente, $pv->id) ; | |||||
foreach($res['data'] as $line) { | |||||
$data[] = $line ; | |||||
} | |||||
} | |||||
if(count($pv->commandes) && strlen($pv->$champs_horaires_point_vente)) { | |||||
$line = ['Total pain'] ; | |||||
$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.$p->diminutif.', ' ; | |||||
} | |||||
} | |||||
} | |||||
$line[] = substr($str_produits, 0, strlen($str_produits) - 2) ; | |||||
$line[] = number_format($pv->recettes_pain,2).' €' ; | |||||
$data[] = $line ; | |||||
$line = ['Total vrac'] ; | |||||
$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.$p->diminutif.', ' ; | |||||
} | |||||
} | |||||
} | |||||
$line[] = substr($str_produits, 0, strlen($str_produits) - 2) ; | |||||
$line[] = number_format($pv->recettes_vrac,2).' €' ; | |||||
$data[] = $line ; | |||||
$data[] = [] ; | |||||
} | |||||
} | |||||
// récap | |||||
//$line = ['Totaux'] ; | |||||
// pain | |||||
$line = ['Total pain'] ; | |||||
$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, $commandes) ; | |||||
$str_quantite = '' ; | |||||
if($quantite) { | |||||
$str_quantite = $quantite ; | |||||
$str_produits .= $str_quantite.''.$p->diminutif.', ' ; | |||||
} | |||||
} | |||||
} | |||||
$line[] = substr($str_produits, 0, strlen($str_produits)-2) ; | |||||
$data[] = $line ; | |||||
// vrac | |||||
$line = ['Total vrac'] ; | |||||
$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, $commandes) ; | |||||
$str_quantite = '' ; | |||||
if($quantite) { | |||||
$str_quantite = $quantite ; | |||||
$str_produits .= $str_quantite.''.$p->diminutif.', ' ; | |||||
} | |||||
} | |||||
} | |||||
$line[] = substr($str_produits, 0, strlen($str_produits)-2) ; | |||||
$data[] = $line ; | |||||
$infos = $this->actionIndex($date, true) ; | |||||
// $data[] = [] ; | |||||
/*$data[] = [ | |||||
'CA potentiel boutique', | |||||
number_format($infos['ca_potentiel'] - $infos['recettes_pain_livre'], 2).' €', | |||||
] ;*/ | |||||
/*$res = $this->contentRecapCSV($date, $produits, $points_vente, $commandes) ; | |||||
$data[] = ['Récapitulatif global'] ; | |||||
foreach($res['data'] as $line) { | |||||
$data[] = $line ; | |||||
}*/ | |||||
CSV::downloadSendHeaders($filename.'.csv'); | |||||
echo CSV::array2csv($data); | |||||
die(); | |||||
} | |||||
/* | |||||
* export individuel | |||||
*/ | |||||
else { | |||||
if($commandes && count($commandes)) { | |||||
$data = [] ; | |||||
// par point de vente | |||||
if($id_point_vente) { | |||||
$res = $this->contentPointVenteCSV($date, $produits, $points_vente, $id_point_vente) ; | |||||
$data = $res['data'] ; | |||||
$filename = $res['filename'] ; | |||||
} | |||||
// récapitulatif | |||||
else { | |||||
$res = $this->contentRecapCSV($date, $produits, $points_vente, $commandes) ; | |||||
$filename = 'recapitulatif_'.$date ; | |||||
$data = $res['data'] ; | |||||
} | |||||
CSV::downloadSendHeaders($filename.'.csv'); | |||||
echo CSV::array2csv($data); | |||||
die(); | |||||
} | |||||
} | |||||
} | |||||
public function contentRecapCSV($date, $produits, $points_vente, $commandes) { | |||||
$data = [] ; | |||||
$filename = 'recapitulatif_'.$date ; | |||||
$production = Production::find()->where('date LIKE \''.$date.'\'')->one(); | |||||
$produits_selec = ProductionProduit::findProduits($production->id) ; | |||||
// head | |||||
$data[0] = ['Lieu'] ; | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$data[0][] = $p->description ; | |||||
} | |||||
} | |||||
$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] ; | |||||
// datas | |||||
foreach($points_vente as $pv) { | |||||
if(count($pv->commandes) && strlen($pv->$champs_horaires_point_vente)) { | |||||
$data_add = [$pv->nom] ; | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$data_add[] = Commande::getQuantiteProduit($p->id, $pv->commandes) ; | |||||
} | |||||
} | |||||
$data[] = $data_add ; | |||||
} | |||||
} | |||||
$data_add = ['Total'] ; | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$data_add[] = Commande::getQuantiteProduit($p->id, $commandes) ; | |||||
} | |||||
} | |||||
$data[] = $data_add ; | |||||
return [ | |||||
'data' => $data, | |||||
'filename' => $filename | |||||
] ; | |||||
} | |||||
public function contentPointVenteCSV($date, $produits, $points_vente, $id_point_vente) { | |||||
$data = [] ; | |||||
$production = Production::find()->where('date LIKE \''.$date.'\'')->one(); | |||||
$produits_selec = ProductionProduit::findProduits($production->id) ; | |||||
// head | |||||
/*$data[0] = ['Client', 'Date commande'] ; | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$data[0][] = $p->description ; | |||||
} | |||||
}*/ | |||||
// datas | |||||
foreach($points_vente as $pv) { | |||||
if($pv->id == $id_point_vente) { | |||||
$filename = 'export_'.$date.'_'.strtolower(str_replace(' ', '-', $pv->nom)) ; | |||||
foreach($pv->commandes as $c) { | |||||
$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)) ; | |||||
} | |||||
// téléphone | |||||
if(strlen($c->user->telephone)) { | |||||
$str_user .= ' ('.$c->user->telephone.')' ; | |||||
} | |||||
$data_add = [$str_user] ; | |||||
// 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.''.$p->diminutif.', ' ; | |||||
$add = true ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
$data_add[] = substr($str_produits, 0, strlen($str_produits) - 2) ; | |||||
$data_add[] = number_format($c->montant,2) .' €' ; | |||||
$data_add[] = $c->commentaire ; | |||||
$data[] = $data_add ; | |||||
} | |||||
} | |||||
} | |||||
return [ | |||||
'data' => $data, | |||||
'filename' => $filename | |||||
] ; | |||||
} | |||||
public function actionChangeState($date, $actif) { | |||||
// changement état | |||||
$production = Production::find()->where(['date' => $date])->one() ; | |||||
$production->actif = $actif ; | |||||
$production->save() ; | |||||
// envoi emails aux personnes qui souhaitent être informées | |||||
if($actif) | |||||
{ | |||||
$jour = date('N', strtotime($date)) ; | |||||
$arr_jour_semaine = [1=>'lundi',2=>'mardi',3=>'mercredi',4=>'jeudi',5=>'vendredi',6=>'samedi',7=>'dimanche'] ; | |||||
$users = User::find()->where('mail_prod_'.$arr_jour_semaine[$jour].' = 1')->all() ; | |||||
//$str_date = strtolower(date('l j F', strtotime($date))) ; | |||||
setlocale (LC_ALL, "fr_FR"); | |||||
$str_date = strtolower(strftime('%A%e %B', strtotime($date))) ; | |||||
$str_date2 = date('d/m', strtotime($date)) ; | |||||
foreach($users as $u) | |||||
{ | |||||
if(!$u->no_mail) | |||||
{ | |||||
Yii::$app->mailer->compose() | |||||
->setTo($u->email) | |||||
->setFrom(['matthieu@lechatdesnoisettes.com' => 'Le Chat des Noisettes']) | |||||
->setSubject('[Le Chat des Noisettes] Production de pain du '.$str_date2) | |||||
->setTextBody( | |||||
"Bonjour, | |||||
Une production de pain est prévue le ".$str_date.". | |||||
Cordialement, | |||||
Matthieu | |||||
PS : Si vous ne souhaitez plus recevoir ces emails, rendez-vous dans votre compte sur www.lechatdesnoisettes.com. | |||||
")->send(); | |||||
} | |||||
} | |||||
} | |||||
$this->redirect(['index','date'=>$date]) ; | |||||
} | |||||
public function actionChangeLivraison($date, $livraison) { | |||||
$production = Production::find()->where(['date' => $date])->one() ; | |||||
$production->livraison = $livraison ; | |||||
$production->save() ; | |||||
$this->redirect(['index','date'=>$date]) ; | |||||
} | |||||
} |
<?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; | |||||
/** | |||||
* PointVenteController implements the CRUD actions for PointVente model. | |||||
*/ | |||||
class PointVenteController extends Controller | |||||
{ | |||||
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 ; | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* Lists all PointVente models. | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$dataProvider = new ActiveDataProvider([ | |||||
'query' => PointVente::find(), | |||||
]); | |||||
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()) { | |||||
return $this->redirect(['view', 'id' => $model->id]); | |||||
} else { | |||||
return $this->render('create', [ | |||||
'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 = $this->findModel($id); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
return $this->redirect(['view', 'id' => $model->id]); | |||||
} else { | |||||
return $this->render('update', [ | |||||
'model' => $model, | |||||
]); | |||||
} | |||||
} | |||||
/** | |||||
* 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(); | |||||
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.'); | |||||
} | |||||
} | |||||
} |
<?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 ProduitController extends Controller | |||||
{ | |||||
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 ; | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* Lists all Produit models. | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$dataProvider = new ActiveDataProvider([ | |||||
'query' => Produit::find()->where('(vrac IS NULL OR vrac = 0)')->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') ; | |||||
// 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.'); | |||||
} | |||||
} | |||||
} |
<?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; | |||||
/** | |||||
* Site controller | |||||
*/ | |||||
class SiteController extends Controller | |||||
{ | |||||
/** | |||||
* @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 ; | |||||
} | |||||
], | |||||
], | |||||
], | |||||
'verbs' => [ | |||||
'class' => VerbFilter::className(), | |||||
'actions' => [ | |||||
'logout' => ['post'], | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* @inheritdoc | |||||
*/ | |||||
public function actions() | |||||
{ | |||||
return [ | |||||
'error' => [ | |||||
'class' => 'yii\web\ErrorAction', | |||||
], | |||||
]; | |||||
} | |||||
public function actionIndex() | |||||
{ | |||||
return $this->render('index'); | |||||
} | |||||
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(); | |||||
} | |||||
} |
<?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 Controller { | |||||
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 ; | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
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 = [] ; | |||||
$data_vrac = [] ; | |||||
// 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 ; | |||||
$data_vrac[$mois] = 0 ; | |||||
} | |||||
// commandes | |||||
$commandes = Commande::find() | |||||
->with('commandeProduits') | |||||
->joinWith('production') | |||||
->where('production.date > '.$date_start) | |||||
->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 ; | |||||
$data_vrac[$mois] += $c->montant_vrac ; | |||||
} | |||||
} | |||||
return $this->render('index', [ | |||||
'data_labels' => $data_labels, | |||||
'data_pain' => $data_pain, | |||||
'data_vrac' => $data_vrac, | |||||
]); | |||||
} | |||||
} | |||||
?> |
<?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; | |||||
/** | |||||
* UserController implements the CRUD actions for User model. | |||||
*/ | |||||
class UserController extends Controller | |||||
{ | |||||
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 ; | |||||
}*/ | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* Lists all User models. | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$dataProvider = new ActiveDataProvider([ | |||||
'query' => User::find(), | |||||
]); | |||||
return $this->render('index', [ | |||||
'dataProvider' => $dataProvider, | |||||
]); | |||||
} | |||||
/** | |||||
* 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->save()) { | |||||
return $this->redirect(['view', 'id' => $model->id]); | |||||
} 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); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
return $this->redirect(['view', 'id' => $model->id]); | |||||
} else { | |||||
return $this->render('update', [ | |||||
'model' => $model, | |||||
]); | |||||
} | |||||
} | |||||
/** | |||||
* Deletes an existing User 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(); | |||||
return $this->redirect(['index']); | |||||
} | |||||
public function actionMail() { | |||||
/*$model = new MailForm() ; | |||||
$model->subject = '[Le Chat des Noisettes] ' ; | |||||
$model->body = | |||||
"Bonjour, | |||||
PS : Si vous ne souhaitez plus recevoir ces emails, rendez-vous dans votre compte sur www.lechatdesnoisettes.com." ; | |||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { | |||||
$id_user = Yii::$app->request->post('id_user') ; | |||||
$user = User::findIdentity($id_user) ; | |||||
if($user) | |||||
{ | |||||
$model->sendEmail($user->email) ; | |||||
} | |||||
}*/ | |||||
$users = User::find()->all() ; | |||||
$arr_users = [] ; | |||||
foreach($users as $u) | |||||
$arr_users[] = $u->email ; | |||||
return $this->render('liste_mails', [ | |||||
//'model' => $model, | |||||
'users' => $arr_users | |||||
]); | |||||
} | |||||
/** | |||||
* 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.'); | |||||
} | |||||
} | |||||
} |
<?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 Controller | |||||
{ | |||||
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 ; | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* 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.'); | |||||
} | |||||
} | |||||
} |
* |
<?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(); | |||||
} | |||||
} |
* | |||||
!.gitignore |
<?php | |||||
use yii\helpers\Html ; | |||||
use common\models\Commande ; | |||||
$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"> | |||||
<?php | |||||
// chargement assets | |||||
common\components\fullcalendar\FullcalendarWidget::widget() ; | |||||
// --> lancement du js en manuel (via lechatdesnoisettes.js) | |||||
?> | |||||
<div id="calendar"></div> | |||||
<?php if($production): ?> | |||||
<!-- produits sélectionnés --> | |||||
<br /> | |||||
<form id="produits-production" action="<?php echo Yii::$app->urlManager->createUrl(['commande/index','date'=>$date]); ?>" method="post"> | |||||
<table class="table table-bordered"> | |||||
<tbody> | |||||
<?php foreach($produits as $p): ?> | |||||
<tr<?php if($p->vrac): ?> style="display:none;"<?php endif;?>> | |||||
<td><label for="produit-<?php echo $p->id; ?>"><?php if(strlen($p->description)): echo Html::encode($p->description) ; else: echo Html::encode($p->nom) ; endif; ?></label></td> | |||||
<td><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><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> | |||||
<input type="submit" name="valider_produit_selec" class="btn btn-default" value="Valider" /> | |||||
</form> | |||||
<?php endif; ?> | |||||
</div> | |||||
<div class="col-md-9"> | |||||
<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 != ''): ?> | |||||
<h1> | |||||
Production du <?php echo date('d/m/Y',strtotime($date)) ; ?> | |||||
<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> | |||||
</h1> | |||||
<strong>Livraison</strong> | |||||
<div class="btn-group" role="group"> | |||||
<a class="btn btn-default<?php if($production->livraison): ?> btn-success<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['commande/change-livraison','date'=>$date,'livraison'=>1]); ?>">Activé</a> | |||||
<a class="btn btn-default<?php if(!$production->livraison): ?> btn-danger<?php endif; ?>" href="<?php echo Yii::$app->urlManager->createUrl(['commande/change-livraison','date'=>$date,'livraison'=>0]); ?>">Désactivé</a> | |||||
</div> | |||||
<br /><br /> | |||||
<?php if(!count($commandes)): ?> | |||||
<div class="alert alert-info">Aucune commande passée pour cette date</div> | |||||
<?php else: ?> | |||||
<a class="btn btn-primary" href="<?php echo Yii::$app->urlManager->createUrl(['commande/download','date'=>$date,'id_point_vente'=>0,'global'=>1]); ?>"><span class="glyphicon glyphicon-download-alt"></span> Récapitulatif global</a> | |||||
<br /> | |||||
<br /> | |||||
<?php endif;?> | |||||
<?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] ; | |||||
?> | |||||
<?php //if(count($pv->commandes)):?> | |||||
<form class="form-commandes-point-vente" action="<?php echo Yii::$app->urlManager->createUrl(['commande/index','date'=>$date]); ?>" method="post"> | |||||
<!-- <h2><?php //echo Html::encode($pv->nom); ?> <a href="<?php //echo Yii::$app->urlManager->createUrl(['commande/download','date'=>$date,'id_point_vente'=>$pv->id]); ?>" class="btn btn-default">CSV</a></h2> --> | |||||
<!-- <p><?php //echo Html::encode($pv->adresse); ?></p> --> | |||||
<table class="table table-striped table-bordered"> | |||||
<thead> | |||||
<tr> | |||||
<td class="title-point-vente" colspan="<?php echo count($produits)+4; ?>"><strong>Global</strong></td> | |||||
</tr> | |||||
<tr> | |||||
<td></td> | |||||
<?php foreach($produits as $p): ?> | |||||
<?php if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?> | |||||
<td class="center<?php if($p->vrac): ?> vrac<?php endif; ?>"> | |||||
<strong><?php echo Html::encode($p->getLibelleAdmin()); ?></strong> | |||||
</td> | |||||
<?php endif; ?> | |||||
<?php endforeach; ?> | |||||
<td><strong>Potentiel</strong></td> | |||||
<td><strong>Commandé</strong></td> | |||||
</tr> | |||||
<tr> | |||||
<td><strong>Pain</strong></td> | |||||
<?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 = 'center total' ; | |||||
if($str_quantite > $produits_selec[$p->id]['quantite_max'] && !$produits_selec[$p->id]['vrac']) { | |||||
$classe .= ' depasse' ; | |||||
} | |||||
if($p->vrac) { | |||||
$classe .= ' vrac' ; | |||||
} | |||||
echo '<td class="'.$classe.'"><strong>'.$str_quantite.' <span>' ; | |||||
if($produits_selec[$p->id]['quantite_max'] && $str_quantite) | |||||
echo '/ '.$produits_selec[$p->id]['quantite_max'].'</span></strong></td>' ; | |||||
} | |||||
} | |||||
?> | |||||
<td><strong><?php echo number_format($ca_potentiel,2) ; ?> €</strong><br /><?php echo number_format($poids_total/1000,2) ; ?> kg</td> | |||||
<td><strong><?php echo str_replace(' ',' ',$recettes_pain.' €') ; ?></strong><br /><?php echo round($poids_pain).' kg'; ?></td> | |||||
<td></td> | |||||
</tr> | |||||
<tr> | |||||
<td><strong>Vrac</strong></td> | |||||
<td colspan="<?php echo $cpt_non_vrac; ?>"> | |||||
<?php | |||||
$first = true ; | |||||
foreach($produits as $p) { | |||||
if($p->vrac) { | |||||
$quantite = Commande::getQuantiteProduit($p->id, $commandes) ; | |||||
if($quantite) { | |||||
if(!$first) | |||||
echo ', ' ; | |||||
echo $quantite.' '.Html::encode($p->diminutif) ; | |||||
$first = false ; | |||||
} | |||||
} | |||||
} | |||||
?> | |||||
</td> | |||||
<!-- liste vrac --> | |||||
<td></td> | |||||
<?php | |||||
foreach($produits as $p) { | |||||
if($p->vrac) | |||||
echo '<td class="vrac"></td>' ; | |||||
} | |||||
?> | |||||
<td><strong><?php echo str_replace(' ',' ',$recettes_vrac.' €') ; ?></strong><br /><?php echo round($poids_vrac).' kg'; ?></td> | |||||
<td></td> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<?php foreach($points_vente as $pv): ?> | |||||
<?php | |||||
if(strlen($pv->$champs_horaires_point_vente)): | |||||
?> | |||||
<tr> | |||||
<td class="title-point-vente" colspan="<?php echo count($produits)+4; ?>"><?php echo Html::encode($pv->nom); ?></td> | |||||
</tr> | |||||
<tr> | |||||
<td></td> | |||||
<?php foreach($produits as $p): ?> | |||||
<?php if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']): ?> | |||||
<td class="center<?php if($p->vrac): ?> vrac<?php endif; ?>"> | |||||
<strong><?php echo Html::encode($p->getLibelleAdmin()); ?></strong> | |||||
</td> | |||||
<?php endif; ?> | |||||
<?php endforeach; ?> | |||||
<td class="center"> | |||||
<strong>VRAC</strong> | |||||
</td> | |||||
<td></td> | |||||
<td></td> | |||||
</tr> | |||||
<?php foreach($pv->commandes as $c): ?> | |||||
<tr> | |||||
<td> | |||||
<?php if(isset($c->user)): ?> | |||||
<?php echo Html::encode($c->user->prenom.' '.$c->user->nom) ;?> | |||||
<?php else: ?> | |||||
<?php echo Html::encode($c->username) ; ?> | |||||
<?php endif; ?> | |||||
<?php if(strlen($c->commentaire)): ?> | |||||
<button type="button" class="btn btn-xs btn-info" data-toggle="popover" title="Commentaire" data-content="<?php echo Html::encode($c->commentaire); ?>"><span class="glyphicon glyphicon-comment"></span></button> | |||||
<?php endif; ?> | |||||
<br /><span class="date-commande"><?php echo date('d/m/Y à H:i ',strtotime($c->date)) ; if($c->date_update && date('d/m/Y',strtotime($c->date_update)) != date('d/m/Y',strtotime($c->date))): ?><br />modif. <?php echo date('d/m/Y',strtotime($c->date_update)) ; ?><?php endif;?></span> | |||||
</td> | |||||
<?php | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
$add = false ; | |||||
$quantite = 0 ; | |||||
foreach($c->commandeProduits as $cp) { | |||||
if($p->id == $cp->id_produit) { | |||||
$quantite = $cp->quantite ; | |||||
$add = true ; | |||||
} | |||||
} | |||||
echo '<td class="td-produit'.(($p->vrac) ? ' vrac' : '').'"><input class="quantite" type="text" value="'.$quantite.'" name="produit_'.$c->id.'_'.$p->id.'" /></td>' ; | |||||
} | |||||
} | |||||
?> | |||||
<!-- liste vrac --> | |||||
<td><?php echo $c->strListeVrac(); ?></td> | |||||
<td><?php echo str_replace(' ',' ',number_format($c->montant,2).' €') ; ?></td> | |||||
<td><a href="<?php echo Yii::$app->urlManager->createUrl(['commande/delete-commande','date'=>$date,'delete'=>1,'id_commande'=>$c->id]) ; ?>" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a></td> | |||||
</tr> | |||||
<?php endforeach; ?> | |||||
<tr> | |||||
<td><!-- <select class="select-user" name="user_pv_<?php echo $pv->id;?>"> | |||||
<?php foreach($users as $id_user => $libelle_user) { | |||||
echo '<option value="'.$id_user.'">'.$libelle_user.'</option>' ; | |||||
}?> | |||||
</select> --> | |||||
<input type="text" placeholder="Nom" class="text" name="username_pv_<?php echo $pv->id;?>" /> | |||||
<br /> | |||||
<input type="text" name="date_commande_pv_<?php echo $pv->id;?>" class="datepicker" value="<?php echo date('d/m/Y'); ?>" /> | |||||
</td> | |||||
<?php | |||||
foreach($produits as $p) { | |||||
if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) { | |||||
echo '<td class="td-produit'.(($p->vrac) ? ' vrac' : '').'"><input class="quantite" type="text" value="0" name="produit_pv_'.$pv->id.'_'.$p->id.'" /></td>' ; | |||||
} | |||||
} | |||||
?> | |||||
<!-- liste vrac --> | |||||
<td><a href="javascript:void(0):" class="btn btn-default btn-xs edit-vrac"><i class="glyphicon glyphicon-pencil"></i></a></td> | |||||
<td></td> | |||||
<td></td> | |||||
</tr> | |||||
<?php if(count($pv->commandes) && strlen($pv->$champs_horaires_point_vente)) { | |||||
echo '<tr>' ; | |||||
echo '<td><strong>Total pain</strong></td>' ; | |||||
//$cpt_non_vrac = 0 ; | |||||
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) { | |||||
//$cpt_non_vrac ++ ; | |||||
if($quantite) | |||||
$str_quantite = $quantite ; | |||||
} | |||||
echo '<td class="center'.(($p->vrac) ? ' vrac' : '').'"><strong>'.$str_quantite.'</strong></td>' ; | |||||
} | |||||
} | |||||
// liste vrac | |||||
echo '<td></td>' ; | |||||
// total | |||||
echo '<td><strong>'.number_format($pv->recettes_pain,2).' €</strong></td><td></td></tr>' ; | |||||
/* | |||||
* VRAC | |||||
*/ | |||||
echo '<tr>' ; | |||||
echo '<td><strong>Total vrac</strong></td>' ; | |||||
echo '<td colspan="'.$cpt_non_vrac.'">'.$pv->strListeVrac().'</td>' ; | |||||
foreach($produits as $p) { | |||||
if($p->vrac) | |||||
echo '<td class="vrac"></td>' ; | |||||
} | |||||
// liste vrac | |||||
echo '<td></td>' ; | |||||
echo '<td><strong>'.number_format($pv->recettes_vrac,2).' €</strong></td><td></td></tr>' ; | |||||
} ?> | |||||
<?php endif; ?> | |||||
<?php endforeach; ?> | |||||
</tbody> | |||||
</table> | |||||
<input type="submit" class="btn btn-primary submit-pv" value="Enregistrer" name="submit_pv" /> | |||||
</form> | |||||
<div class="clr"></div> | |||||
<?php if(count($commandes) && false): ?> | |||||
<h2>Récapitulatif production <a href="<?php echo Yii::$app->urlManager->createUrl(['commande/download','date'=>$date]); ?>" class="btn btn-default">CSV</a></h2> | |||||
<table class="table table-striped table-bordered"> | |||||
<thead> | |||||
<tr> | |||||
<th>Lieu</th> | |||||
<?php foreach($produits as $p): ?> | |||||
<?php if(isset($produits_selec[$p->id]['actif']) && $produits_selec[$p->id]['actif']) : ?> | |||||
<th><?php echo Html::encode($p->description); ?></th> | |||||
<?php endif; ?> | |||||
<?php endforeach; ?> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<?php | |||||
foreach($points_vente as $pv) { | |||||
if(count($pv->commandes) && strlen($pv->$champs_horaires_point_vente)) { | |||||
echo '<tr>' ; | |||||
echo '<td>'.Html::encode($pv->nom).'</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($quantite) | |||||
$str_quantite = $quantite ; | |||||
echo '<td>'.$str_quantite.'</td>' ; | |||||
} | |||||
} | |||||
echo '</tr>' ; | |||||
} | |||||
} | |||||
?> | |||||
</tbody> | |||||
<tfoot> | |||||
<tr> | |||||
<td><strong>Total</strong></td> | |||||
<?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 ; | |||||
echo '<td class="'.(($p->vrac) ? 'vrac' : '').'">'.$str_quantite.'</td>' ; | |||||
} | |||||
} | |||||
?> | |||||
</tr> | |||||
</tfoot> | |||||
</table> | |||||
<?php endif;?> | |||||
<?php endif; ?> | |||||
</div> | |||||
</div> |
<?php | |||||
use backend\assets\AppAsset; | |||||
use yii\helpers\Html; | |||||
use yii\bootstrap\Nav; | |||||
use yii\bootstrap\NavBar; | |||||
use yii\widgets\Breadcrumbs; | |||||
/* @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"> | |||||
<?= Html::csrfMetaTags() ?> | |||||
<title><?= Html::encode($this->title) ?> - Le Chat des Noisettes</title> | |||||
<?php $this->head() ?> | |||||
</head> | |||||
<body> | |||||
<?php $this->beginBody() ?> | |||||
<div class="wrap"> | |||||
<?php | |||||
NavBar::begin([ | |||||
'brandLabel' => 'Le Chat des Noisettes', | |||||
'brandUrl' => Yii::$app->homeUrl, | |||||
'options' => [ | |||||
'class' => 'navbar-inverse navbar-fixed-top', | |||||
], | |||||
]); | |||||
$menuItems = [ | |||||
['label' => 'Production', 'url' => ['/commande/index'], 'visible'=> !Yii::$app->user->isGuest], | |||||
['label' => 'Pain', 'url' => ['/produit/index'], 'visible'=> !Yii::$app->user->isGuest], | |||||
['label' => 'Vrac', 'url' => ['/vrac/index'], 'visible'=> !Yii::$app->user->isGuest], | |||||
['label' => 'Points de vente', 'url' => ['/point-vente/index'], 'visible'=> !Yii::$app->user->isGuest], | |||||
['label' => 'Utilisateurs', 'url' => ['/user/index'], 'visible'=> !Yii::$app->user->isGuest], | |||||
['label' => 'Statistiques', 'url' => ['/stats/index'], 'visible'=> !Yii::$app->user->isGuest], | |||||
]; | |||||
if (Yii::$app->user->isGuest) { | |||||
$menuItems[] = ['label' => 'Connexion', 'url' => ['/site/login']]; | |||||
} else { | |||||
$menuItems[] = [ | |||||
'label' => 'Déconnexion (' . Yii::$app->user->identity->username . ')', | |||||
'url' => ['/site/logout'], | |||||
'linkOptions' => ['data-method' => 'post'] | |||||
]; | |||||
} | |||||
echo Nav::widget([ | |||||
'options' => ['class' => 'navbar-nav navbar-right'], | |||||
'items' => $menuItems, | |||||
]); | |||||
NavBar::end(); | |||||
?> | |||||
<div class="container"> | |||||
<?= Breadcrumbs::widget([ | |||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], | |||||
]) ?> | |||||
<?= $content ?> | |||||
</div> | |||||
</div> | |||||
<footer class="footer"> | |||||
<div class="container"> | |||||
<p class="pull-left"></p> | |||||
<p class="pull-right"><?= Yii::powered() ?></p> | |||||
</div> | |||||
</footer> | |||||
<?php $this->endBody() ?> | |||||
</body> | |||||
</html> | |||||
<?php $this->endPage() ?> |
<?php | |||||
use yii\helpers\Html; | |||||
use yii\widgets\ActiveForm; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model backend\models\PointVente */ | |||||
/* @var $form yii\widgets\ActiveForm */ | |||||
?> | |||||
<div class="point-vente-form"> | |||||
<?php $form = ActiveForm::begin(); ?> | |||||
<?php //$form->field($model, 'point_fabrication')->checkbox() ?> | |||||
<?= $form->field($model, 'nom')->textInput(['maxlength' => 255]) ?> | |||||
<?= $form->field($model, 'localite')->textInput(['maxlength' => 255]) ?> | |||||
<?= $form->field($model, 'adresse')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'pain')->checkbox(); ?> | |||||
<?= $form->field($model, 'vrac')->checkbox(); ?> | |||||
<h2>Horaires</h2> | |||||
<div class="alert alert-info">Laisser vide si le point de vente est fermé</div> | |||||
<?= $form->field($model, 'horaires_lundi')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'horaires_mardi')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'horaires_mercredi')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'horaires_jeudi')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'horaires_vendredi')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'horaires_samedi')->textarea(['rows' => 6]) ?> | |||||
<?= $form->field($model, 'horaires_dimanche')->textarea(['rows' => 6]) ?> | |||||
<div class="form-group"> | |||||
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model backend\models\PointVente */ | |||||
$this->title = 'Create Point Vente'; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Point Ventes', 'url' => ['index']]; | |||||
$this->params['breadcrumbs'][] = $this->title; | |||||
?> | |||||
<div class="point-vente-create"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<?= $this->render('_form', [ | |||||
'model' => $model, | |||||
]) ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
use yii\grid\GridView; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $dataProvider yii\data\ActiveDataProvider */ | |||||
$this->title = 'Point Ventes'; | |||||
$this->params['breadcrumbs'][] = $this->title; | |||||
?> | |||||
<div class="point-vente-index"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<p> | |||||
<?= Html::a('Create Point Vente', ['create'], ['class' => 'btn btn-success']) ?> | |||||
</p> | |||||
<?= GridView::widget([ | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
//['class' => 'yii\grid\SerialColumn'], | |||||
//'id', | |||||
'nom', | |||||
'localite', | |||||
//'point_fabrication', | |||||
//'adresse:ntext', | |||||
['class' => 'yii\grid\ActionColumn'], | |||||
], | |||||
]); ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model backend\models\PointVente */ | |||||
$this->title = 'Update Point Vente: ' . ' ' . $model->id; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Point Ventes', 'url' => ['index']]; | |||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; | |||||
$this->params['breadcrumbs'][] = 'Update'; | |||||
?> | |||||
<div class="point-vente-update"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<?= $this->render('_form', [ | |||||
'model' => $model, | |||||
]) ?> | |||||
</div> |
<?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> |
<?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, 'recette')->textarea() ?> | |||||
<?= $form->field($model, 'saison')->dropDownList(['all' => 'Toutes les saisons', 'printemps' => 'Printemps', 'ete' => 'Été', 'automne' => 'Automne', 'hiver' => 'Hiver']) ; ?> | |||||
<?= $form->field($model, 'prix')->textInput() ?> | |||||
<?= $form->field($model, 'poids')->textInput() ?> | |||||
<?= $form->field($model, 'quantite_max')->textInput() ?> | |||||
<?= $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 />' ; | |||||
} | |||||
?> | |||||
<?= $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 />' ; | |||||
} | |||||
?> | |||||
<h2>Production</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 class="form-group"> | |||||
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model app\models\Produit */ | |||||
$this->title = 'Create Produit'; | |||||
$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> |
<?php | |||||
use yii\helpers\Html; | |||||
use yii\grid\GridView; | |||||
/* @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) ?></h1> | |||||
<p> | |||||
<?= Html::a('Create Produit', ['create'], ['class' => 'btn btn-success']) ?> | |||||
</p> | |||||
<?= GridView::widget([ | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
//['class' => 'yii\grid\SerialColumn'], | |||||
'order', | |||||
'diminutif', | |||||
'nom', | |||||
//'description', | |||||
//'actif', | |||||
//'illustration', | |||||
// 'photo', | |||||
'saison', | |||||
// 'prix', | |||||
// 'poids', | |||||
'actif', | |||||
['class' => 'yii\grid\ActionColumn'], | |||||
], | |||||
]); ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model app\models\Produit */ | |||||
$this->title = 'Update Produit: ' . ' ' . $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> |
<?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> |
<?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> |
<?php | |||||
/* @var $this yii\web\View */ | |||||
$this->title = 'Administration'; | |||||
?> | |||||
<div class="site-index"> | |||||
<?php | |||||
// chargement assets | |||||
common\components\fullcalendar\FullcalendarWidget::widget() ; | |||||
// --> lancement du js en manuel (via lechatdesnoisettes.js) | |||||
?> | |||||
<div id="calendar"></div> | |||||
</div> |
<?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 = 'Login'; | |||||
$this->params['breadcrumbs'][] = $this->title; | |||||
?> | |||||
<div class="site-login"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<p>Please fill out the following fields to login:</p> | |||||
<div class="row"> | |||||
<div class="col-lg-5"> | |||||
<?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('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> | |||||
</div> | |||||
</div> |
<?php | |||||
$this->title = 'Statistiques' ; | |||||
use dosamigos\chartjs\ChartJs; | |||||
?> | |||||
<h2>Recettes des commandes (pain / vrac)</h2> | |||||
<?= ChartJs::widget([ | |||||
'type' => 'Line', | |||||
'options' => [ | |||||
'height' => 400, | |||||
'width' => 1100 | |||||
], | |||||
'data' => [ | |||||
'labels' => $data_labels, | |||||
'datasets' => [ | |||||
[ | |||||
'fillColor' => "rgba(220,220,220,0.5)", | |||||
'strokeColor' => "rgba(220,220,220,1)", | |||||
'pointColor' => "rgba(220,220,220,1)", | |||||
'pointStrokeColor' => "#fff", | |||||
'data' => $data_vrac | |||||
], | |||||
[ | |||||
'fillColor' => "rgba(253,212,75,0.5)", | |||||
'strokeColor' => "rgba(253,212,75,1)", | |||||
'pointColor' => "rgba(253,212,75,1)", | |||||
'pointStrokeColor' => "#fff", | |||||
'data' => $data_pain | |||||
] | |||||
] | |||||
] | |||||
]); | |||||
?> |
<?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(); ?> | |||||
<p>Si cette option n'est pas cochée, l'utilisateur ne pourra commander que 3 pains à la fois.</p> | |||||
<?= $form->field($model, 'confiance')->checkbox() ?> | |||||
<?= $form->field($model, 'nom')->textInput() ?> | |||||
<?= $form->field($model, 'prenom')->textInput() ?> | |||||
<?= $form->field($model, 'telephone')->textInput() ?> | |||||
<?= $form->field($model, 'email')->textInput() ?> | |||||
<?= $form->field($model, 'status')->textInput() ?> | |||||
<div class="form-group"> | |||||
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model common\models\User */ | |||||
$this->title = 'Create User'; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; | |||||
$this->params['breadcrumbs'][] = $this->title; | |||||
?> | |||||
<div class="user-create"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<?= $this->render('_form', [ | |||||
'model' => $model, | |||||
]) ?> | |||||
</div> |
<?php | |||||
use yii\helpers\Html; | |||||
use yii\grid\GridView; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $dataProvider yii\data\ActiveDataProvider */ | |||||
$this->title = 'Utilisateurs'; | |||||
$this->params['breadcrumbs'][] = $this->title; | |||||
?> | |||||
<div class="user-index"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<p> | |||||
<?= Html::a('Ajouter un utilisateur', ['create'], ['class' => 'btn btn-success']) ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?> | |||||
</p> | |||||
<?= GridView::widget([ | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
//['class' => 'yii\grid\SerialColumn'], | |||||
//'id', | |||||
//'username', | |||||
//'auth_key', | |||||
//'password_hash', | |||||
//'password_reset_token', | |||||
// 'email:email', | |||||
// 'status', | |||||
// 'created_at', | |||||
// 'updated_at', | |||||
'nom', | |||||
'prenom', | |||||
//'telephone', | |||||
//'email', | |||||
//'confiance', | |||||
['class' => 'yii\grid\ActionColumn'], | |||||
], | |||||
]); ?> | |||||
</div> |
<?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. | |||||
*/ | |||||
$this->title = 'Liste des emails utilisateurs'; | |||||
?> | |||||
<h1><?= count($users); ?> utilisateurs</h1> | |||||
<?= implode(', ', $users); ?> | |||||
<?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(); ?> | |||||
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $model common\models\User */ | |||||
$this->title = 'Update User: ' . ' ' . $model->id; | |||||
$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; | |||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; | |||||
$this->params['breadcrumbs'][] = 'Update'; | |||||
?> | |||||
<div class="user-update"> | |||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<?= $this->render('_form', [ | |||||
'model' => $model, | |||||
]) ?> | |||||
</div> |
<?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' => 'Users', '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> |
<?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> |
<?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> |
<?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> |
<?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> |
<?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> |
/index.php | |||||
/index-test.php |
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 |