]> _ Git - cubeextranet.git/commitdiff
wip #3720 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 22 Jun 2020 08:55:54 +0000 (08:55 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 22 Jun 2020 08:55:54 +0000 (08:55 +0000)
inc/commons/class.common.url.php
inc/extranet/Controlleur/class.extranet.url.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Metier/class.ws.book.parametres.php

index eb829ae9d27cc6c5b0d6a348bc576e90473fcfaa..5f2c0615c3476903820ce69e69adfdce34955795 100644 (file)
@@ -64,12 +64,6 @@ class commonUrl
 \r
         $message = $tentative ? '<p class="message"><br />' . __('Identifiants incorrects') . '</p>' : '';\r
 \r
-        if (MODE === 'ws') {\r
-            $forgot = 'https://toolbox.fluidbook.com/password/reset?redirectTo=https://workshop.fluidbook.com/';\r
-        } else if (MODE === 'extranet') {\r
-            $forgot = 'https://dev.extranet.cubedesigners.com/password/reset?redirectTo=https://extranet.cubedesigners.com/';\r
-        }\r
-\r
         $res = commonPage::barre();\r
         $res .= commonPage::tMain();\r
         $res .= commonPage::bh('login');\r
@@ -80,7 +74,7 @@ class commonUrl
         $res .= '<table>';\r
         $res .= '<tr><td>' . __('Votre e-mail ou login') . ' : </td><td>' . cubeForm::email('user_email', 20, 64, '') . '</td></tr>';\r
         $res .= '<tr><td>' . __('Votre mot de passe') . ' : </td><td>' . form::password('user_password', 20, 64, '') . '</td></tr>';\r
-        $res .= '<tr><td colspan="2"><a href="' . $forgot . '">' . __('Mot de passe oublié ? Cliquez ici') . '</a></td></tr>';\r
+        $res .= '<tr><td colspan="2"><a href="#" class="popup" rel="motdepasseOublie">' . __('Première connexion ?') . ' ' . __('Mot de passe oublié ? Cliquez ici') . '</a></td></tr>';\r
         $res .= '<tr><td colspan="2" class="right"><a href="#" class="submit">' . $core->typo->BoutonOK('Cliquez-ici pour vous identifier') . '</a></td></tr>';\r
         $res .= '</table>';\r
         $res .= '</form>';\r
