From bfb48ecce92490347b2ca2ad754f014031e300db Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 9 Jul 2016 15:30:42 +0200
Subject: [PATCH] Where is the info tab of project ?

---
 htdocs/core/lib/project.lib.php       |  5 ++
 htdocs/projet/class/project.class.php | 49 +++++++++++++++++++
 htdocs/projet/info.php                | 69 +++++++++++++++++++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 htdocs/projet/info.php

diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index fecead20822..602f45db67d 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -110,6 +110,11 @@ function project_prepare_head($object)
 		$h++;
 	}
 
+	$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id;
+	$head[$h][1] = $langs->trans("Info");
+	$head[$h][2] = 'info';
+	$h++;
+	
 	complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove');
 
 	return $head;
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 86548031d8b..ef4d4d7d20f 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -1728,5 +1728,54 @@ class Project extends CommonObject
         return $this->datee < ($now - $conf->projet->warning_delay);
 	}	
 
+	
+	/**
+	 *	Charge les informations d'ordre info dans l'objet commande
+	 *
+	 *	@param  int		$id       Id of order
+	 *	@return	void
+	 */
+	function info($id)
+	{
+	    $sql = 'SELECT c.rowid, datec as datec, tms as datem,';
+	    $sql.= ' date_close as datecloture,';
+	    $sql.= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture';
+	    $sql.= ' FROM '.MAIN_DB_PREFIX.'projet as c';
+	    $sql.= ' WHERE c.rowid = '.$id;
+	    $result=$this->db->query($sql);
+	    if ($result)
+	    {
+	        if ($this->db->num_rows($result))
+	        {
+	            $obj = $this->db->fetch_object($result);
+	            $this->id = $obj->rowid;
+	            if ($obj->fk_user_author)
+	            {
+	                $cuser = new User($this->db);
+	                $cuser->fetch($obj->fk_user_author);
+	                $this->user_creation   = $cuser;
+	            }
+	
+	            if ($obj->fk_user_cloture)
+	            {
+	                $cluser = new User($this->db);
+	                $cluser->fetch($obj->fk_user_cloture);
+	                $this->user_cloture   = $cluser;
+	            }
+	
+	            $this->date_creation     = $this->db->jdate($obj->datec);
+	            $this->date_modification = $this->db->jdate($obj->datem);
+	            $this->date_cloture      = $this->db->jdate($obj->datecloture);
+	        }
+	
+	        $this->db->free($result);
+	
+	    }
+	    else
+	    {
+	        dol_print_error($this->db);
+	    }
+	}
+	
 }
 
diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php
new file mode 100644
index 00000000000..c2e45560f74
--- /dev/null
+++ b/htdocs/projet/info.php
@@ -0,0 +1,69 @@
+<?php
+/* Copyright (C) 2005-2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@capnetworks.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/projet/info.php
+ *      \ingroup    commande
+ *		\brief      Page with info on project
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
+
+if (!$user->rights->projet->lire)	accessforbidden();
+
+$langs->load("projects");
+
+// Security check
+$socid=0;
+$id = GETPOST("id",'int');
+if ($user->societe_id) $socid=$user->societe_id;
+$result=restrictedArea($user,'projet',$id,'');
+
+
+
+/*
+ * View
+ */
+
+$title=$langs->trans("Project").' - '.$object->ref.' '.$object->name;
+if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info");
+$help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
+llxHeader("",$title,$help_url);
+
+$projet = new Project($db);
+$projet->fetch($id);
+$projet->info($id);
+$soc = new Societe($db);
+$soc->fetch($projet->socid);
+
+$head = project_prepare_head($projet);
+
+dol_fiche_head($head, 'info', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
+
+
+print '<table width="100%"><tr><td>';
+dol_print_object_info($projet);
+print '</td></tr></table>';
+
+print '</div>';
+
+llxFooter();
+$db->close();
-- 
GitLab