Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Ajout de la possibilité de choisir la couleur de fond ainsi que l'opa…
Browse files Browse the repository at this point in the history
…cité
  • Loading branch information
bulton-fr committed Dec 30, 2013
1 parent e767629 commit abd940e
Show file tree
Hide file tree
Showing 12 changed files with 385 additions and 9 deletions.
13 changes: 13 additions & 0 deletions controlers/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,17 @@
}
}

if(isset($idUser))
{
$BackColor = $Memcache->getVal('U'.$idUser.'_BackColor');
$BackOpacity = $Memcache->getVal('U'.$idUser.'_BackOpacity');
$TextColorBlack = $Memcache->getVal('U'.$idUser.'_TextColorBlack');

$TPL->AddBlock('cssLogged', array(
'backColor' => $BackColor,
'backOpacity' => $BackOpacity,
'textColorBlack' => $TextColorBlack
));
}

$TPL->End();
7 changes: 5 additions & 2 deletions controlers/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
'css' => array(
$path.'jquery_ui/themes/redmond/jquery-ui.css',
$path.'jquery_ui/timepicker/timepicker.css',
$path.'farbtastic/farbtastic.css',
$path.'css/index.css',
$path.'css/recap.css',
$path.'css/vendu.css',
$path.'css/ventes.css',
$path.'css/enAttente.css',
$path.'css/perso.css'
$path.'css/perso.css',
$path.'css/compte.css'
),
'js' => array(
'https://www.google.com/jsapi',
Expand All @@ -19,7 +21,8 @@
$path.'js/ventes.js',
$path.'js/enAttente.js',
$path.'jquery_ui/ui/jquery-ui.min.js',
$path.'jquery_ui/timepicker/jquery-ui-timepicker-addon.js'
$path.'jquery_ui/timepicker/jquery-ui-timepicker-addon.js',
$path.'farbtastic/farbtastic.js'
)
);

Expand Down
57 changes: 57 additions & 0 deletions controlers/monCompte.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php
$init = get(0);

$oldMDP = post('oldMDP');
$newMDP = post('newMDP');

$backColor = post('backColor');
$backOpacity = post('backOpacity');
$textColor = post('textColor');

