Преглед на файлове

Ajustement des commandes automatiques

Tri des utilisateurs par ordre alphabétique,
Possibilité de mettre un utilisateur non inscrit.
master
keun преди 8 години
родител
ревизия
8a3f96f3ed
променени са 11 файла, в които са добавени 147 реда и са изтрити 41 реда
  1. +2
    -1
      backend/controllers/CommandeautoController.php
  2. +9
    -9
      backend/views/commande/index.php
  3. +14
    -4
      backend/views/commandeauto/_form.php
  4. +34
    -2
      backend/views/commandeauto/index.php
  5. Двоични данни
      backend/web/.sass-cache/c8fef7d48da4dc7f024edc2b0fada9d8d6de5dac/screen.scssc
  6. +20
    -6
      backend/web/css/screen.css
  7. +14
    -0
      backend/web/sass/screen.scss
  8. +19
    -10
      common/models/CommandeAuto.php
  9. +17
    -8
      common/models/CommandeAutoForm.php
  10. +1
    -1
      console/migrations/m161125_075714_commandes_automatiques.php
  11. +17
    -0
      console/migrations/m161206_080722_add_champs_username_commandeauto.php

+ 2
- 1
backend/controllers/CommandeautoController.php Целия файл

@@ -70,7 +70,7 @@ class CommandeautoController extends BackendController {
->where(['id_etablissement' => $model->id_etablissement])
->orderBy('order ASC')
->all();
if($model->load(Yii::$app->request->post()) && $model->validate() && $model->save())
{
@@ -93,6 +93,7 @@ class CommandeautoController extends BackendController {
$model->id = $id ;
$model->id_etablissement = $commandeauto->id_etablissement ;
$model->id_user = $commandeauto->id_user ;
$model->username = $commandeauto->username ;
$model->id_point_vente = $commandeauto->id_point_vente ;
$model->date_debut = date('d/m/Y',strtotime($commandeauto->date_debut)) ;
if(strlen($model->date_fin))

+ 9
- 9
backend/views/commande/index.php Целия файл

@@ -168,18 +168,18 @@ foreach ($produits as $p) {
<span class="user">
<?php if(isset($c->user)): ?>
<?= Html::encode($c->user->nom.' '.$c->user->prenom); ?>
<?php if($c->type): ?>
<?php if($c->type == Commande::TYPE_ADMIN): ?>
<span class="label label-warning">vous</span>
<?php elseif($c->type == Commande::TYPE_AUTO): ?>
<span class="label label-default">auto</span>
<?php elseif($c->type == Commande::TYPE_USER): ?>
<span class="label label-success">client</span>
<?php endif; ?>
<?php endif; ?>
<?php else: ?>
<?= Html::encode($c->username); ?>
<?php endif; ?>
<?php if($c->type): ?>
<?php if($c->type == Commande::TYPE_ADMIN): ?>
<span class="label label-warning">vous</span>
<?php elseif($c->type == Commande::TYPE_AUTO): ?>
<span class="label label-default">auto</span>
<?php elseif($c->type == Commande::TYPE_USER): ?>
<span class="label label-success">client</span>
<?php endif; ?>
<?php endif; ?>
</span>
<?php if (strlen($c->commentaire)): ?>
<span class="glyphicon glyphicon-comment"></span>

+ 14
- 4
backend/views/commandeauto/_form.php Целия файл

@@ -9,10 +9,20 @@ use common\models\PointVente ;
?>

<div class="commandeauto-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_user')->dropDownList( ArrayHelper::map(User::find()->joinWith('userEtablissement')->where('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement)->all(), 'id', function($model, $defaultValue) {
return $model['nom'].' '.$model['prenom'];
}), ['prompt' => '--','class' => 'form-control user-id', ]) ?>
<?php $form = ActiveForm::begin(['enableClientValidation' => false]); ?>
<div class="col-md-5" id="bloc-select-user">
<?= $form->field($model, 'id_user')->dropDownList( ArrayHelper::map(User::find()->joinWith('userEtablissement')->where('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement)->orderBy('nom ASC, prenom ASC')->all(), 'id', function($model, $defaultValue) {
return $model['nom'].' '.$model['prenom'];
}), ['prompt' => '--','class' => 'form-control user-id', ]) ?>
</div>
<div class="col-md-1" id="or-user">
<span>OU</span>
</div>
<div class="col-md-6">
<?= $form->field($model, 'username')->textInput() ?>
</div>
<div class="clr"></div>
<?= $form->field($model, 'id_etablissement')->hiddenInput() ?>
<?= $form->field($model, 'id_point_vente')->dropDownList( ArrayHelper::map(PointVente::find()->where('id_etablissement = '.Yii::$app->user->identity->id_etablissement)->all(), 'id', function($model, $defaultValue) {
return $model['nom'];

+ 34
- 2
backend/views/commandeauto/index.php Целия файл

@@ -16,12 +16,18 @@ $this->params['breadcrumbs'][] = $this->title;
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'id_user',
'format' => 'raw',
'value' => function($model) {
return Html::encode($model->user->nom.' '.$model->user->prenom) ;
if(strlen($model->username))
{
return Html::encode($model->username) ;
}
else {
return Html::encode($model->user->nom.' '.$model->user->prenom) ;
}
}
],
[
@@ -58,6 +64,32 @@ $this->params['breadcrumbs'][] = $this->title;
return 'indéterminée' ;
}
],
[
'attribute' => 'lundi',
'label' => 'Jours',
'value' => function($model) {
$html = '' ;
if($model->lundi)
$html .= 'lundi, ' ;
if($model->mardi)
$html .= 'mardi, ' ;
if($model->mercredi)
$html .= 'mercredi, ' ;
if($model->jeudi)
$html .= 'jeudi, ' ;
if($model->vendredi)
$html .= 'vendredi, ' ;
if($model->samedi)
$html .= 'samedi, ' ;
if($model->dimanche)
$html .= 'dimanche, ' ;
if(strlen($html))
return substr ($html, 0, strlen($html) - 2) ;
else
return '' ;
}
],
[
'attribute' => 'periodicite_semaine',
'value' => function($model) {

Двоични данни
backend/web/.sass-cache/c8fef7d48da4dc7f024edc2b0fada9d8d6de5dac/screen.scssc Целия файл


+ 20
- 6
backend/web/css/screen.css Целия файл

@@ -859,32 +859,46 @@ a:hover, a:focus, a:active {
}

/* commandes auto */
/* line 860, ../sass/screen.scss */
/* line 861, ../sass/screen.scss */
.commandeauto-form #bloc-select-user {
padding-left: 0px;
}
/* line 865, ../sass/screen.scss */
.commandeauto-form #or-user {
font-size: 20px;
text-align: center;
}
/* line 868, ../sass/screen.scss */
.commandeauto-form #or-user span {
position: relative;
top: 24px;
}
/* line 874, ../sass/screen.scss */
.commandeauto-form .field-commandeautoform-id_etablissement {
display: none;
}
/* line 864, ../sass/screen.scss */
/* line 878, ../sass/screen.scss */
.commandeauto-form .jours .form-group {
float: left;
margin-right: 20px;
}
/* line 871, ../sass/screen.scss */
/* line 885, ../sass/screen.scss */
.commandeauto-form .produits .table {
width: 500px;
}
/* line 874, ../sass/screen.scss */
/* line 888, ../sass/screen.scss */
.commandeauto-form .produits .quantite {
text-align: center;
}

/* points de vente */
/* line 883, ../sass/screen.scss */
/* line 897, ../sass/screen.scss */
.point-vente-form #pointvente-users {
display: none;
height: 500px;
overflow-y: scroll;
}
/* line 887, ../sass/screen.scss */
/* line 901, ../sass/screen.scss */
.point-vente-form #pointvente-users label {
font-weight: normal;
display: block;

