public function execute($input)
 {
     $liste_moment = requetemysql::liste_moment();
     $liste_cat_planning = requetemysql::liste_cat_planning();
     $array = array();
     $array[] = $liste_moment;
     $array[] = $liste_cat_planning;
     // do something
     return $array;
 }
예제 #2
0
 /**
  * variable send to external javascript and collected by AJAX request
  * 
  * @param int $cas 1 if superuser(master shift) or no login 2 if member of the shift
  * @return array container for all variables send to js at the beginnning
  * 
  */
 public function _php_to_js($cas)
 {
     /**
      * list of type for the shift. Exemple : penalty or guard
      * @var array $liste_cat_planning
      */
     if (!empty($_SESSION['login'])) {
         if ($cas == 1) {
             $chargement_premiere_partie = requetemysql::chargement_premiere_partie(array('permission' => $_SESSION['login2']));
         } else {
             if ($cas == 2) {
                 $chargement_premiere_partie = requetemysql::chargement_premiere_partie(array('permission' => $_SESSION['tour']));
             }
         }
         //	var_error_log($chargement_premiere_partie );
         if (count($chargement_premiere_partie) == 0) {
             $chargement_premiere_partie[0] = array('cat_planning' => json_encode([]), 'j_normal' => json_encode([]), 'j_ferie' => json_encode([]), 'moment' => json_encode([]));
         }
         $liste_cat_planning = $chargement_premiere_partie[0]['cat_planning'];
     } else {
         $liste_cat_planning = requetemysql::liste_cat_planning();
     }
     /**
      * array of hour in the day : 0h to 23h
      * 
      * @var $liste_heure
      */
     $liste_heure = array(array('nom' => TXT_CHARGEMENT_CONTROLLER_H0, 'valeur' => 0), array('nom' => TXT_CHARGEMENT_CONTROLLER_H1, 'valeur' => 1), array('nom' => TXT_CHARGEMENT_CONTROLLER_H2, 'valeur' => 2), array('nom' => TXT_CHARGEMENT_CONTROLLER_H3, 'valeur' => 3), array('nom' => TXT_CHARGEMENT_CONTROLLER_H4, 'valeur' => 4), array('nom' => TXT_CHARGEMENT_CONTROLLER_H5, 'valeur' => 5), array('nom' => TXT_CHARGEMENT_CONTROLLER_H6, 'valeur' => 6), array('nom' => TXT_CHARGEMENT_CONTROLLER_H7, 'valeur' => 7), array('nom' => TXT_CHARGEMENT_CONTROLLER_H8, 'valeur' => 8), array('nom' => TXT_CHARGEMENT_CONTROLLER_H9, 'valeur' => 9), array('nom' => TXT_CHARGEMENT_CONTROLLER_H10, 'valeur' => 10), array('nom' => TXT_CHARGEMENT_CONTROLLER_H11, 'valeur' => 11), array('nom' => TXT_CHARGEMENT_CONTROLLER_H12, 'valeur' => 12), array('nom' => TXT_CHARGEMENT_CONTROLLER_H13, 'valeur' => 13), array('nom' => TXT_CHARGEMENT_CONTROLLER_H14, 'valeur' => 14), array('nom' => TXT_CHARGEMENT_CONTROLLER_H15, 'valeur' => 15), array('nom' => TXT_CHARGEMENT_CONTROLLER_H16, 'valeur' => 16), array('nom' => TXT_CHARGEMENT_CONTROLLER_H17, 'valeur' => 17), array('nom' => TXT_CHARGEMENT_CONTROLLER_H18, 'valeur' => 18), array('nom' => TXT_CHARGEMENT_CONTROLLER_H19, 'valeur' => 19), array('nom' => TXT_CHARGEMENT_CONTROLLER_H20, 'valeur' => 20), array('nom' => TXT_CHARGEMENT_CONTROLLER_H21, 'valeur' => 21), array('nom' => TXT_CHARGEMENT_CONTROLLER_H22, 'valeur' => 22), array('nom' => TXT_CHARGEMENT_CONTROLLER_H23, 'valeur' => 23));
     /**
      * array for end's date when day is not same at beginning 
      * for exemple : end : 5h D+1
      * 
      * @var array $liste_jour_fin
      */
     $liste_jour_fin = array(array('nom' => TXT_CHARGEMENT_CONTROLLER_D0, 'valeur' => 0), array('nom' => TXT_CHARGEMENT_CONTROLLER_D1, 'valeur' => 1));
     /**
      * list of week's day
      * @var array $liste_jour
      */
     $liste_jour = array(array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY1, 'valeur' => 1), array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY2, 'valeur' => 2), array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY3, 'valeur' => 3), array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY4, 'valeur' => 4), array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY5, 'valeur' => 5), array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY6, 'valeur' => 6), array('nom' => TXT_CHARGEMENT_CONTROLLER_DAY7, 'valeur' => 0));
     /**
      * list of week's day with only 1 letter
      * @var array $liste_jour_short
      */
     $liste_jour_short = array(TXT_CHARGEMENT_CONTROLLER_SHORTDAY7, TXT_CHARGEMENT_CONTROLLER_SHORTDAY1, TXT_CHARGEMENT_CONTROLLER_SHORTDAY2, TXT_CHARGEMENT_CONTROLLER_SHORTDAY3, TXT_CHARGEMENT_CONTROLLER_SHORTDAY4, TXT_CHARGEMENT_CONTROLLER_SHORTDAY5, TXT_CHARGEMENT_CONTROLLER_SHORTDAY6);
     /**
      * caracterisitic of a period in the shift. Exemple : nom: Day, deb_h 8h, deb_f 19h, deb_j 0
      * @var array $liste_moment
      */
     if (!empty($_SESSION['login'])) {
         $liste_moment = $chargement_premiere_partie[0]['moment'];
     } else {
         $liste_moment = requetemysql::liste_moment();
     }
     /**
      * numeric choice for the person's number in a time slot
      */
     $compteur = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
     /** @var array $month list of month's name's abbreviation */
     $month = array(TXT_CHARGEMENT_CONTROLLER_MONTH_1, TXT_CHARGEMENT_CONTROLLER_MONTH_2, TXT_CHARGEMENT_CONTROLLER_MONTH_3, TXT_CHARGEMENT_CONTROLLER_MONTH_4, TXT_CHARGEMENT_CONTROLLER_MONTH_5, TXT_CHARGEMENT_CONTROLLER_MONTH_6, TXT_CHARGEMENT_CONTROLLER_MONTH_7, TXT_CHARGEMENT_CONTROLLER_MONTH_8, TXT_CHARGEMENT_CONTROLLER_MONTH_9, TXT_CHARGEMENT_CONTROLLER_MONTH_10, TXT_CHARGEMENT_CONTROLLER_MONTH_11, TXT_CHARGEMENT_CONTROLLER_MONTH_12);
     if (!empty($_SESSION['login'])) {
         /** @var array $vetos list the staff and caracteristic like adress, tel, email... */
         if ($cas == 1) {
             $chargement_seconde_partie = requetemysql::chargement_seconde_partie(array('permission' => $_SESSION['login2']));
         } else {
             if ($cas == 2) {
                 $chargement_seconde_partie = requetemysql::chargement_seconde_partie(array('permission' => $_SESSION['tour']));
             }
         }
         $chargement_seconde_partie = json_decode($chargement_seconde_partie, true);
         if (count($chargement_seconde_partie) == 0) {
             $vetos = requetemysql::listevetos();
             $vetos2 = json_encode(array());
             $vetos3 = requetemysql::listevetos();
             $team_action = json_encode(array());
             $delais = 0;
             $memoire = 0;
             $memoire2 = true;
             $memoire3 = mktime(0, 0, 0, date("m"), 1, date("Y")) * 1000;
             $couleur_entre_deux = "#ff00ff";
             $couleur_absent = "#0000ff";
             $couleur_max = "#c2d6d6";
             $couleur_wedding = "#33CC00";
             $couleur_clash = "#FF3300";
             $interval_for_unavailable = false;
             $date_deb_unavailable = mktime(0, 0, 0, date("m"), 1, date("Y")) * 1000;
             $date_fin_unavailable = mktime(0, 0, 0, date("m") + 2, 1, date("Y")) * 1000;
             $limit_number_unavailable = false;
             $max_unavailable = 10;
             $limit_pourcent_unavailable = false;
             $pourcent_unavailable = 50;
             $couleur_limit_unavailable = "#FFFF00";
         } else {
             $vetos = $chargement_seconde_partie[0]['team'];
             $vetos2 = $chargement_seconde_partie[0]['team2'];
             $vetos3 = requetemysql::listevetos();
             $team_action = $chargement_seconde_partie[0]['team_action'];
             $delais = $chargement_seconde_partie[0]['delais'];
             $memoire = $chargement_seconde_partie[0]['memoire'];
             $memoire2 = $chargement_seconde_partie[0]['interval_or_date'] ? true : false;
             $memoire3 = $chargement_seconde_partie[0]['date_memoire'] * 1000;
             $couleur_entre_deux = $chargement_seconde_partie[0]['couleur_entre_deux'];
             $couleur_absent = $chargement_seconde_partie[0]['couleur_absent'];
             $couleur_max = $chargement_seconde_partie[0]['couleur_max'];
             $couleur_wedding = $chargement_seconde_partie[0]['couleur_wedding'];
             $couleur_clash = $chargement_seconde_partie[0]['couleur_clash'];
             $interval_for_unavailable = $chargement_seconde_partie[0]['interval_for_unavailable'] ? true : false;
             $date_deb_unavailable = $chargement_seconde_partie[0]['date_deb_unavailable'] * 1000;
             $date_fin_unavailable = $chargement_seconde_partie[0]['date_fin_unavailable'] * 1000;
             $limit_number_unavailable = $chargement_seconde_partie[0]['limit_number_unavailable'] ? true : false;
             $max_unavailable = $chargement_seconde_partie[0]['max_unavailable'];
             $limit_pourcent_unavailable = $chargement_seconde_partie[0]['limit_pourcent_unavailable'] ? true : false;
             $pourcent_unavailable = $chargement_seconde_partie[0]['pourcent_unavailable'];
             $couleur_limit_unavailable = $chargement_seconde_partie[0]['couleur_limit_unavailable'];
         }
     } else {
         $vetos = json_encode(array());
         $vetos2 = json_encode(array());
         $vetos3 = json_encode(array());
         $team_action = json_encode(array());
         $delais = 0;
         $memoire = 0;
         $memoire2 = true;
         $memoire3 = mktime(0, 0, 0, date("m"), 1, date("Y")) * 1000;
         $couleur_entre_deux = "#ff00ff";
         $couleur_absent = "#0000ff";
         $couleur_max = "#c2d6d6";
         $couleur_wedding = "#33CC00";
         $couleur_clash = "#FF3300";
         $interval_for_unavailable = false;
         $date_deb_unavailable = mktime(0, 0, 0, date("m"), 1, date("Y")) * 1000;
         $date_fin_unavailable = mktime(0, 0, 0, date("m") + 2, 1, date("Y")) * 1000;
         $limit_number_unavailable = false;
         $max_unavailable = 10;
         $limit_pourcent_unavailable = false;
         $pourcent_unavailable = 50;
         $couleur_limit_unavailable = "#FFFF00";
     }
     $date_debut = mktime(0, 0, 0, date("m"), 1, date("Y"));
     $date_fin = mktime(0, 0, 0, date("m") + 1, 1, date("Y"));
     if (!empty($_SESSION['login'])) {
         /** @var array $historique list of the shift sort by day in the month... */
         if ($cas == 1) {
             $historique = requetemysql::liste_garde(array('debut' => $date_debut, 'fin' => $date_fin));
         } else {
             if ($cas == 2) {
                 $historique = array();
             }
         }
         $absent = requetemysql::liste_absent(array('debut' => $date_debut, 'fin' => $date_fin));
     } else {
         $historique = array();
         $absent = array();
     }
     /** @var array $jour_ajoutees_feries caracteristics of public holiday (ma_date : date:date, assignment_defaut : array:caracteristic of shift job, period_defaut : array:time caracteristics of the shift, compteur_defaut: int:number of staff) */
     if (!empty($_SESSION['login'])) {
         $jour_ajoutees_feries = $chargement_premiere_partie[0]['j_ferie'];
     } else {
         $jour_ajoutees_feries = json_encode([]);
     }
     /** @var array $jour_ajoutees caracteristics of normal day in the shift (ma_date : date:date, assignment_defaut : array:caracteristic of shift job, period_defaut : array:time caracteristics of the shift, compteur_defaut: int:number of staff) */
     if (!empty($_SESSION['login'])) {
         $jour_ajoutees = $chargement_premiere_partie[0]['j_normal'];
     } else {
         $jour_ajoutees = json_encode([]);
     }
     if ($memoire2) {
         $date_debut_historique = mktime(0, 0, 0, date("m") - $memoire, 1, date("Y"));
         $date_fin_historique = mktime(0, 0, 0, date("m"), 1, date("Y"));
     } else {
         $date_debut_historique = mktime(0, 0, 0, date("m", $memoire3), 1, date("Y", $memoire3));
         $date_fin_historique = mktime(0, 0, 0, date("m"), 1, date("Y"));
     }
     /** @var array $point_historique score of each member of the team (number of job) for  each sort of job in function time historic period selected */
     if (!empty($_SESSION['login'])) {
         if ($cas == 1) {
             $obj2 = array();
             foreach (json_decode($jour_ajoutees, true) as $key => $item) {
                 $obj2[$item['jour']] = isset($obj2[$item['jour']]) ? $obj2[$item['jour']] : array();
                 $obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']] = isset($obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']]) ? $obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']] : array();
                 $obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']] = isset($obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']]) ? $obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']] : array();
                 $obj2[$item['jour']][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']][$item['assignment_defaut']['valeur']] = $item['assignment_defaut']['nom'];
             }
             $obj = array();
             foreach (json_decode($jour_ajoutees_feries, true) as $key => $item) {
                 $ma_date = strtotime($item['ma_date']);
                 $obj[$ma_date] = isset($obj[$ma_date]) ? $obj[$ma_date] : array();
                 $obj[$ma_date][$item['period_defaut']['defaut_heure_debut']] = isset($obj[$ma_date][$item['period_defaut']['defaut_heure_debut']]) ? $obj[$ma_date][$item['period_defaut']['defaut_heure_debut']] : array();
                 $obj[$ma_date][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']] = isset($obj[$ma_date][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']]) ? $obj[$ma_date][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']] : array();
                 $obj[$ma_date][$item['period_defaut']['defaut_heure_debut']][$item['period_defaut']['defaut_heure_fin']][$item['assignment_defaut']['valeur']] = $item['assignment_defaut']['nom'];
             }
             $point_historique = requetemysql::point_historique(array('jour_ajoutees' => json_encode($obj2), 'jour_ajoutees_feries' => json_encode($obj), 'debut' => $date_debut_historique, 'fin' => $date_fin_historique, 'categorie' => $liste_cat_planning, 'team' => $vetos2));
             //		$point_historique = json_encode([[],[],[],[],[],[]]);
         } else {
             if ($cas == 2) {
                 $point_historique = json_encode([[], [], [], [], [], [], [], [], []]);
             }
         }
     } else {
         $point_historique = json_encode([[], [], [], [], [], [], [], [], []]);
     }
     /**
      * array of day's number for exemple minimum interval between two penalty
      *
      * @var $liste_entre_2
      */
     $liste_entre_2 = array(array('nom' => TXT_CHARGEMENT_CONTROLLER_NOTIMELIMIT, 'valeur' => 0), array('nom' => "1" . " " . TXT_CHARGEMENT_CONTROLLER_DAY, 'valeur' => 1), array('nom' => "2" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 2), array('nom' => "3" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 3), array('nom' => "4" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 4), array('nom' => "5" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 5), array('nom' => "6" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 6), array('nom' => "7" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 7), array('nom' => "10" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 10), array('nom' => "15" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 15), array('nom' => "21" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 21), array('nom' => "30" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 30), array('nom' => "45" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 45), array('nom' => "60" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 60), array('nom' => "90" . " " . TXT_CHARGEMENT_CONTROLLER_DAYS, 'valeur' => 90));
     /**
      * array of month's number for equalized number of jobs between team
      *
      * @var $liste_memoire
      */
     $liste_memoire = array(array('nom' => TXT_CHARGEMENT_CONTROLLER_NOMONTHLIMIT, 'valeur' => 0), array('nom' => "1" . " " . TXT_CHARGEMENT_CONTROLLER_MONTH, 'valeur' => 1), array('nom' => "2" . " " . TXT_CHARGEMENT_CONTROLLER_MONTH, 'valeur' => 2), array('nom' => "6" . " " . TXT_CHARGEMENT_CONTROLLER_MONTH, 'valeur' => 6), array('nom' => "12" . " " . TXT_CHARGEMENT_CONTROLLER_MONTH, 'valeur' => 12), array('nom' => "24" . " " . TXT_CHARGEMENT_CONTROLLER_MONTH, 'valeur' => 24));
     /**
      * array of choice to gather or split teamm (conflicting or wedding)
      * @var array $liste_action
      */
     $liste_action = array(array('nom' => TXT_CHARGEMENT_CONTROLLER_NEVER, 'valeur' => 1), array('nom' => TXT_CHARGEMENT_CONTROLLER_ALLWAYS, 'valeur' => 2));
     $mon_texte = array('incomptabilite' => TXT_CHARGEMENT_CONTROLLER_INCOMPTABILITY, 'begin' => TXT_CHARGEMENT_CONTROLLER_BEGIN, 'end' => TXT_CHARGEMENT_CONTROLLER_END, 'paire' => TXT_CHARGEMENT_CONTROLLER_WEDDING, 'impossible_select1' => TXT_CHARGEMENT_CONTROLLER_IMPOSSIBLE_SELECT1, 'impossible_select2' => TXT_CHARGEMENT_CONTROLLER_IMPOSSIBLE_SELECT2, 'impossible_select3' => TXT_CHARGEMENT_CONTROLLER_IMPOSSIBLE_SELECT3, 'impossible_select4' => TXT_CHARGEMENT_CONTROLLER_IMPOSSIBLE_SELECT4, 'impossible_select5' => TXT_CHARGEMENT_CONTROLLER_IMPOSSIBLE_SELECT5, 'mail_send' => TXT_CHARGEMENT_CONTROLLER_MAIL_SEND, 'shift_created' => TXT_CHARGEMENT_CONTROLLER_SHIFT_CREATED, 'personnal_data_changed' => TXT_CHARGEMENT_CONTROLLER_PERSONNAL_DATA_CHANGED, 'log_in_ok' => TXT_CHARGEMENT_CONTROLLER_LOG_IN_OK);
     if (isset($_SESSION['login2'])) {
         $login = $_SESSION['login2'];
     } else {
         $login = "";
     }
     return array('staff3' => $vetos3, 'interval_for_unavailable' => $interval_for_unavailable, 'date_deb_unavailable' => $date_deb_unavailable, 'date_fin_unavailable' => $date_fin_unavailable, 'limit_number_unavailable' => $limit_number_unavailable, 'max_unavailable' => $max_unavailable, 'limit_pourcent_unavailable' => $limit_pourcent_unavailable, 'pourcent_unavailable' => $pourcent_unavailable, 'couleur_limit_unavailable' => $couleur_limit_unavailable, 'memoire2' => $memoire2, 'memoire3' => $memoire3, 'absent' => $absent, 'staff2' => $vetos2, 'jour_ajoutees' => $jour_ajoutees, 'liste_cat_planning' => $liste_cat_planning, 'liste_jour' => $liste_jour, 'liste_jour_fin' => $liste_jour_fin, 'liste_heure' => $liste_heure, 'liste_moment' => $liste_moment, 'compteur' => $compteur, 'mois' => $month, 'staff' => $vetos, 'liste_jour_short' => $liste_jour_short, 'historique' => $historique, 'jour_ajoutees_feries' => $jour_ajoutees_feries, 'jour_ajoutees' => $jour_ajoutees, 'liste_entre_2' => $liste_entre_2, 'liste_memoire' => $liste_memoire, 'delais' => $delais, 'memoire' => $memoire, 'point_historique' => $point_historique, 'couleur_entre_deux' => $couleur_entre_deux, 'couleur_absent' => $couleur_absent, 'couleur_max' => $couleur_max, 'liste_action' => $liste_action, 'team_action' => $team_action, 'mot_recherche' => TXT_CHARGEMENT_REPARTITION3, 'login' => $login, 'couleur_wedding' => $couleur_wedding, 'couleur_clash' => $couleur_clash, 'mon_texte' => $mon_texte);
 }