if(!is_null($oldMDP) || !is_null($newMDP))
{
$status = 403;
Expand All @@ -27,13 +33,64 @@

echo json_encode(array('status' => $status, 'erreur' => $erreur));
}
elseif($init == 'init')
{
$MUser = new \modules\users\modeles\Users;

$BackColor = '#ffffff';
$BackOpacity = 93;
$TextColorBlack = true;

if(!$MUser->setBackgroundColor($idUser, $BackColor)) {ErrorView(500, false);}
else {$Memcache->setVal('U'.$idUser.'_BackColor', $BackColor);}

if(!$MUser->setBackgroundOpacity($idUser, $BackOpacity)) {ErrorView(500, false);}
else {$Memcache->setVal('U'.$idUser.'_BackOpacity', $BackOpacity);}

if(!$MUser->setColorTextBlack($idUser, $TextColorBlack)) {ErrorView(500, false);}
else {$Memcache->setVal('U'.$idUser.'_TextColorBlack', $TextColorBlack);}

echo json_encode(array(
'backgroundColor' => $BackColor,
'backgroundOpacity' => $BackOpacity,
'textColor' => 'black',
'textColorBlack' => $TextColorBlack
));
}
elseif(!is_null($backColor) || !is_null($backOpacity) || !is_null($textColor))
{
if(empty($backColor) || empty($backOpacity) || empty($textColor)) {ErrorView(500, false);}

$MUser = new \modules\users\modeles\Users;

if(!$MUser->setBackgroundColor($idUser, $backColor)) {ErrorView(500, false);}
else {$Memcache->setVal('U'.$idUser.'_BackColor', $backColor);}

if(!$MUser->setBackgroundOpacity($idUser, (int) $backOpacity)) {ErrorView(500, false);}
else {$Memcache->setVal('U'.$idUser.'_BackOpacity', (int) $backOpacity);}

$textColor = ($textColor == 'true') ? true : false;
if(!$MUser->setColorTextBlack($idUser, $textColor)) {ErrorView(500, false);}
else {$Memcache->setVal('U'.$idUser.'_TextColorBlack', (int) $textColor);}
}
else
{
$TPL = new \BFW_Tpl\Classes\Template('monCompte.html');

$edit = get(0);
if(!is_null($edit) && $edit == 'ok') {$TPL->AddBlockWithEnd('modifOk');}

$BackColor = $Memcache->getVal('U'.$idUser.'_BackColor');
$BackOpacity = $Memcache->getVal('U'.$idUser.'_BackOpacity');
$TextColorBlack = $Memcache->getVal('U'.$idUser.'_TextColorBlack');

$textColorCheck = ($TextColorBlack == 1) ? 'checked="checked"' : '';
$TPL->AddVars(array(
'backColor' => $BackColor,
'backOpacity' => $BackOpacity,
'textColorCheck' => $textColorCheck
));

$TPL->End();
}
?>
5 changes: 4 additions & 1 deletion modules/app/fonctions/rom.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ function set_po($po)
*/
function get_color_item($color)
{
$color = str_replace('ffffff', '000000', $color); //Blanc en noir
global $Memcache, $idUser;
$textBlack = $Memcache->getVal('U'.$idUser.'_TextColorBlack');

if($textBlack) {$color = str_replace('ffffff', '000000', $color);} //Blanc en noir
$color = str_replace('00ff00', '00C000', $color); //Vert plus foncé car trop clair

return $color;
Expand Down
18 changes: 15 additions & 3 deletions modules/users/inclus.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
$logged = false;
//La personne cherche à se connecter.

$modele_user = new \modules\users\modeles\Users;
$MUser = new \modules\users\modeles\Users;

$idUser = $modele_user->IdFromLogin($login);
$idUser = $MUser->IdFromLogin($login);
if($idUser != false)
{
$mdpBDD = $modele_user->getMdp($idUser);
$mdpBDD = $MUser->getMdp($idUser);
$mdp = hashage($mdp);

if($mdp == $mdpBDD)
Expand All @@ -27,6 +27,18 @@
$_SESSION['idUser'] = $idUser;
$_SESSION['Login'] = $login;

$BackColor = $MUser->getBackgroundColor($idUser);
$BackOpacity = $MUser->getBackgroundOpacity($idUser);
$TextColorBlack = $MUser->getColorTextBlack($idUser);

if($BackColor == false || is_null($BackColor)) {$BackColor = '#ffffff';}
if($BackOpacity == false || is_null($BackOpacity)) {$BackOpacity = '93';}
if($TextColorBlack == false) {$TextColorBlack = 'black';}

$Memcache->setVal('U'.$idUser.'_BackColor', $BackColor);
$Memcache->setVal('U'.$idUser.'_BackOpacity', $BackOpacity);
$Memcache->setVal('U'.$idUser.'_TextColorBlack', $TextColorBlack);

ob_clean();
echo json_encode(array('status' => 200, 'login' => $login));
exit;
Expand Down
141 changes: 141 additions & 0 deletions modules/users/modeles/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,145 @@ public function recalculPo($idUser)

return $this->setPo($idUser, $po);
}

/**
* Récupère la valeur de la couleur de fond
*
* @param int $idUser : L'id de l'user
*
* @return string
*/
public function getBackgroundColor($idUser)
{
$default = false;
if(!is_int($idUser))
{
if($this->get_debug()) {throw new Exception('Erreur sur l\'id donnée en paramètre.');}
else {return $default;}
}

$req = $this->select()->from($this->_name, 'backgroundColor')->where('id=:id', array(':id' => $id));
$res = $req->fetchRow();

if($res) {return $res['backgroundColor'];}
else {return $default;}
}

/**
* Change la valeur de la couleur de fond
*
* @param int $idUser : L'id de l'user
* @param string $color : la nouvelle couleur
*
* @return bool
*/
public function setBackgroundColor($idUser, $color)
{
$default = false;

if(!is_int($idUser) || !is_string($color))
{
if($this->get_debug()) {throw new Exception('Les paramètres données sont incorrect.');}
else {return $default;}
}

$req = $this->update($this->_name, array('backgroundColor' => $color))->where('id=:id', array(':id' => $idUser));

if($req->execute()) {return true;}
else {return $default;}
}

/**
* Récupère la valeur de l'opacité du fond
*
* @param int $idUser : L'id de l'user
*
* @return string
*/
public function getBackgroundOpacity($idUser)
{
$default = false;
if(!is_int($idUser))
{
if($this->get_debug()) {throw new Exception('Erreur sur l\'id donnée en paramètre.');}
else {return $default;}
}

$req = $this->select()->from($this->_name, 'backgroundOpacity')->where('id=:id', array(':id' => $id));
$res = $req->fetchRow();

if($res) {return $res['backgroundOpacity'];}
else {return $default;}
}

/**
* Change la valeur de l'opacité du fond
*
* @param int $idUser : L'id de l'user
* @param int $opacity : la nouvelle opacité
*
* @return bool
*/
public function setBackgroundOpacity($idUser, $opacity)
{
$default = false;

if(!is_int($idUser) || !is_int($opacity))
{
if($this->get_debug()) {throw new Exception('Les paramètres données sont incorrect.');}
else {return $default;}
}

$req = $this->update($this->_name, array('backgroundOpacity' => $opacity))->where('id=:id', array(':id' => $idUser));

if($req->execute()) {return true;}
else {return $default;}
}

/**
* Récupère la valeur du texte noir ou non
*
* @param int $idUser : L'id de l'user
*
* @return string
*/
public function getColorTextBlack($idUser)
{
$default = true;
if(!is_int($idUser))
{
if($this->get_debug()) {throw new Exception('Erreur sur l\'id donnée en paramètre.');}
else {return $default;}
}

$req = $this->select()->from($this->_name, 'textColorBlack')->where('id=:id', array(':id' => $id));
$res = $req->fetchRow();

if($res) {return $res['textColorBlack'];}
else {return $default;}
}

/**
* Change la valeur du texte noir ou non
*
* @param int $idUser : L'id de l'user
* @param bool $textBlack : la nouvelle valeur
*
* @return bool
*/
public function setColorTextBlack($idUser, $textBlack)
{
$default = false;

if(!is_int($idUser) || !is_bool($textBlack))
{
if($this->get_debug()) {throw new Exception('Les paramètres données sont incorrect.');}
else {return $default;}
}

$req = $this->update($this->_name, array('textColorBlack' => $textBlack))->where('id=:id', array(':id' => $idUser));

if($req->execute()) {return true;}
else {return $default;}
}
}
15 changes: 15 additions & 0 deletions view/css/compte.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#changeBackground {width: 300px;}

#changeBackground {float: left;}
#pickerColor {float: right;}

.labelOpacity
{
margin-top: 7px;
float: left;
}
#sliderOpacity
{
margin-left: 100px;
margin-top: 7px;
}
2 changes: 1 addition & 1 deletion view/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
min-height: 120px;
margin-top: 50px;

background-color: white;
background-color: #ffffff;
opacity: 0.93;

border: 3px solid #C0C0C0;
Expand Down
6 changes: 6 additions & 0 deletions view/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<script type="text/javascript">
base_url = "<var name='base_url' />";
path = "<var name='path' />";

<block name="cssLogged">
BackColor = "<var name='backColor' />";
BackOpacity = parseInt("<var name='backOpacity' />");
TextColorBlack = parseInt("<var name='textColorBlack' />");
</block>
</script>
<script type="text/javascript" src="<var name='path' />jquery/jquery-2.0.3.min.js"></script>
<block name="js"><script type="text/javascript" src="<var name='link' />"></script></block>
Expand Down
Loading

0 comments on commit abd940e

Please sign in to comment.