Fix: A lot of debug in project module

This commit is contained in:
Laurent Destailleur 2009-02-04 20:38:07 +00:00
parent b7ee6c6e5e
commit 0d386d7e6c
14 changed files with 311 additions and 209 deletions

View File

@ -189,7 +189,7 @@ class FactureRec extends Facture
$this->id = $rowid; $this->id = $rowid;
$this->titre = $obj->titre; $this->titre = $obj->titre;
$this->ref = $obj->facnumber; $this->ref = $obj->titre;
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
$this->type = $obj->type; $this->type = $obj->type;
$this->datep = $obj->dp; $this->datep = $obj->dp;
@ -457,5 +457,31 @@ class FactureRec extends Facture
return -2; return -2;
} }
} }
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien ('', 'withdraw')
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?facid='.$this->id.'">';
$lienfin='</a>';
$picto='bill';
$label=$langs->trans("ShowInvoice").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
return $result;
}
} }
?> ?>

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -22,7 +22,7 @@
\ingroup facture \ingroup facture
\brief Page d'affichage d'une facture récurrent \brief Page d'affichage d'une facture récurrent
\version $Id$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once("./facture-rec.class.php"); require_once("./facture-rec.class.php");
@ -30,14 +30,14 @@ require_once(DOL_DOCUMENT_ROOT."/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
if (!$user->rights->facture->lire) if (!$user->rights->facture->lire)
accessforbidden(); accessforbidden();
$facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"]; $facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"];
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
if ($page == -1) if ($page == -1)
{ {
$page = 0 ; $page = 0 ;
} }
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
@ -99,10 +99,10 @@ llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-
$html = new Form($db); $html = new Form($db);
/********************************************************************* /*********************************************************************
* *
* Mode creation * Mode creation
* *
************************************************************************/ ************************************************************************/
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
print_titre($langs->trans("CreateRepeatableInvoice")); print_titre($langs->trans("CreateRepeatableInvoice"));
@ -393,8 +393,7 @@ else
} }
else else
{ {
/* Facture non trouvée */ print $langs->trans("ErrorRecordNotFound");
print "Facture inexistante ou accés refusé";
} }
} else { } else {
/*************************************************************************** /***************************************************************************
@ -479,9 +478,9 @@ else
} }
} }
} }
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -157,19 +157,20 @@ class FormOther
/** /**
* \brief Retourn list of project and tasks * \brief Retourn list of project and tasks
* \param selected Pre-selected value * \param selected Pre-selected value
* \param htmlname Name of html select
* \param modeproject 1 to restrict on projects owned by user * \param modeproject 1 to restrict on projects owned by user
* \param modetask 1 to restrict on tasks associated to user * \param modetask 1 to restrict on tasks associated to user
* \param htmlname Name of html select * \param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
*/ */
function selectProjectTasks($selected='',$htmlname='task_parent', $modeproject=0, $modetask=0) function selectProjectTasks($selected='',$htmlname='task_parent', $modeproject=0, $modetask=0, $mode)
{ {
global $user; global $user, $langs;
require_once(DOL_DOCUMENT_ROOT."/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/project.class.php");
//print $modeproject.'-'.$modetask; //print $modeproject.'-'.$modetask;
$project=new Project($this->db); $project=new Project($this->db);
$tasksarray=$project->getTasksArray($modetask?$user:0, $modeproject?$user:0); $tasksarray=$project->getTasksArray($modetask?$user:0, $modeproject?$user:0, $mode);
if ($tasksarray) if ($tasksarray)
{ {
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
@ -179,40 +180,45 @@ class FormOther
PLineSelect($j, 0, $tasksarray, $level); PLineSelect($j, 0, $tasksarray, $level);
print '</select>'; print '</select>';
} }
else
{
print '<div class="warning">'.$langs->trans("NoProject").'</div>';
}
} }
} }
/** /**
* Enter description here... * Write all lines of a project (if parent = 0)
* *
* @param unknown_type $inc * @param unknown_type $inc
* @param unknown_type $parent * @param unknown_type $parent
* @param unknown_type $lines * @param unknown_type $lines
* @param unknown_type $level * @param unknown_type $level
*/ */
function PLineSelect(&$inc, $parent, $lines, &$level) function PLineSelect(&$inc, $parent, $lines, $level=0)
{ {
global $langs; global $langs, $user, $conf;
$lastprojectid=0; $lastprojectid=0;
for ($i = 0 ; $i < sizeof($lines) ; $i++) for ($i = 0 ; $i < sizeof($lines) ; $i++)
{ {
if ($parent == 0) $level = 0;
if ($lines[$i]->fk_parent == $parent) if ($lines[$i]->fk_parent == $parent)
{ {
$var = !$var; $var = !$var;
// Break on a new project // Break on a new project
if ($parent == 0 && $lines[$i]->projectid != $lastprojectid) if ($parent == 0)
{ {
print '<option value="'.$lines[$i]->projectid.'_0">'; if ($lines[$i]->projectid != $lastprojectid)
{
if ($i > 0 && $conf->browser->firefox) print '<option value="0" disabled="true">----------</option>';
print '<option value="'.$lines[$i]->projectid.'_0">'; // Project -> Task
print $langs->trans("Project").' '.$lines[$i]->projectref; print $langs->trans("Project").' '.$lines[$i]->projectref;
if ($lines[$i]->name || $lines[$i]->fistname) if ($lines[$i]->name || $lines[$i]->fistname)
{ {
//print ' ('.$lines[$i]->name.($lines[$i]->name && $lines[$i]->firstname?' ':'').$lines[$i]->firstname.')'; if ($user->admin) print ' ('.$langs->trans("Owner").': '.$lines[$i]->name.($lines[$i]->name && $lines[$i]->firstname?' ':'').$lines[$i]->firstname.')';
} }
else else
{ {
@ -224,12 +230,16 @@ function PLineSelect(&$inc, $parent, $lines, &$level)
$lastprojectid=$lines[$i]->projectid; $lastprojectid=$lines[$i]->projectid;
$inc++; $inc++;
} }
}
// Print task
if ($lines[$i]->id > 0)
{
print '<option value="'.$lines[$i]->projectid.'_'.$lines[$i]->id.'">'; print '<option value="'.$lines[$i]->projectid.'_'.$lines[$i]->id.'">';
print $langs->trans("Project").' '.$lines[$i]->projectref; print $langs->trans("Project").' '.$lines[$i]->projectref;
if ($lines[$i]->name || $lines[$i]->fistname) if ($lines[$i]->name || $lines[$i]->fistname)
{ {
//print ' ('.$lines[$i]->name.($lines[$i]->name && $lines[$i]->firstname?' ':'').$lines[$i]->firstname.')'; if ($user->admin) print ' ('.$langs->trans("Owner").': '.$lines[$i]->name.($lines[$i]->name && $lines[$i]->firstname?' ':'').$lines[$i]->firstname.')';
} }
else else
{ {
@ -241,8 +251,8 @@ function PLineSelect(&$inc, $parent, $lines, &$level)
print "&nbsp;&nbsp;&nbsp;"; print "&nbsp;&nbsp;&nbsp;";
} }
print $lines[$i]->title."</option>\n"; print $lines[$i]->title."</option>\n";
$inc++; $inc++;
}
$level++; $level++;
if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level); if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level);

View File

@ -17,7 +17,7 @@ AllProjects=All projects
ProjectsList=List of projects ProjectsList=List of projects
ShowProject=Show project ShowProject=Show project
SetProject=Set project SetProject=Set project
NoProject=No project defined NoProject=No project defined or owned
NbOpenTasks=Nb of opened tasks NbOpenTasks=Nb of opened tasks
NbOfProjects=Nb of projects NbOfProjects=Nb of projects
TimeSpent=Time spent TimeSpent=Time spent
@ -38,11 +38,12 @@ MyActivities=My tasks/activities
DurationEffective=Effective duration DurationEffective=Effective duration
MyProjects=My projects MyProjects=My projects
Time=Time Time=Time
ListProposalsAssociatedProject=Lists of the commercial proposals associated with the project ListProposalsAssociatedProject=List of the commercial proposals associated with the project
ListOrdersAssociatedProject=Lists of the orders associated with the project ListOrdersAssociatedProject=List of customers' orders associated with the project
ListInvoicesAssociatedProject=Lists of the invoices associated with the project ListInvoicesAssociatedProject=List of customers' invoices associated with the project
ListSupplierOrdersAssociatedProject=List of suppliers orders associated with the project ListPredefinedInvoicesAssociatedProject=List of customers' predefined invoices associated with project
ListSupplierInvoicesAssociatedProject=List of suppliers invoices associated with the project ListSupplierOrdersAssociatedProject=List of suppliers' orders associated with the project
ListSupplierInvoicesAssociatedProject=List of suppliers' invoices associated with the project
ListContractAssociatedProject=List of contracts associated with the project ListContractAssociatedProject=List of contracts associated with the project
ActivityOnProjectThisWeek=Activity on project this week ActivityOnProjectThisWeek=Activity on project this week
ActivityOnProjectThisMonth=Activity on project this month ActivityOnProjectThisMonth=Activity on project this month

View File

@ -17,7 +17,7 @@ AllProjects=Tous les projets
ProjectsList=Liste des projets ProjectsList=Liste des projets
ShowProject=Afficher projet ShowProject=Afficher projet
SetProject=Définir projet SetProject=Définir projet
NoProject=Aucun projet défini NoProject=Aucun projet défini ou responsable
NbOpenTasks=Nb Tâches Ouvertes NbOpenTasks=Nb Tâches Ouvertes
NbOfProjects=Nombre de projets NbOfProjects=Nombre de projets
TimeSpent=Temps consommé TimeSpent=Temps consommé
@ -41,6 +41,7 @@ Time=Temps
ListProposalsAssociatedProject=Liste des propositions commerciales associées au projet ListProposalsAssociatedProject=Liste des propositions commerciales associées au projet
ListOrdersAssociatedProject=Liste des commandes clients associées au projet ListOrdersAssociatedProject=Liste des commandes clients associées au projet
ListInvoicesAssociatedProject=Liste des factures clients associées au projet ListInvoicesAssociatedProject=Liste des factures clients associées au projet
ListPredefinedInvoicesAssociatedProject=Liste des factures clients prédéfinies associées au projet
ListSupplierOrdersAssociatedProject=Liste des commandes fournisseurs associées au projet ListSupplierOrdersAssociatedProject=Liste des commandes fournisseurs associées au projet
ListSupplierInvoicesAssociatedProject=Liste des factures fournisseur associées au projet ListSupplierInvoicesAssociatedProject=Liste des factures fournisseur associées au projet
ListContractAssociatedProject=Liste des contrats associés au projet ListContractAssociatedProject=Liste des contrats associés au projet

View File

@ -242,15 +242,6 @@ function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1)
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
if ($showproject)
{
print "<td>";
$projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref;
print $projectstatic->getNomUrl(1);
print "</td>";
}
print "<td>".$lines[$i]->id."</td>"; print "<td>".$lines[$i]->id."</td>";
print "<td>"; print "<td>";
@ -261,10 +252,18 @@ function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1)
print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n"; print '<a href="task.php?id='.$lines[$i]->id.'">'.$lines[$i]->title."</a></td>\n";
if ($showproject)
{
print "<td>";
$projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref;
print $projectstatic->getNomUrl(1);
print "</td>";
}
$heure = intval($lines[$i]->duration); $heure = intval($lines[$i]->duration);
$minutes = round((($lines[$i]->duration - $heure) * 60),0); $minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2); $minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n"; print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
print "</tr>\n"; print "</tr>\n";

View File

@ -74,7 +74,8 @@ class Project extends CommonObject
$sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."',"; $sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."',";
$sql.= " ".($this->socid > 0?$this->socid:"null").","; $sql.= " ".($this->socid > 0?$this->socid:"null").",";
$sql.= " ".$user->id.","; $sql.= " ".$user->id.",";
$sql.= " ".$this->user_resp_id.", ".$this->db->idate(mktime()).", 0)"; $sql.= " ".($this->user_resp_id>0?$this->user_resp_id:'null').",";
$sql.= " ".$this->db->idate(mktime()).", 0)";
dolibarr_syslog("Project::create sql=".$sql,LOG_DEBUG); dolibarr_syslog("Project::create sql=".$sql,LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -227,6 +228,7 @@ class Project extends CommonObject
if ($type == 'propal') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=".$this->id; if ($type == 'propal') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal WHERE fk_projet=".$this->id;
if ($type == 'order') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=".$this->id; if ($type == 'order') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande WHERE fk_projet=".$this->id;
if ($type == 'invoice') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=".$this->id; if ($type == 'invoice') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE fk_projet=".$this->id;
if ($type == 'invoice_predefined') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_rec WHERE fk_projet=".$this->id;
if ($type == 'order_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE fk_projet=".$this->id; if ($type == 'order_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE fk_projet=".$this->id;
if ($type == 'invoice_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn WHERE fk_projet=".$this->id; if ($type == 'invoice_supplier') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture_fourn WHERE fk_projet=".$this->id;
if ($type == 'contract') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."contrat WHERE fk_projet=".$this->id; if ($type == 'contract') $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."contrat WHERE fk_projet=".$this->id;
@ -449,9 +451,10 @@ class Project extends CommonObject
* Sort order is on project, TODO then of position of task, and last on title of first level task * Sort order is on project, TODO then of position of task, and last on title of first level task
* @param usert Object user to limit task affected to a particular user * @param usert Object user to limit task affected to a particular user
* @param userp Object user to limit projects of a particular user * @param userp Object user to limit projects of a particular user
* @param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
* @return array Array of tasks * @return array Array of tasks
*/ */
function getTasksArray($usert=0,$userp=0) function getTasksArray($usert=0, $userp=0, $mode=0)
{ {
$tasks = array(); $tasks = array();
@ -461,6 +464,22 @@ class Project extends CommonObject
$sql = "SELECT p.rowid as projectid, p.ref, p.title as ptitle,"; $sql = "SELECT p.rowid as projectid, p.ref, p.title as ptitle,";
$sql.= " t.rowid, t.title, t.fk_task_parent, t.duration_effective,"; $sql.= " t.rowid, t.title, t.fk_task_parent, t.duration_effective,";
$sql.= " up.name, up.firstname"; $sql.= " up.name, up.firstname";
if ($mode == 0)
{
$sql.= " FROM (".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."projet_task as t";
if (is_object($usert)) // Limit to task affected to a user
{
$sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as ta";
}
$sql.= ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
$sql.= " WHERE t.fk_projet = p.rowid";
if ($this->id) $sql .= " AND t.fk_projet =".$this->id;
if (is_object($usert)) $sql .= " AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
}
if ($mode == 1)
{
$sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql.= " FROM (".MAIN_DB_PREFIX."projet as p";
if (is_object($usert)) // Limit to task affected to a user if (is_object($usert)) // Limit to task affected to a user
{ {
@ -479,6 +498,7 @@ class Project extends CommonObject
if (is_object($usert)) $sql .= " AND t.fk_projet = p.rowid AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id; if (is_object($usert)) $sql .= " AND t.fk_projet = p.rowid AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)"; if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
$sql.= " ORDER BY p.ref, t.title"; $sql.= " ORDER BY p.ref, t.title";
}
dolibarr_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG); dolibarr_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -258,7 +258,7 @@ print "</table><br />";
/* Affichage de la liste des projets du mois */ /* Affichage de la liste des projets du mois */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.strftime("%B %Y", $now).'</td>'; print '<td>'.$langs->trans("ActivityOnProjectThisMonth").': '.dolibarr_print_date($now,"%B %Y").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>'; print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -28,6 +28,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/facture-rec.class.php");
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.facture.class.php"); if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.facture.class.php");
if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"); if ($conf->fournisseur->enabled) require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
@ -113,6 +114,10 @@ $listofreferent=array(
'title'=>"ListInvoicesAssociatedProject", 'title'=>"ListInvoicesAssociatedProject",
'class'=>'Facture', 'class'=>'Facture',
'test'=>$conf->facture->enabled), 'test'=>$conf->facture->enabled),
'invoice_predefined'=>array(
'title'=>"ListPredefinedInvoicesAssociatedProject",
'class'=>'FactureRec',
'test'=>$conf->facture->enabled && $conf->global->FACTURE_ENABLE_RECUR),
'order_supplier'=>array( 'order_supplier'=>array(
'title'=>"ListSupplierOrdersAssociatedProject", 'title'=>"ListSupplierOrdersAssociatedProject",
'class'=>'CommandeFournisseur', 'class'=>'CommandeFournisseur',

View File

@ -70,11 +70,14 @@ $userstatic = new User($db);
$staticsoc=new Societe($db); $staticsoc=new Societe($db);
$sql = "SELECT p.rowid as projectid, p.ref, p.title, ".$db->pdate("p.dateo")." as do, p.fk_user_resp,"; $sql = "SELECT p.rowid as projectid, p.ref, p.title, ".$db->pdate("p.dateo")." as do, p.fk_user_resp,";
$sql .= " u.login,";
$sql .= " s.nom, s.rowid as socid, s.client"; $sql .= " s.nom, s.rowid as socid, s.client";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql .= " FROM (".MAIN_DB_PREFIX."projet as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ") LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = p.fk_soc"; $sql .= ")";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on p.fk_user_resp = u.rowid";
$sql .= " WHERE 1 = 1 "; $sql .= " WHERE 1 = 1 ";
if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id; if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
@ -165,7 +168,7 @@ if ($resql)
// Title // Title
$userstatic->id=$objp->fk_user_resp; $userstatic->id=$objp->fk_user_resp;
$userstatic->nom=$objp->fk_user_resp; $userstatic->nom=$objp->login;
print '<td align="left">'; print '<td align="left">';
if ($objp->fk_user_resp > 0) print $userstatic->getNomUrl(1); if ($objp->fk_user_resp > 0) print $userstatic->getNomUrl(1);
else print $langs->trans("SharedProject"); else print $langs->trans("SharedProject");

View File

@ -41,10 +41,12 @@ $result = restrictedArea($user, 'projet', $projetid);
* Actions * Actions
*/ */
if ($_POST["action"] == 'createtask' && empty($_POST["cancel"]) && $user->rights->projet->creer) if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
{ {
$error=0; $error=0;
if (empty($_POST["cancel"]))
{
if (empty($_POST['task_parent'])) if (empty($_POST['task_parent']))
{ {
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTaks")); $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTaks"));
@ -65,12 +67,13 @@ if ($_POST["action"] == 'createtask' && empty($_POST["cancel"]) && $user->rights
$result=$project->CreateTask($user, $_POST["task_name"], $task_parent, $_POST["userid"]); $result=$project->CreateTask($user, $_POST["task_name"], $task_parent, $_POST["userid"]);
} }
}
if (! $error) if (! $error)
{ {
if (empty($projetid)) if (empty($projetid))
{ {
Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'); Header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($_REQUEST["mode"])?'':'?mode='.$_REQUEST["mode"]));
exit; exit;
} }
else else
@ -150,16 +153,21 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("ChildOfTaks").'</td><td>'; print '<tr><td>'.$langs->trans("ChildOfTaks").'</td><td>';
print $htmlother->selectProjectTasks($projet->id, 'task_parent', 1, 0); print $htmlother->selectProjectTasks($projet->id, 'task_parent', $user->admin?0:1, 0, 1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>'; print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
print $form->select_users($user->id,'userid',1); print $form->select_users($user->id,'userid',1);
print '</td></tr>'; print '</td></tr>';
$project=new Project($db);
$tasksarray=$project->getTasksArray(0, $user, 1);
print '<tr><td colspan="2" align="center">'; print '<tr><td colspan="2" align="center">';
if (sizeof($tasksarray))
{
print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
}
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>'; print '</td></tr>';

View File

@ -85,9 +85,9 @@ $tasksarray=$projet->getTasksArray($_GET["mode"]=='mine'?$user:0);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td>'.$langs->trans("Task").'</td>'; print '<td>'.$langs->trans("Task").'</td>';
print '<td>'.$langs->trans("Label").'</td>'; print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("Project").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -62,6 +62,10 @@ alter table llx_commande_fournisseur_log add column comment varchar(255) NULL;
delete from llx_categorie_association where fk_categorie_mere = fk_categorie_fille; delete from llx_categorie_association where fk_categorie_mere = fk_categorie_fille;
-- V4.1 delete from llx_projet_task where fk_projet not in (select rowid from llx_projet);
-- V4.1 ALTER TABLE llx_projet_task ADD CONSTRAINT fk_projet_task_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);
-- Put at the end. Cas have duplicate values -- Put at the end. Cas have duplicate values
ALTER TABLE llx_categorie_association drop index idx_categorie_association_fk_categorie_fille; ALTER TABLE llx_categorie_association drop index idx_categorie_association_fk_categorie_fille;
ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association (fk_categorie_mere, fk_categorie_fille); ALTER TABLE llx_categorie_association ADD UNIQUE INDEX uk_categorie_association (fk_categorie_mere, fk_categorie_fille);

View File

@ -0,0 +1,26 @@
-- ============================================================================
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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 2 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, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
--
-- ============================================================================
ALTER TABLE llx_projet_task ADD CONSTRAINT fk_projet_task_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);