From: vincent@cubedesigners.com Date: Wed, 9 Feb 2011 16:17:56 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=aacca6cb89ea219c524cb0593071e83373bb465d;p=cubeextranet.git --- diff --git a/inc/config.inc.php b/inc/config.inc.php index 7437e67d6..62cd222ce 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -11,7 +11,7 @@ define('WEBROOT', ''); define('SITE_PATH', WEBROOT . '/'); define('FONT_PATH', ROOT . '/fluidbook/fonts/'); define('FTPROOT', '/home/extranet/ftp/'); -define('DEV', false); +define('DEV', $dev); define('WINDOWS', false); define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/dev/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF'); define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc'); @@ -23,12 +23,18 @@ if ($dev) { define('DB_NAME', 'extranet_dev'); define('DB_USER', 'ws'); define('DB_PASSWORD', '*arica*2'); + + define('EXTRANET_URL', 'http://dev.extranet.cubedesigners.com'); + define('WS_URL', 'http://dev.ws.fluidbook.com'); } else { // Définition des variables dans l'environnement de production define('DB_HOST', 'localhost'); define('DB_NAME', 'extranet'); define('DB_USER', 'ws'); define('DB_PASSWORD', '*arica*2'); + + define('EXTRANET_URL', 'http://extranet.cubedesigners.com'); + define('WS_URL', 'http://ws.fluidbook.com'); } if ($ws) { diff --git a/inc/extranet/Controlleur/class.extranet.url.php b/inc/extranet/Controlleur/class.extranet.url.php index ff485d60c..be5941cf7 100644 --- a/inc/extranet/Controlleur/class.extranet.url.php +++ b/inc/extranet/Controlleur/class.extranet.url.php @@ -442,7 +442,7 @@ class extranetUrl { $dao = new extranetDAOProjet($core->con); $projet = $dao->selectById($projet_id); - $hasFacture = $dao->projectHasFacture($projet_id); + $hasFacture = $dao->hasFacture($projet_id); $droits = extranetDroits::projet($projet, false); diff --git a/inc/extranet/DAO/class.extranet.dao.projet.php b/inc/extranet/DAO/class.extranet.dao.projet.php index 6328fd54d..2ea19692a 100644 --- a/inc/extranet/DAO/class.extranet.dao.projet.php +++ b/inc/extranet/DAO/class.extranet.dao.projet.php @@ -135,15 +135,19 @@ class extranetDAOProjet extends commonDAO { $c = $this->con->openCursor('projets'); $c->nom = $data['nom']; $c->chef = $data['chef']; - $c->date_debut = cubeDate::formFreeToTime($data['date_debut']); - $c->deadline = cubeDate::formFreeToTime($data['deadline']); - $c->date_fin = cubeDate::formFreeToTime($data['date_fin']); + if (isset($data['date_debut'])) { + $c->date_debut = cubeDate::formFreeToTime($data['date_debut']); + $c->deadline = cubeDate::formFreeToTime($data['deadline']); + $c->date_fin = cubeDate::formFreeToTime($data['date_fin']); + } elseif ($data['projet_id'] == 'new') { + $c->date_debut = $c->deadline = $c->date_fin = TIME; + } $c->client = $data['client']; $c->devis = $data['devis']; if ($data['projet_id'] == 'new') { $c->status = 0; $c->projet_id = $this->getNextId(); - $c->date_creation = time(); + $c->date_creation = TIME; $c->insert(); return $c->projet_id; } else { @@ -161,7 +165,7 @@ class extranetDAOProjet extends commonDAO { public function hasFacture($projet_id) { - $r = $this->con->select('SELECT * FROM factures WHERE projet=\'' . $core->con->escape($projet_id) . '\''); + $r = $this->con->select('SELECT * FROM factures WHERE projet=\'' . $this->con->escape($projet_id) . '\''); return $r->count() > 0; } diff --git a/inc/extranet/DAO/class.extranet.dao.tache.php b/inc/extranet/DAO/class.extranet.dao.tache.php index ddac57801..20a60d7fe 100644 --- a/inc/extranet/DAO/class.extranet.dao.tache.php +++ b/inc/extranet/DAO/class.extranet.dao.tache.php @@ -89,11 +89,14 @@ class extranetDAOTache extends commonDAO { } if ($data['tache_id'] == 'new') { - $c->tache_id = $this->getNextId(); - return $c->insert(); + $tache_id=$c->tache_id = $this->getNextId(); + $c->insert(); } else { - return $c->update('WHERE tache_id=\'' . $this->con->escape($data['tache_id']) . '\''); + $tache_id=$data['tache_id']; + $c->update('WHERE tache_id=\'' . $this->con->escape($data['tache_id']) . '\''); } + + return $tache_id; } public function supprime($tache_id) diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index c346df2fe..3684b7771 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -236,8 +236,9 @@ class wsAjax extends cubeAjax { $book_id = $args[1]; $status = $args[2]; - if ($status == 2 && isset($args[3])) { + if ($status == 2) { $x->addOpenPopup(self::formBookChooseProject($book_id)); + return; } $daoBook = new wsDAOBook($core->con); @@ -253,9 +254,29 @@ class wsAjax extends cubeAjax { public static function bookChooseProject($args, &$x) { + global $core; + $book_id = $_POST['book_id']; + if ($_POST['book_project'] == 0) { - $project = 0; + if (!isset($_POST['new_book_project_nom']) || $_POST['new_book_project_nom'] == '') { + $x->addError('new_book_project_nom'); + return; + } + + $core->loadExtranetClasses(); + + $daoBook = new wsDAOBook($core->con); + $book = $daoBook->selectById($book_id); + + $daoProjet = new extranetDAOProjet($core->con); + $data = array(); + $data['nom'] = $_POST['new_book_project_nom']; + $data['chef'] = $core->user->utilisateur_id; + $data['client'] = $book->proprietaire_id; + $data['devis'] = 0; + $data['projet_id'] = 'new'; + $project = $daoProjet->sauve($data); } else { $project = $_POST['book_project']; } @@ -270,16 +291,50 @@ class wsAjax extends cubeAjax { public static function bookChooseTache($args, &$x) { + global $core; + $book_id = $_POST['book_id']; $projet_id = $_POST['projet_id']; - if ($_POST['book_tache'] == 0) { - $tache = 0; + if ($_POST['tache'] == 0) { + $ok = true; + + if (!isset($_POST['nom']) || $_POST['nom'] == '') { + $x->addError('nom'); + $ok = false; + } else { + $x->addOk('nom'); + } + + if (!isset($_POST['budget']) || $_POST['budget'] == '') { + $x->addError('budget'); + $ok = false; + } else { + $x->addOk('budget'); + } + + $core->loadExtranetClasses(); + $daoTache = new extranetDAOTache($core->con); + + $data = array(); + $data['tache_id'] = 'new'; + $data['projet'] = $projet_id; + $data['nom'] = $_POST['nom']; + $data['categorie'] = 8; + $data['taux_journalier'] = TAUX_JOURNALIER; + $data['budget'] = $_POST['budget']; + $data['type'] = 0; + + $tache = $daoTache->sauve($data); } else { - $tache = $_POST['book_tache']; + $tache = $_POST['tache']; } + $daoBook = new wsDAOBook($core->con); + $daoBook->setTache($book_id, $tache); + $x->addClosePopup(); + $x->addContent('listeBooks', wsUrl::listeBooks()); } public static function changeLang($args, &$x) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 24bf79d9b..c526610a5 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -98,7 +98,12 @@ class wsUrl { } if ($droits->revendeur) { if ($droits->admin || $book->status <= 1) { - $res .= '' . $core->books_status[$book->status] . ''; + $p = ''; + if (!is_null($book->projet)) { + $p = ' ' . cubeMedia::silk('arrow_right.png') . ''; + } + + $res .= '' . $core->books_status[$book->status] . '' . $p . ''; } else if ($book->status > 1) { $res .= '' . $core->books_status[1] . ''; } @@ -151,6 +156,7 @@ class wsUrl { if (wsDroits::admin()) { $status = $core->books_status; + $status[2] = __('Facturé (associé à un projet)'); } else { $status = array(); $status[-1] = $core->books_status[-1]; @@ -163,9 +169,6 @@ class wsUrl { foreach($status as $s => $title) { $res .= '
  • ' . $title . '
  • '; } - if (wsDroits::admin()) { - $res .= '
  • ' . __('Ajouter à un projet') . '
  • '; - } $res .= ''; return $res; } @@ -497,13 +500,13 @@ html{height:100%}' . "\n"; $book = $dao->selectById($book_id); $projects = array("--" => '0'); - $r = $core->con->select('SELECT * FROM projets WHERE client IN( SELECT facturable_id FROM ws_users_tree WHERE utilisateur_id IN (SELECT utilisateur_id FROM utilisateurs WHERE entreprise=\'' . $core->con->escape($book->proprietaire_id) . '\')) ORDER BY projet_id DESC'); + $r = $core->con->select('SELECT * FROM projets WHERE client IN(SELECT entreprise FROM utilisateurs WHERE utilisateur_id IN( SELECT facturable_id FROM ws_users_tree WHERE utilisateur_id IN (SELECT utilisateur_id FROM utilisateurs WHERE entreprise=\'' . $core->con->escape($book->proprietaire_id) . '\'))) ORDER BY projet_id DESC'); while ($r->fetch()) { $projects[$r->projet_id . ' - ' . $r->nom] = $r->projet_id; } - $res = '' . __('Choisir un projet') . ' : ' . form::hidden('book_id', $book_id) . form::combo('book_project', $projects,$book->projet) . ''; - $res .= '' . __('ou créer un nouveau projet') . ' : ' . form::field('new_book_project_nom', 64, 1024) . ''; + $res = '' . __('Choisir un projet') . ' : ' . form::hidden('book_id', $book_id) . form::combo('book_project', $projects, $book->projet) . ''; + $res .= '' . __('ou créer un nouveau projet') . ' : ' . form::field('new_book_project_nom', 64, 1024, $book->nom) . ''; return $res; } @@ -516,13 +519,26 @@ html{height:100%}' . "\n"; $book = $dao->selectById($book_id); $taches = array("--" => '0'); - $r = $core->con->select('SELECT * FROM taches WHERE projet=\'' . $core->con->escape($projet_id) . '\''); + $r = $core->con->select('SELECT * FROM taches WHERE projet=\'' . $core->con->escape($projet_id) . '\' AND categorie=8'); while ($r->fetch()) { $taches[$r->nom] = $r->tache_id; } - $res = '' . __('Choisir une tâche') . ' : ' . form::hidden('book_id', $book_id) . form::hidden('projet_id', $projet_id) . form::combo('tache', $taches) . ''; - $res .= '' . __('ou créer une nouvelle tâche') . ' : ' . form::field('nom', 32, 1024, $book->nom) . ' ' . __('ayant le budget suivant') . ' ' . form::field('budget', 6, 6) . ''; + $res = ''; + + if ($r->count() > 0) { + $res .= '' . __('Choisir une tâche') . ' : ' . form::hidden('book_id', $book_id) . form::hidden('projet_id', $projet_id) . form::combo('tache', $taches) . ''; + $res .= '' . __('ou créer une nouvelle tâche') . ' : ' . form::field('nom', 32, 1024, 'Fluidbook #' . $book->book_id . ' : ' . $book->nom) . ' ' . __('ayant le budget suivant') . ' ' . form::field('budget', 6, 6) . ''; + } else { + $res .= '' . __('Créer une tâche') . ' : ' + . form::hidden('book_id', $book_id) + . form::hidden('projet_id', $projet_id) + . form::hidden('tache', '0') + . form::field('nom', 32, 1024, 'Fluidbook #' . $book->book_id . ' : ' . $book->nom) + . ' ' . __('ayant le budget suivant') + . ' ' . form::field('budget', 6, 6) . ''; + } + return $res; } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index e1d7d6277..5aea76c7c 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -53,7 +53,7 @@ class wsDAOBook extends commonDAO { $book->date = TIME; $book->chapters = json_encode(array()); $book->parametres = new wsBookParametres(); - $book->tache=0; + $book->tache = 0; $book->pages = array(); return $book; } @@ -439,6 +439,14 @@ class wsDAOBook extends commonDAO { $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } + public function setTache($book_id, $tache) + { + $c = $this->con->openCursor('books'); + $c->tache = $tache; + $c->status = 2; + $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + } + public function touch($book_id) { $c = $this->con->openCursor('books'); diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index 729cf258b..b7e0ccaf8 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -16,6 +16,9 @@ class wsBook extends cubeMetier { protected $hash; protected $compteur_visites; + protected $tache; + protected $projet; + protected $status; protected $date_status; diff --git a/style/ws/style.css b/style/ws/style.css index a776abb3c..f1f06af15 100644 --- a/style/ws/style.css +++ b/style/ws/style.css @@ -193,6 +193,7 @@ input[type="text"],input[type="password"],select,textarea{ .liste .action{width:1px;} .liste th a{color:#797D62;text-decoration:none;font-weight:bold;} .liste th a:hover{text-decoration:underline;} +.liste td a.icon img{vertical-align:middle;margin-top:0px;} .form td a img, .liste td a img{margin-top:4px;} @@ -508,3 +509,5 @@ th.stats_col{ .downbookContextMenu a{ text-decoration:none; } + +