Merge branch 'develop' of https://github.com/dev-fsociety/DFS-2016 into develop
This commit is contained in:
commit
610d73c860
src
Controller
Model/Table
Template
Camps
Element/Flash
Items
Layout
Users
webroot/css
@ -66,11 +66,21 @@ class CategoriesController extends AppController
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
// $camp = ... Recupérer le camp_id de l'utilisateur ici
|
||||
$camp = $this->Auth->user('camp_id');
|
||||
|
||||
$categories = $this->Categories->find('list', ['limit' => 200]);
|
||||
$sub_q = $this->Categories->Items->find()
|
||||
->select(['id'])
|
||||
->where(function ($exp, $q) {
|
||||
return $exp->equalFields('Categories.id', 'Items.category_id');
|
||||
});
|
||||
|
||||
$categories = $this->Categories->find('list')->where(
|
||||
function ($exp, $q) use ($sub_q) {
|
||||
return $exp->notExists($sub_q);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$this->set(compact('category', 'camp', 'categories'));
|
||||
$this->set('_serialize', ['category']);
|
||||
}
|
||||
|
@ -59,7 +59,19 @@ class ItemsController extends AppController
|
||||
$this->Flash->error(__('The item could not be saved. Please, try again.'));
|
||||
}
|
||||
}
|
||||
$categories = $this->Items->Categories->find('list', ['limit' => 200]);
|
||||
|
||||
$sub_q = $this->Items->find()
|
||||
->select(['id'])
|
||||
->where(function ($exp, $q) {
|
||||
return $exp->equalFields('Categories.id', 'Items.category_id');
|
||||
});
|
||||
|
||||
$categories = $this->Items->Categories->find('list')->where(
|
||||
function ($exp, $q) use ($sub_q) {
|
||||
return $exp->Exists($sub_q);
|
||||
}
|
||||
);
|
||||
|
||||
$this->set(compact('item', 'categories'));
|
||||
$this->set('_serialize', ['item']);
|
||||
}
|
||||
@ -112,7 +124,7 @@ class ItemsController extends AppController
|
||||
}
|
||||
|
||||
/**
|
||||
* List method
|
||||
* byCategory method
|
||||
*
|
||||
* @param string|null $id Item id.
|
||||
* @return \Cake\Network\Response|null Redirects to index.
|
||||
@ -126,5 +138,20 @@ class ItemsController extends AppController
|
||||
$this->set(compact('items', 'category'));
|
||||
}
|
||||
|
||||
public function process($id = null){
|
||||
$r = $this->Items->Offers->find()->where(['item_id' => $id])->toArray() ;
|
||||
if( empty($r) ){
|
||||
//No result we have to create the needs
|
||||
// add a needs for the item indentified by $id
|
||||
return $this->redirect(['controller' => 'needs','action' => 'add', $id]);
|
||||
}else{
|
||||
//redirect the user to the needs view
|
||||
//$r[0]->id is the id of the offer
|
||||
return $this->redirect(['controller' => 'offers','action' => 'view', $r[0]->id]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -326,12 +326,11 @@ class UsersController extends AppController
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(in_array($this->request->action, ['index']))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
return parent::isAuthorized($user);
|
||||
}
|
||||
|
||||
public function beforeFilter(Event $event)
|
||||
@ -343,8 +342,17 @@ class UsersController extends AppController
|
||||
|
||||
public function logout()
|
||||
{
|
||||
$this->Flash->success('You are now logged out.');
|
||||
$this->redirect($this->Auth->logout());
|
||||
if($this->request->session()->read('Auth.User.id') != null)
|
||||
{
|
||||
$this->Flash->success('You are now logged out.');
|
||||
return $this->redirect($this->Auth->logout());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$this->Flash->warning('You can\'t logout because you\'re not connected.');
|
||||
return $this->redirect('/');
|
||||
}
|
||||
}
|
||||
|
||||
public function profile($id = null)
|
||||
|
@ -94,10 +94,10 @@ class UsersTable extends Table
|
||||
$validator
|
||||
->requirePresence('phone', 'create')
|
||||
->allowEmpty('phone')
|
||||
/*->add('phone', 'validFormat', [
|
||||
'rule' => ['custom', '^0[0-79][0-9]{8}$'],
|
||||
->add('phone', 'validFormat', [
|
||||
'rule' => ['custom', '#^0[0-79][0-9]{8}$#'],
|
||||
'message' => 'Please enter a valid phone number.']
|
||||
)*/;
|
||||
);
|
||||
|
||||
$validator
|
||||
->requirePresence('description', 'create')
|
||||
|
@ -1,4 +1,4 @@
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<!-- <nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('Edit Camp'), ['action' => 'edit', $camp->id]) ?> </li>
|
||||
@ -31,4 +31,54 @@
|
||||
<td><?= $this->Number->format($refugee_count) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<br>
|
||||
<div class="row">
|
||||
|
||||
<div class="large-9 columns">
|
||||
|
||||
<h2> <?= h($camp->name) ?> </h2>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Nombre de migrants : <?= $refugee_count ?></p>
|
||||
|
||||
<p>Localisation : lng : <?= $this->Number->format($camp->lng) ?>, lat : <?= $this->Number->format($camp->lat) ?></p>
|
||||
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
|
||||
<?= $this->Html->link(__('Edit Camp'), ['action' => 'edit', $camp->id], array('class' => 'button expanded')) ?>
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="large-9 columns">
|
||||
|
||||
<!-- <?= debug($camp) ?>
|
||||
-->
|
||||
<h4> Categories for this camp </h4>
|
||||
|
||||
<ul>
|
||||
|
||||
<?php foreach($camp->categories as $category): ?>
|
||||
|
||||
<li> <?= h($category->name) ?> <?= $this->Form->postLink(__('<i class="fi-x-circle"></i>'), ['controller' => 'Categories', 'action' => 'delete', $category->id], ['confirm' => __('Are you sure you want to delete : {0}?', $category->name), 'escape' => false]) ?></li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="large-3 columns">
|
||||
|
||||
<?= $this->Html->link(__('New Category'), ['controller' => 'Categories', 'action' => 'add'], array('class' => 'button expanded')) ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
@ -3,4 +3,9 @@ if (!isset($params['escape']) || $params['escape'] !== false) {
|
||||
$message = h($message);
|
||||
}
|
||||
?>
|
||||
<div class="message error" onclick="this.classList.add('hidden');"><?= $message ?></div>
|
||||
<div class="alert callout" data-closable>
|
||||
<p><?= $message ?></p>
|
||||
<button class="close-button" aria-label="Dismiss alert" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
@ -3,4 +3,9 @@ if (!isset($params['escape']) || $params['escape'] !== false) {
|
||||
$message = h($message);
|
||||
}
|
||||
?>
|
||||
<div class="message success" onclick="this.classList.add('hidden')"><?= $message ?></div>
|
||||
<div class="success callout" data-closable>
|
||||
<p><?= $message ?></p>
|
||||
<button class="close-button" aria-label="Dismiss alert" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
11
src/Template/Element/Flash/warning.ctp
Normal file
11
src/Template/Element/Flash/warning.ctp
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
if (!isset($params['escape']) || $params['escape'] !== false) {
|
||||
$message = h($message);
|
||||
}
|
||||
?>
|
||||
<div class="warning callout" data-closable>
|
||||
<p><?= $message ?></p>
|
||||
<button class="close-button" aria-label="Dismiss alert" type="button" data-close>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
@ -7,26 +7,25 @@
|
||||
<?php foreach ($items as $item): ?>
|
||||
<!-- if right camp -->
|
||||
<?php $sclass = "square square-color" . (string)($counter%4) ?>
|
||||
<div class="row">
|
||||
<?php $rclass = "row bycat row-color" . (string)($counter%4) ?>
|
||||
|
||||
<a href=<?php echo "../process/" . $item->id; ?> >
|
||||
<div class="<?php echo $rclass; ?>" style="background-color: #DEDEDE;">
|
||||
<div class="column large-3 medium-3 small-3 text-center square-container">
|
||||
<div class="<?php echo $sclass; ?>">
|
||||
<div class="square-content"><?= h($item->name) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column large-3 medium-3 small-3 text-center">
|
||||
<div class="column large-3 medium-3 small-3"></div>
|
||||
<div class="column large-6 medium-6 small-6">
|
||||
<div class="cat-desc">
|
||||
<?= h($item->category) ?>
|
||||
<?= $this->Text->autoParagraph(h($item->description)); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column large-3 medium-3 small-3 text-center">
|
||||
<div class="cat-desc">
|
||||
<a href="#" class="button large radius">Hot+1</a>
|
||||
<br> <?= $this->Number->format($item->hot) ?> <br>
|
||||
<a href="#" class="button large radius">Get some <?= h($item->name) ?> !</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<br>
|
||||
<?php $counter++;?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
@ -46,14 +46,17 @@ $cakeDescription = 'CampCare';
|
||||
<span data-responsive-toggle="responsive-menu" data-hide-for="medium">
|
||||
<button class="menu-icon dark" type="button" data-toggle></button>
|
||||
</span>
|
||||
<a href=""><?= $this->Html->image('long_logo.png', array('class'=>'topbar_logo')); ?></a>
|
||||
<a href="<?= $this->Url->build('/', true); ?>"><?= $this->Html->image('long_logo.png', ['class'=>'topbar_logo', 'url' => '/']); ?></a>
|
||||
</div>
|
||||
<div id="responsive-menu">
|
||||
<div class="top-bar-left">
|
||||
</div>
|
||||
<div class="top-bar-right">
|
||||
<ul class="menu">
|
||||
<li><a href="#" class="profile_icon"><i class="fi-torso"></i></a></li>
|
||||
<?php if($this->request->session()->read('Auth.User.id') != null): ?>
|
||||
<li><a href="<?= $this->Url->build('/users', true); ?>" class="profile_icon"><i class="fi-torso"></i></a></li>
|
||||
<li><a href="<?= $this->Url->build('/users/logout', true); ?>" class="profile_icon"><i class="fi-power"></i></a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -61,7 +64,6 @@ $cakeDescription = 'CampCare';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?= $this->Flash->render() ?>
|
||||
<div class="container clearfix">
|
||||
<?= $this->fetch('content') ?>
|
||||
@ -73,8 +75,8 @@ $cakeDescription = 'CampCare';
|
||||
<p class="links">
|
||||
<a href="https://twitter.com/dev_fsociety">Twitter</a>
|
||||
<a href="http://www.nuitdelinfo.com/">Nuit de l'Info</a>
|
||||
<a href="https://github.com/dev-fsociety/DFS-2016">Git Hub</a>
|
||||
<a href="#">About</a>
|
||||
<a href="https://github.com/dev-fsociety/DFS-2016">GitHub</a>
|
||||
<a href="https://github.com/orgs/dev-fsociety/teams">About</a>
|
||||
</p>
|
||||
<p class="copywrite">Copywrite /DEV/FSOCIETY © 2016</p>
|
||||
</div>
|
||||
|
@ -1,8 +1,21 @@
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background: url(../img/login_bg.jpg) no-repeat center center fixed;
|
||||
-webkit-background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
-o-background-size: cover;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
<div class="medium-6 medium-centered large-4 large-centered columns">
|
||||
|
||||
<!-- Log In section -->
|
||||
<div class="row column log-in-form" style="padding:1rem; margin-bottom: 10px; margin-top: 10px;">
|
||||
<div class="row column log-in-form" style="padding:1rem; margin-bottom: 10px; margin-top: 20%;">
|
||||
<?= $this->Form->create() ?>
|
||||
<fieldset>
|
||||
<h4 class="text-center"> Log In </h4>
|
||||
|
@ -145,6 +145,7 @@ h1 {
|
||||
background: #53777A;
|
||||
}
|
||||
|
||||
|
||||
.square-color0:hover {
|
||||
background: #a8243a;
|
||||
}
|
||||
@ -253,9 +254,15 @@ div.message.hidden {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.bycat .square-container {
|
||||
margin-top: 0%!important;
|
||||
}
|
||||
|
||||
.cat-desc {
|
||||
margin-top: 20%;
|
||||
font-size: 2em;
|
||||
|
||||
}
|
||||
|
||||
.column {
|
||||
padding: 0px;
|
||||
}
|
||||
|
6
webroot/css/foundation.css
vendored
6
webroot/css/foundation.css
vendored
@ -2076,11 +2076,11 @@ select {
|
||||
.callout.secondary {
|
||||
background-color: #ebebeb; }
|
||||
.callout.success {
|
||||
background-color: #e1faea; }
|
||||
background-color: #00cc66; }
|
||||
.callout.warning {
|
||||
background-color: #fff3d9; }
|
||||
background-color: #f06600; }
|
||||
.callout.alert {
|
||||
background-color: #fce6e2; }
|
||||
background-color: #f03232; }
|
||||
.callout.small {
|
||||
padding-top: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
|
@ -3,7 +3,7 @@
|
||||
border: 1px solid #cacaca;
|
||||
border-radius: 3px;
|
||||
padding:1rem;
|
||||
|
||||
background-color: #fff;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user