Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #127 from Prytoegrian:topic/assets
Browse files Browse the repository at this point in the history
  • Loading branch information
wouldsmina committed Feb 24, 2016
1 parent 0528042 commit 36adf6c
Show file tree
Hide file tree
Showing 180 changed files with 489 additions and 363 deletions.
3 changes: 3 additions & 0 deletions .atoum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$runner->addTestsFromDirectory(__DIR__ . '/Tests/Units');
$script->bootstrapFile(__DIR__ . '/.bootstrap.atoum.php');
4 changes: 4 additions & 0 deletions .bootstrap.atoum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
/* Autoload */
define('ROOT_PATH', '');
require_once ROOT_PATH . 'vendor/autoload.php';
52 changes: 52 additions & 0 deletions App/Helpers/Formatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace App\Helpers;

/**
* Classe de formatage de petits utilitaires de l'application
*
* @since 1.9
* @author Prytoegrian <prytoegrian@protonmail.com>
* @see \Tests\Units\App\Helpers\Formatter
*/
class Formatter
{
/**
* Transforme une date du format français (dd/mm/YYY) au format ISO (YYYY-mm-dd)
*
* @param string $date
*
* @access public
* @static
* @return string
* @throws \Exception Si le paramètre d'entrée n'est pas bien formé
* @TODO \Exception out of bounds ?
* @since 1.9
*/
public static function dateFr2Iso($date)
{
if (!preg_match('#^(\d{2})/(\d{2})/(\d{4})$#', $date, $matches)) {
throw new \Exception('Date mal formée');
}
return $matches[3] . '-' . $matches[2] . '-' . $matches[1];
}

/**
* Transforme une date du format ISO (YYYY-mm-dd) au format français (dd/mm/YYYY)
*
* @param string $date
*
* @access public
* @static
* @return string
* @throws \Exception Si le paramètre d'entrée n'est pas bien formé
* @TODO \Exception out of bounds ?
* @since 1.9
*/
public static function dateIso2Fr($date)
{
if (!preg_match('#^(\d{4})-(\d{2})-(\d{2})$#', $date, $matches)) {
throw new \Exception('Date mal formée');
}
return $matches[3] . '/' . $matches[2] . '/' . $matches[1];
}
}
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
101 changes: 101 additions & 0 deletions Public/Assets/Js/reboot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Ouvre une popup
*
* @param string MyFile nom du fichier contenant le code HTML du pop-up
* @param string MyWindow nom de la fenêtre (ne pas mettre d'espace)
* @param int MyWidth entier indiquant la largeur de la fenêtre en pixels
* @param int MyHeight entier indiquant la hauteur de la fenêtre en pixels
*/
function OpenPopUp(MyFile,MyWindow,MyWidth,MyHeight)
{
var ns4 = (document.layers)? true:false; //NS 4
var ie4 = (document.all)? true:false; //IE 4
var dom = (document.getElementById)? true:false; //DOM
var xMax, yMax, xOffset, yOffset;;

if (ie4 || dom) {
xMax = screen.width;
yMax = screen.height;
} else if (ns4) {
xMax = window.outerWidth;
yMax = window.outerHeight;
} else {
xMax = 800;
yMax = 600;
}
xOffset = (xMax - MyWidth)/2;
yOffset = (yMax - MyHeight)/2;
window.open(MyFile,MyWindow,'width='+MyWidth
+',height='+MyHeight
+',screenX='+xOffset
+',screenY='+yOffset
+',top='+yOffset
+',left='+xOffset
+',scrollbars=yes,resizable=yes');
}

/**
* Compte le nombre de jours de congés entre deux dates en fonctions du contexte (temps partiel, jours fériés, fermeture, ...)
*/
function compter_jours()
{
$(document).ready(function () {
var login = document.forms["dem_conges"].user_login.value;
var session = document.forms["dem_conges"].session.value;
var d_debut = document.forms["dem_conges"].new_debut.value;
var d_fin = document.forms["dem_conges"].new_fin.value;
var opt_deb = document.forms["dem_conges"].new_demi_jour_deb.value;
var opt_fin = document.forms["dem_conges"].new_demi_jour_fin.value;
var p_num = "";

if( document.forms["dem_conges"].p_num_to_update ) {
var p_num = document.forms["dem_conges"].p_num_to_update.value;
}

if( (d_debut) && (d_fin)) {
var page = '../calcul_nb_jours_pris.php?session=' + session + '&date_debut=' + d_debut + '&date_fin=' + d_fin+'&user=' + login + '&opt_debut=' +opt_deb + '&opt_fin=' + opt_fin + '&p_num=' +p_num;

$.ajax({
type : 'GET',
url : page,
dataType : 'text', // expected returned data format.
success : function(data)
{
var arr = new Array();
arr = JSON.parse(data);
document.forms["dem_conges"].new_nb_jours.value=arr["nb"];
document.getElementById('comment_nbj').innerHTML = arr["comm"];
},
});
}
});
}

/**
* Génère le datepicker sur un champ, paramétré par des options précises
*
* @param object opts
*/
function generateDatePicker(opts)
{
var defaultOpts = {
format : 'dd/mm/yyyy',
language : 'fr',
autoclose : true,
todayHighlight : true,
daysOfWeekDisabled : [],
datesDisabled : [],
startDate : ''
};
var toApply = defaultOpts;

/* On ne peut pas écraser une option qui n'existe en défaut */
for (var i in defaultOpts) {
toApply[i] = (undefined !== opts[i]) ? opts[i] : defaultOpts[i];
}
$(document).ready(function () {
$('input.date').datepicker(toApply).on("change", function() {
compter_jours();
});
});
}
File renamed without changes.
79 changes: 79 additions & 0 deletions Tests/Units/App/Helpers/Formatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
namespace Tests\Units\App\Helpers;

use \App\Helpers\Formatter as _Formatter;
use \atoum;

/**
* Classe de test des formatages
*
* @since 1.9
* @author Prytoegrian <prytoegrian@protonmail.com>
* @see \App\Helpers\Formatter
*/
class Formatter extends atoum
{
/**
* Test de la transformation d'une date Fr -> ISO avec une date mal formée
*
* @return void
* @access public
* @since 1.9
*/
public function testDateFr2IsoBadFormat()
{
$string = 'test';

$this->exception(function () use ($string) {
_Formatter::dateFr2Iso($string);
})->isInstanceOf('\Exception');
}

/**
* Test de la transformation d'une date Fr -> ISO avec une date bien formée
*
* @return void
* @access public
* @since 21.9
*/
public function testDateFr2IsoWithoutError()
{
$date = '25/12/1969';

$return = _Formatter::dateFr2Iso($date);

$this->string($return)->isIdenticalTo('1969-12-25');
}

/**
* Test de la transformation d'une date ISO -> Fr avec une date mal formée
*
* @access public
* @return void
* @since 1.9
*/
public function testDateIso2FrBadFormat()
{
$string = 'test';

$this->exception(function () use ($string) {
_Formatter::dateIso2Fr($string);
})->isInstanceOf('\Exception');
}

/**
* Test de la transformation d'une date ISO -> Fr avec une date bien formée
*
* @access public
* @return void
* @since 1.9
*/
public function testDateIso2FrWithoutError()
{
$date = '5555-33-22';

$return = _Formatter::dateIso2Fr($date);

$this->string($return)->isIdenticalTo('22/33/5555');
}
}
16 changes: 8 additions & 8 deletions admin/Fonctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ public static function restaure($fichier_restaure_name, $fichier_restaure_tmpnam
$return.= '</td>';
$return.= '</tr><tr>';
$return.= '<td align="center">';
$return.= '<input type="button" value="' . _('form_cancel') . '" onClick="javascript:window.close();">';
$return.= '<input type="button" value="' . _('form_cancel') . '" onClick="window.close();">';
$return.= '</td>';
$return.= '</tr></table></form>';
} else {
Expand All @@ -1611,7 +1611,7 @@ public static function restaure($fichier_restaure_name, $fichier_restaure_tmpnam
$return .= '</tr>';
$return .= '<tr>';
$return .= '<td align="center">';
$return .= '<input type="button" value="' . _('form_close_window') . '" onClick="javascript:window.close();">';
$return .= '<input type="button" value="' . _('form_close_window') . '" onClick="window.close();">';
$return .= '</td>';
$return .= '</tr></table></form>';
}
Expand Down Expand Up @@ -1654,7 +1654,7 @@ public static function choix_restaure()
$return .= '</tr>';
$return .= '<tr>';
$return .= '<td align="center">';
$return .= '<input type="button" value="' . _('form_cancel') . '" onClick="javascript:window.close();">';
$return .= '<input type="button" value="' . _('form_cancel') . '" onClick="window.close();">';
$return .= '</td>';
$return .= '</tr></table></form>';

Expand Down Expand Up @@ -1718,7 +1718,7 @@ public static function sauve($type_sauvegarde)
$return .= '<th colspan="2">' . _('admin_sauve_db_save_ok') . ' ...</th>';
$return .= '</tr><tr>';
$return .= '<td colspan="2" align="center">';
$return .= '<input type="button" value="' . _('form_close_window') . '" onClick="javascript:window.close();">';
$return .= '<input type="button" value="' . _('form_close_window') . '" onClick="window.close();">';
$return .= '</td>';
$return .= '</tr></table></form>';

Expand Down Expand Up @@ -1759,7 +1759,7 @@ public static function choix_sauvegarde()
$return .= '</td>';
$return .= '</tr><tr>';
$return .= '<td colspan="2" align="center">';
$return .= '<input type="button" value="' . _('form_cancel') . '" onClick="javascript:window.close();">';
$return .= '<input type="button" value="' . _('form_cancel') . '" onClick="window.close();">';
$return .= '</td>';
$return .= '</tr></table></form>';

Expand Down Expand Up @@ -1804,7 +1804,7 @@ public static function choix_save_restore()
$return .= '</tr>';
$return .= '<tr>';
$return .= '<td colspan="2" align="center">';
$return .= '<input type="button" value="' . _('form_cancel') . '" onClick="javascript:window.close();">';
$return .= '<input type="button" value="' . _('form_cancel') . '" onClick="window.close();">';
$return .= '</td></tr></table></form>';
echo $return;
bottom();
Expand Down Expand Up @@ -3123,7 +3123,7 @@ public static function verif_new_param(&$tab_new_user, &$tab_new_jours_an, &$tab
$valid=verif_saisie_decimal($tab_new_jours_an[$id_cong]); //verif la bonne saisie du nombre décimal
$valid=verif_saisie_decimal($tab_new_solde[$id_cong]); //verif la bonne saisie du nombre décimal
}

// verif des parametres reçus :
// si on travaille avec la base dbconges, on teste tout, mais si on travaille avec ldap, on ne teste pas les champs qui viennent de ldap ...
if(!\admin\Fonctions::test_form_add_user($tab_new_user)) {
Expand Down Expand Up @@ -3488,7 +3488,7 @@ public static function saisie_jours_absence_temps_partiel($login)
$return .= '<td class="histo">' . $imp_di_pm . '</td>';
}
$return .= '</tr></tbody></table>';
$return .= '</td><td><img src="'. TEMPLATE_PATH . 'img/shim.gif" width="15" height="2" border="0" vspace="0" hspace="0"></td><td>';
$return .= '</td><td><img src="'. IMG_PATH . 'shim.gif" width="15" height="2" border="0" vspace="0" hspace="0"></td><td>';

//tableau semaines paires
$return .= '<b><u>'. _('admin_temps_partiel_sem_paires') .':</u></b><br>';
Expand Down
1 change: 0 additions & 1 deletion admin/admin_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@

$add_css = '<style>#onglet_menu .onglet{ width: '. (str_replace(',', '.', 100 / count($onglets) )).'% ;}</style>';
header_menu('', 'Libertempo : '._('button_admin_mode'),$add_css);
include ROOT_PATH .'fonctions_javascript.php' ;

/*********************************/
/* AFFICHAGE DES ONGLETS... */
Expand Down
Loading

0 comments on commit 36adf6c

Please sign in to comment.