+ 14
- 0
backend/web/sass/screen.scss Целия файл

@@ -857,6 +857,20 @@ a {
/* commandes auto */

.commandeauto-form {
#bloc-select-user {
padding-left: 0px ;
}
#or-user {
font-size: 20px ;
text-align: center ;
span {
position: relative ;
top: 24px ;
}
}
.field-commandeautoform-id_etablissement {
display: none ;
}

+ 19
- 10
common/models/CommandeAuto.php Целия файл

@@ -26,6 +26,7 @@ use common\models\CommandeProduit ;
* @property integer $samedi
* @property integer $dimanche
* @property integer $periodicite_semaine
* @property string $username
*/
class CommandeAuto extends \yii\db\ActiveRecord
{
@@ -43,9 +44,9 @@ class CommandeAuto extends \yii\db\ActiveRecord
public function rules()
{
return [
[['id_user', 'id_etablissement', 'id_point_vente'], 'required'],
[['id_etablissement', 'id_point_vente'], 'required'],
[['id_user', 'id_etablissement', 'id_point_vente', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche', 'periodicite_semaine'], 'integer'],
[['date_debut', 'date_fin'], 'safe'],
[['date_debut', 'date_fin','username'], 'safe'],
];
}

@@ -118,14 +119,15 @@ class CommandeAuto extends \yii\db\ActiveRecord
$jour = date('N', strtotime($date)) ;
switch($jour)
{
case 1 : $jour = 'lundi' ;
case 2 : $jour = 'mardi' ;
case 3 : $jour = 'mercredi' ;
case 4 : $jour = 'jeudi' ;
case 5 : $jour = 'vendredi' ;
case 6 : $jour = 'samedi' ;
case 7 : $jour = 'dimanche' ;
case 1 : $jour = 'lundi' ; break ;
case 2 : $jour = 'mardi' ; break ;
case 3 : $jour = 'mercredi' ; break ;
case 4 : $jour = 'jeudi' ; break ;
case 5 : $jour = 'vendredi' ; break ;
case 6 : $jour = 'samedi' ; break ;
case 7 : $jour = 'dimanche' ; break ;
}
if($c->$jour)
{
$arr_commandes_auto[] = $c ;
@@ -168,7 +170,14 @@ class CommandeAuto extends \yii\db\ActiveRecord
{
// commande
$commande = new Commande ;
$commande->id_user = $this->id_user ;
if(strlen($this->username))
{
$commande->username = $this->username ;
$commande->id_user = 0 ;
}
else {
$commande->id_user = $this->id_user ;
}
$commande->date = date('Y-m-d H:i:s') ;
$commande->type = Commande::TYPE_AUTO ;
$commande->id_point_vente = $this->id_point_vente ;

+ 17
- 8
common/models/CommandeAutoForm.php Целия файл

@@ -13,6 +13,7 @@ class CommandeAutoForm extends Model
{
public $id ;
public $id_user ;
public $username ;
public $id_etablissement ;
public $id_point_vente ;
public $date_debut;
@@ -33,15 +34,20 @@ class CommandeAutoForm extends Model
public function rules()
{
return [
[['id_user', 'id_etablissement', 'periodicite_semaine', 'id_point_vente'], 'integer'],
[['id_etablissement', 'periodicite_semaine', 'id_point_vente'], 'integer'],
[['date_debut', 'date_fin'], 'date', 'format' => 'php:d/m/Y'],
[['lundi','mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'], 'boolean'],
[['id_user','id_point_vente', 'id_etablissement', 'date_debut'],'required', 'message' => 'Champs obligatoire'],
['produits' , 'safe'],
[['id_point_vente', 'id_etablissement', 'date_debut'],'required', 'message' => 'Champs obligatoire'],
[['produits','id_user','username'], 'safe'],
['id_user', function ($attribute, $params) {
if(!$this->id_user && !strlen($this->username))
{
$this->addError($attribute,'Vous devez sélectionner ou saisir un utilisateur.') ;
}
},'skipOnEmpty' => false],
['produits', function($attribute, $params) {
$produits = $this->produits ;
$quantite = 0 ;
if(count($produits))
{
foreach($produits as $name_input => $quantite_produit) {
@@ -53,11 +59,11 @@ class CommandeAutoForm extends Model
if(!$quantite)
{
$this->addError($attribute, 'Vous devez saisir au moins un produit');
}
}]
}
}],
];
}
}
public function attributeLabels()
{
@@ -76,6 +82,7 @@ class CommandeAutoForm extends Model
'samedi' => 'Samedi',
'dimanche' => 'Dimanche',
'periodicite_semaine' => 'Périodicité (semaines)',
'username' => 'Nom d\'utilisateur',
];
}
@@ -92,6 +99,7 @@ class CommandeAutoForm extends Model
if($commandeauto)
{
$commandeauto->id_user = $this->id_user ;
$commandeauto->username = $this->username ;
$commandeauto->id_etablissement = $this->id_etablissement ;
$commandeauto->id_point_vente = $this->id_point_vente ;
$commandeauto->date_debut = date('Y-m-d',strtotime(str_replace('/','-',$this->date_debut))) ;
@@ -108,6 +116,7 @@ class CommandeAutoForm extends Model
$commandeauto->dimanche = $this->dimanche ;
$commandeauto->periodicite_semaine = $this->periodicite_semaine ;
$commandeauto->save() ;
// produits

+ 1
- 1
console/migrations/m161125_075714_commandes_automatiques.php Целия файл

@@ -9,7 +9,7 @@ class m161125_075714_commandes_automatiques extends Migration
{
$this->createTable('commande_auto', [
'id' => 'pk',
'id_user' => Schema::TYPE_INTEGER . ' NOT NULL',
'id_user' => Schema::TYPE_INTEGER ,
'id_etablissement' => Schema::TYPE_INTEGER. ' NOT NULL',
'date_debut' => Schema::TYPE_DATE,
'date_fin' => Schema::TYPE_DATE,

+ 17
- 0
console/migrations/m161206_080722_add_champs_username_commandeauto.php Целия файл

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

use yii\db\Migration;
use yii\db\Schema;

class m161206_080722_add_champs_username_commandeauto extends Migration
{
public function up()
{
$this->addColumn('commande_auto', 'username', Schema::TYPE_STRING) ;
}

public function down()
{
$this->dropColumn('commande_auto', 'username') ;
}
}

Loading…
Отказ
Запис