index 99eac0f9103431333a1f9db8b69377ef39022188..b4b705331a258cdd82a16082d833bec27173934b 100644 (file)
 class extranetUrl
 {
 
-       public static function clients($args)
-       {
-               global $core;
-               cubePage::truePopup();
-               cubePage::autoComplete();
-               cubePage::emptyfield();
-               commonDroits::min(1);
-               $settings = $core->user->getSettings('clients');
-
-               $shortcuts = array();
-               $shortcuts[] = '<a href="#" class="popup" rel="formClient/new">' . $core->typo->Ajouter('Créer un nouveau client') . '</a>';
-               $filtres = array();
-               $filtres[] = new commonFiltre(__('Ayant un projet'), 'status_client_projet', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Ayant des impayés'), 'impaye', $settings['filtres']);
-               $res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts);
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeClients">';
-               $res .= self::listeClients();
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function listeClients($dashboard = null, $settings = null)
-       {
-               global $core;
-               commonDroits::min(1);
-               $settings = is_null($settings) ? $core->user->getSettings('clients') : $settings;
-               $change = is_null($dashboard) ? 'Client' : 'Dashboard/' . $dashboard;
-               $dao = new commonDAOEntreprise($core->con);
-               if (isset($settings['search']) && !is_null($settings['search'])) {
-                       $dao->setSearch($settings['search']);
-               }
-               $dao->setFiltres($settings['filtres']);
-               $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
-
-               $res = '<table class="liste">';
-               $res .= '<tr><th>' . commonUrl::orderby('#', 'entreprise_id', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Raison sociale'), 'nom', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . __('Contacts') . '</th>';
-               $res .= '<th>' . __('Type') . '</th>';
-               $res .= '<th>' . commonUrl::orderby('<abbr title="' . __("Chiffre d'affaire") . '">CA</abbr>', 'ca', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby('Impayés', 'impaye', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="min"></th><th class="min"></th></tr>';
-               $i = 0;
-               foreach ($liste as $id => $client) {
-                       if (!is_array($client->contacts)) {
-                               continue;
-                       }
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $client->entreprise_id . '</td>';
-                       $res .= '<td>' . $client->nom . '</td>';
-                       $contacts = array();
-
-                       foreach ($client->contacts as $c) {
-                               $contacts[] = '<a href="#" class="popup" rel="formContact/' . $c->utilisateur_id . '">' . $c->prenom . ' ' . $c->nom . '</a>';
-                       }
-
-                       $res .= '<td id="contacts_' . $client->entreprise_id . '">' . implode(', ', $contacts) . '</td>';
-                       $res .= '<td class="nowrap">' . $core->client_type[$client->type] . '</td>';
-                       $res .= '<td class="nowrap">';
-                       if ($client->ca) {
-                               $res .= '<a href="#" class="popup" rel="clientDetailCa/' . $client->entreprise_id . '" title="' . __("Voir le détail du chiffre d'affaire") . '">' . number_format($client->ca, 0, ',', ' ') . '</a>';
-                       }
-
-                       $res .= '</td>';
-                       if ($client->impaye) {
-                               $res .= '<td class="nowrap"><a href="#" class="popup" rel="clientDetailImpaye/' . $client->entreprise_id . '">' . number_format($client->impaye, 0, '.', ' ') . '</a></td>';
-                       } else {
-                               $res .= '<td></td>';
-                       }
-
-                       $res .= '<td class="action"><a href="#" class="popup" rel="formClient/' . $client->entreprise_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                       if (is_null($client->ca)) {
-                               $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeClient/' . $client->entreprise_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce client ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
-                       } else {
-                               $res .= '<td></td>';
-                       }
-                       $res .= '</tr>';
-                       $i++;
-               }
-               if (!isset($settings['search']) || is_null($settings['search'])) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '><td colspan="10">';
-                       $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
-                       $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients'));
-                       $res .= '</td></tr>';
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function clientDetailCa($entreprise_id)
-       {
-               global $core;
-               $dao = new commonDAOEntreprise($core->con);
-               $annees = $dao->getCaDetails($entreprise_id);
-               $res = '';
-               $i = 0;
-               foreach ($annees as $annee => $ca) {
-                       $class = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $class . '><td><strong>' . $annee . '</strong></td><td>' . number_format($ca, 0, ',', ' ') . ' €</td></tr>';
-                       $i++;
-               }
-               return $res;
-       }
-
-       public static function clientDetailImpaye($entreprise_id)
-       {
-               global $core;
-               $dao = new extranetDAOFacture($core->con);
-               $daoClient = new commonDAOEntreprise($core->con);
-               $factures = $dao->getImpayesOfClient($entreprise_id);
-               $client = $daoClient->selectById($entreprise_id);
-               $res = '';
-               $i = 0;
-               foreach ($factures as $facture) {
-                       $class = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $class . '>';
-                       $res .= '<td>' . $facture->facture_id . '</td>';
-                       $res .= '<td>';
-                       if ($facture->facture_id > 0) {
-                               $res .= '<a href="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" class="popupA4">' . $facture->nom . '</a>';
-                       } else {
-                               $res .= $facture->nom;
-                       }
-                       $res .= '</td>';
-                       $tva = cubeTaxes::tva($client->pays);
-                       $res .= '<td>' . number_format($facture->total_ht, 0, ',', '') . ' €';
-                       if ($tva > 0 && $tva != 'UE') {
-                               $res .= ' HT </td><td> ' . number_format(cubePrices::HTtoTTC($facture->total_ht, $tva), 2, ',', '') . ' € TTC';
-                       } else {
-                               $res .= '<td></td>';
-                       }
-                       $res .= '</td></tr>';
-                       $i++;
-               }
-               return $res;
-       }
-
-       public static function formClient($entreprise_id = 'new')
-       {
-               global $core;
-               commonDroits::min(1);
-               $dao = new commonDAOEntreprise($core->con);
-               $daoUtilisateur = new commonDAOUtilisateur($core->con);
-               if ($entreprise_id == 'new') {
-                       $client = $dao->cree();
-               } else {
-                       $client = $dao->selectById($entreprise_id);
-               }
-
-               $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('entreprise_id', $client->entreprise_id) . '' . $client->entreprise_id . '</td></tr>';
-               $res .= '<tr><td>' . __('Raison sociale') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
-               $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
-               $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';
-               $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';
-               $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';
-               $res .= '<tr><td>' . __('Adresse de facturaton') . '</td><td>' . form::textarea('adresse_facturation', 40, 3, $client->adresse_facturation) . '</td></tr>';
-               $res .= '<tr><td>' . __('Site internet') . '</td><td>' . form::field('site', 30, 128, $client->site) . '</td></tr>';
-               $res .= '<tr><td>' . __('Numéro de TVA intracommunautaire') . '</td><td>' . form::field('tva_intra', 15, 64, $client->tva_intra) . '</td></tr>';
-               $res .= '<tr><td>' . __('Type de société') . '</td><td>' . form::combo('type', array_flip($core->client_type), $client->type) . '</td></tr>';
-               $res .= '<tr class="light"><th colspan="2" class="light"><strong>' . __('Fluidbook Workshop') . '</strong></th></tr>';
-               $res .= '<tr class="odd"><td>' . __('Grade') . '</td><td>' . form::combo('ws_grade', array_flip($core->ws_grades), $client->ws_grade) . '</td></tr>';
-               if ($entreprise_id == 'new' || !$client->ws_admin) {
-                       $class = 'empty-field';
-                       $default_id = '';
-                       $default = __("Entrez le nom du revendeur ou de l'administrateur");
-               } else {
-                       $class = '';
-                       $default_id = $client->ws_admin;
-                       $wsa = $daoUtilisateur->selectById($client->ws_admin, 'utilisateurs_entreprise');
-                       $default = $wsa->utilisateur_id . ' - ' . $wsa->rs . ' (' . $wsa->prenom . ' ' . $wsa->nom . ')';
-               }
-
-               $d = $dao->getWSDatas($entreprise_id);
-
-               $res .= '<tr class="odd"><td>' . __('Revendeur / Administrateur') . '</td><td>' . form::field('ws_admin_nom', 60, 128, $default, $class) . form::hidden('ws_admin', $default_id) . '</td></tr>';
-               if (!is_null($d)) {
-                       $res .= '<tr class="odd"><td>' . __('Entité facturable') . '</td><td>' . $d->facturable->prenom . ' ' . $d->facturable->nom . ' (' . $d->facturable->rs . ')</td></tr>';
-                       $res .= '<tr class="odd"><td>' . __('Administrateur responsable') . '</td><td>' . $d->administrateur->prenom . ' ' . $d->administrateur->nom . ' (' . $d->administrateur->rs . ')</td></tr>';
-               }
-               if ($entreprise_id == 'new') {
-                       $daoContact = new commonDAOClient($core->con);
-                       $contact = $daoContact->cree();
-                       $res .= '<tr><th colspan="2" class="light"><strong>' . __('Contact') . '</strong></th></tr>';
-                       $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field(array('contact[email]'), 30, 128, $contact->email) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field(array('contact[password]'), 30, 128, $contact->password) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Prénom') . '</td><td>' . form::field(array('contact[prenom]'), 30, 128, $contact->prenom) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Nom') . '</td><td>' . form::field(array('contact[nom]'), 30, 128, $contact->nom) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field(array('contact[telephone]'), 20, 128, $contact->telephone) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field(array('contact[mobile]'), 20, 128, $contact->mobile) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field(array('contact[fax]'), 20, 128, $contact->fax) . '</td></tr>';
-                       $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo(array('contact[lang]'), cubeLang::getAvailableLangs(true), $contact->lang) . '</td></tr>';
-               }
-               return $res;
-       }
-
-       public static function listeContacts($entreprise_id)
-       {
-               global $core;
-               commonDroits::min(1);
-               $dao = new commonDAOEntreprise($core->con);
-               $contacts = $dao->getContacts($entreprise_id);
-
-               $res = '<table class="liste light">';
-               $res .= '<tr class="light"><th colspan="5"><a href="" class="popup" rel="formContact/new/' . $entreprise_id . '">' . $core->typo->Contact('Ajouter un contact') . '</a></th></tr>';
-               $i = 0;
-               foreach ($contacts as $contact) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '><td>' . trim($contact->prenom . ' ' . $contact->nom) . '</td>';
-                       $res .= '<td><a href="mailto:' . trim($contact->prenom . ' ' . $contact->nom) . '<' . $contact->email . '>">' . $contact->email . '</a></td>';
-                       $res .= '<td class="min"><a href="' . SITE_PATH . 'fichiers/' . $contact->utilisateur_id . '">FTP</a></td>';
-                       //$res .= '<td><a class="ajax" href="#" rel="connectAs/' . $contact->utilisateur_id . '">Se connecter comme ...</a></td>';
-                       $res .= '<td class="right"><a href="#" rel="formContact/' . $contact->utilisateur_id . '" class="popup">' . cubeMedia::image(IMG . '/edit.png') . '</a></td></tr>';
-                       $i++;
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function formContact($client_id = 'new', $entreprise_id = null)
-       {
-               global $core;
-               commonDroits::min(1);
-
-               $dao = new commonDAOClient($core->con);
-               if ($client_id == 'new') {
-                       $client = $dao->creeFromEntreprise($entreprise_id);
-               } else {
-                       $client = $dao->selectById($client_id);
-               }
-
-               $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('grade', 0) . form::hidden('entreprise', $client->entreprise) . form::hidden('utilisateur_id', $client->utilisateur_id) . '' . $client->utilisateur_id . '</td></tr>';
-               $res .= '<tr><td>' . __('Login activé') . '</td><td>' . form::hidden('enabled', 0) . form::checkbox('enabled', 1, $client->enabled) . '</td></tr>';
-               $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field('email', 30, 128, $client->email) . '</td></tr>';
-               $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field('password', 30, 128, $client->password) . '</td></tr>';
-               $res .= '<tr><td>' . __('Prénom du contact') . '</td><td>' . form::field('prenom', 30, 128, $client->prenom) . '</td></tr>';
-               $res .= '<tr><td>' . __('Nom du contact') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
-               $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
-               $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';
-               $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';
-               $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';
-               $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field('telephone', 20, 128, $client->telephone) . '</td></tr>';
-               $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field('mobile', 20, 128, $client->mobile) . '</td></tr>';
-               $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field('fax', 20, 128, $client->fax) . '</td></tr>';
-               $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo('lang', cubeLang::getAvailableLangs(true), $client->lang) . '</td></tr>';
-               if ($client_id != 'new') {
-                       $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
-                       $res .= '<tr><td></td><td><a href="' . SITE_PATH . 'fichiers/' . $client->utilisateur_id . '">' . __('FTP') . '</a></td></tr>';
-                       //$res .= '<tr><td></td><td><a class="ajax" href="#" rel="connectAs/' . $client->utilisateur_id . '">' . __('Se connecter comme ...') . '</a></td></tr>';
-                       $res .= '<tr><td>' . __("Paramètres de connexion à l'extranet") . '</td><td>' . __('Adresse') . ' : https://extranet.cubedesigners.com/<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . $client->password . '</td></tr>';
-                       $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
-                       // $res .= '<tr><td>' . __("Paramètres de connexion au FTP") . '</td><td>' . __('Serveur FTP') . ' : extranet.cubedesigners.com (ftp://extranet.cubedesigners.com)<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . $client->password . '</td></tr>';
-               }
-               return $res;
-       }
-
-       public static function formNotes($utilisateur_id)
-       {
-               global $core;
-               commonDroits::min(1);
-               $dao = new commonDAOUtilisateur($core->con);
-               $utilisateur = $dao->selectById($utilisateur_id);
-               $res = '<tr><td colspan="2">' . form::hidden('utilisateur_id', $utilisateur_id) . '</td></tr>';
-               $res .= '<tr><td colspan="2">' . form::textarea('notes', 100, 30, $utilisateur->notes) . '</td></tr>';
-               $res .= '<tr><td colspan="2"></td></tr>';
-               return $res;
-       }
-
-       public static function projets($args)
-       {
-               global $core;
-               commonDroits::min(0.5);
-
-               $settings = $core->user->getSettings('projets');
-
-               $shortcuts = array();
-               if ($core->user->grade >= 1) {
-                       $shortcuts[] = '<a href="#" class="popup" rel="formProjet/new">' . $core->typo->Ajouter('Créer un projet') . '</a>';
-               }
-
-               $filtres = array();
-               $filtres[] = new commonFiltre(__('Crée par'), 'equipier', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Status'), 'status_projet', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Année'), 'annee', $settings['filtres']);
-
-               $res = commonPage::barre($filtres, 'filtreProjet', 'projets', $shortcuts);
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeProjets">';
-               $res .= self::listeProjets();
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function listeProjets($dashboard = null, $settings = null)
-       {
-               global $core;
-               commonDroits::min(0.5);
-               $settings = is_null($settings) ? $core->user->getSettings('projets') : $settings;
-               $change = is_null($dashboard) ? 'Projet' : 'Dashboard/' . $dashboard;
-
-               $res = '<table class="liste">';
-               $res .= '<tr><th>' . commonUrl::orderby('#', 'projet_id', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Projet'), 'nom', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Année'), 'annee_fin', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Chef'), 'chef', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';
-               if ($core->user->grade >= 1) {
-                       $res .= '<th>' . commonUrl::orderby(__('Facturé'), 'rapport_facturation', $settings, 'sort' . $change) . '</th>';
-                       $res .= '<th>' . commonUrl::orderby(__('Payé'), 'rapport_paiement', $settings, 'sort' . $change) . '</th>';
-                       $res .= '<th>' . commonUrl::orderby('<abbr title="' . __('Budget') . '">B</abbr>', 'budget', $settings, 'sort' . $change) . '</th>';
-               }
-               $res .= '<th>' . commonUrl::orderby('<abbr title="' . __('Progression') . '">Pr</abbr>', 'progression', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="min"></th></tr>';
-
-               $dao = new extranetDAOProjet($core->con);
-               $dao->setFiltres($settings['filtres']);
-               if (isset($settings['search']) && !is_null($settings['search'])) {
-                       $dao->setSearch($settings['search']);
-               }
-               $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
-
-               $i = 0;
-               foreach ($liste as $projet) {
-                       $droits = extranetDroits::projet($projet, false);
-
-                       $projet->progression = !$projet->progression ? '-' : $projet->progression . '%';
-                       $projet->jours_prevus = !$projet->jours_prevus ? '-' : $projet->jours_prevus;
-                       $projet->jours_consommes = !$projet->jours_consommes ? '-' : $projet->jours_consommes;
-
-                       $projet->budget = !$projet->budget || !$droits ? '-' : $projet->budget;
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $projet->projet_id . '</td>';
-                       $res .= '<td>' . $projet->nom . '</td>';
-                       $res .= '<td>' . $projet->client . '</td>';
-                       $res .= '<td>' . $projet->annee_fin . '</td>';
-                       $res .= '<td>' . $projet->chef . '</td>';
-                       if ($droits) {
-                               $res .= '<td><a href="#" class="ajax" rel="changeProjetsStatus/' . $projet->projet_id . '" title="' . __('Modifier le status du projet') . '">' . $core->projets_status[$projet->status] . '</a></td>';
-                       } else {
-                               $res .= '<td>' . $core->projets_status[$projet->status] . '</td>';
-                       }
-
-                       $rf = $projet->rapport_facturation;
-                       if ($projet->budget == '-') {
-                               $rapport_facturation = '-';
-                       } elseif (!$rf) {
-                               $rapport_facturation = __('Non');
-                       } elseif ($rf == 1) {
-                               $rapport_facturation = __('Oui');
-                       } elseif ($rf < 1) {
-                               $rapport_facturation = __('Partie');
-                       } elseif ($rf > 1) {
-                               $rapport_facturation = __('Trop');
-                       }
-
-                       $rp = $projet->rapport_paiement;
-                       if ($projet->budget == '-') {
-                               $rapport_paiement = '-';
-                       } elseif (!$rp) {
-                               $rapport_paiement = __('Non');
-                       } elseif ($rp == 1) {
-                               $rapport_paiement = __('Oui');
-                       } elseif ($rp < 1) {
-                               $rapport_paiement = __('Partie');
-                       } elseif ($rp > 1) {
-                               $rapport_paiement = __('Trop');
-                       }
-
-                       if ($core->user->grade >= 1) {
-                               $res .= '<td>';
-                               if ($projet->status == 1 && !$rf) {
-                                       $res .= '<a href="' . SITE_PATH . 'editefacture/new/' . $projet->projet_id . '" title="' . __('Créer la facture pour ce projet') . '">' . $rapport_facturation . '</a>';
-                               } else {
-                                       $res .= $rapport_facturation;
-                               }
-                               $res .= '</td>';
-                               $res .= '<td>' . $rapport_paiement . '</td>';
-
-                               $res .= '<td>' . $projet->budget . '</td>';
-                       }
-                       // $res .= '<td>' . $projet->jours_prevus . '</td>';
-                       // $res .= '<td>' . $projet->jours_consommes . '</td>';
-                       $res .= '<td>' . $projet->progression . '</td>';
-                       $res .= '<td><a href="' . SITE_PATH . 'projet/' . $projet->projet_id . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
-
-                       $res .= '</tr>';
-                       $i++;
-               }
-               if (!isset($settings['search']) || is_null($settings['search'])) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '><td colspan="11">';
-                       $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
-                       $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('projets'));
-                       $res .= '</td></tr>';
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function projet($args)
-       {
-               global $core;
-               commonDroits::min(0.5);
-
-               $shortcuts = array();
-               if ($core->user->grade >= 1) {
-                       $shortcuts[] = '<a href="#" class="popup" rel="formTacheNormale/new/' . $args[1] . '">' . $core->typo->Ajouter('Créer une tâche') . '</a>';
-                       $shortcuts[] = '<a href="#" class="popup" rel="formTacheSousTraitee/new/' . $args[1] . '">' . $core->typo->Ajouter('Créer une tâche sous-traitée') . '</a>';
-               }
-
-               $res = commonPage::barre(null, null, null, $shortcuts);
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeProjet">';
-               $res .= self::listeProjet($args[1]);
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function listeProjet($projet_id)
-       {
-               global $core;
-               commonDroits::min(0.5);
-
-               $res = '<table class="liste">';
-               $res .= '<tr><th>#</th>';
-               $res .= '<th><strong>' . __('Projet') . '</strong> / ' . __('Tâche') . '</th>';
-               $res .= '<th><strong>' . __('Client') . '</strong> / ' . __('Catégorie') . '</th>';
-               $res .= '<th>' . __('Année') . '</th>';
-               $res .= '<th>' . __('Chef de projet') . '</th>';
-               $res .= '<th>' . __('Status') . '</th>';
-               if ($core->user->grade >= 1) {
-                       $res .= '<th><abbr title="' . __('Budget') . '">B</abbr></th>';
-               }
-               $res .= '<th><abbr title="' . __('Jours prévus') . '">Pl</abbr></th>';
-               $res .= '<th><abbr title="' . __('Jours consommés') . '">Co</abbr></th>';
-               $res .= '<th><abbr title="' . __('Progression') . '">Pr</abbr></th>';
-               $res .= '<th class="min"></th><th class="min"></th></tr>';
-
-               $dao = new extranetDAOProjet($core->con);
-               $projet = $dao->selectById($projet_id);
-
-               $hasFacture = $dao->hasFacture($projet_id);
-
-               $droits = extranetDroits::projet($projet, false);
-
-               $projet->progression = !$projet->progression ? '-' : $projet->progression . '%';
-               $projet->jours_prevus = !$projet->jours_prevus ? '-' : $projet->jours_prevus;
-               $projet->jours_consommes = !$projet->jours_consommes ? '-' : $projet->jours_consommes;
-
-               $projet->budget = !$projet->budget || !$droits ? '-' : $projet->budget;
-
-               $res .= '<tr class="bold">';
-               $res .= '<td>' . $projet->projet_id . '</td>';
-               $res .= '<td>' . $projet->nom . '</td>';
-               $res .= '<td>' . $projet->client . '</td>';
-               $res .= '<td>' . $projet->annee_fin . '</td>';
-               $res .= '<td>' . $projet->chef . '</td>';
-               if ($droits) {
-                       $res .= '<td><a href="#" class="ajax" rel="changeProjetStatus/' . $projet->projet_id . '" title="' . __('Modifier le status du projet') . '">' . $core->projets_status[$projet->status] . '</a></td>';
-               } else {
-                       $res .= '<td>' . $core->projets_status[$projet->status] . '</td>';
-               }
-               if ($core->user->grade >= 1) {
-                       $res .= '<td>' . $projet->budget . '</td>';
-               }
-               $res .= '<td>' . $projet->jours_prevus . '</td>';
-               $res .= '<td>' . $projet->jours_consommes . '</td>';
-               $res .= '<td>' . $projet->progression . '</td>';
-               if ($droits) {
-                       $res .= '<td class="action"><a href="#" class="popup" rel="formProjet/' . $projet->projet_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                       if (!count($projet->taches) && !$hasFacture) {
-                               $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeProjet/' . $projet->projet_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce projet ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
-                       } else {
-                               $res .= '<td></td>';
-                       }
-               } else {
-                       $res .= '<td></td><td></td>';
-               }
-               $res .= '</tr>';
-               $i = 1;
-               foreach ($projet->taches as $tache) {
-                       $tache->budget = !$tache->budget || !$droits ? '-' : $tache->budget;
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>T' . $i . '</td>';
-                       $res .= '<td>' . $tache->nom . '</td>';
-                       $res .= '<td>' . $core->categories[$tache->categorie] . '</td>';
-                       if (count($tache->books)) {
-                               $n = array();
-                               foreach ($tache->books as $b) {
-                                       $n[] = '<a class="blank" href="' . WS_URL . '/publications/' . $b . '">' . $b . '</a>';
-                               }
-                               $res .= '<td colspan="3">Fluidbooks # ' . implode(', ', $n) . '</td>';
-                       } else {
-                               $res .= '<td colspan="3"></td>';
-                       }
-
-                       if ($core->user->grade >= 1) {
-                               $res .= '<td>' . $tache->budget . '</td>';
-                       }
-
-                       if ($tache instanceof extranetTacheNormale) {
-                               $progression = !$tache->progression ? '-' : $tache->progression . '%';
-                               $jours_prevus = !$tache->jours_prevus ? '-' : $tache->jours_prevus;
-                               $jours_consommes = !$tache->jours_consommes ? '-' : $tache->jours_consommes;
-                               $res .= '<td>' . $jours_prevus . '</td>';
-                               $res .= '<td>' . $jours_consommes . '</td>';
-                               $res .= '<td>' . $progression . '</td>';
-                               if ($droits) {
-                                       $res .= '<td class="action"><a href="#" class="popup" rel="formTacheNormale/' . $tache->tache_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                               } else {
-                                       $res .= '<td></td>';
-                               }
-                       } else {
-                               $res .= '<td colspan="3">' . __('Tâche sous-traitée') . '</td>';
-                               if ($droits) {
-                                       $res .= '<td class="action"><a href="#" class="popup" rel="formTacheSousTraitee/' . $tache->tache_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                               } else {
-                                       $res .= '<td></td>';
-                               }
-                       }
-
-                       $res .= '<td class="action">';
-                       if ($core->user->grade >= 1) {
-                               $res .= '<a href="#" class="ajax" rel="supprimeTache/' . $tache->tache_id . '" title="' . __('Supprimer cette tâche va également supprimer les timereports associés. Êtes vous certain de vouloir supprimer cette tâche ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a>';
-                       }
-                       $res .= '</td>';
-
-                       $res .= '</tr>';
-                       $i++;
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function formProjet($projet_id = 'new')
-       {
-               global $core;
-               commonDroits::min(1);
-
-               $dao = new extranetDAOProjet($core->con);
-               if ($projet_id == 'new') {
-                       $projet = $dao->cree($core->user->utilisateur_id);
-               } else {
-                       $projet = $dao->selectById($projet_id);
-               }
-
-               $daoClient = new commonDAOClient($core->con);
-               $clients = $daoClient->getListe();
-
-               $listeClients = array();
-               foreach ($clients as $client) {
-                       if (empty($client->utilisateur_id)) {
-                               continue;
-                       }
-                       $listeClients[trim($client->rs) . ' (' . $client->prenom . ' ' . $client->nom . ')'] = $client->utilisateur_id;
-               }
-               ksort($listeClients);
-               $listeClients = array_merge(array('--' => ''), $listeClients);
-
-               $daoEquipier = new commonDAOEquipier($core->con);
-               $equipiers = $daoEquipier->getListe();
-
-               $listeEquipiers = array();
-               foreach ($equipiers as $equipier) {
-                       $listeEquipiers[$equipier->prenom . ' ' . $equipier->nom . ' (' . $equipier->agence . ')'] = $equipier->utilisateur_id;
-               }
-
-               $daoDevis = new extranetDAODevis($core->con);
-               $devis = $daoDevis->getListeValidesLibres($projet_id);
-               $listeDevis = array('--' => 0);
-               foreach ($devis as $id => $dev) {
-                       $listeDevis[$dev->nom] = $dev->devis_id;
-               }
-
-               $res = '<tr><td>' . __('Numéro de projet') . '</td><td>' . form::hidden('projet_id', $projet->projet_id) . '' . $projet->projet_id . '</td></tr>';
-               $res .= '<tr><td>' . __('Nom du projet') . '</td><td>' . form::textarea('nom', 50, 3, html::escapeHTML($projet->nom)) . '</td></tr>';
-               $res .= '<tr><td>' . __('Chef de projet') . '</td><td>';
-               if ($core->user->grade > 1) {
-                       $res .= form::combo('chef', $listeEquipiers, $projet->chef_id);
-               } else {
-                       $res .= form::hidden('chef', $projet->chef_id) . ' ' . $projet->chef;
-               }
-               $res .= '</td></tr>';
-               $res .= '<tr><td>' . __('Date de début') . '</td><td>' . cubeForm::dateFree('date_debut', $projet->date_debut) . '</td></tr>';
-               $res .= '<tr><td>' . __('Deadline') . '</td><td>' . cubeForm::dateFree('deadline', $projet->deadline) . '</td></tr>';
-               $res .= '<tr><td>' . __('Date de fin') . '</td><td>' . cubeForm::dateFree('date_fin', $projet->date_fin) . '</td></tr>';
-               $res .= '<tr><td>' . __('Client') . '</td><td>' . form::combo('client', $listeClients, $projet->client_id) . '</td></tr>';
-               $res .= '<tr><td>' . __('Devis') . '</td><td>' . form::combo('devis', $listeDevis, $projet->devis) . '</td></tr>';
-               return $res;
-       }
-
-       public static function formTache($tache)
-       {
-               global $core;
-               commonDroits::min(1);
-
-               $res = '<tr><td>' . __('Numéro de tâche') . '</td><td>' . form::hidden('projet', $tache->projet) . form::hidden('tache_id', $tache->tache_id) . '' . $tache->tache_id . '</td></tr>';
-               $res .= '<tr><td>' . __('Catégorie') . '</td><td>' . form::combo('categorie', array_flip($core->categories), $tache->categorie) . '</td></tr>';
-               $res .= '<tr><td>' . __('Nom') . '</td><td>' . form::textarea('nom', 50, 3, html::escapeHTML($tache->nom)) . '</td></tr>';
-
-               return $res;
-       }
-
-       public static function formTacheNormale($tache_id, $projet_id = null)
-       {
-               global $core;
-               commonDroits::min(1);
-               $dao = new extranetDAOTache($core->con);
-               if ($tache_id == 'new') {
-                       $tache = $dao->creeNormale();
-                       $tache->projet = $projet_id;
-               } else {
-                       $tache = $dao->selectById($tache_id);
-               }
-               $res = self::formTache($tache);
-               $res .= '<tr><td>' . __('Taux journalier') . '</td><td>' . form::field('taux_journalier', 6, 6, $tache->taux_journalier) . '</td></tr>';
-               $res .= '<tr><td>' . __('Budget') . '</td><td>' . form::hidden('type', '0') . form::field('budget', 6, 6, $tache->budget) . '</td></tr>';
-               return $res;
-       }
-
-       public static function formTacheSousTraitee($tache_id, $projet_id = null)
-       {
-               global $core;
-               commonDroits::min(1);
-               $dao = new extranetDAOTache($core->con);
-               if ($tache_id == 'new') {
-                       $tache = $dao->creeSousTraitee();
-                       $tache->projet = $projet_id;
-               } else {
-                       $tache = $dao->selectById($tache_id);
-               }
-               $res = self::formTache($tache);
-               $res .= '<tr><td>' . __('Budget') . '</td><td>' . form::hidden('type', '1') . form::field('budget', 6, 6, $tache->budget) . '</td></tr>';
-               return $res;
-       }
-
-       public static function timereport($args)
-       {
-               global $core;
-               commonDroits::min(0.5);
-               $settings = $core->user->getSettings('timereport');
-               $res = '';
-               if (!isset($_GET['light'])) {
-                       $filtres = array();
-                       $filtres[] = new commonFiltre(__('Participants'), 'equipier_participe', $settings['filtres']);
-                       $res .= commonPage::barre($filtres, 'filtreTimereport', 'timereport', null);
-                       $res .= commonPage::tMain();
-                       $res .= commonPage::bh();
-               }
-               $res .= '<div id="listeTimereport">';
-               $res .= self::listeTimereport();
-               $res .= '</div>';
-               if (!isset($_GET['light'])) {
-                       $res .= commonPage::bf();
-                       $res .= commonPage::bMain();
-               }
-               return $res;
-       }
-
-       public static function listeTimereport($dashboard = null, $settings = null)
-       {
-               global $core;
-               commonDroits::min(0.5);
-               // Récupère la liste des projets
-               $settings = is_null($settings) ? $core->user->getSettings('timereport') : $settings;
-               $change = is_null($dashboard) ? 'Timereport' : 'Dashboard/' . $dashboard;
-
-               $dao = new extranetDAOProjet($core->con);
-               if (isset($settings['search']) && !is_null($settings['search'])) {
-                       $dao->setSearch($settings['search']);
-               }
-               $dao->setFiltres($settings['filtres']);
-               $liste = $dao->getProjetsForTimereport($settings['orderby'], $settings['sens'], $settings['limit'], $core->user->utilisateur_id);
-               // Extrait la liste des tâches
-               $taches = array();
-               foreach ($liste as $id => $projet) {
-                       foreach ($projet->taches as $tache) {
-                               if ($tache instanceof extranetTacheNormale) {
-                                       $taches[] = $tache->tache_id;
-                               }
-                       }
-               }
-               // Fixe les limites des jours à afficher
-               $time = cubeDate::round(null, 'd'); // aujourd'hui
-               $avant = $time - (3600 * 24 * 15); // 15 jours avant
-               $apres = $time; // aujourd'hui
-               // Récupère la liste des timereports à afficher
-               $daoTimereport = new extranetDAOTimereport($core->con);
-               $timereports = $daoTimereport->getListe($taches, $core->user->utilisateur_id, array('start' => $avant, 'end' => $apres));
-               // Affiche le tableau
-               $res = '<table class="liste listeTimereport">';
-               $res .= '<tr><th class="normal">' . commonUrl::orderby('#', 'projet_id', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="normal">' . commonUrl::orderby(__('Projet'), 'nom', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="normal">' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
-               for ($date = $avant; $date <= $apres; $date += 3600 * 24) {
-                       $res .= '<th>' . date('d', $date) . '' . cubeMedia::spacer(16, 1, '', 'spacer') . '</th>';
-               }
-               $res .= '<th class="normal info">' . commonUrl::orderby('<abbr title="' . __('Progression') . '">Pr</abbr>', 'progression', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="normal info">' . commonUrl::orderby('<abbr title="' . __('Jours consommés') . '">Co</abbr>', 'jours_consommes', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="normal info">' . commonUrl::orderby('<abbr title="' . __('Jours prévus') . '">Pl</abbr>', 'jours_prevus', $settings, 'sort' . $change) . '</th>';
-               $res .= '</tr>';
-
-               foreach ($liste as $projet) {
-                       $res .= '<tr class="bold">';
-                       $res .= '<td class="normal">' . $projet->projet_id . '</td>';
-                       $res .= '<td class="normal">' . $projet->nom . '</td>';
-                       $res .= '<td class="normal">' . $projet->client . '</td>';
-                       for ($date = $avant; $date <= $apres; $date += 3600 * 24) {
-                               $cc = self::getClassOfDay($date);
-                               $class = ($cc == '') ? '' : ' class="' . $cc . '"';
-                               $res .= '<td' . $class . '></td>';
-                       }
-                       $projet->progression = !$projet->progression ? '-' : $projet->progression . '%';
-                       $projet->jours_prevus = !$projet->jours_prevus ? '-' : $projet->jours_prevus;
-                       $projet->jours_consommes = !$projet->jours_consommes ? '-' : $projet->jours_consommes;
-                       $res .= '<td class="normal info"><span id="progress_projet_' . $projet->projet_id . '">' . $projet->progression . '</span></td>';
-                       $res .= '<td class="normal info"><span id="consommees_projet_' . $projet->projet_id . '">' . $projet->jours_consommes . '</span></td>';
-                       $res .= '<td class="normal info">' . $projet->jours_prevus . '</td>';
-                       $res .= '</tr>';
-                       $i = 1;
-                       foreach ($projet->taches as $tache) {
-                               if ($tache instanceof extranetTacheNormale) {
-                                       $res .= '<tr class="odd">';
-                                       $res .= '<td class="normal">T' . $i . '</td>';
-                                       $res .= '<td class="normal">' . $tache->nom . '</td>';
-                                       $res .= '<td class="normal">' . $core->categories[$tache->categorie] . '</td>';
-                                       for ($date = $avant; $date <= $apres; $date += (3600 * 24)) {
-                                               $hh = isset($timereports[$tache->tache_id][$date]) ? $timereports[$tache->tache_id][$date]->heures : '';
-                                               $c = ($hh == '') ? '' : 'filled';
-                                               $cc = trim(self::getClassOfDay($date) . ' ' . $c);
-                                               $class = ($cc == '') ? '' : ' class="' . $cc . '"';
-                                               $res .= '<td' . $class . '>' . form::field(array('timereport', 't_' . $date . '_' . $tache->tache_id), 1, 3, $hh, 'timereport_field') . '</td>';
-                                       }
-                                       $tache->progression = !$tache->progression ? '-' : $tache->progression . '%';
-                                       $tache->jours_prevus = !$tache->jours_prevus ? '-' : $tache->jours_prevus;
-                                       $tache->jours_consommes = !$tache->jours_consommes ? '-' : $tache->jours_consommes;
-                                       $res .= '<td class="normal info"><span id="progress_' . $tache->tache_id . '">' . $tache->progression . '</span></td>';
-                                       $res .= '<td class="normal info"><span id="consommees_' . $tache->tache_id . '">' . $tache->jours_consommes . '</span></td>';
-                                       $res .= '<td class="normal info">' . $tache->jours_prevus . '</td>';
-                                       $res .= '</tr>';
-                                       $i++;
-                               }
-                       }
-               }
-
-               if (!isset($settings['search']) || is_null($settings['search'])) {
-                       $res .= '<tr><td colspan="22"> ';
-                       $res .= commonPage::pager($settings['page'], $dao->countActifs(), $settings['par_page'], 'page' . $change . '/%d');
-                       $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('projets'));
-                       $res .= ' </td></tr>';
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function getClassOfDay($date)
-       {
-               $aujourdhui = cubeDate::round(null, 'd');
-               $highlight = ($date == $aujourdhui);
-               $we = (date('N', $date) >= 6);
-               if ($highlight) {
-                       return 'highlight';
-               }
-               if ($we) {
-                       return 'we';
-               }
-               return '';
-       }
-
-       public static function devis($args)
-       {
-               global $core;
-               cubePage::truePopup();
-               cubePage::contextMenu();
-
-               if ($core->user->grade == 0) {
-                       return self::devis_client($args);
-               }
-               $settings = $core->user->getSettings('devis');
-               commonDroits::min(1);
-
-               $shortcuts = array();
-               $shortcuts[] = '<a href="' . SITE_PATH . 'editedevis/new">' . $core->typo->Ajouter('Créer un devis') . '</a>';
-
-               $filtres = array();
-               $filtres[] = new commonFiltre(__('Créées par'), 'equipier', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Status'), 'status_devis', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Année'), 'annee_facture', $settings['filtres']);
-
-               $res = commonPage::barre($filtres, 'filtreDevis', 'devis', $shortcuts);
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeDevis">';
-               $res .= self::listeDevis();
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function devis_client($args)
-       {
-               global $core;
-
-               $res = commonPage::barre();
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeDevis">';
-               $res .= self::listeDevis();
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function listeDevis($dashboard = null, $settings = null)
-       {
-               global $core;
-
-               if ($core->user->grade == 0) {
-                       return self::listeDevisClient($dashboard, $settings);
-               } else {
-                       return self::listeDevisEquipier($dashboard, $settings);
-               }
-       }
-
-       public static function contextDevis($id)
-       {
-               global $core;
-               $res = '<div class="contextMenu" id="' . $id . '">';
-               $res .= '<ul>';
-               $res .= '<li class="head">' . __("Changer le status du devis") . '</li>';
-               foreach ($core->devis_status as $k => $v) {
-                       if ($k == 0) {
-                               continue;
-                       }
-                       $res .= '<li><a href="#" rel="changeDevisStatus/$1/' . $k . '" class="ajax">' . $v . '</a></li>';
-                       if ($k == 2) {
-                               $res .= '<li><a href="#" rel="changeDevisStatus/$1/' . $k . '/createProjet" class="ajax">' . __('Valider puis créer le projet correspondant') . '</a></li>';
-                       }
-               }
-               $res .= '</ul></div>';
-               return $res;
-       }
-
-       public static function listeDevisEquipier($dashboard = null, $settings = null)
-       {
-               global $core;
-               commonDroits::min(1);
-               $settings = is_null($settings) ? $core->user->getSettings('devis') : $settings;
-               $change = is_null($dashboard) ? 'Devis' : 'Dashboard/' . $dashboard;
-               $context_id = is_null($dashboard) ? 'contextDevis' : 'contextDashboard_' . $dashboard;
-
-               $dao = new extranetDAODevis($core->con);
-               if (isset($settings['search']) && !is_null($settings['search'])) {
-                       $dao->setSearch($settings['search']);
-               }
-               $dao->setFiltres($settings['filtres']);
-               $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
-               $res = self::contextDevis($context_id);
-               $res .= '<table class="liste">';
-               $res .= '<tr><th>' . commonUrl::orderby('#', 'devis_id', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Crée par'), 'createur', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th class="min"></th><th class="min"></th><th class="min"></th></tr>';
-               $i = 0;
-               foreach ($liste as $devis) {
-                       $droits = extranetDroits::devis($devis, 'w', false);
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $devis->devis_id . '</td>';
-                       $res .= '<td>' . $devis->nom . '</td>';
-                       $res .= '<td>' . $devis->client . '</td>';
-                       $res .= '<td>' . $devis->createur . '</td>';
-                       $res .= '<td>' . date(__('d/m/Y'), $devis->date_creation) . '</td>';
-                       $res .= '<td>' . $devis->total_ht . '</td>';
-
-                       if ($devis->status == 0) {
-                               $res .= '<td>' . $core->devis_status[$devis->status] . '</td>';
-                       } else {
-                               if ($droits) {
-                                       $res .= '<td><a href="#" class="openContextMenu" rel="' . $context_id . '" rev="' . $devis->devis_id . '">' . $core->devis_status[$devis->status] . '</a></td>';
-                               } else {
-                                       $res .= '<td>' . $core->devis_status[$devis->status] . '</td>';
-                               }
-                       }
-
-                       if (in_array($devis->status, array(0, 1)) && $droits) {
-                               $res .= '<td class="action"><a href="' . SITE_PATH . 'editedevis/' . $devis->devis_id . '" title="' . __('Editer le devis') . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                       } else {
-                               $res .= '<td></td>';
-                       }
-                       $res .= '<td><a href="' . SITE_PATH . 'voirdevis/' . $devis->devis_id . '" class="popupA4" title="' . __('Voir le devis') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
-                       if ($devis->status == 0) {
-                               if ($droits) {
-                                       $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeDevis/' . $devis->devis_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce devis ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
-                               } else {
-                                       $res .= '<td></td>';
-                               }
-                       } elseif ($devis->status >= 1) {
-                               $res .= '<td><a href="#" class="ajax" rel="duplicateDevis/' . $devis->devis_id . '" title="' . __('Dupliquer le devis') . '">' . cubeMedia::image(IMG . '/duplicate.png') . '</a></td>';
-                       }
-
-                       $res .= '</tr>';
-                       $i++;
-               }
-               if (!isset($settings['search']) || is_null($settings['search'])) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '><td colspan="10">';
-                       $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
-                       $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('devis'));
-                       $res .= '</td></tr>';
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function listeDevisClient($dashboard = null, $settings = null)
-       {
-               global $core;
-               cubePage::truePopup();
-
-               $dao = new extranetDAODevis($core->con);
-               $settings = $core->user->getSettings('devis');
-               $liste = $dao->getListeForEntreprise($core->user->entreprise, $settings['orderby'], $settings['sens']);
-               $res = '<table class="liste">';
-               $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sortDevis') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sortDevis') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sortDevis') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sortDevis') . '</th>';
-               $res .= '<th class="min"></th></tr>';
-               $i = 0;
-               foreach ($liste as $devis) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $devis->nom . '</td>';
-                       $res .= '<td>' . date(__('d/m/Y'), $devis->date_creation) . '</td>';
-                       $res .= '<td>' . $devis->total_ht . '</td>';
-                       $res .= '<td>' . $core->devis_status[$devis->status] . '</td>';
-                       $res .= '<td><a href="' . SITE_PATH . 'voirdevis/' . $devis->devis_id . '" class="popupA4" title="' . __('Voir le devis') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
-                       $res .= '</tr>';
-                       $i++;
-               }
-               if (!count($liste)) {
-                       $res .= '<tr><td colspan="6" class="center">' . __("Vous n'avez pour le moment aucun devis associé à votre compte") . '</td></tr>';
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function voirdevis($args)
-       {
-               global $core;
-               // Charge le devis
-               $dao = new extranetDAODevis($core->con);
-               $devis = $dao->selectById($args[1]);
-
-               $forceDownload = isset($args[2]) && $args[2];
-
-               // Vérification des droits en lecture de l'utilisateur
-               extranetDroits::devis($devis, 'r');
-
-               if ($forceDownload) {
-                       cubeHTTP::forceDownload('Devis_' . $args[1] . '.pdf');
-               }
-               cubeHTTP::relayNoCache(ROOT . '/docs/devis/' . $args[1] . '.pdf');
-       }
-
-       public static function editedevis($args)
-       {
-               global $core;
-               commonDroits::min(1);
-               $res = commonPage::barre();
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= self::formDevis($args[1]);
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function formDevis($devis_id = 'new')
-       {
-               global $core;
-               cubePage::autocomplete();
-               cubePage::emptyField();
-               cubePage::ui('Sortable');
-               commonDroits::min(1);
-               $dao = new extranetDAODevis($core->con);
-               if ($devis_id == 'new') {
-                       $devis = $dao->cree();
-               } else {
-                       $devis = $dao->selectById($devis_id);
-               }
-
-               $res = '<div id="editeDevis">';
-               $res .= '<form action="previewDevis" method="post">';
-
-               $res .= '<div id="devisTop">';
-               // Adresse
-               $res .= '<div id="devisAdresse">';
-               if ($devis->devis_id == 'new') {
-                       $default = __('Entrez le nom du client');
-                       $default_id = '';
-                       $class = 'empty-field';
-               } else {
-                       $default = $devis->client;
-                       $default_id = $devis->client_id;
-                       $class = '';
-               }
-
-               $res .= form::field('client_nom', 40, 128, $default, $class);
-               $res .= form::hidden('client', $default_id);
-               $res .= '<div id="devisAdresseDisplay">';
-               if ($devis->client_id) {
-                       $res .= commonUrl::adresse($devis->client_id, null, 'devis', $devis->adresse);
-               }
-               $res .= '</div>';
-               $res .= '</div>';
-               // Titre
-               $res .= '<div id="devisTitre">';
-               $res .= form::hidden('devis_id', $devis->devis_id);
-               $res .= form::textarea('nom', 40, 4, $devis->nom);
-               $res .= '</div>';
-               $res .= '</div>';
-
-               $res .= '<div id="devisMiddle">';
-               $res .= '<div id="devisLignes">';
-               // Lignes du devis
-               $nb_lignes = max(4, count($devis->lignes) + 2);
-
-               for ($i = 0; $i < $nb_lignes; $i++) {
-                       if (isset($devis->lignes[$i])) {
-                               $titre = $devis->lignes[$i]['titre'];
-                               $description = $devis->lignes[$i]['description'];
-                               $montant = $devis->lignes[$i]['montant'];
-                       } else {
-                               $titre = $description = $montant = '';
-                       }
-                       $res .= '<div class="devisLigne">';
-                       $res .= '<div class="devisLigneRight">';
-                       $res .= form::field(array('montant[]'), 6, 15, $montant) . " €";
-                       $res .= '</div>';
-                       $res .= '<div class="devisLigneLeft">';
-                       $res .= form::field(array('titre[]'), 105, 256, htmlspecialchars($titre, ENT_QUOTES)) . '<br /><br />';
-                       $res .= form::textarea(array('description[]'), 110, 4, $description);
-                       $res .= '</div>';
-
-                       $res .= '</div>';
-               }
-
-               $res .= '</div>';
-               $res .= '</div>';
-               //              $res .= '<div id="devisBottom">' . cubeMedia::spacer(10, 10) . '</div>';
-               //              $res .= '<div id="devisMail">';
-               //              $res .= '<table>';
-               //              $res .= '<tr><td>' . __('De') . '</td><td>' . $core->user->prenom . ' ' . $core->user->nom . ' &lt;' . $core->user->email . '&gt;</td></tr>';
-               //              $res .= '<tr><td>' . __('Sujet') . '</td><td>' . form::field(array('email[sujet]'), 80, 128, htmlspecialchars($devis->email['sujet'], ENT_QUOTES)) . '</td></tr>';
-               //              $res .= '<tr><td>' . __('Corps') . '</td><td>' . form::textarea(array('email[corps]'), 80, 20, $devis->email['corps']) . '</td></tr>';
-               //              $res .= '</table>';
-               //              $res .= '</div>';
-               $res .= '<div class="right"><a href="#" class="submit">' . $core->typo->BoutonOK('Enregistrer et prévisualiser') . '</a></div>';
-               $res .= '</form>';
-               $res .= '</div>';
-
-               return $res;
-       }
-
-       public static function previewDevis($args)
-       {
-               global $core;
-
-               $dao = new extranetDAODevis($core->con);
-               $devis = $dao->selectById($args[1]);
-
-               $daoUtilisateur = new commonDAOUtilisateur($core->con);
-               $createur = $devis->createur = $daoUtilisateur->selectById($devis->createur_id);
-               $client = $devis->client = $daoUtilisateur->selectById($devis->client_id);
-
-               $res = commonPage::barre();
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<iframe src="' . SITE_PATH . 'voirdevis/' . $devis->devis_id . '/?junk=' . TIME . '" width="960" height="1000" frameborder="0"></iframe>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bh();
-               $res .= '<div id="devis_email">';
-               $res .= '<table class="liste">';
-               $res .= '<tr><td>' . __('De') . '</td><td>' . $createur->prenom . ' ' . $createur->nom . '&lt;' . $createur->email . '&gt;</td></tr>';
-               $res .= '<tr class="odd"><td>' . __('A') . '</td><td>' . $client->prenom . ' ' . $client->nom . '&lt;' . $client->email . '&gt;</td></tr>';
-               $res .= '<tr><td>' . __('Sujet') . '</td><td>' . $devis->email['sujet'] . '</td></tr>';
-               $res .= '<tr class="odd"><td>' . __('Message') . '</td><td>' . nl2br($devis->email['corps'] . "\n\n" . $createur->getSignature()) . '</td></tr>';
-               $res .= '<tr><td colspan="2" class="right">';
-               $res .= cubeMedia::spacer(40, 40) . '<a href="' . SITE_PATH . 'editedevis/' . $devis->devis_id . '">' . $core->typo->BoutonOK(__('Editer le devis')) . '</a> ';
-               $res .= '<a href="#" rel="expedieDevis/0/' . $devis->devis_id . '" class="ajax"">' . $core->typo->BoutonOK(__('Valider')) . '</a> ';
-               //$res .= '<a href="#" rel="expedieDevis/1/' . $devis->devis_id . '" class="ajax" title="' . __("Le devis est sur le point d'être envoyé. Veuillez confirmer votre choix ?") . '">' . $core->typo->BoutonOK(__('Valider et envoyer le devis')) . '</a></td></tr>';
-               $res .= '</table>';
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function factures($args)
-       {
-               global $core;
-
-               if ($core->user->grade == 0) {
-                       return self::factures_client($args);
-               }
-               $settings = $core->user->getSettings('factures');
-
-               commonDroits::min(1);
-               $shortcuts = array();
-               if ($core->user->grade != 3) {
-                       $shortcuts[] = '<a href="' . SITE_PATH . 'editefacture/new">' . $core->typo->Ajouter('Créer une facture') . '</a>';
-               }
-               $shortcuts[] = '<a href="#" rel="formPrintFactures" title="Imprimer les factures" class="popup">' . cubeMedia::image(IMG . '/print.png') . '</a>';
-               $filtres = array();
-               $filtres[] = new commonFiltre(__('Créées par'), 'equipier', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Status'), 'status_facture', $settings['filtres']);
-               $filtres[] = new commonFiltre(__('Année'), 'annee_facture', $settings['filtres']);
-               $res = commonPage::barre($filtres, 'filtreFactures', 'factures', $shortcuts);
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeFactures">';
-               $res .= self::listeFactures();
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function factures_client($args)
-       {
-               global $core;
-               $res = commonPage::barre();
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<div id="listeFactures">';
-               $res .= self::listeFactures();
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function contextFacture($id)
-       {
-               global $core;
-               $res = '<div class="contextMenu" id="' . $id . '">';
-               $res .= '<ul>';
-               $res .= '<li class="head">' . __("Changer le status de la facture") . '</li>';
-               foreach ($core->factures_status as $k => $v) {
-                       if (in_array($k, array(0, 4))) {
-                               continue;
-                       }
-                       if ($k == 2) {
-                               $res .= '<li><a href="#" rel="changeFacturePaiement/$1" class="popup">' . $v . '</a></li>';
-                       } else {
-                               if ($k == 3) {
-                                       $title = ' title="' . __("Êtes-vous certain de vouloir annuler cette facture ? Cette action est irreversible et provoquera la création d'un avoir correpondant.") . '"';
-                               } else {
-                                       $title = '';
-                               }
-                               $res .= '<li><a href="#" rel="changeFactureStatus/$1/' . $k . '" class="ajax"' . $title . '>' . $v . '</a></li>';
-                       }
-               }
-               $res .= '</ul></div>';
-               return $res;
-       }
-
-       public static function listeFactures($dashboard = null, $settings = null)
-       {
-               global $core;
-               if ($core->user->grade == 0) {
-                       return self::listeFacturesClient($dashboard, $settings);
-               } else {
-                       return self::listeFacturesEquipier($dashboard, $settings);
-               }
-       }
-
-       public static function listeFacturesEquipier($dashboard = null, $settings = null)
-       {
-               global $core;
-               cubePage::truePopup();
-               cubePage::contextMenu();
-
-               $settings = is_null($settings) ? $core->user->getSettings('factures') : $settings;
-               $change = is_null($dashboard) ? 'Facture' : 'Dashboard/' . $dashboard;
-               $context_id = is_null($dashboard) ? 'contextFacture' : 'contextDashboard_' . $dashboard;
-               $dao = new extranetDAOFacture($core->con);
-               if (isset($settings['search']) && !is_null($settings['search'])) {
-                       $dao->setSearch($settings['search']);
-               } else {
-                       $dao->setFiltres($settings['filtres']);
-               }
-
-               if ($core->user->grade != 3) {
-                       $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
-               } else {
-                       $liste = $dao->getListeCompta($settings['orderby'], $settings['sens'], $settings['limit']);
-               }
-
-               $res = self::contextFacture($context_id);
-               $res .= '<table class="liste">';
-               $res .= '<tr><th>' . commonUrl::orderby('#', 'facture_id', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Crée par'), 'createur', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th><th class="min"></th><th class="min"></th><th class="min"></th></tr>';
-               $i = 0;
-               foreach ($liste as $facture) {
-                       $droits = extranetDroits::facture($facture, 'w', false);
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $facture->facture_id . '</td>';
-                       $res .= '<td>' . $facture->nom . '</td>';
-                       $res .= '<td>' . $facture->client . '</td>';
-                       $res .= '<td>' . $facture->createur . '</td>';
-                       $res .= '<td>' . date(__('d/m/Y'), $facture->date_creation) . '</td>';
-                       $res .= '<td>' . $facture->total_ht . '</td>';
-                       if ($facture->status == 0) {
-                               $res .= '<td>' . $core->factures_status[$facture->status] . '</td>';
-                               if ($droits) {
-                                       $res .= '<td></td>';
-                                       $res .= '<td class="action"><a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '" title="' . __('Editer la facture') . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                                       $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeFacture/' . $facture->facture_id . '" title="' . __('Êtes vous certain de vouloir supprimer cette facture ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
-                               } else {
-                                       $res .= '<td></td><td></td>';
-                               }
-                       } elseif ($facture->status >= 1) {
-                               if ($facture->status < 3 || $facture->status == 5) {
-                                       if ($droits) {
-                                               $res .= '<td><a href="#" class="openContextMenu" rel="' . $context_id . '" rev="' . $facture->facture_id . '">' . $core->factures_status[$facture->status] . '</a></td>';
-                                       } else {
-                                               $res .= '<td>' . $core->factures_status[$facture->status] . '</td>';
-                                       }
-                               } else {
-                                       $title = $facture->status == 3 ? __("Voir l'avoir correspondant") : __("Voir la facture annulée correspondante");
-                                       $res .= '<td><a href="' . SITE_PATH . 'voirfacture/' . $facture->avoir . '" class="popupA4" title="' . $title . '">' . $core->factures_status[$facture->status] . '</a></td>';
-                               }
-                               if ($facture->facture_id > 0) {
-                                       if ($droits && $facture->status == 1) {
-                                               $res .= '<td>' . '<a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '" title="' . __('Editer la facture') . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                                       } else {
-                                               $res .= '<td></td>';
-                                       }
-                                       $res .= '<td><a href="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" class="popupA4" title="' . __('Voir la facture') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
-                                       if ($facture->status != 4 && $core->user->grade != 3) {
-                                               $res .= '<td><a href="#" class="ajax" rel="duplicateFacture/' . $facture->facture_id . '" title="' . __('Dupliquer la facture') . '">' . cubeMedia::image(IMG . '/duplicate.png') . '</a></td>';
-                                       } else {
-                                               $res .= '<td></td>';
-                                       }
-                               } else {
-                                       $res .= '<td></td><td></td><td></td>';
-                               }
-                       }
-
-                       $res .= '</tr>';
-                       $i++;
-               }
-               if (!isset($settings['search']) || is_null($settings['search'])) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '><td colspan="10">';
-                       if ($core->user->grade != 3) {
-                               $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
-                       } else {
-                               $res .= commonPage::pager($settings['page'], $dao->countCompta(), $settings['par_page'], 'page' . $change . '/%d');
-                       }
-                       $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('factures'));
-                       $res .= '</td></tr>';
-               }
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function listeFacturesClient($dashboard = null, $settings = null)
-       {
-               global $core;
-               cubePage::truePopup();
-               $settings = $core->user->getSettings('factures');
-               $dao = new extranetDAOFacture($core->con);
-               $liste = $dao->getListeForEntreprise($core->user->entreprise, $settings['orderby'], $settings['sens'], true);
-
-               $res = '<table class="liste">';
-               $res .= '<tr><th>' . commonUrl::orderby('#', 'facture_id', $settings, 'sortFacture') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sortFacture') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sortFacture') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sortFacture') . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sortFacture') . '</th>';
-               $res .= '<th class="min"></th></tr>';
-               $i = 0;
-               foreach ($liste as $facture) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $facture->numeroFacture() . '</td>';
-                       $res .= '<td>' . $facture->nom . '</td>';
-                       $res .= '<td>' . date(__('d/m/Y'), $facture->date_creation) . '</td>';
-                       $res .= '<td>' . $facture->total_ht . '</td>';
-                       $res .= '<td>' . $core->factures_status[$facture->status] . '</td>';
-                       $res .= '<td><a href="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" class="popupA4" title="' . __('Voir la facture') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
-                       $res .= '</tr>';
-                       $i++;
-               }
-               if (!count($liste)) {
-                       $res .= '<tr><td colspan="6" class="center">' . __("Vous n'avez pour le moment aucune facture associée à votre compte") . '</td></tr>';
-               }
-
-               $res .= '</table>';
-               return $res;
-       }
-
-       public static function formFacturePaiement($facture_id)
-       {
-               global $core;
-               $dao = new extranetDAOFacture($core->con);
-               $facture = $dao->selectById($facture_id);
-               $date = !$facture->date_paiement ? null : $facture->date_paiement;
-
-               $res = '<tr><td>' . form::hidden('facture_id', $facture_id) . __('Date de paiement') . '</td><td>' . cubeForm::date('date_paiement', $date) . '</td></tr>';
-               $res .= '<tr><td>' . __('Informations de paiement') . '</td><td>' . form::textarea('informations_paiement', 40, 3, $facture->informations_paiement) . '</td></tr>';
-
-               return $res;
-       }
-
-       public static function voirfacture($args)
-       {
-               global $core;
-               // Charge la facture
-               $dao = new extranetDAOFacture($core->con);
-               $facture = $dao->selectById($args[1]);
-               // Vérification des droits de l'utilisateur
-               extranetDroits::facture($facture, 'r', true);
-
-               cubeHTTP::relayNoCache(ROOT . '/docs/factures/' . $args[1] . '.pdf');
-       }
-
-       public static function editefacture($args)
-       {
-               global $core;
-               commonDroits::min(1);
-               $res = commonPage::barre();
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               if (isset($args[2])) {
-                       $res .= self::formFacture($args[1], $args[2]);
-               } else {
-                       $res .= self::formFacture($args[1]);
-               }
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function formFacture($facture_id = 'new', $projet_id = null)
-       {
-               global $core;
-               commonDroits::min(1);
-               cubePage::autoComplete();
-               cubePage::emptyField();
-               cubePage::ui('Sortable');
-
-               $daoProjet = new extranetDAOProjet($core->con);
-               $dao = new extranetDAOFacture($core->con);
-
-               $projet_id = isset($_POST['projet_id']) && $_POST['projet_id'] > 0 ? $_POST['projet_id'] : $projet_id;
-
-               if ($facture_id == 'new') {
-                       $facture = $dao->cree();
-               } elseif ($facture_id == 'ws') {
-                       $facture = $dao->cree();
-                       $facture->facture_id = 'ws';
-               } else {
-                       $facture = $dao->selectById($facture_id);
-               }
-
-               if (!is_null($projet_id) && $facture_id == 'new') {
-                       $projet = $daoProjet->selectById($projet_id);
-                       $facture->projet_id = $projet->projet_id;
-                       $facture->client = $projet->client;
-                       $facture->projet = $facture->nom = $projet->nom;
-                       $lignes = array();
-                       foreach ($projet->taches as $tache) {
-                               $lignes[] = array('montant' => $tache->budget, 'titre' => $tache->nom, 'description' => '');
-                       }
-                       $facture->lignes = $lignes;
-               } elseif ($facture_id == 'ws') {
-                       if (is_null($projet_id)) {
-                               $daoClient = new commonDAOClient($core->con);
-                               $client = $daoClient->selectById($_POST['client_id']);
-                               $facture->projet_id = 'new';
-                               $facture->client = $client->rs;
-                               $facture->client_id = $client->utilisateur_id;
-                               $facture->projet = __('Nouveau projet');
-                               $facture->nom = 'Fluidbook';
-                       } else {
-                               $projet = $daoProjet->selectById($projet_id);
-                               $facture->projet_id = $projet->projet_id;
-                               $facture->client = $projet->client;
-                               $facture->projet = $facture->nom = $projet->nom;
-                       }
-                       $lignes = array();
-                       $b = $core->con->select('SELECT * FROM ws.book WHERE bid IN(' . implode(',', array_keys($_POST['book_facture'])) . ')');
-                       while ($b->fetch()) {
-                               $lignes[] = array('book' => $b->bid, 'montant' => 0, 'titre' => 'Fluidbook &laquo; ' . $b->titre . ' &raquo;', 'description' => '');
-                       }
-                       $facture->lignes = $lignes;
-               }
-
-               $res = '<div id="editeDevis">';
-               $res .= '<form action="previewFacture" method="post">';
-               $res .= '<div id="devisTop">';
-               // Adresse
-               if ($facture->facture_id == 'new' && is_null($projet_id)) {
-                       $class = 'empty-field';
-                       $default_id = '';
-                       $default = __('Entrez le nom du projet ou du client');
-               } else {
-                       $class = '';
-                       $default_id = $facture->projet_id;
-                       $default = $facture->projet_id . ' - ' . $facture->projet . ' (' . $facture->client . ')';
-               }
-
-               $res .= '<div id="factureAdresse">';
-               $res .= form::field('projet_nom', 40, 128, $default, $class);
-               $res .= form::hidden('projet', $default_id);
-               $res .= '<div id="factureAdresseDisplay">';
-               if ($facture->projet_id != 'new') {
-                       $res .= commonUrl::adresse(null, $facture->projet_id, 'facture', $facture->adresse);
-               } else {
-                       $res .= commonUrl::adresse($facture->client_id, null, 'facture', $facture->adresse);
-                       $res .= form::hidden('client', $facture->client_id);
-               }
-
-               $res .= '</div>';
-               $res .= form::textarea('texte_complementaire', 50, 2, $facture->texte_complementaire);
-               $res .= '</div>';
-               // Titre
-               $res .= '<div id="devisTitre">';
-               $res .= 'Date : ' . cubeForm::date('date_creation', $facture->date_creation) . '<br /><br />';
-               $res .= form::hidden('facture_id', $facture->facture_id);
-               $res .= form::textarea('nom', 40, 4, $facture->nom);
-               $res .= '</div>';
-               $res .= '</div>';
-
-               $res .= '<div id="devisMiddle">';
-               $res .= '<div id="devisLignes">';
-               // Lignes du devis
-               $nb_lignes = max(4, count($facture->lignes) + 2);
-
-               for ($i = 0; $i < $nb_lignes; $i++) {
-                       if (isset($facture->lignes[$i])) {
-                               $titre = $facture->lignes[$i]['titre'];
-                               $description = $facture->lignes[$i]['description'];
-                               $montant = $facture->lignes[$i]['montant'];
-                               $book = isset($facture->lignes[$i]['book']) ? $facture->lignes[$i]['book'] : null;
-                       } else {
-                               $titre = $description = $montant = '';
-                       }
-
-                       $res .= '<div class="devisLigne">';
-
-                       $res .= '<div class="devisLigneRight">';
-                       $res .= form::field(array('montant[]'), 6, 15, $montant) . " €";
-                       if (isset($book) && !is_null($book)) {
-                               $res .= form::hidden(array('book[]'), $book);
-                       }
-                       $res .= '</div>';
-                       $res .= '<div class="devisLigneLeft">';
-                       $res .= form::field(array('titre[]'), 80, 256, htmlspecialchars($titre, ENT_QUOTES)) . '<br /><br />';
-                       $res .= form::textarea(array('description[]'), 80, 2, $description);
-                       $res .= '</div>';
-
-                       $res .= '</div>';
-               }
-
-               $res .= '</div>';
-               $res .= '</div>';
-               $res .= '<div id="devisBottom">' . cubeMedia::spacer(10, 10) . '</div>';
-               $res .= '<div class="right"><a href="#" class="submit">' . $core->typo->BoutonOK('Enregistrer et prévisualiser') . '</a></div>';
-               $res .= '</form>';
-               $res .= '</div>';
-               return $res;
-       }
-
-       public static function previewFacture($args)
-       {
-               global $core;
-               commonDroits::min(1);
-               $dao = new extranetDAOFacture($core->con);
-               $facture = $dao->selectById($args[1]);
-
-               $res = commonPage::barre();
-               $res .= commonPage::tMain();
-               $res .= commonPage::bh();
-               $res .= '<iframe src="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" width="960" height="1000" frameborder="0"></iframe>';
-
-               $res .= '<div class="right">' . '<a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '">' . $core->typo->BoutonOK(__('Editer la facture')) . '</a> ';
-               if ($facture->status == 0) {
-                       $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax" title="' . __("La facture est sur le point d'être validée. Veuillez confirmer votre choix ?") . '">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';
-               } else {
-                       $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';
-               }
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function formPrintFactures()
-       {
-               global $core;
-               $last = $core->user->getLastPrint();
-               $res = '';
-               if ($last['date']) {
-                       $res .= '<tr><td>' . __('Dernière factures imprimées') . ' : </td><td>' . __('Factures') . ' <a href="' . SITE_PATH . 'voirfacture/print_' . $core->user->utilisateur_id . '_' . $last['date'] . '" class="popupA4">' . $last['pages'] . ' (' . date('Y-m-d', $last['date']) . ')</a></td></tr>';
-               }
-               $res .= '<tr><td>' . __('Factures à imprimer') . '</td><td>' . form::field('factures', 20, 64) . '</td></tr>';
-               $res .= '<tr><td colspan="2"><em>' . __('Ex') . ' : 1;3-5;7;9 ' . __('signifie factures') . ' 1,3,4,5,7,9</em></td></tr>';
-               return $res;
-       }
-
-       public static function chiffres($args)
-       {
-               global $core;
-               commonDroits::min(2);
-               // $res = commonPage::barre(null, null, null, array('<a href="http://www.google.com/calendar/" class="blank">' . $core->typo->Favoris(__('Gérer les charges sur Google Agenda')) . '</a>'));
-               $res = commonPage::barre(null, null, null, null);
-               $res .= commonPage::tMain();
-               $res .= extranetPageChiffres::listeChiffres();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function traduction($args)
-       {
-               global $core;
-               commonDroits::min(1);
-               $res = commonPage::barre();
-               $res .= commonPage::tMain("traduction");
-               $res .= commonPage::bh();
-               $res .= '<form action="saveTrad" method="post">';
-               $res .= '<table class="liste">';
-               $res .= '<tr><th>' . __("Traduction de l'application en anglais") . '</th><th></th></tr>';
-               $res .= '</table>';
-               $res .= cubeLang::translationForm(array(ROOT . '/inc/commons', ROOT . '/inc/extranet', ROOT . '/inc/ws', COMPOSER_SOURCES), 'en', ROOT . '/l10n', '', array(), '<a href="#" class="submit">' . $core->typo->BoutonOK('Enregistrer') . '</a>');
-               $res .= '</form>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function cleanTimereport($args)
-       {
-               global $core;
-
-               $r = $core->con->select('SELECT * FROM timereport');
-               $t = array();
-               while ($r->fetch()) {
-                       if (!isset($t[date('Y', $r->date)][$r->utilisateur_id][$r->tache_id])) {
-                               $t[date('Y', $r->date)][$r->utilisateur_id][$r->tache_id] = 0;
-                       }
-                       $t[date('Y', $r->date)][$r->utilisateur_id][$r->tache_id] += $r->heures;
-               }
-
-               foreach ($t as $annee => $t1) {
-                       if ($annee == date('Y')) {
-                               continue;
-                       }
-                       $limit = cubeDate::limitYear($annee);
-                       $core->con->execute('DELETE FROM timereport WHERE date BETWEEN ' . $limit['start'] . ' AND ' . $limit['end']);
-                       $c = $core->con->openCursor('timereport');
-                       $c->date = mktime(1, 1, 1, 1, 1, $annee);
-                       foreach ($t1 as $uid => $t2) {
-                               $c->utilisateur_id = $uid;
-                               foreach ($t2 as $tache_id => $heures) {
-                                       $c->tache_id = $tache_id;
-                                       $c->heures = $heures;
-                                       $c->insert();
-                               }
-                       }
-               }
-       }
-
-       public static function rh($args)
-       {
-               global $core;
-               commonDroits::min(2);
-               $res = commonPage::barre();
-               $res .= commonPage::tMain("rh");
-               $res .= commonPage::bh();
-               $res .= '<div id="listeEquipiers">';
-               $res .= extranetUrl::listeRh(null, null);
-               $res .= '</div>';
-               $res .= commonPage::bf();
-               $res .= commonPage::bMain();
-               return $res;
-       }
-
-       public static function listeRh($dashboard = null, $settings = null)
-       {
-               global $core;
-               commonDroits::min(2);
-               $settings = is_null($settings) ? $core->user->getSettings('equipiers') : $settings;
-               $change = is_null($dashboard) ? 'Equipier' : 'Dashboard/' . $dashboard;
-               $dao = new commonDAOEquipier($core->con);
-               $liste = $dao->getListe(null, $settings['orderby'], $settings['sens'], $settings['limit']);
-
-               $res = '<table class="liste">';
-               $res .= '<tr><th>' . commonUrl::orderby('#', 'utilisateur_id', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Agence'), 'agence', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('E-mail'), 'email', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>' . commonUrl::orderby(__('Grade'), 'grade', $settings, 'sort' . $change) . '</th>';
-               $res .= '<th>Notes</th>';
-               // $res .= '<th class="min"></th><th class="min"></th></tr>';
-               $i = 0;
-               foreach ($liste as $id => $equipier) {
-                       $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
-                       $res .= '<tr' . $odd . '>';
-                       $res .= '<td>' . $equipier->utilisateur_id . '</td>';
-                       $res .= '<td>' . $equipier->agence . '</td>';
-                       $res .= '<td>' . $equipier->prenom . ' ' . $equipier->nom . '</td>';
-
-                       $email = strlen($equipier->email) > 20 ? substr($equipier->email, 0, 17) . '...' : $equipier->email;
-
-                       $res .= '<td><a href="mailto:' . cubeMail::encodeForURL($equipier->email) . '">' . $email . '</a></td>';
-                       $res .= '<td>' . $core->grades[$equipier->grade] . '</td>';
-                       $res .= '<td class="action center"><a href="#" class="popup" rel="formNotes/' . $equipier->utilisateur_id . '">' . cubeMedia::image(IMG . '/postit.png') . '</a></td>';
-                       // $res .= '<td class="action"><a href="#" class="popup" rel="formClient/' . $equipier->utilisateur_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
-                       // $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeClient/' . $equipier->utilisateur_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce client ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
-                       $res .= '</tr>';
-                       $i++;
-               }
-               /* if (!isset($settings['search']) || is_null($settings['search'])) {
-                 $odd = cubeMath::isOdd($i)?' class="odd"':'';
-                 $res .= '<tr' . $odd . '><td colspan="10">';
-                 $res .= commonPage::pager($settings['page'], $dao->count() , $settings['par_page'], 'page' . $change . '/%d');
-                 $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients'));
-                 $res .= '</td></tr>';
-                 } */
-               $res .= '</table>';
-               return $res;
-       }
+    public static function clients($args)
+    {
+        global $core;
+        cubePage::truePopup();
+        cubePage::autoComplete();
+        cubePage::emptyfield();
+        commonDroits::min(1);
+        $settings = $core->user->getSettings('clients');
+
+        $shortcuts = array();
+        $shortcuts[] = '<a href="#" class="popup" rel="formClient/new">' . $core->typo->Ajouter('Créer un nouveau client') . '</a>';
+        $filtres = array();
+        $filtres[] = new commonFiltre(__('Ayant un projet'), 'status_client_projet', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Ayant des impayés'), 'impaye', $settings['filtres']);
+        $res = commonPage::barre($filtres, 'filtreClients', 'clients', $shortcuts);
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeClients">';
+        $res .= self::listeClients();
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function listeClients($dashboard = null, $settings = null)
+    {
+        global $core;
+        commonDroits::min(1);
+        $settings = is_null($settings) ? $core->user->getSettings('clients') : $settings;
+        $change = is_null($dashboard) ? 'Client' : 'Dashboard/' . $dashboard;
+        $dao = new commonDAOEntreprise($core->con);
+        if (isset($settings['search']) && !is_null($settings['search'])) {
+            $dao->setSearch($settings['search']);
+        }
+        $dao->setFiltres($settings['filtres']);
+        $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
+
+        $res = '<table class="liste">';
+        $res .= '<tr><th>' . commonUrl::orderby('#', 'entreprise_id', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Raison sociale'), 'nom', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . __('Contacts') . '</th>';
+        $res .= '<th>' . __('Type') . '</th>';
+        $res .= '<th>' . commonUrl::orderby('<abbr title="' . __("Chiffre d'affaire") . '">CA</abbr>', 'ca', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby('Impayés', 'impaye', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="min"></th><th class="min"></th></tr>';
+        $i = 0;
+        foreach ($liste as $id => $client) {
+            if (!is_array($client->contacts)) {
+                continue;
+            }
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $client->entreprise_id . '</td>';
+            $res .= '<td>' . $client->nom . '</td>';
+            $contacts = array();
+
+            foreach ($client->contacts as $c) {
+                $contacts[] = '<a href="#" class="popup" rel="formContact/' . $c->utilisateur_id . '">' . $c->prenom . ' ' . $c->nom . '</a>';
+            }
+
+            $res .= '<td id="contacts_' . $client->entreprise_id . '">' . implode(', ', $contacts) . '</td>';
+            $res .= '<td class="nowrap">' . $core->client_type[$client->type] . '</td>';
+            $res .= '<td class="nowrap">';
+            if ($client->ca) {
+                $res .= '<a href="#" class="popup" rel="clientDetailCa/' . $client->entreprise_id . '" title="' . __("Voir le détail du chiffre d'affaire") . '">' . number_format($client->ca, 0, ',', ' ') . '</a>';
+            }
+
+            $res .= '</td>';
+            if ($client->impaye) {
+                $res .= '<td class="nowrap"><a href="#" class="popup" rel="clientDetailImpaye/' . $client->entreprise_id . '">' . number_format($client->impaye, 0, '.', ' ') . '</a></td>';
+            } else {
+                $res .= '<td></td>';
+            }
+
+            $res .= '<td class="action"><a href="#" class="popup" rel="formClient/' . $client->entreprise_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+            if (is_null($client->ca)) {
+                $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeClient/' . $client->entreprise_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce client ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
+            } else {
+                $res .= '<td></td>';
+            }
+            $res .= '</tr>';
+            $i++;
+        }
+        if (!isset($settings['search']) || is_null($settings['search'])) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '><td colspan="10">';
+            $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
+            $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients'));
+            $res .= '</td></tr>';
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function clientDetailCa($entreprise_id)
+    {
+        global $core;
+        $dao = new commonDAOEntreprise($core->con);
+        $annees = $dao->getCaDetails($entreprise_id);
+        $res = '';
+        $i = 0;
+        foreach ($annees as $annee => $ca) {
+            $class = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $class . '><td><strong>' . $annee . '</strong></td><td>' . number_format($ca, 0, ',', ' ') . ' €</td></tr>';
+            $i++;
+        }
+        return $res;
+    }
+
+    public static function clientDetailImpaye($entreprise_id)
+    {
+        global $core;
+        $dao = new extranetDAOFacture($core->con);
+        $daoClient = new commonDAOEntreprise($core->con);
+        $factures = $dao->getImpayesOfClient($entreprise_id);
+        $client = $daoClient->selectById($entreprise_id);
+        $res = '';
+        $i = 0;
+        foreach ($factures as $facture) {
+            $class = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $class . '>';
+            $res .= '<td>' . $facture->facture_id . '</td>';
+            $res .= '<td>';
+            if ($facture->facture_id > 0) {
+                $res .= '<a href="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" class="popupA4">' . $facture->nom . '</a>';
+            } else {
+                $res .= $facture->nom;
+            }
+            $res .= '</td>';
+            $tva = cubeTaxes::tva($client->pays);
+            $res .= '<td>' . number_format($facture->total_ht, 0, ',', '') . ' €';
+            if ($tva > 0 && $tva != 'UE') {
+                $res .= ' HT </td><td> ' . number_format(cubePrices::HTtoTTC($facture->total_ht, $tva), 2, ',', '') . ' € TTC';
+            } else {
+                $res .= '<td></td>';
+            }
+            $res .= '</td></tr>';
+            $i++;
+        }
+        return $res;
+    }
+
+    public static function formClient($entreprise_id = 'new')
+    {
+        global $core;
+        commonDroits::min(1);
+        $dao = new commonDAOEntreprise($core->con);
+        $daoUtilisateur = new commonDAOUtilisateur($core->con);
+        if ($entreprise_id == 'new') {
+            $client = $dao->cree();
+        } else {
+            $client = $dao->selectById($entreprise_id);
+        }
+
+        $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('entreprise_id', $client->entreprise_id) . '' . $client->entreprise_id . '</td></tr>';
+        $res .= '<tr><td>' . __('Raison sociale') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
+        $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
+        $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';
+        $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';
+        $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';
+        $res .= '<tr><td>' . __('Adresse de facturaton') . '</td><td>' . form::textarea('adresse_facturation', 40, 3, $client->adresse_facturation) . '</td></tr>';
+        $res .= '<tr><td>' . __('Site internet') . '</td><td>' . form::field('site', 30, 128, $client->site) . '</td></tr>';
+        $res .= '<tr><td>' . __('Numéro de TVA intracommunautaire') . '</td><td>' . form::field('tva_intra', 15, 64, $client->tva_intra) . '</td></tr>';
+        $res .= '<tr><td>' . __('Type de société') . '</td><td>' . form::combo('type', array_flip($core->client_type), $client->type) . '</td></tr>';
+        $res .= '<tr class="light"><th colspan="2" class="light"><strong>' . __('Fluidbook Workshop') . '</strong></th></tr>';
+        $res .= '<tr class="odd"><td>' . __('Grade') . '</td><td>' . form::combo('ws_grade', array_flip($core->ws_grades), $client->ws_grade) . '</td></tr>';
+        if ($entreprise_id == 'new' || !$client->ws_admin) {
+            $class = 'empty-field';
+            $default_id = '';
+            $default = __("Entrez le nom du revendeur ou de l'administrateur");
+        } else {
+            $class = '';
+            $default_id = $client->ws_admin;
+            $wsa = $daoUtilisateur->selectById($client->ws_admin, 'utilisateurs_entreprise');
+            $default = $wsa->utilisateur_id . ' - ' . $wsa->rs . ' (' . $wsa->prenom . ' ' . $wsa->nom . ')';
+        }
+
+        $d = $dao->getWSDatas($entreprise_id);
+
+        $res .= '<tr class="odd"><td>' . __('Revendeur / Administrateur') . '</td><td>' . form::field('ws_admin_nom', 60, 128, $default, $class) . form::hidden('ws_admin', $default_id) . '</td></tr>';
+        if (!is_null($d)) {
+            $res .= '<tr class="odd"><td>' . __('Entité facturable') . '</td><td>' . $d->facturable->prenom . ' ' . $d->facturable->nom . ' (' . $d->facturable->rs . ')</td></tr>';
+            $res .= '<tr class="odd"><td>' . __('Administrateur responsable') . '</td><td>' . $d->administrateur->prenom . ' ' . $d->administrateur->nom . ' (' . $d->administrateur->rs . ')</td></tr>';
+        }
+        if ($entreprise_id == 'new') {
+            $daoContact = new commonDAOClient($core->con);
+            $contact = $daoContact->cree();
+            $res .= '<tr><th colspan="2" class="light"><strong>' . __('Contact') . '</strong></th></tr>';
+            $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field(array('contact[email]'), 30, 128, $contact->email) . '</td></tr>';
+            $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field(array('contact[password]'), 30, 128, $contact->password) . '</td></tr>';
+            $res .= '<tr><td>' . __('Prénom') . '</td><td>' . form::field(array('contact[prenom]'), 30, 128, $contact->prenom) . '</td></tr>';
+            $res .= '<tr><td>' . __('Nom') . '</td><td>' . form::field(array('contact[nom]'), 30, 128, $contact->nom) . '</td></tr>';
+            $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field(array('contact[telephone]'), 20, 128, $contact->telephone) . '</td></tr>';
+            $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field(array('contact[mobile]'), 20, 128, $contact->mobile) . '</td></tr>';
+            $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field(array('contact[fax]'), 20, 128, $contact->fax) . '</td></tr>';
+            $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo(array('contact[lang]'), cubeLang::getAvailableLangs(true), $contact->lang) . '</td></tr>';
+        }
+        return $res;
+    }
+
+    public static function listeContacts($entreprise_id)
+    {
+        global $core;
+        commonDroits::min(1);
+        $dao = new commonDAOEntreprise($core->con);
+        $contacts = $dao->getContacts($entreprise_id);
+
+        $res = '<table class="liste light">';
+        $res .= '<tr class="light"><th colspan="5"><a href="" class="popup" rel="formContact/new/' . $entreprise_id . '">' . $core->typo->Contact('Ajouter un contact') . '</a></th></tr>';
+        $i = 0;
+        foreach ($contacts as $contact) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '><td>' . trim($contact->prenom . ' ' . $contact->nom) . '</td>';
+            $res .= '<td><a href="mailto:' . trim($contact->prenom . ' ' . $contact->nom) . '<' . $contact->email . '>">' . $contact->email . '</a></td>';
+            $res .= '<td class="min"><a href="' . SITE_PATH . 'fichiers/' . $contact->utilisateur_id . '">FTP</a></td>';
+            //$res .= '<td><a class="ajax" href="#" rel="connectAs/' . $contact->utilisateur_id . '">Se connecter comme ...</a></td>';
+            $res .= '<td class="right"><a href="#" rel="formContact/' . $contact->utilisateur_id . '" class="popup">' . cubeMedia::image(IMG . '/edit.png') . '</a></td></tr>';
+            $i++;
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function formContact($client_id = 'new', $entreprise_id = null)
+    {
+        global $core;
+        commonDroits::min(1);
+
+        $dao = new commonDAOClient($core->con);
+        if ($client_id == 'new') {
+            $client = $dao->creeFromEntreprise($entreprise_id);
+        } else {
+            $client = $dao->selectById($client_id);
+        }
+
+        $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('grade', 0) . form::hidden('entreprise', $client->entreprise) . form::hidden('utilisateur_id', $client->utilisateur_id) . '' . $client->utilisateur_id . '</td></tr>';
+        $res .= '<tr><td>' . __('Login activé') . '</td><td>' . form::hidden('enabled', 0) . form::checkbox('enabled', 1, $client->enabled) . '</td></tr>';
+        $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field('email', 30, 128, $client->email) . '</td></tr>';
+        //$res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field('password', 30, 128, $client->password) . '</td></tr>';
+        $res .= '<tr><td>' . __('Prénom du contact') . '</td><td>' . form::field('prenom', 30, 128, $client->prenom) . '</td></tr>';
+        $res .= '<tr><td>' . __('Nom du contact') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
+        $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
+        $res .= '<tr><td>' . __('Code postal') . '</td><td>' . form::field('code_postal', 10, 20, $client->code_postal) . '</td></tr>';
+        $res .= '<tr><td>' . __('Ville') . '</td><td>' . form::field('ville', 30, 128, $client->ville) . '</td></tr>';
+        $res .= '<tr><td>' . __('Pays') . '</td><td>' . form::combo('pays', cubeCountry::getList(), $client->pays) . '</td></tr>';
+        $res .= '<tr><td>' . __('Téléphone') . '</td><td>' . form::field('telephone', 20, 128, $client->telephone) . '</td></tr>';
+        $res .= '<tr><td>' . __('Mobile') . '</td><td>' . form::field('mobile', 20, 128, $client->mobile) . '</td></tr>';
+        $res .= '<tr><td>' . __('Fax') . '</td><td>' . form::field('fax', 20, 128, $client->fax) . '</td></tr>';
+        $res .= '<tr><td>' . __('Langue') . '</td><td>' . form::combo('lang', cubeLang::getAvailableLangs(true), $client->lang) . '</td></tr>';
+        if ($client_id != 'new') {
+            $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
+            $res .= '<tr><td></td><td><a href="' . SITE_PATH . 'fichiers/' . $client->utilisateur_id . '">' . __('FTP') . '</a></td></tr>';
+            //$res .= '<tr><td></td><td><a class="ajax" href="#" rel="connectAs/' . $client->utilisateur_id . '">' . __('Se connecter comme ...') . '</a></td></tr>';
+            $res .= '<tr><td>' . __("Paramètres de connexion à l'extranet") . '</td><td>' . __('Adresse') . ' : https://extranet.cubedesigners.com/<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . __('Utiliser la fonction "Mot de passe oublié" pour le créer ou le réinitialiser') . '</td></tr>';
+            $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
+            // $res .= '<tr><td>' . __("Paramètres de connexion au FTP") . '</td><td>' . __('Serveur FTP') . ' : extranet.cubedesigners.com (ftp://extranet.cubedesigners.com)<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . $client->password . '</td></tr>';
+        }
+        return $res;
+    }
+
+    public static function formNotes($utilisateur_id)
+    {
+        global $core;
+        commonDroits::min(1);
+        $dao = new commonDAOUtilisateur($core->con);
+        $utilisateur = $dao->selectById($utilisateur_id);
+        $res = '<tr><td colspan="2">' . form::hidden('utilisateur_id', $utilisateur_id) . '</td></tr>';
+        $res .= '<tr><td colspan="2">' . form::textarea('notes', 100, 30, $utilisateur->notes) . '</td></tr>';
+        $res .= '<tr><td colspan="2"></td></tr>';
+        return $res;
+    }
+
+    public static function projets($args)
+    {
+        global $core;
+        commonDroits::min(0.5);
+
+        $settings = $core->user->getSettings('projets');
+
+        $shortcuts = array();
+        if ($core->user->grade >= 1) {
+            $shortcuts[] = '<a href="#" class="popup" rel="formProjet/new">' . $core->typo->Ajouter('Créer un projet') . '</a>';
+        }
+
+        $filtres = array();
+        $filtres[] = new commonFiltre(__('Crée par'), 'equipier', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Status'), 'status_projet', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Année'), 'annee', $settings['filtres']);
+
+        $res = commonPage::barre($filtres, 'filtreProjet', 'projets', $shortcuts);
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeProjets">';
+        $res .= self::listeProjets();
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function listeProjets($dashboard = null, $settings = null)
+    {
+        global $core;
+        commonDroits::min(0.5);
+        $settings = is_null($settings) ? $core->user->getSettings('projets') : $settings;
+        $change = is_null($dashboard) ? 'Projet' : 'Dashboard/' . $dashboard;
+
+        $res = '<table class="liste">';
+        $res .= '<tr><th>' . commonUrl::orderby('#', 'projet_id', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Projet'), 'nom', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Année'), 'annee_fin', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Chef'), 'chef', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';
+        if ($core->user->grade >= 1) {
+            $res .= '<th>' . commonUrl::orderby(__('Facturé'), 'rapport_facturation', $settings, 'sort' . $change) . '</th>';
+            $res .= '<th>' . commonUrl::orderby(__('Payé'), 'rapport_paiement', $settings, 'sort' . $change) . '</th>';
+            $res .= '<th>' . commonUrl::orderby('<abbr title="' . __('Budget') . '">B</abbr>', 'budget', $settings, 'sort' . $change) . '</th>';
+        }
+        $res .= '<th>' . commonUrl::orderby('<abbr title="' . __('Progression') . '">Pr</abbr>', 'progression', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="min"></th></tr>';
+
+        $dao = new extranetDAOProjet($core->con);
+        $dao->setFiltres($settings['filtres']);
+        if (isset($settings['search']) && !is_null($settings['search'])) {
+            $dao->setSearch($settings['search']);
+        }
+        $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
+
+        $i = 0;
+        foreach ($liste as $projet) {
+            $droits = extranetDroits::projet($projet, false);
+
+            $projet->progression = !$projet->progression ? '-' : $projet->progression . '%';
+            $projet->jours_prevus = !$projet->jours_prevus ? '-' : $projet->jours_prevus;
+            $projet->jours_consommes = !$projet->jours_consommes ? '-' : $projet->jours_consommes;
+
+            $projet->budget = !$projet->budget || !$droits ? '-' : $projet->budget;
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $projet->projet_id . '</td>';
+            $res .= '<td>' . $projet->nom . '</td>';
+            $res .= '<td>' . $projet->client . '</td>';
+            $res .= '<td>' . $projet->annee_fin . '</td>';
+            $res .= '<td>' . $projet->chef . '</td>';
+            if ($droits) {
+                $res .= '<td><a href="#" class="ajax" rel="changeProjetsStatus/' . $projet->projet_id . '" title="' . __('Modifier le status du projet') . '">' . $core->projets_status[$projet->status] . '</a></td>';
+            } else {
+                $res .= '<td>' . $core->projets_status[$projet->status] . '</td>';
+            }
+
+            $rf = $projet->rapport_facturation;
+            if ($projet->budget == '-') {
+                $rapport_facturation = '-';
+            } elseif (!$rf) {
+                $rapport_facturation = __('Non');
+            } elseif ($rf == 1) {
+                $rapport_facturation = __('Oui');
+            } elseif ($rf < 1) {
+                $rapport_facturation = __('Partie');
+            } elseif ($rf > 1) {
+                $rapport_facturation = __('Trop');
+            }
+
+            $rp = $projet->rapport_paiement;
+            if ($projet->budget == '-') {
+                $rapport_paiement = '-';
+            } elseif (!$rp) {
+                $rapport_paiement = __('Non');
+            } elseif ($rp == 1) {
+                $rapport_paiement = __('Oui');
+            } elseif ($rp < 1) {
+                $rapport_paiement = __('Partie');
+            } elseif ($rp > 1) {
+                $rapport_paiement = __('Trop');
+            }
+
+            if ($core->user->grade >= 1) {
+                $res .= '<td>';
+                if ($projet->status == 1 && !$rf) {
+                    $res .= '<a href="' . SITE_PATH . 'editefacture/new/' . $projet->projet_id . '" title="' . __('Créer la facture pour ce projet') . '">' . $rapport_facturation . '</a>';
+                } else {
+                    $res .= $rapport_facturation;
+                }
+                $res .= '</td>';
+                $res .= '<td>' . $rapport_paiement . '</td>';
+
+                $res .= '<td>' . $projet->budget . '</td>';
+            }
+            // $res .= '<td>' . $projet->jours_prevus . '</td>';
+            // $res .= '<td>' . $projet->jours_consommes . '</td>';
+            $res .= '<td>' . $projet->progression . '</td>';
+            $res .= '<td><a href="' . SITE_PATH . 'projet/' . $projet->projet_id . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
+
+            $res .= '</tr>';
+            $i++;
+        }
+        if (!isset($settings['search']) || is_null($settings['search'])) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '><td colspan="11">';
+            $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
+            $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('projets'));
+            $res .= '</td></tr>';
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function projet($args)
+    {
+        global $core;
+        commonDroits::min(0.5);
+
+        $shortcuts = array();
+        if ($core->user->grade >= 1) {
+            $shortcuts[] = '<a href="#" class="popup" rel="formTacheNormale/new/' . $args[1] . '">' . $core->typo->Ajouter('Créer une tâche') . '</a>';
+            $shortcuts[] = '<a href="#" class="popup" rel="formTacheSousTraitee/new/' . $args[1] . '">' . $core->typo->Ajouter('Créer une tâche sous-traitée') . '</a>';
+        }
+
+        $res = commonPage::barre(null, null, null, $shortcuts);
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeProjet">';
+        $res .= self::listeProjet($args[1]);
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function listeProjet($projet_id)
+    {
+        global $core;
+        commonDroits::min(0.5);
+
+        $res = '<table class="liste">';
+        $res .= '<tr><th>#</th>';
+        $res .= '<th><strong>' . __('Projet') . '</strong> / ' . __('Tâche') . '</th>';
+        $res .= '<th><strong>' . __('Client') . '</strong> / ' . __('Catégorie') . '</th>';
+        $res .= '<th>' . __('Année') . '</th>';
+        $res .= '<th>' . __('Chef de projet') . '</th>';
+        $res .= '<th>' . __('Status') . '</th>';
+        if ($core->user->grade >= 1) {
+            $res .= '<th><abbr title="' . __('Budget') . '">B</abbr></th>';
+        }
+        $res .= '<th><abbr title="' . __('Jours prévus') . '">Pl</abbr></th>';
+        $res .= '<th><abbr title="' . __('Jours consommés') . '">Co</abbr></th>';
+        $res .= '<th><abbr title="' . __('Progression') . '">Pr</abbr></th>';
+        $res .= '<th class="min"></th><th class="min"></th></tr>';
+
+        $dao = new extranetDAOProjet($core->con);
+        $projet = $dao->selectById($projet_id);
+
+        $hasFacture = $dao->hasFacture($projet_id);
+
+        $droits = extranetDroits::projet($projet, false);
+
+        $projet->progression = !$projet->progression ? '-' : $projet->progression . '%';
+        $projet->jours_prevus = !$projet->jours_prevus ? '-' : $projet->jours_prevus;
+        $projet->jours_consommes = !$projet->jours_consommes ? '-' : $projet->jours_consommes;
+
+        $projet->budget = !$projet->budget || !$droits ? '-' : $projet->budget;
+
+        $res .= '<tr class="bold">';
+        $res .= '<td>' . $projet->projet_id . '</td>';
+        $res .= '<td>' . $projet->nom . '</td>';
+        $res .= '<td>' . $projet->client . '</td>';
+        $res .= '<td>' . $projet->annee_fin . '</td>';
+        $res .= '<td>' . $projet->chef . '</td>';
+        if ($droits) {
+            $res .= '<td><a href="#" class="ajax" rel="changeProjetStatus/' . $projet->projet_id . '" title="' . __('Modifier le status du projet') . '">' . $core->projets_status[$projet->status] . '</a></td>';
+        } else {
+            $res .= '<td>' . $core->projets_status[$projet->status] . '</td>';
+        }
+        if ($core->user->grade >= 1) {
+            $res .= '<td>' . $projet->budget . '</td>';
+        }
+        $res .= '<td>' . $projet->jours_prevus . '</td>';
+        $res .= '<td>' . $projet->jours_consommes . '</td>';
+        $res .= '<td>' . $projet->progression . '</td>';
+        if ($droits) {
+            $res .= '<td class="action"><a href="#" class="popup" rel="formProjet/' . $projet->projet_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+            if (!count($projet->taches) && !$hasFacture) {
+                $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeProjet/' . $projet->projet_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce projet ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
+            } else {
+                $res .= '<td></td>';
+            }
+        } else {
+            $res .= '<td></td><td></td>';
+        }
+        $res .= '</tr>';
+        $i = 1;
+        foreach ($projet->taches as $tache) {
+            $tache->budget = !$tache->budget || !$droits ? '-' : $tache->budget;
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>T' . $i . '</td>';
+            $res .= '<td>' . $tache->nom . '</td>';
+            $res .= '<td>' . $core->categories[$tache->categorie] . '</td>';
+            if (count($tache->books)) {
+                $n = array();
+                foreach ($tache->books as $b) {
+                    $n[] = '<a class="blank" href="' . WS_URL . '/publications/' . $b . '">' . $b . '</a>';
+                }
+                $res .= '<td colspan="3">Fluidbooks # ' . implode(', ', $n) . '</td>';
+            } else {
+                $res .= '<td colspan="3"></td>';
+            }
+
+            if ($core->user->grade >= 1) {
+                $res .= '<td>' . $tache->budget . '</td>';
+            }
+
+            if ($tache instanceof extranetTacheNormale) {
+                $progression = !$tache->progression ? '-' : $tache->progression . '%';
+                $jours_prevus = !$tache->jours_prevus ? '-' : $tache->jours_prevus;
+                $jours_consommes = !$tache->jours_consommes ? '-' : $tache->jours_consommes;
+                $res .= '<td>' . $jours_prevus . '</td>';
+                $res .= '<td>' . $jours_consommes . '</td>';
+                $res .= '<td>' . $progression . '</td>';
+                if ($droits) {
+                    $res .= '<td class="action"><a href="#" class="popup" rel="formTacheNormale/' . $tache->tache_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+                } else {
+                    $res .= '<td></td>';
+                }
+            } else {
+                $res .= '<td colspan="3">' . __('Tâche sous-traitée') . '</td>';
+                if ($droits) {
+                    $res .= '<td class="action"><a href="#" class="popup" rel="formTacheSousTraitee/' . $tache->tache_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+                } else {
+                    $res .= '<td></td>';
+                }
+            }
+
+            $res .= '<td class="action">';
+            if ($core->user->grade >= 1) {
+                $res .= '<a href="#" class="ajax" rel="supprimeTache/' . $tache->tache_id . '" title="' . __('Supprimer cette tâche va également supprimer les timereports associés. Êtes vous certain de vouloir supprimer cette tâche ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a>';
+            }
+            $res .= '</td>';
+
+            $res .= '</tr>';
+            $i++;
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function formProjet($projet_id = 'new')
+    {
+        global $core;
+        commonDroits::min(1);
+
+        $dao = new extranetDAOProjet($core->con);
+        if ($projet_id == 'new') {
+            $projet = $dao->cree($core->user->utilisateur_id);
+        } else {
+            $projet = $dao->selectById($projet_id);
+        }
+
+        $daoClient = new commonDAOClient($core->con);
+        $clients = $daoClient->getListe();
+
+        $listeClients = array();
+        foreach ($clients as $client) {
+            if (empty($client->utilisateur_id)) {
+                continue;
+            }
+            $listeClients[trim($client->rs) . ' (' . $client->prenom . ' ' . $client->nom . ')'] = $client->utilisateur_id;
+        }
+        ksort($listeClients);
+        $listeClients = array_merge(array('--' => ''), $listeClients);
+
+        $daoEquipier = new commonDAOEquipier($core->con);
+        $equipiers = $daoEquipier->getListe();
+
+        $listeEquipiers = array();
+        foreach ($equipiers as $equipier) {
+            $listeEquipiers[$equipier->prenom . ' ' . $equipier->nom . ' (' . $equipier->agence . ')'] = $equipier->utilisateur_id;
+        }
+
+        $daoDevis = new extranetDAODevis($core->con);
+        $devis = $daoDevis->getListeValidesLibres($projet_id);
+        $listeDevis = array('--' => 0);
+        foreach ($devis as $id => $dev) {
+            $listeDevis[$dev->nom] = $dev->devis_id;
+        }
+
+        $res = '<tr><td>' . __('Numéro de projet') . '</td><td>' . form::hidden('projet_id', $projet->projet_id) . '' . $projet->projet_id . '</td></tr>';
+        $res .= '<tr><td>' . __('Nom du projet') . '</td><td>' . form::textarea('nom', 50, 3, html::escapeHTML($projet->nom)) . '</td></tr>';
+        $res .= '<tr><td>' . __('Chef de projet') . '</td><td>';
+        if ($core->user->grade > 1) {
+            $res .= form::combo('chef', $listeEquipiers, $projet->chef_id);
+        } else {
+            $res .= form::hidden('chef', $projet->chef_id) . ' ' . $projet->chef;
+        }
+        $res .= '</td></tr>';
+        $res .= '<tr><td>' . __('Date de début') . '</td><td>' . cubeForm::dateFree('date_debut', $projet->date_debut) . '</td></tr>';
+        $res .= '<tr><td>' . __('Deadline') . '</td><td>' . cubeForm::dateFree('deadline', $projet->deadline) . '</td></tr>';
+        $res .= '<tr><td>' . __('Date de fin') . '</td><td>' . cubeForm::dateFree('date_fin', $projet->date_fin) . '</td></tr>';
+        $res .= '<tr><td>' . __('Client') . '</td><td>' . form::combo('client', $listeClients, $projet->client_id) . '</td></tr>';
+        $res .= '<tr><td>' . __('Devis') . '</td><td>' . form::combo('devis', $listeDevis, $projet->devis) . '</td></tr>';
+        return $res;
+    }
+
+    public static function formTache($tache)
+    {
+        global $core;
+        commonDroits::min(1);
+
+        $res = '<tr><td>' . __('Numéro de tâche') . '</td><td>' . form::hidden('projet', $tache->projet) . form::hidden('tache_id', $tache->tache_id) . '' . $tache->tache_id . '</td></tr>';
+        $res .= '<tr><td>' . __('Catégorie') . '</td><td>' . form::combo('categorie', array_flip($core->categories), $tache->categorie) . '</td></tr>';
+        $res .= '<tr><td>' . __('Nom') . '</td><td>' . form::textarea('nom', 50, 3, html::escapeHTML($tache->nom)) . '</td></tr>';
+
+        return $res;
+    }
+
+    public static function formTacheNormale($tache_id, $projet_id = null)
+    {
+        global $core;
+        commonDroits::min(1);
+        $dao = new extranetDAOTache($core->con);
+        if ($tache_id == 'new') {
+            $tache = $dao->creeNormale();
+            $tache->projet = $projet_id;
+        } else {
+            $tache = $dao->selectById($tache_id);
+        }
+        $res = self::formTache($tache);
+        $res .= '<tr><td>' . __('Taux journalier') . '</td><td>' . form::field('taux_journalier', 6, 6, $tache->taux_journalier) . '</td></tr>';
+        $res .= '<tr><td>' . __('Budget') . '</td><td>' . form::hidden('type', '0') . form::field('budget', 6, 6, $tache->budget) . '</td></tr>';
+        return $res;
+    }
+
+    public static function formTacheSousTraitee($tache_id, $projet_id = null)
+    {
+        global $core;
+        commonDroits::min(1);
+        $dao = new extranetDAOTache($core->con);
+        if ($tache_id == 'new') {
+            $tache = $dao->creeSousTraitee();
+            $tache->projet = $projet_id;
+        } else {
+            $tache = $dao->selectById($tache_id);
+        }
+        $res = self::formTache($tache);
+        $res .= '<tr><td>' . __('Budget') . '</td><td>' . form::hidden('type', '1') . form::field('budget', 6, 6, $tache->budget) . '</td></tr>';
+        return $res;
+    }
+
+    public static function timereport($args)
+    {
+        global $core;
+        commonDroits::min(0.5);
+        $settings = $core->user->getSettings('timereport');
+        $res = '';
+        if (!isset($_GET['light'])) {
+            $filtres = array();
+            $filtres[] = new commonFiltre(__('Participants'), 'equipier_participe', $settings['filtres']);
+            $res .= commonPage::barre($filtres, 'filtreTimereport', 'timereport', null);
+            $res .= commonPage::tMain();
+            $res .= commonPage::bh();
+        }
+        $res .= '<div id="listeTimereport">';
+        $res .= self::listeTimereport();
+        $res .= '</div>';
+        if (!isset($_GET['light'])) {
+            $res .= commonPage::bf();
+            $res .= commonPage::bMain();
+        }
+        return $res;
+    }
+
+    public static function listeTimereport($dashboard = null, $settings = null)
+    {
+        global $core;
+        commonDroits::min(0.5);
+        // Récupère la liste des projets
+        $settings = is_null($settings) ? $core->user->getSettings('timereport') : $settings;
+        $change = is_null($dashboard) ? 'Timereport' : 'Dashboard/' . $dashboard;
+
+        $dao = new extranetDAOProjet($core->con);
+        if (isset($settings['search']) && !is_null($settings['search'])) {
+            $dao->setSearch($settings['search']);
+        }
+        $dao->setFiltres($settings['filtres']);
+        $liste = $dao->getProjetsForTimereport($settings['orderby'], $settings['sens'], $settings['limit'], $core->user->utilisateur_id);
+        // Extrait la liste des tâches
+        $taches = array();
+        foreach ($liste as $id => $projet) {
+            foreach ($projet->taches as $tache) {
+                if ($tache instanceof extranetTacheNormale) {
+                    $taches[] = $tache->tache_id;
+                }
+            }
+        }
+        // Fixe les limites des jours à afficher
+        $time = cubeDate::round(null, 'd'); // aujourd'hui
+        $avant = $time - (3600 * 24 * 15); // 15 jours avant
+        $apres = $time; // aujourd'hui
+        // Récupère la liste des timereports à afficher
+        $daoTimereport = new extranetDAOTimereport($core->con);
+        $timereports = $daoTimereport->getListe($taches, $core->user->utilisateur_id, array('start' => $avant, 'end' => $apres));
+        // Affiche le tableau
+        $res = '<table class="liste listeTimereport">';
+        $res .= '<tr><th class="normal">' . commonUrl::orderby('#', 'projet_id', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="normal">' . commonUrl::orderby(__('Projet'), 'nom', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="normal">' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
+        for ($date = $avant; $date <= $apres; $date += 3600 * 24) {
+            $res .= '<th>' . date('d', $date) . '' . cubeMedia::spacer(16, 1, '', 'spacer') . '</th>';
+        }
+        $res .= '<th class="normal info">' . commonUrl::orderby('<abbr title="' . __('Progression') . '">Pr</abbr>', 'progression', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="normal info">' . commonUrl::orderby('<abbr title="' . __('Jours consommés') . '">Co</abbr>', 'jours_consommes', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="normal info">' . commonUrl::orderby('<abbr title="' . __('Jours prévus') . '">Pl</abbr>', 'jours_prevus', $settings, 'sort' . $change) . '</th>';
+        $res .= '</tr>';
+
+        foreach ($liste as $projet) {
+            $res .= '<tr class="bold">';
+            $res .= '<td class="normal">' . $projet->projet_id . '</td>';
+            $res .= '<td class="normal">' . $projet->nom . '</td>';
+            $res .= '<td class="normal">' . $projet->client . '</td>';
+            for ($date = $avant; $date <= $apres; $date += 3600 * 24) {
+                $cc = self::getClassOfDay($date);
+                $class = ($cc == '') ? '' : ' class="' . $cc . '"';
+                $res .= '<td' . $class . '></td>';
+            }
+            $projet->progression = !$projet->progression ? '-' : $projet->progression . '%';
+            $projet->jours_prevus = !$projet->jours_prevus ? '-' : $projet->jours_prevus;
+            $projet->jours_consommes = !$projet->jours_consommes ? '-' : $projet->jours_consommes;
+            $res .= '<td class="normal info"><span id="progress_projet_' . $projet->projet_id . '">' . $projet->progression . '</span></td>';
+            $res .= '<td class="normal info"><span id="consommees_projet_' . $projet->projet_id . '">' . $projet->jours_consommes . '</span></td>';
+            $res .= '<td class="normal info">' . $projet->jours_prevus . '</td>';
+            $res .= '</tr>';
+            $i = 1;
+            foreach ($projet->taches as $tache) {
+                if ($tache instanceof extranetTacheNormale) {
+                    $res .= '<tr class="odd">';
+                    $res .= '<td class="normal">T' . $i . '</td>';
+                    $res .= '<td class="normal">' . $tache->nom . '</td>';
+                    $res .= '<td class="normal">' . $core->categories[$tache->categorie] . '</td>';
+                    for ($date = $avant; $date <= $apres; $date += (3600 * 24)) {
+                        $hh = isset($timereports[$tache->tache_id][$date]) ? $timereports[$tache->tache_id][$date]->heures : '';
+                        $c = ($hh == '') ? '' : 'filled';
+                        $cc = trim(self::getClassOfDay($date) . ' ' . $c);
+                        $class = ($cc == '') ? '' : ' class="' . $cc . '"';
+                        $res .= '<td' . $class . '>' . form::field(array('timereport', 't_' . $date . '_' . $tache->tache_id), 1, 3, $hh, 'timereport_field') . '</td>';
+                    }
+                    $tache->progression = !$tache->progression ? '-' : $tache->progression . '%';
+                    $tache->jours_prevus = !$tache->jours_prevus ? '-' : $tache->jours_prevus;
+                    $tache->jours_consommes = !$tache->jours_consommes ? '-' : $tache->jours_consommes;
+                    $res .= '<td class="normal info"><span id="progress_' . $tache->tache_id . '">' . $tache->progression . '</span></td>';
+                    $res .= '<td class="normal info"><span id="consommees_' . $tache->tache_id . '">' . $tache->jours_consommes . '</span></td>';
+                    $res .= '<td class="normal info">' . $tache->jours_prevus . '</td>';
+                    $res .= '</tr>';
+                    $i++;
+                }
+            }
+        }
+
+        if (!isset($settings['search']) || is_null($settings['search'])) {
+            $res .= '<tr><td colspan="22"> ';
+            $res .= commonPage::pager($settings['page'], $dao->countActifs(), $settings['par_page'], 'page' . $change . '/%d');
+            $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('projets'));
+            $res .= ' </td></tr>';
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function getClassOfDay($date)
+    {
+        $aujourdhui = cubeDate::round(null, 'd');
+        $highlight = ($date == $aujourdhui);
+        $we = (date('N', $date) >= 6);
+        if ($highlight) {
+            return 'highlight';
+        }
+        if ($we) {
+            return 'we';
+        }
+        return '';
+    }
+
+    public static function devis($args)
+    {
+        global $core;
+        cubePage::truePopup();
+        cubePage::contextMenu();
+
+        if ($core->user->grade == 0) {
+            return self::devis_client($args);
+        }
+        $settings = $core->user->getSettings('devis');
+        commonDroits::min(1);
+
+        $shortcuts = array();
+        $shortcuts[] = '<a href="' . SITE_PATH . 'editedevis/new">' . $core->typo->Ajouter('Créer un devis') . '</a>';
+
+        $filtres = array();
+        $filtres[] = new commonFiltre(__('Créées par'), 'equipier', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Status'), 'status_devis', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Année'), 'annee_facture', $settings['filtres']);
+
+        $res = commonPage::barre($filtres, 'filtreDevis', 'devis', $shortcuts);
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeDevis">';
+        $res .= self::listeDevis();
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function devis_client($args)
+    {
+        global $core;
+
+        $res = commonPage::barre();
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeDevis">';
+        $res .= self::listeDevis();
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function listeDevis($dashboard = null, $settings = null)
+    {
+        global $core;
+
+        if ($core->user->grade == 0) {
+            return self::listeDevisClient($dashboard, $settings);
+        } else {
+            return self::listeDevisEquipier($dashboard, $settings);
+        }
+    }
+
+    public static function contextDevis($id)
+    {
+        global $core;
+        $res = '<div class="contextMenu" id="' . $id . '">';
+        $res .= '<ul>';
+        $res .= '<li class="head">' . __("Changer le status du devis") . '</li>';
+        foreach ($core->devis_status as $k => $v) {
+            if ($k == 0) {
+                continue;
+            }
+            $res .= '<li><a href="#" rel="changeDevisStatus/$1/' . $k . '" class="ajax">' . $v . '</a></li>';
+            if ($k == 2) {
+                $res .= '<li><a href="#" rel="changeDevisStatus/$1/' . $k . '/createProjet" class="ajax">' . __('Valider puis créer le projet correspondant') . '</a></li>';
+            }
+        }
+        $res .= '</ul></div>';
+        return $res;
+    }
+
+    public static function listeDevisEquipier($dashboard = null, $settings = null)
+    {
+        global $core;
+        commonDroits::min(1);
+        $settings = is_null($settings) ? $core->user->getSettings('devis') : $settings;
+        $change = is_null($dashboard) ? 'Devis' : 'Dashboard/' . $dashboard;
+        $context_id = is_null($dashboard) ? 'contextDevis' : 'contextDashboard_' . $dashboard;
+
+        $dao = new extranetDAODevis($core->con);
+        if (isset($settings['search']) && !is_null($settings['search'])) {
+            $dao->setSearch($settings['search']);
+        }
+        $dao->setFiltres($settings['filtres']);
+        $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
+        $res = self::contextDevis($context_id);
+        $res .= '<table class="liste">';
+        $res .= '<tr><th>' . commonUrl::orderby('#', 'devis_id', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Crée par'), 'createur', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th class="min"></th><th class="min"></th><th class="min"></th></tr>';
+        $i = 0;
+        foreach ($liste as $devis) {
+            $droits = extranetDroits::devis($devis, 'w', false);
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $devis->devis_id . '</td>';
+            $res .= '<td>' . $devis->nom . '</td>';
+            $res .= '<td>' . $devis->client . '</td>';
+            $res .= '<td>' . $devis->createur . '</td>';
+            $res .= '<td>' . date(__('d/m/Y'), $devis->date_creation) . '</td>';
+            $res .= '<td>' . $devis->total_ht . '</td>';
+
+            if ($devis->status == 0) {
+                $res .= '<td>' . $core->devis_status[$devis->status] . '</td>';
+            } else {
+                if ($droits) {
+                    $res .= '<td><a href="#" class="openContextMenu" rel="' . $context_id . '" rev="' . $devis->devis_id . '">' . $core->devis_status[$devis->status] . '</a></td>';
+                } else {
+                    $res .= '<td>' . $core->devis_status[$devis->status] . '</td>';
+                }
+            }
+
+            if (in_array($devis->status, array(0, 1)) && $droits) {
+                $res .= '<td class="action"><a href="' . SITE_PATH . 'editedevis/' . $devis->devis_id . '" title="' . __('Editer le devis') . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+            } else {
+                $res .= '<td></td>';
+            }
+            $res .= '<td><a href="' . SITE_PATH . 'voirdevis/' . $devis->devis_id . '" class="popupA4" title="' . __('Voir le devis') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
+            if ($devis->status == 0) {
+                if ($droits) {
+                    $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeDevis/' . $devis->devis_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce devis ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
+                } else {
+                    $res .= '<td></td>';
+                }
+            } elseif ($devis->status >= 1) {
+                $res .= '<td><a href="#" class="ajax" rel="duplicateDevis/' . $devis->devis_id . '" title="' . __('Dupliquer le devis') . '">' . cubeMedia::image(IMG . '/duplicate.png') . '</a></td>';
+            }
+
+            $res .= '</tr>';
+            $i++;
+        }
+        if (!isset($settings['search']) || is_null($settings['search'])) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '><td colspan="10">';
+            $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
+            $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('devis'));
+            $res .= '</td></tr>';
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function listeDevisClient($dashboard = null, $settings = null)
+    {
+        global $core;
+        cubePage::truePopup();
+
+        $dao = new extranetDAODevis($core->con);
+        $settings = $core->user->getSettings('devis');
+        $liste = $dao->getListeForEntreprise($core->user->entreprise, $settings['orderby'], $settings['sens']);
+        $res = '<table class="liste">';
+        $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sortDevis') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sortDevis') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sortDevis') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sortDevis') . '</th>';
+        $res .= '<th class="min"></th></tr>';
+        $i = 0;
+        foreach ($liste as $devis) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $devis->nom . '</td>';
+            $res .= '<td>' . date(__('d/m/Y'), $devis->date_creation) . '</td>';
+            $res .= '<td>' . $devis->total_ht . '</td>';
+            $res .= '<td>' . $core->devis_status[$devis->status] . '</td>';
+            $res .= '<td><a href="' . SITE_PATH . 'voirdevis/' . $devis->devis_id . '" class="popupA4" title="' . __('Voir le devis') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
+            $res .= '</tr>';
+            $i++;
+        }
+        if (!count($liste)) {
+            $res .= '<tr><td colspan="6" class="center">' . __("Vous n'avez pour le moment aucun devis associé à votre compte") . '</td></tr>';
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function voirdevis($args)
+    {
+        global $core;
+        // Charge le devis
+        $dao = new extranetDAODevis($core->con);
+        $devis = $dao->selectById($args[1]);
+
+        $forceDownload = isset($args[2]) && $args[2];
+
+        // Vérification des droits en lecture de l'utilisateur
+        extranetDroits::devis($devis, 'r');
+
+        if ($forceDownload) {
+            cubeHTTP::forceDownload('Devis_' . $args[1] . '.pdf');
+        }
+        cubeHTTP::relayNoCache(ROOT . '/docs/devis/' . $args[1] . '.pdf');
+    }
+
+    public static function editedevis($args)
+    {
+        global $core;
+        commonDroits::min(1);
+        $res = commonPage::barre();
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= self::formDevis($args[1]);
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function formDevis($devis_id = 'new')
+    {
+        global $core;
+        cubePage::autocomplete();
+        cubePage::emptyField();
+        cubePage::ui('Sortable');
+        commonDroits::min(1);
+        $dao = new extranetDAODevis($core->con);
+        if ($devis_id == 'new') {
+            $devis = $dao->cree();
+        } else {
+            $devis = $dao->selectById($devis_id);
+        }
+
+        $res = '<div id="editeDevis">';
+        $res .= '<form action="previewDevis" method="post">';
+
+        $res .= '<div id="devisTop">';
+        // Adresse
+        $res .= '<div id="devisAdresse">';
+        if ($devis->devis_id == 'new') {
+            $default = __('Entrez le nom du client');
+            $default_id = '';
+            $class = 'empty-field';
+        } else {
+            $default = $devis->client;
+            $default_id = $devis->client_id;
+            $class = '';
+        }
+
+        $res .= form::field('client_nom', 40, 128, $default, $class);
+        $res .= form::hidden('client', $default_id);
+        $res .= '<div id="devisAdresseDisplay">';
+        if ($devis->client_id) {
+            $res .= commonUrl::adresse($devis->client_id, null, 'devis', $devis->adresse);
+        }
+        $res .= '</div>';
+        $res .= '</div>';
+        // Titre
+        $res .= '<div id="devisTitre">';
+        $res .= form::hidden('devis_id', $devis->devis_id);
+        $res .= form::textarea('nom', 40, 4, $devis->nom);
+        $res .= '</div>';
+        $res .= '</div>';
+
+        $res .= '<div id="devisMiddle">';
+        $res .= '<div id="devisLignes">';
+        // Lignes du devis
+        $nb_lignes = max(4, count($devis->lignes) + 2);
+
+        for ($i = 0; $i < $nb_lignes; $i++) {
+            if (isset($devis->lignes[$i])) {
+                $titre = $devis->lignes[$i]['titre'];
+                $description = $devis->lignes[$i]['description'];
+                $montant = $devis->lignes[$i]['montant'];
+            } else {
+                $titre = $description = $montant = '';
+            }
+            $res .= '<div class="devisLigne">';
+            $res .= '<div class="devisLigneRight">';
+            $res .= form::field(array('montant[]'), 6, 15, $montant) . " €";
+            $res .= '</div>';
+            $res .= '<div class="devisLigneLeft">';
+            $res .= form::field(array('titre[]'), 105, 256, htmlspecialchars($titre, ENT_QUOTES)) . '<br /><br />';
+            $res .= form::textarea(array('description[]'), 110, 4, $description);
+            $res .= '</div>';
+
+            $res .= '</div>';
+        }
+
+        $res .= '</div>';
+        $res .= '</div>';
+        //             $res .= '<div id="devisBottom">' . cubeMedia::spacer(10, 10) . '</div>';
+        //             $res .= '<div id="devisMail">';
+        //             $res .= '<table>';
+        //             $res .= '<tr><td>' . __('De') . '</td><td>' . $core->user->prenom . ' ' . $core->user->nom . ' &lt;' . $core->user->email . '&gt;</td></tr>';
+        //             $res .= '<tr><td>' . __('Sujet') . '</td><td>' . form::field(array('email[sujet]'), 80, 128, htmlspecialchars($devis->email['sujet'], ENT_QUOTES)) . '</td></tr>';
+        //             $res .= '<tr><td>' . __('Corps') . '</td><td>' . form::textarea(array('email[corps]'), 80, 20, $devis->email['corps']) . '</td></tr>';
+        //             $res .= '</table>';
+        //             $res .= '</div>';
+        $res .= '<div class="right"><a href="#" class="submit">' . $core->typo->BoutonOK('Enregistrer et prévisualiser') . '</a></div>';
+        $res .= '</form>';
+        $res .= '</div>';
+
+        return $res;
+    }
+
+    public static function previewDevis($args)
+    {
+        global $core;
+
+        $dao = new extranetDAODevis($core->con);
+        $devis = $dao->selectById($args[1]);
+
+        $daoUtilisateur = new commonDAOUtilisateur($core->con);
+        $createur = $devis->createur = $daoUtilisateur->selectById($devis->createur_id);
+        $client = $devis->client = $daoUtilisateur->selectById($devis->client_id);
+
+        $res = commonPage::barre();
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<iframe src="' . SITE_PATH . 'voirdevis/' . $devis->devis_id . '/?junk=' . TIME . '" width="960" height="1000" frameborder="0"></iframe>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bh();
+        $res .= '<div id="devis_email">';
+        $res .= '<table class="liste">';
+        $res .= '<tr><td>' . __('De') . '</td><td>' . $createur->prenom . ' ' . $createur->nom . '&lt;' . $createur->email . '&gt;</td></tr>';
+        $res .= '<tr class="odd"><td>' . __('A') . '</td><td>' . $client->prenom . ' ' . $client->nom . '&lt;' . $client->email . '&gt;</td></tr>';
+        $res .= '<tr><td>' . __('Sujet') . '</td><td>' . $devis->email['sujet'] . '</td></tr>';
+        $res .= '<tr class="odd"><td>' . __('Message') . '</td><td>' . nl2br($devis->email['corps'] . "\n\n" . $createur->getSignature()) . '</td></tr>';
+        $res .= '<tr><td colspan="2" class="right">';
+        $res .= cubeMedia::spacer(40, 40) . '<a href="' . SITE_PATH . 'editedevis/' . $devis->devis_id . '">' . $core->typo->BoutonOK(__('Editer le devis')) . '</a> ';
+        $res .= '<a href="#" rel="expedieDevis/0/' . $devis->devis_id . '" class="ajax"">' . $core->typo->BoutonOK(__('Valider')) . '</a> ';
+        //$res .= '<a href="#" rel="expedieDevis/1/' . $devis->devis_id . '" class="ajax" title="' . __("Le devis est sur le point d'être envoyé. Veuillez confirmer votre choix ?") . '">' . $core->typo->BoutonOK(__('Valider et envoyer le devis')) . '</a></td></tr>';
+        $res .= '</table>';
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function factures($args)
+    {
+        global $core;
+
+        if ($core->user->grade == 0) {
+            return self::factures_client($args);
+        }
+        $settings = $core->user->getSettings('factures');
+
+        commonDroits::min(1);
+        $shortcuts = array();
+        if ($core->user->grade != 3) {
+            $shortcuts[] = '<a href="' . SITE_PATH . 'editefacture/new">' . $core->typo->Ajouter('Créer une facture') . '</a>';
+        }
+        $shortcuts[] = '<a href="#" rel="formPrintFactures" title="Imprimer les factures" class="popup">' . cubeMedia::image(IMG . '/print.png') . '</a>';
+        $filtres = array();
+        $filtres[] = new commonFiltre(__('Créées par'), 'equipier', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Status'), 'status_facture', $settings['filtres']);
+        $filtres[] = new commonFiltre(__('Année'), 'annee_facture', $settings['filtres']);
+        $res = commonPage::barre($filtres, 'filtreFactures', 'factures', $shortcuts);
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeFactures">';
+        $res .= self::listeFactures();
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function factures_client($args)
+    {
+        global $core;
+        $res = commonPage::barre();
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<div id="listeFactures">';
+        $res .= self::listeFactures();
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function contextFacture($id)
+    {
+        global $core;
+        $res = '<div class="contextMenu" id="' . $id . '">';
+        $res .= '<ul>';
+        $res .= '<li class="head">' . __("Changer le status de la facture") . '</li>';
+        foreach ($core->factures_status as $k => $v) {
+            if (in_array($k, array(0, 4))) {
+                continue;
+            }
+            if ($k == 2) {
+                $res .= '<li><a href="#" rel="changeFacturePaiement/$1" class="popup">' . $v . '</a></li>';
+            } else {
+                if ($k == 3) {
+                    $title = ' title="' . __("Êtes-vous certain de vouloir annuler cette facture ? Cette action est irreversible et provoquera la création d'un avoir correpondant.") . '"';
+                } else {
+                    $title = '';
+                }
+                $res .= '<li><a href="#" rel="changeFactureStatus/$1/' . $k . '" class="ajax"' . $title . '>' . $v . '</a></li>';
+            }
+        }
+        $res .= '</ul></div>';
+        return $res;
+    }
+
+    public static function listeFactures($dashboard = null, $settings = null)
+    {
+        global $core;
+        if ($core->user->grade == 0) {
+            return self::listeFacturesClient($dashboard, $settings);
+        } else {
+            return self::listeFacturesEquipier($dashboard, $settings);
+        }
+    }
+
+    public static function listeFacturesEquipier($dashboard = null, $settings = null)
+    {
+        global $core;
+        cubePage::truePopup();
+        cubePage::contextMenu();
+
+        $settings = is_null($settings) ? $core->user->getSettings('factures') : $settings;
+        $change = is_null($dashboard) ? 'Facture' : 'Dashboard/' . $dashboard;
+        $context_id = is_null($dashboard) ? 'contextFacture' : 'contextDashboard_' . $dashboard;
+        $dao = new extranetDAOFacture($core->con);
+        if (isset($settings['search']) && !is_null($settings['search'])) {
+            $dao->setSearch($settings['search']);
+        } else {
+            $dao->setFiltres($settings['filtres']);
+        }
+
+        if ($core->user->grade != 3) {
+            $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);
+        } else {
+            $liste = $dao->getListeCompta($settings['orderby'], $settings['sens'], $settings['limit']);
+        }
+
+        $res = self::contextFacture($context_id);
+        $res .= '<table class="liste">';
+        $res .= '<tr><th>' . commonUrl::orderby('#', 'facture_id', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Client'), 'client', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Crée par'), 'createur', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th><th class="min"></th><th class="min"></th><th class="min"></th></tr>';
+        $i = 0;
+        foreach ($liste as $facture) {
+            $droits = extranetDroits::facture($facture, 'w', false);
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $facture->facture_id . '</td>';
+            $res .= '<td>' . $facture->nom . '</td>';
+            $res .= '<td>' . $facture->client . '</td>';
+            $res .= '<td>' . $facture->createur . '</td>';
+            $res .= '<td>' . date(__('d/m/Y'), $facture->date_creation) . '</td>';
+            $res .= '<td>' . $facture->total_ht . '</td>';
+            if ($facture->status == 0) {
+                $res .= '<td>' . $core->factures_status[$facture->status] . '</td>';
+                if ($droits) {
+                    $res .= '<td></td>';
+                    $res .= '<td class="action"><a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '" title="' . __('Editer la facture') . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+                    $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeFacture/' . $facture->facture_id . '" title="' . __('Êtes vous certain de vouloir supprimer cette facture ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
+                } else {
+                    $res .= '<td></td><td></td>';
+                }
+            } elseif ($facture->status >= 1) {
+                if ($facture->status < 3 || $facture->status == 5) {
+                    if ($droits) {
+                        $res .= '<td><a href="#" class="openContextMenu" rel="' . $context_id . '" rev="' . $facture->facture_id . '">' . $core->factures_status[$facture->status] . '</a></td>';
+                    } else {
+                        $res .= '<td>' . $core->factures_status[$facture->status] . '</td>';
+                    }
+                } else {
+                    $title = $facture->status == 3 ? __("Voir l'avoir correspondant") : __("Voir la facture annulée correspondante");
+                    $res .= '<td><a href="' . SITE_PATH . 'voirfacture/' . $facture->avoir . '" class="popupA4" title="' . $title . '">' . $core->factures_status[$facture->status] . '</a></td>';
+                }
+                if ($facture->facture_id > 0) {
+                    if ($droits && $facture->status == 1) {
+                        $res .= '<td>' . '<a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '" title="' . __('Editer la facture') . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+                    } else {
+                        $res .= '<td></td>';
+                    }
+                    $res .= '<td><a href="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" class="popupA4" title="' . __('Voir la facture') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
+                    if ($facture->status != 4 && $core->user->grade != 3) {
+                        $res .= '<td><a href="#" class="ajax" rel="duplicateFacture/' . $facture->facture_id . '" title="' . __('Dupliquer la facture') . '">' . cubeMedia::image(IMG . '/duplicate.png') . '</a></td>';
+                    } else {
+                        $res .= '<td></td>';
+                    }
+                } else {
+                    $res .= '<td></td><td></td><td></td>';
+                }
+            }
+
+            $res .= '</tr>';
+            $i++;
+        }
+        if (!isset($settings['search']) || is_null($settings['search'])) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '><td colspan="10">';
+            if ($core->user->grade != 3) {
+                $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d');
+            } else {
+                $res .= commonPage::pager($settings['page'], $dao->countCompta(), $settings['par_page'], 'page' . $change . '/%d');
+            }
+            $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('factures'));
+            $res .= '</td></tr>';
+        }
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function listeFacturesClient($dashboard = null, $settings = null)
+    {
+        global $core;
+        cubePage::truePopup();
+        $settings = $core->user->getSettings('factures');
+        $dao = new extranetDAOFacture($core->con);
+        $liste = $dao->getListeForEntreprise($core->user->entreprise, $settings['orderby'], $settings['sens'], true);
+
+        $res = '<table class="liste">';
+        $res .= '<tr><th>' . commonUrl::orderby('#', 'facture_id', $settings, 'sortFacture') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sortFacture') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Date'), 'date_creation', $settings, 'sortFacture') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Montant HT'), 'total_ht', $settings, 'sortFacture') . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Status'), 'status', $settings, 'sortFacture') . '</th>';
+        $res .= '<th class="min"></th></tr>';
+        $i = 0;
+        foreach ($liste as $facture) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $facture->numeroFacture() . '</td>';
+            $res .= '<td>' . $facture->nom . '</td>';
+            $res .= '<td>' . date(__('d/m/Y'), $facture->date_creation) . '</td>';
+            $res .= '<td>' . $facture->total_ht . '</td>';
+            $res .= '<td>' . $core->factures_status[$facture->status] . '</td>';
+            $res .= '<td><a href="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" class="popupA4" title="' . __('Voir la facture') . '">' . cubeMedia::image(IMG . '/view.png') . '</a></td>';
+            $res .= '</tr>';
+            $i++;
+        }
+        if (!count($liste)) {
+            $res .= '<tr><td colspan="6" class="center">' . __("Vous n'avez pour le moment aucune facture associée à votre compte") . '</td></tr>';
+        }
+
+        $res .= '</table>';
+        return $res;
+    }
+
+    public static function formFacturePaiement($facture_id)
+    {
+        global $core;
+        $dao = new extranetDAOFacture($core->con);
+        $facture = $dao->selectById($facture_id);
+        $date = !$facture->date_paiement ? null : $facture->date_paiement;
+
+        $res = '<tr><td>' . form::hidden('facture_id', $facture_id) . __('Date de paiement') . '</td><td>' . cubeForm::date('date_paiement', $date) . '</td></tr>';
+        $res .= '<tr><td>' . __('Informations de paiement') . '</td><td>' . form::textarea('informations_paiement', 40, 3, $facture->informations_paiement) . '</td></tr>';
+
+        return $res;
+    }
+
+    public static function voirfacture($args)
+    {
+        global $core;
+        // Charge la facture
+        $dao = new extranetDAOFacture($core->con);
+        $facture = $dao->selectById($args[1]);
+        // Vérification des droits de l'utilisateur
+        extranetDroits::facture($facture, 'r', true);
+
+        cubeHTTP::relayNoCache(ROOT . '/docs/factures/' . $args[1] . '.pdf');
+    }
+
+    public static function editefacture($args)
+    {
+        global $core;
+        commonDroits::min(1);
+        $res = commonPage::barre();
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        if (isset($args[2])) {
+            $res .= self::formFacture($args[1], $args[2]);
+        } else {
+            $res .= self::formFacture($args[1]);
+        }
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function formFacture($facture_id = 'new', $projet_id = null)
+    {
+        global $core;
+        commonDroits::min(1);
+        cubePage::autoComplete();
+        cubePage::emptyField();
+        cubePage::ui('Sortable');
+
+        $daoProjet = new extranetDAOProjet($core->con);
+        $dao = new extranetDAOFacture($core->con);
+
+        $projet_id = isset($_POST['projet_id']) && $_POST['projet_id'] > 0 ? $_POST['projet_id'] : $projet_id;
+
+        if ($facture_id == 'new') {
+            $facture = $dao->cree();
+        } elseif ($facture_id == 'ws') {
+            $facture = $dao->cree();
+            $facture->facture_id = 'ws';
+        } else {
+            $facture = $dao->selectById($facture_id);
+        }
+
+        if (!is_null($projet_id) && $facture_id == 'new') {
+            $projet = $daoProjet->selectById($projet_id);
+            $facture->projet_id = $projet->projet_id;
+            $facture->client = $projet->client;
+            $facture->projet = $facture->nom = $projet->nom;
+            $lignes = array();
+            foreach ($projet->taches as $tache) {
+                $lignes[] = array('montant' => $tache->budget, 'titre' => $tache->nom, 'description' => '');
+            }
+            $facture->lignes = $lignes;
+        } elseif ($facture_id == 'ws') {
+            if (is_null($projet_id)) {
+                $daoClient = new commonDAOClient($core->con);
+                $client = $daoClient->selectById($_POST['client_id']);
+                $facture->projet_id = 'new';
+                $facture->client = $client->rs;
+                $facture->client_id = $client->utilisateur_id;
+                $facture->projet = __('Nouveau projet');
+                $facture->nom = 'Fluidbook';
+            } else {
+                $projet = $daoProjet->selectById($projet_id);
+                $facture->projet_id = $projet->projet_id;
+                $facture->client = $projet->client;
+                $facture->projet = $facture->nom = $projet->nom;
+            }
+            $lignes = array();
+            $b = $core->con->select('SELECT * FROM ws.book WHERE bid IN(' . implode(',', array_keys($_POST['book_facture'])) . ')');
+            while ($b->fetch()) {
+                $lignes[] = array('book' => $b->bid, 'montant' => 0, 'titre' => 'Fluidbook &laquo; ' . $b->titre . ' &raquo;', 'description' => '');
+            }
+            $facture->lignes = $lignes;
+        }
+
+        $res = '<div id="editeDevis">';
+        $res .= '<form action="previewFacture" method="post">';
+        $res .= '<div id="devisTop">';
+        // Adresse
+        if ($facture->facture_id == 'new' && is_null($projet_id)) {
+            $class = 'empty-field';
+            $default_id = '';
+            $default = __('Entrez le nom du projet ou du client');
+        } else {
+            $class = '';
+            $default_id = $facture->projet_id;
+            $default = $facture->projet_id . ' - ' . $facture->projet . ' (' . $facture->client . ')';
+        }
+
+        $res .= '<div id="factureAdresse">';
+        $res .= form::field('projet_nom', 40, 128, $default, $class);
+        $res .= form::hidden('projet', $default_id);
+        $res .= '<div id="factureAdresseDisplay">';
+        if ($facture->projet_id != 'new') {
+            $res .= commonUrl::adresse(null, $facture->projet_id, 'facture', $facture->adresse);
+        } else {
+            $res .= commonUrl::adresse($facture->client_id, null, 'facture', $facture->adresse);
+            $res .= form::hidden('client', $facture->client_id);
+        }
+
+        $res .= '</div>';
+        $res .= form::textarea('texte_complementaire', 50, 2, $facture->texte_complementaire);
+        $res .= '</div>';
+        // Titre
+        $res .= '<div id="devisTitre">';
+        $res .= 'Date : ' . cubeForm::date('date_creation', $facture->date_creation) . '<br /><br />';
+        $res .= form::hidden('facture_id', $facture->facture_id);
+        $res .= form::textarea('nom', 40, 4, $facture->nom);
+        $res .= '</div>';
+        $res .= '</div>';
+
+        $res .= '<div id="devisMiddle">';
+        $res .= '<div id="devisLignes">';
+        // Lignes du devis
+        $nb_lignes = max(4, count($facture->lignes) + 2);
+
+        for ($i = 0; $i < $nb_lignes; $i++) {
+            if (isset($facture->lignes[$i])) {
+                $titre = $facture->lignes[$i]['titre'];
+                $description = $facture->lignes[$i]['description'];
+                $montant = $facture->lignes[$i]['montant'];
+                $book = isset($facture->lignes[$i]['book']) ? $facture->lignes[$i]['book'] : null;
+            } else {
+                $titre = $description = $montant = '';
+            }
+
+            $res .= '<div class="devisLigne">';
+
+            $res .= '<div class="devisLigneRight">';
+            $res .= form::field(array('montant[]'), 6, 15, $montant) . " €";
+            if (isset($book) && !is_null($book)) {
+                $res .= form::hidden(array('book[]'), $book);
+            }
+            $res .= '</div>';
+            $res .= '<div class="devisLigneLeft">';
+            $res .= form::field(array('titre[]'), 80, 256, htmlspecialchars($titre, ENT_QUOTES)) . '<br /><br />';
+            $res .= form::textarea(array('description[]'), 80, 2, $description);
+            $res .= '</div>';
+
+            $res .= '</div>';
+        }
+
+        $res .= '</div>';
+        $res .= '</div>';
+        $res .= '<div id="devisBottom">' . cubeMedia::spacer(10, 10) . '</div>';
+        $res .= '<div class="right"><a href="#" class="submit">' . $core->typo->BoutonOK('Enregistrer et prévisualiser') . '</a></div>';
+        $res .= '</form>';
+        $res .= '</div>';
+        return $res;
+    }
+
+    public static function previewFacture($args)
+    {
+        global $core;
+        commonDroits::min(1);
+        $dao = new extranetDAOFacture($core->con);
+        $facture = $dao->selectById($args[1]);
+
+        $res = commonPage::barre();
+        $res .= commonPage::tMain();
+        $res .= commonPage::bh();
+        $res .= '<iframe src="' . SITE_PATH . 'voirfacture/' . $facture->facture_id . '" width="960" height="1000" frameborder="0"></iframe>';
+
+        $res .= '<div class="right">' . '<a href="' . SITE_PATH . 'editefacture/' . $facture->facture_id . '">' . $core->typo->BoutonOK(__('Editer la facture')) . '</a> ';
+        if ($facture->status == 0) {
+            $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax" title="' . __("La facture est sur le point d'être validée. Veuillez confirmer votre choix ?") . '">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';
+        } else {
+            $res .= '<a href="#" rel="valideFacture/' . $facture->facture_id . '" class="ajax">' . $core->typo->BoutonOK(__('Valider la facture')) . '</a>';
+        }
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function formPrintFactures()
+    {
+        global $core;
+        $last = $core->user->getLastPrint();
+        $res = '';
+        if ($last['date']) {
+            $res .= '<tr><td>' . __('Dernière factures imprimées') . ' : </td><td>' . __('Factures') . ' <a href="' . SITE_PATH . 'voirfacture/print_' . $core->user->utilisateur_id . '_' . $last['date'] . '" class="popupA4">' . $last['pages'] . ' (' . date('Y-m-d', $last['date']) . ')</a></td></tr>';
+        }
+        $res .= '<tr><td>' . __('Factures à imprimer') . '</td><td>' . form::field('factures', 20, 64) . '</td></tr>';
+        $res .= '<tr><td colspan="2"><em>' . __('Ex') . ' : 1;3-5;7;9 ' . __('signifie factures') . ' 1,3,4,5,7,9</em></td></tr>';
+        return $res;
+    }
+
+    public static function chiffres($args)
+    {
+        global $core;
+        commonDroits::min(2);
+        // $res = commonPage::barre(null, null, null, array('<a href="http://www.google.com/calendar/" class="blank">' . $core->typo->Favoris(__('Gérer les charges sur Google Agenda')) . '</a>'));
+        $res = commonPage::barre(null, null, null, null);
+        $res .= commonPage::tMain();
+        $res .= extranetPageChiffres::listeChiffres();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function traduction($args)
+    {
+        global $core;
+        commonDroits::min(1);
+        $res = commonPage::barre();
+        $res .= commonPage::tMain("traduction");
+        $res .= commonPage::bh();
+        $res .= '<form action="saveTrad" method="post">';
+        $res .= '<table class="liste">';
+        $res .= '<tr><th>' . __("Traduction de l'application en anglais") . '</th><th></th></tr>';
+        $res .= '</table>';
+        $res .= cubeLang::translationForm(array(ROOT . '/inc/commons', ROOT . '/inc/extranet', ROOT . '/inc/ws', COMPOSER_SOURCES), 'en', ROOT . '/l10n', '', array(), '<a href="#" class="submit">' . $core->typo->BoutonOK('Enregistrer') . '</a>');
+        $res .= '</form>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function cleanTimereport($args)
+    {
+        global $core;
+
+        $r = $core->con->select('SELECT * FROM timereport');
+        $t = array();
+        while ($r->fetch()) {
+            if (!isset($t[date('Y', $r->date)][$r->utilisateur_id][$r->tache_id])) {
+                $t[date('Y', $r->date)][$r->utilisateur_id][$r->tache_id] = 0;
+            }
+            $t[date('Y', $r->date)][$r->utilisateur_id][$r->tache_id] += $r->heures;
+        }
+
+        foreach ($t as $annee => $t1) {
+            if ($annee == date('Y')) {
+                continue;
+            }
+            $limit = cubeDate::limitYear($annee);
+            $core->con->execute('DELETE FROM timereport WHERE date BETWEEN ' . $limit['start'] . ' AND ' . $limit['end']);
+            $c = $core->con->openCursor('timereport');
+            $c->date = mktime(1, 1, 1, 1, 1, $annee);
+            foreach ($t1 as $uid => $t2) {
+                $c->utilisateur_id = $uid;
+                foreach ($t2 as $tache_id => $heures) {
+                    $c->tache_id = $tache_id;
+                    $c->heures = $heures;
+                    $c->insert();
+                }
+            }
+        }
+    }
+
+    public static function rh($args)
+    {
+        global $core;
+        commonDroits::min(2);
+        $res = commonPage::barre();
+        $res .= commonPage::tMain("rh");
+        $res .= commonPage::bh();
+        $res .= '<div id="listeEquipiers">';
+        $res .= extranetUrl::listeRh(null, null);
+        $res .= '</div>';
+        $res .= commonPage::bf();
+        $res .= commonPage::bMain();
+        return $res;
+    }
+
+    public static function listeRh($dashboard = null, $settings = null)
+    {
+        global $core;
+        commonDroits::min(2);
+        $settings = is_null($settings) ? $core->user->getSettings('equipiers') : $settings;
+        $change = is_null($dashboard) ? 'Equipier' : 'Dashboard/' . $dashboard;
+        $dao = new commonDAOEquipier($core->con);
+        $liste = $dao->getListe(null, $settings['orderby'], $settings['sens'], $settings['limit']);
+
+        $res = '<table class="liste">';
+        $res .= '<tr><th>' . commonUrl::orderby('#', 'utilisateur_id', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Agence'), 'agence', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Nom'), 'nom', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('E-mail'), 'email', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>' . commonUrl::orderby(__('Grade'), 'grade', $settings, 'sort' . $change) . '</th>';
+        $res .= '<th>Notes</th>';
+        // $res .= '<th class="min"></th><th class="min"></th></tr>';
+        $i = 0;
+        foreach ($liste as $id => $equipier) {
+            $odd = cubeMath::isOdd($i) ? ' class="odd"' : '';
+            $res .= '<tr' . $odd . '>';
+            $res .= '<td>' . $equipier->utilisateur_id . '</td>';
+            $res .= '<td>' . $equipier->agence . '</td>';
+            $res .= '<td>' . $equipier->prenom . ' ' . $equipier->nom . '</td>';
+
+            $email = strlen($equipier->email) > 20 ? substr($equipier->email, 0, 17) . '...' : $equipier->email;
+
+            $res .= '<td><a href="mailto:' . cubeMail::encodeForURL($equipier->email) . '">' . $email . '</a></td>';
+            $res .= '<td>' . $core->grades[$equipier->grade] . '</td>';
+            $res .= '<td class="action center"><a href="#" class="popup" rel="formNotes/' . $equipier->utilisateur_id . '">' . cubeMedia::image(IMG . '/postit.png') . '</a></td>';
+            // $res .= '<td class="action"><a href="#" class="popup" rel="formClient/' . $equipier->utilisateur_id . '">' . cubeMedia::image(IMG . '/edit.png') . '</a></td>';
+            // $res .= '<td class="action"><a href="#" class="ajax" rel="supprimeClient/' . $equipier->utilisateur_id . '" title="' . __('Êtes vous certain de vouloir supprimer ce client ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';
+            $res .= '</tr>';
+            $i++;
+        }
+        /* if (!isset($settings['search']) || is_null($settings['search'])) {
+          $odd = cubeMath::isOdd($i)?' class="odd"':'';
+          $res .= '<tr' . $odd . '><td colspan="10">';
+          $res .= commonPage::pager($settings['page'], $dao->count() , $settings['par_page'], 'page' . $change . '/%d');
+          $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('clients'));
+          $res .= '</td></tr>';
+          } */
+        $res .= '</table>';
+        return $res;
+    }
 
 }
 
index 77152caee2f97533f55aa2d186f56e9898a90d6d..af03c9129ab4434ab1bec2a4b419eec5432cdaa4 100644 (file)
@@ -1956,7 +1956,7 @@ html.tall{height:150%}' . "\n";
         $res = '<tr><td>' . __('Numéro de client') . '</td><td>' . form::hidden('grade', 0) . form::hidden('entreprise', $client->entreprise) . form::hidden('utilisateur_id', $client->utilisateur_id) . '' . $client->utilisateur_id . '</td></tr>';
         $res .= '<tr><td>' . __('Login activé') . '</td><td>' . form::hidden('enabled', 0) . form::checkbox('enabled', 1, $client->enabled) . '</td></tr>';
         $res .= '<tr><td>' . __('Adresse e-mail') . '</td><td>' . form::field('email', 30, 128, $client->email) . '</td></tr>';
-        $res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field('password', 30, 128, $client->password) . '</td></tr>';
+        //$res .= '<tr><td>' . __('Mot de passe') . '</td><td>' . form::field('password', 30, 128, $client->password) . '</td></tr>';
         $res .= '<tr><td>' . __('Prénom du contact') . '</td><td>' . form::field('prenom', 30, 128, $client->prenom) . '</td></tr>';
         $res .= '<tr><td>' . __('Nom du contact') . '</td><td>' . form::field('nom', 30, 128, $client->nom) . '</td></tr>';
         $res .= '<tr><td>' . __('Adresse') . '</td><td>' . form::textarea('adresse', 40, 3, $client->adresse) . '</td></tr>';
@@ -1971,7 +1971,7 @@ html.tall{height:150%}' . "\n";
             $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
             $res .= '<tr><td></td><td><a href="' . SITE_PATH . 'fichiers/' . $client->utilisateur_id . '">' . __('FTP') . '</a></td></tr>';
             //$res .= '<tr><td></td><td><a href="#" class="ajax" rel="connectAs/' . $client->utilisateur_id . '">' . __('Se connecter comme ...') . '</a></td></tr>';
-            $res .= '<tr><td>' . __("Paramètres de connexion au Fluidbook Workshop") . '</td><td>' . __('Adresse') . ' : https://' . $_SERVER['HTTP_HOST'] . '/<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . $client->password . '</td></tr>';
+            $res .= '<tr><td>' . __("Paramètres de connexion au Fluidbook Workshop") . '</td><td>' . __('Adresse') . ' : https://' . $_SERVER['HTTP_HOST'] . '/<br />' . __("Nom d'utilisateur") . ' : ' . $client->email . '<br />' . __('Mot de passe') . ' : ' . __('Utiliser la fonction "Mot de passe oublié" pour le créer ou le réinitialiser') . '</td></tr>';
             $res .= '<tr><td colspan="2">' . cubeMedia::spacer(10, 10) . '</td></tr>';
         }
         return $res;
index 29b9b2e1c00570487c4fc517f63a64e4af76cd4e..a0f47a76cbcd3184a10aefb4772f9ca080c08f2d 100644 (file)
@@ -426,8 +426,10 @@ class wsBookParametres extends wsParametres
         $this->fields['textPopupStylesheet'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Feuille de style des popups de texte'), 'fileFilter' => $cssFilter];
         $this->fields['textPopupWidth'] = ['type' => 'integer', 'default' => '600', 'editable' => true, 'label' => __('Largeur optimale des popups')];
         $this->fields['iframePopupMaxWidth'] = ['type' => 'integer', 'default' => '0', 'editable' => true, 'label' => __('Largeur maximale des popups iframe')];
+        $this->fields['OAMChromeFactor'] = ['type' => 'float', 'default' => '1', 'editable' => true, 'label' => __('Facteur OAM Chrome')];
+        $this->fields['OAMIEFactor'] = ['type' => 'float', 'default' => '1', 'editable' => true, 'label' => __('Facteur OAM IE11')];
         $this->forms['multimedia'] = array('label' => __('Liens et multimédia'),
-            'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'customLinkClass', 'ignoreLinksTypes', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'inlineSlideshowTransitionDuration', 'inlineSlideshowDuration', '|', 'videoReset', 'videoBigPlay', '|', 'brightcovePlayerId', 'brightcovePlayerSecret', '|', 'textPopupStylesheet', 'textPopupWidth', '|', 'iframePopupMaxWidth'));
+            'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'customLinkClass', 'ignoreLinksTypes', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'inlineSlideshowTransitionDuration', 'inlineSlideshowDuration', '|', 'videoReset', 'videoBigPlay', '|', 'brightcovePlayerId', 'brightcovePlayerSecret', '|', 'textPopupStylesheet', 'textPopupWidth', '|', 'iframePopupMaxWidth','|','OAMChromeFactor','OAMIEFactor'));
         //.
 
         $this->fields['product_zoom_references'] = array('type' => 'freefile', 'default' => '', 'editable' => true,