Commit 8061770ca71ecaedf76efe887aad49a2092876c3
1 parent
9e64b15e
Exists in
master
and in
3 other branches
changement indentation
Showing
3 changed files
with
13 additions
and
27 deletions
Show diff stats
src/Controller/DocumentsController.php
@@ -238,7 +238,6 @@ class DocumentsController extends AppController { | @@ -238,7 +238,6 @@ class DocumentsController extends AppController { | ||
238 | ]); | 238 | ]); |
239 | } else { | 239 | } else { |
240 | // Ajout de doc au matériel | 240 | // Ajout de doc au matériel |
241 | - $materiel->documents = $materiel->documents + 1; | ||
242 | // $this->sendEmailToManagementWith('[LabInvent] Ajout d\'un document', $userName.' (email = '.$userEmail.') a ajouté un document de type "'.$nomType.'" au matériel "'.$materiel->designation.'" (id = '.$materiel->id.').'); | 241 | // $this->sendEmailToManagementWith('[LabInvent] Ajout d\'un document', $userName.' (email = '.$userEmail.') a ajouté un document de type "'.$nomType.'" au matériel "'.$materiel->designation.'" (id = '.$materiel->id.').'); |
243 | $this->sendEmail(null, '[LabInvent] Ajout d\'un document', $userName . ' a ajouté un document de type "' . $nomType . '" au matériel "' . $materiel->designation . '" (id = ' . $materiel->id . ').'); | 242 | $this->sendEmail(null, '[LabInvent] Ajout d\'un document', $userName . ' a ajouté un document de type "' . $nomType . '" au matériel "' . $materiel->designation . '" (id = ' . $materiel->id . ').'); |
244 | return $this->redirect([ | 243 | return $this->redirect([ |
@@ -410,7 +409,6 @@ class DocumentsController extends AppController { | @@ -410,7 +409,6 @@ class DocumentsController extends AppController { | ||
410 | $id | 409 | $id |
411 | ]); | 410 | ]); |
412 | } else { | 411 | } else { |
413 | - $materiel->documents = $materiel->documents - 1; | ||
414 | return $this->redirect([ | 412 | return $this->redirect([ |
415 | 'controller' => 'materiels', | 413 | 'controller' => 'materiels', |
416 | 'action' => 'view', | 414 | 'action' => 'view', |
src/Controller/MaterielsController.php
@@ -327,7 +327,7 @@ class MaterielsController extends AppController { | @@ -327,7 +327,7 @@ class MaterielsController extends AppController { | ||
327 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. | 327 | * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. |
328 | */ | 328 | */ |
329 | public function view($id = null) { | 329 | public function view($id = null) { |
330 | - var_dump($this); | 330 | + // var_dump($this); |
331 | $materiel = $this->Materiels->get($id, [ | 331 | $materiel = $this->Materiels->get($id, [ |
332 | 'contain' => [ | 332 | 'contain' => [ |
333 | 'SurCategories', | 333 | 'SurCategories', |
src/Model/Table/MaterielsTable.php
@@ -80,7 +80,7 @@ class MaterielsTable extends AppTable { | @@ -80,7 +80,7 @@ class MaterielsTable extends AppTable { | ||
80 | $this->belongsTo('Fournisseurs', [ | 80 | $this->belongsTo('Fournisseurs', [ |
81 | 'foreignKey' => 'fournisseur_id' | 81 | 'foreignKey' => 'fournisseur_id' |
82 | ]); | 82 | ]); |
83 | - | 83 | + |
84 | // EP 9/6/17 added : | 84 | // EP 9/6/17 added : |
85 | $this->belongsTo('Users', [ | 85 | $this->belongsTo('Users', [ |
86 | 'foreignKey' => 'gestionnaire_id' | 86 | 'foreignKey' => 'gestionnaire_id' |
@@ -122,11 +122,9 @@ class MaterielsTable extends AppTable { | @@ -122,11 +122,9 @@ class MaterielsTable extends AppTable { | ||
122 | 'message' => 'Le statut doit prendre une des 4 valeurs CREATED, VALIDATED, TOBEARCHIVED, ou ARCHIVED', | 122 | 'message' => 'Le statut doit prendre une des 4 valeurs CREATED, VALIDATED, TOBEARCHIVED, ou ARCHIVED', |
123 | 'provider' => 'table' | 123 | 'provider' => 'table' |
124 | ]); | 124 | ]); |
125 | - $configuration = TableRegistry::get('Configurations')->find() | ||
126 | - ->where([ | 125 | + $configuration = TableRegistry::get('Configurations')->find()->where([ |
127 | 'id =' => 1 | 126 | 'id =' => 1 |
128 | - ]) | ||
129 | - ->first(); | 127 | + ])->first(); |
130 | if ($configuration->date_commande_facultative) { | 128 | if ($configuration->date_commande_facultative) { |
131 | $validator->allowEmpty('date_acquisition'); | 129 | $validator->allowEmpty('date_acquisition'); |
132 | } else { | 130 | } else { |
@@ -137,9 +135,7 @@ class MaterielsTable extends AppTable { | @@ -137,9 +135,7 @@ class MaterielsTable extends AppTable { | ||
137 | 'message' => 'Ce champ contient des caractères interdits', | 135 | 'message' => 'Ce champ contient des caractères interdits', |
138 | 'provider' => 'table' | 136 | 'provider' => 'table' |
139 | ]); | 137 | ]); |
140 | - $validator->numeric('prix_ht') | ||
141 | - ->allowEmpty('prix_ht') | ||
142 | - ->add('prix_ht', 'valid', [ | 138 | + $validator->numeric('prix_ht')->allowEmpty('prix_ht')->add('prix_ht', 'valid', [ |
143 | 'rule' => 'check_string', | 139 | 'rule' => 'check_string', |
144 | 'message' => 'Ce champ contient des caractères interdits', | 140 | 'message' => 'Ce champ contient des caractères interdits', |
145 | 'provider' => 'table' | 141 | 'provider' => 'table' |
@@ -216,30 +212,24 @@ class MaterielsTable extends AppTable { | @@ -216,30 +212,24 @@ class MaterielsTable extends AppTable { | ||
216 | * @return \Cake\ORM\RulesChecker | 212 | * @return \Cake\ORM\RulesChecker |
217 | */ | 213 | */ |
218 | public function buildRules(RulesChecker $rules) { | 214 | public function buildRules(RulesChecker $rules) { |
219 | - $configuration = TableRegistry::get('Configurations')->find() | ||
220 | - ->where([ | 215 | + $configuration = TableRegistry::get('Configurations')->find()->where([ |
221 | 'id =' => 1 | 216 | 'id =' => 1 |
222 | - ]) | ||
223 | - ->first(); | 217 | + ])->first(); |
224 | $checkAtLeastOneChecked = function ($entity) { | 218 | $checkAtLeastOneChecked = function ($entity) { |
225 | return ($entity->materiel_administratif || $entity->materiel_technique); | 219 | return ($entity->materiel_administratif || $entity->materiel_technique); |
226 | }; | 220 | }; |
227 | // return if price >= $configuration->prix_inventaire_administratif € then must be checked as "administratif" | 221 | // return if price >= $configuration->prix_inventaire_administratif € then must be checked as "administratif" |
228 | $checkIfIsAdministratifWhenShouldBe = function ($entity) { | 222 | $checkIfIsAdministratifWhenShouldBe = function ($entity) { |
229 | - $configuration = TableRegistry::get('Configurations')->find() | ||
230 | - ->where([ | 223 | + $configuration = TableRegistry::get('Configurations')->find()->where([ |
231 | 'id =' => 1 | 224 | 'id =' => 1 |
232 | - ]) | ||
233 | - ->first(); | 225 | + ])->first(); |
234 | return ! (isset($entity->prix_ht) && $entity->prix_ht >= $configuration->prix_inventaire_administratif && ! $entity->materiel_administratif); | 226 | return ! (isset($entity->prix_ht) && $entity->prix_ht >= $configuration->prix_inventaire_administratif && ! $entity->materiel_administratif); |
235 | }; | 227 | }; |
236 | // return if price <800€ then must NOT be checked as "administratif" | 228 | // return if price <800€ then must NOT be checked as "administratif" |
237 | $checkIfIsNotAdministratifWhenShouldNotBe = function ($entity) { | 229 | $checkIfIsNotAdministratifWhenShouldNotBe = function ($entity) { |
238 | - $configuration = TableRegistry::get('Configurations')->find() | ||
239 | - ->where([ | 230 | + $configuration = TableRegistry::get('Configurations')->find()->where([ |
240 | 'id =' => 1 | 231 | 'id =' => 1 |
241 | - ]) | ||
242 | - ->first(); | 232 | + ])->first(); |
243 | return ! (isset($entity->prix_ht) && $entity->prix_ht < $configuration->prix_inventaire_administratif && $entity->materiel_administratif); | 233 | return ! (isset($entity->prix_ht) && $entity->prix_ht < $configuration->prix_inventaire_administratif && $entity->materiel_administratif); |
244 | }; | 234 | }; |
245 | // return if checked as "administratif" price MUST be set | 235 | // return if checked as "administratif" price MUST be set |
@@ -297,11 +287,9 @@ class MaterielsTable extends AppTable { | @@ -297,11 +287,9 @@ class MaterielsTable extends AppTable { | ||
297 | $entity->set('nom_responsable', $entity->get('nom_ancien_responsable')); | 287 | $entity->set('nom_responsable', $entity->get('nom_ancien_responsable')); |
298 | } | 288 | } |
299 | // numero_laboratoire generator (QC changed this in Jan 2015) | 289 | // numero_laboratoire generator (QC changed this in Jan 2015) |
300 | - $configuration = TableRegistry::get('Configurations')->find() | ||
301 | - ->where([ | 290 | + $configuration = TableRegistry::get('Configurations')->find()->where([ |
302 | 'id =' => 1 | 291 | 'id =' => 1 |
303 | - ]) | ||
304 | - ->first(); | 292 | + ])->first(); |
305 | if ($configuration->numero_labo_sans_annee) { | 293 | if ($configuration->numero_labo_sans_annee) { |
306 | if (empty($entity->get('numero_laboratoire'))) { | 294 | if (empty($entity->get('numero_laboratoire'))) { |
307 | $labShortName = $configuration->labNameShort; | 295 | $labShortName = $configuration->labNameShort; |