/** * prend les tableaux complets en paramètre et génère le code html qui correspond * * @param array $tab_jour * @param array $tab_client * @param array $tab_conge * @param array $tab_projet * @return string */ function ram_to_html(&$tab_jour, &$tab_client, &$tab_conge, &$tab_projet) { $tab_nom_jour = array('D', 'L', 'M', 'M', 'J', 'V', 'S'); $ligne_nom_jour = '<table border="1" class="table table-bordered table-condensed"><thead style="background-color:lightgrey;"><tr ><th class="not_printed"></th><th class="not_printed"></th>'; $ligne_jour = '<tr><th class="not_printed" style="min-width:125px">Client</th><th class="not_printed" style="min-width:125px">Projet</th>'; $ligne_conge = '<tr class="not_printed"><td>Absences</td><td></td>'; $ligne_client = array(); /* * si on n'a qu'un client, on passe en readonly * par contre, du moment qu'on n'est pas en modification, on force à disabled */ $disabled = $_POST['nb_client'] == 1 ? 'readonly' : ''; $disabled = $_POST['mode'] == 'modif' || $_POST['mode'] == 'creer' ? $disabled : 'disabled'; $i = 1; foreach ($tab_client as $nom => $client) { $ligne_client[$nom] = '<tr class="' . $nom . '"> <td class="not_printed">' . $tab_projet[$nom]['CLI_NOM'] . '<input type="hidden" name="client' . $i . '" value = "' . $tab_projet[$nom]['CLI_NO'] . '"/></td> <td class="not_printed">' . $tab_projet[$nom]['PRO_NOM'] . '<input type="hidden" name="projet' . $i . '" value = "' . $nom . '"/></td>'; $i++; } foreach ($tab_jour as $jour => $ligne) { if (isset($ligne['classe'])) { $classe = ' class="' . $ligne['classe'] . '" '; } else { $classe = ''; } $ligne_nom_jour .= '<th' . $classe . '>' . $tab_nom_jour[check_jour($_POST['mois'], $jour, $_POST['annee'])] . '</th>'; $ligne_jour .= '<th' . $classe . '>' . $jour . '</th>'; $ligne_conge .= '<td' . $classe . '>' . select('c', $jour, $tab_conge[$jour], 'disabled') . '</td>'; foreach ($tab_client as $nom => $client) { $ligne_client[$nom] .= '<td' . $classe . '>' . select($nom, $jour, isset($client[$jour]) ? $client[$jour] : array(), $disabled) . '</td>'; } } $retour = $ligne_nom_jour . '</tr>' . $ligne_jour . '</tr></thead><tbody>'; foreach ($ligne_client as $client) { $retour .= $client . '</tr>'; } return $retour . $ligne_conge . '</tr></tbody></table>'; }
$COL_NO = $col_row['COL_NO']; $COL_NOM = $col_row['COL_PRENOM'] . " " . $col_row['COL_NOM']; $CLI_NO = $cli_row['CLI_NO']; $ENT_NO = 0; $BAN_NO = 0; $FAC_CODFOU = $cli_row['CLI_CODE_FOUR']; $PRO_NO = $pro_row['PRO_NO']; $CTC_NO = $ctc['CTC_NO']; $FAC_ANNNE = $_POST['annee']; $FAC_MOIS = $_POST['mois']; $date = $_POST['annee'] . '-' . $_POST['mois'] . '-'; $nbJour = nbjoursMois($_POST['mois'], $_POST['annee']); //Obtenir le dernier vendredi d'un mois (cas non pris en compte : Jour férié) $t = 0; do { $t = check_jour($_POST['mois'], $nbJour, $_POST['annee']); echo $nbJour; echo $t; if ($t == 0 || $t == 6) { $nbJour--; } } while ($t == 0 || $t == 6); $FAC_DATE = $date . $nbJour; $FAC_PERIODE = nomMois($_POST['mois']); $FAC_SUIVIPAR = $com_row['COL_NO']; $FAC_MODE_REG = 0; $FAC_NOMCOM = $com_row['COL_PRENOM'] . " " . $com_row['COL_NOM']; $FAC_CODCLI = $cli_row['CLI_CODE']; $FAC_NOMCLI = $cli_row['CLI_NOMFAC']; $FAC_ADR1 = $cli_row['CLI_ADRFAC_1']; $FAC_ADR2 = $cli_row['CLI_ADRFAC_2'];
include 'inc/verif_parametres.php'; include 'calendrier/fonction_dimanche_samedi.php'; include 'calendrier/fonction_nbjoursMois.php'; function cmp($a, $b) { $retour = strcmp($a['COL_NOM'], $b['COL_NOM']); if ($retour == 0) { return strcmp($a['COL_PRENOM'], $b['COL_PRENOM']); } else { return $retour; } } $nbJours = nbjoursMois($_POST['mois'], $_POST['annee']); $weekend = array(); for ($i = 1; $i <= $nbJours; $i++) { $jour = check_jour($_POST['mois'], $i, $_POST['annee']); if ($jour == 6 || $jour == 0) { $weekend[] = $i; } } $query = "SELECT CO.COL_NO, CO.COL_MNEMONIC, COL_NOM, COL_PRENOM, CLI_NOM, PRO_NOM, SUM(RAM_NBH) AS NBH, M.MIS_TJM, P.PRO_NO\n FROM COLLABORATEUR CO, PROJET P, RAM R, CLIENT CL, MISSION M \n WHERE CO.COL_NO = R.COL_NO\n AND R.PRO_NO = P.PRO_NO\n AND P.PRO_NO = M.PRO_NO AND M.MIS_ARCHIVE = 0 \n AND P.CLI_NO = CL.CLI_NO\n AND R.RAM_MOIS='" . $_POST['mois'] . "'\n AND R.RAM_ANNEE='" . $_POST['annee'] . "'\n AND R.RAM_JOUR NOT IN ('" . implode("', '", $weekend) . "')\n GROUP BY P.PRO_NO, CO.COL_NO\n ORDER BY COL_NO, PRO_NO"; $query_we = "SELECT SUM(RAM_NBH) AS NBH_WE, PRO_NO, COL_NO\n FROM RAM\n WHERE RAM_MOIS='" . $_POST['mois'] . "'\n AND RAM_ANNEE='" . $_POST['annee'] . "'\n AND RAM_JOUR IN ('" . implode("', '", $weekend) . "')\n GROUP BY PRO_NO, COL_NO\n ORDER BY COL_NO, PRO_NO"; $result = $GLOBALS['connexion']->query($query) or die(mysqli_error($GLOBALS['connexion'])); $result_we = $GLOBALS['connexion']->query($query_we) or die(mysqli_error($GLOBALS['connexion'])); $tableau = array("Trigramme", "Collaborateur", "Client", "Projet", "J W", "WE W", "Taux journalier moyen", "Montant TTC"); $corps = array(); $nbh_weekend = $result_we->fetch_assoc(); while ($row = $result->fetch_assoc()) { while ($nbh_weekend && ($nbh_weekend['COL_NO'] < $row['COL_NO'] || $nbh_weekend['COL_NO'] == $row['COL_NO'] && $nbh_weekend['PRO_NO'] < $row['PRO_NO'])) { $nbh_weekend = $result_we->fetch_assoc(); }
<?php include 'calendrier/fonction_nbjoursMois.php'; include 'calendrier/fonction_dimanche_samedi.php'; //$date = $_POST['annee'].'-'.$_POST['mois']; //Boucle tant que le dernier jour du mois est un samedi ou un dimanche $nbJour = nbjoursMois(01, 2015); $date = '2015-01-'; $t = 0; do { $t = check_jour(substr($date, 5, 2), $nbJour, substr($date, 0, 4)); if ($t == 0 || $t == 6) { $nbJour--; } } while ($t == 0 || $t == 6); echo $date . $nbJour;