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

@ -40,7 +40,7 @@ class FactureRec extends Facture
var $table_element='facture_rec';
var $table_element_line='facturedet_rec';
var $fk_element='fk_facture';
var $id ;
var $socid; // Id client
@ -69,7 +69,7 @@ class FactureRec extends Facture
$this->db = $DB ;
$this->facid = $facid;
}
/**
* \brief Créé la facture recurrente/modele
* \return int <0 si ko, id facture rec crée si ok
@ -77,9 +77,9 @@ class FactureRec extends Facture
function create($user)
{
global $langs;
$error=0;
// Nettoyage parametere
$this->titre=trim($this->titre);
@ -91,7 +91,7 @@ class FactureRec extends Facture
}
$this->db->begin();
// Charge facture modele
$facsrc=new Facture($this->db);
$result=$facsrc->fetch($this->facid);
@ -127,7 +127,7 @@ class FactureRec extends Facture
$error++;
}
}
if ($error)
{
$this->db->rollback();
@ -189,7 +189,7 @@ class FactureRec extends Facture
$this->id = $rowid;
$this->titre = $obj->titre;
$this->ref = $obj->facnumber;
$this->ref = $obj->titre;
$this->ref_client = $obj->ref_client;
$this->type = $obj->type;
$this->datep = $obj->dp;
@ -362,14 +362,14 @@ class FactureRec extends Facture
}
}
/**
* \brief Ajoute une ligne de facture
*/
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0)
{
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
if ($this->brouillon)
{
if (strlen(trim($qty))==0)
@ -379,7 +379,7 @@ class FactureRec extends Facture
$remise = 0;
$price = $pu;
$subprice = $price;
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
@ -388,13 +388,13 @@ class FactureRec extends Facture
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
if (trim(strlen($remise_percent)) > 0)
{
$remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, total_ht, total_tva, total_ttc)";
$sql .= " VALUES ('".$facid."', '".addslashes($desc)."'";
$sql .= ",".price2num($price);
@ -407,7 +407,7 @@ class FactureRec extends Facture
$sql .= ",'".price2num($total_ht)."'";
$sql .= ",'".price2num($total_tva)."'";
$sql .= ",'".price2num($total_ttc)."') ;";
dolibarr_syslog("Facture-rec::addline sql=".$sql, LOG_DEBUG);
if ($this->db->query( $sql))
{
@ -423,8 +423,8 @@ class FactureRec extends Facture
}
}
}
/**
* \brief Rend la facture automatique
*
@ -433,13 +433,13 @@ class FactureRec extends Facture
{
if ($user->rights->facture->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec ";
$sql .= " SET frequency = '".$freq."', last_gen='".$courant."'";
$sql .= " WHERE rowid = ".$this->facid.";";
$resql = $this->db->query($sql);
if ($resql)
{
$this->frequency = $freq;
@ -457,5 +457,31 @@ class FactureRec extends Facture
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
/* 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
* it under the terms of the GNU General Public License as published by
@ -18,11 +18,11 @@
*/
/**
\file htdocs/compta/facture/fiche-rec.php
\ingroup facture
\brief Page d'affichage d'une facture récurrent
\version $Id$
*/
\file htdocs/compta/facture/fiche-rec.php
\ingroup facture
\brief Page d'affichage d'une facture récurrent
\version $Id$
*/
require("./pre.inc.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");
if (!$user->rights->facture->lire)
accessforbidden();
accessforbidden();
$facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"];
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
if ($page == -1)
{
$page = 0 ;
$page = 0 ;
}
$limit = $conf->liste_limit;
$offset = $limit * $page ;
@ -50,16 +50,16 @@ $sortfield="f.datef";
// Sécurité accés client
if ($user->societe_id > 0)
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
$action = '';
$socid = $user->societe_id;
}
/*
* Actions
*/
*/
// Ajout
if ($_POST["action"] == 'add')
@ -99,16 +99,16 @@ llxHeader('',$langs->trans("RepeatableInvoices"),'ch-facture.html#s-fac-facture-
$html = new Form($db);
/*********************************************************************
*
* Mode creation
*
************************************************************************/
*
* Mode creation
*
************************************************************************/
if ($_GET["action"] == 'create')
{
print_titre($langs->trans("CreateRepeatableInvoice"));
if ($mesg) print $mesg.'<br>';
$facture = new Facture($db);
if ($facture->fetch($_GET["facid"]) > 0)
@ -152,15 +152,15 @@ if ($_GET["action"] == 'create')
print '<br>';
if ($conf->service->enabled) {
print_titre($langs->trans("ProductsAndServices"));
print_titre($langs->trans("ProductsAndServices"));
} else {
print_titre($langs->trans("Products"));
print_titre($langs->trans("Products"));
}
/*
* Lignes de factures
*
*/
* Lignes de factures
*
*/
print '<table class="noborder" width="100%">';
print '<tr><td colspan="3">';
@ -293,10 +293,10 @@ else
print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre);
print '<br>';
/*
* Facture
*/
* Facture
*/
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Customer").'</td>';
print "<td colspan=\"3\">";
@ -336,9 +336,9 @@ else
print "</table><br>";
/*
* Lignes
*
*/
* Lignes
*
*/
print_titre($langs->trans("Products"));
print '<table class="noborder" width="100%">';
@ -380,8 +380,8 @@ else
/**
* Barre d'actions
*/
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($fac->statut == 0 && $user->rights->facture->supprimer)
@ -393,95 +393,94 @@ else
}
else
{
/* Facture non trouvée */
print "Facture inexistante ou accés refusé";
print $langs->trans("ErrorRecordNotFound");
}
} else {
/***************************************************************************
} else {
/***************************************************************************
* *
* Mode Liste *
* *
* *
***************************************************************************/
if ($user->rights->facture->lire)
if ($user->rights->facture->lire)
{
$sql = "SELECT s.nom, s.rowid as socid, f.titre, f.total, f.rowid as facid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql.= " WHERE f.fk_soc = s.rowid";
if ($socid)
$sql .= " AND s.rowid = ".$socid;
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
// $sql .= $db->plimit($limit + 1,$offset);
$result = $db->query($sql);
}
if ($result)
{
$num = $db->num_rows($result);
print_barre_liste($langs->trans("RepeatableInvoices"),$page,"fiche-rec.php","&socid=$socid",$sortfield,$sortorder,'',$num);
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socid=$socid","",$sortfiled,$sortorder);
print '</td><td align="right">'.$langs->trans("Amount").'</td>';
print '<td>&nbsp;</td>';
print "</td>\n";
if ($num > 0)
{
$sql = "SELECT s.nom, s.rowid as socid, f.titre, f.total, f.rowid as facid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql.= " WHERE f.fk_soc = s.rowid";
if ($socid)
$sql .= " AND s.rowid = ".$socid;
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
// $sql .= $db->plimit($limit + 1,$offset);
$result = $db->query($sql);
}
if ($result)
{
$num = $db->num_rows($result);
print_barre_liste($langs->trans("RepeatableInvoices"),$page,"fiche-rec.php","&socid=$socid",$sortfield,$sortorder,'',$num);
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socid=$socid","",$sortfiled,$sortorder);
print '</td><td align="right">'.$langs->trans("Amount").'</td>';
print '<td>&nbsp;</td>';
print "</td>\n";
if ($num > 0)
$var=True;
while ($i < min($num,$limit))
{
$var=True;
while ($i < min($num,$limit))
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche-rec.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
print '<td><a href="../fiche.php?socid='.$objp->socid.'">'.$objp->nom.'</a></td>';
print "<td align=\"right\">".price($objp->total)."</td>\n";
if (! $objp->paye)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="fiche-rec.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
print "</a></td>\n";
print '<td><a href="../fiche.php?socid='.$objp->socid.'">'.$objp->nom.'</a></td>';
print "<td align=\"right\">".price($objp->total)."</td>\n";
if (! $objp->paye)
if ($objp->fk_statut == 0)
{
if ($objp->fk_statut == 0)
{
print '<td align="center">brouillon</td>';
}
else
{
print '<td align="center"><a href="facture.php?filtre=paye:0,fk_statut:1">impayée</a></td>';
}
print '<td align="center">brouillon</td>';
}
else
{
print '<td>&nbsp;</td>';
print '<td align="center"><a href="facture.php?filtre=paye:0,fk_statut:1">impayée</a></td>';
}
print "</tr>\n";
$i++;
}
else
{
print '<td>&nbsp;</td>';
}
print "</tr>\n";
$i++;
}
}
print "</table>";
$db->free();
}
else
{
dolibarr_print_error($db);
}
print "</table>";
$db->free();
}
else
{
dolibarr_print_error($db);
}
}
$db->close();
}
llxFooter('$Date$ - $Revision$');
?>
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -157,19 +157,20 @@ class FormOther
/**
* \brief Retourn list of project and tasks
* \param selected Pre-selected value
* \param htmlname Name of html select
* \param modeproject 1 to restrict on projects owned by 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");
//print $modeproject.'-'.$modetask;
$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)
{
print '<select class="flat" name="'.$htmlname.'">';
@ -179,71 +180,80 @@ class FormOther
PLineSelect($j, 0, $tasksarray, $level);
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 $parent
* @param unknown_type $lines
* @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;
for ($i = 0 ; $i < sizeof($lines) ; $i++)
{
if ($parent == 0) $level = 0;
if ($lines[$i]->fk_parent == $parent)
{
$var = !$var;
// 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;
if ($lines[$i]->name || $lines[$i]->fistname)
{
if ($user->admin) print ' ('.$langs->trans("Owner").': '.$lines[$i]->name.($lines[$i]->name && $lines[$i]->firstname?' ':'').$lines[$i]->firstname.')';
}
else
{
print ' ('.$langs->trans("SharedProject").')';
}
//print '-'.$parent.'-'.$lines[$i]->projectid.'-'.$lastprojectid;
print "</option>\n";
$lastprojectid=$lines[$i]->projectid;
$inc++;
}
}
// Print task
if ($lines[$i]->id > 0)
{
print '<option value="'.$lines[$i]->projectid.'_'.$lines[$i]->id.'">';
print $langs->trans("Project").' '.$lines[$i]->projectref;
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
{
print ' ('.$langs->trans("SharedProject").')';
}
//print '-'.$parent.'-'.$lines[$i]->projectid.'-'.$lastprojectid;
print "</option>\n";
$lastprojectid=$lines[$i]->projectid;
if ($lines[$i]->id) print ' > ';
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp;&nbsp;&nbsp;";
}
print $lines[$i]->title."</option>\n";
$inc++;
}
print '<option value="'.$lines[$i]->projectid.'_'.$lines[$i]->id.'">';
print $langs->trans("Project").' '.$lines[$i]->projectref;
if ($lines[$i]->name || $lines[$i]->fistname)
{
//print ' ('.$lines[$i]->name.($lines[$i]->name && $lines[$i]->firstname?' ':'').$lines[$i]->firstname.')';
}
else
{
print ' ('.$langs->trans("SharedProject").')';
}
if ($lines[$i]->id) print ' > ';
for ($k = 0 ; $k < $level ; $k++)
{
print "&nbsp;&nbsp;&nbsp;";
}
print $lines[$i]->title."</option>\n";
$inc++;
$level++;
if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level);
$level--;

View File

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

View File

@ -17,7 +17,7 @@ AllProjects=Tous les projets
ProjectsList=Liste des projets
ShowProject=Afficher projet
SetProject=Définir projet
NoProject=Aucun projet défini
NoProject=Aucun projet défini ou responsable
NbOpenTasks=Nb Tâches Ouvertes
NbOfProjects=Nombre de projets
TimeSpent=Temps consommé
@ -41,6 +41,7 @@ Time=Temps
ListProposalsAssociatedProject=Liste des propositions commerciales associées au projet
ListOrdersAssociatedProject=Liste des commandes 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
ListSupplierInvoicesAssociatedProject=Liste des factures fournisseur associées 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";
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>";
@ -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";
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);
$minutes = round((($lines[$i]->duration - $heure) * 60),0);
$minutes = substr("00"."$minutes", -2);
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
print "</tr>\n";

View File

@ -74,7 +74,8 @@ class Project extends CommonObject
$sql.= " VALUES ('".addslashes($this->ref)."', '".addslashes($this->title)."',";
$sql.= " ".($this->socid > 0?$this->socid:"null").",";
$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);
$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 == '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_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 == '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;
@ -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
* @param usert Object user to limit task affected to 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
*/
function getTasksArray($usert=0,$userp=0)
function getTasksArray($usert=0, $userp=0, $mode=0)
{
$tasks = array();
@ -461,24 +464,41 @@ class Project extends CommonObject
$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.= " up.name, up.firstname";
$sql.= " FROM (".MAIN_DB_PREFIX."projet as p";
if (is_object($usert)) // Limit to task affected to a user
if ($mode == 0)
{
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as ta";
$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)";
}
else
if ($mode == 1)
{
$sql.= ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " FROM (".MAIN_DB_PREFIX."projet as p";
if (is_object($usert)) // Limit to task affected to a user
{
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as ta";
$sql.= ")";
}
else
{
$sql.= ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
}
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
$sql.= " WHERE 1 = 1";
if ($this->id) $sql .= " AND t.fk_projet =".$this->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)";
$sql.= " ORDER BY p.ref, t.title";
}
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
$sql.= " WHERE 1 = 1";
if ($this->id) $sql .= " AND t.fk_projet =".$this->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)";
$sql.= " ORDER BY p.ref, t.title";
dolibarr_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@ -258,7 +258,7 @@ print "</table><br />";
/* Affichage de la liste des projets du mois */
print '<table class="noborder" width="100%">';
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 "</tr>\n";

View File

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

View File

@ -70,11 +70,14 @@ $userstatic = new User($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 .= " u.login,";
$sql .= " s.nom, s.rowid as socid, s.client";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM (".MAIN_DB_PREFIX."projet as p";
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 ";
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;
@ -165,7 +168,7 @@ if ($resql)
// Title
$userstatic->id=$objp->fk_user_resp;
$userstatic->nom=$objp->fk_user_resp;
$userstatic->nom=$objp->login;
print '<td align="left">';
if ($objp->fk_user_resp > 0) print $userstatic->getNomUrl(1);
else print $langs->trans("SharedProject");

View File

@ -41,36 +41,39 @@ $result = restrictedArea($user, 'projet', $projetid);
* Actions
*/
if ($_POST["action"] == 'createtask' && empty($_POST["cancel"]) && $user->rights->projet->creer)
if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
{
$error=0;
if (empty($_POST['task_parent']))
if (empty($_POST["cancel"]))
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTaks"));
$_GET["action"]='create';
$error++;
}
if (empty($_POST['task_parent']))
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTaks"));
$_GET["action"]='create';
$error++;
}
if (! $error)
{
$tmparray=split('_',$_POST['task_parent']);
$projectid=$tmparray[0];
$task_parent=$tmparray[1];
if (empty($task_parent)) $task_parent=0; // If task_parent is ''
if (! $error)
{
$tmparray=split('_',$_POST['task_parent']);
$projectid=$tmparray[0];
$task_parent=$tmparray[1];
if (empty($task_parent)) $task_parent=0; // If task_parent is ''
//print $_POST['task_parent'].'-'.$projectid.'-'.$task_parent;exit;
$project = new Project($db);
$result = $project->fetch($projectid);
//print $_POST['task_parent'].'-'.$projectid.'-'.$task_parent;exit;
$project = new Project($db);
$result = $project->fetch($projectid);
$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 (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;
}
else
@ -150,16 +153,21 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '</td></tr>';
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 '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
print $form->select_users($user->id,'userid',1);
print '</td></tr>';
$project=new Project($db);
$tasksarray=$project->getTasksArray(0, $user, 1);
print '<tr><td colspan="2" align="center">';
print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">';
print ' &nbsp; &nbsp; ';
if (sizeof($tasksarray))
{
print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">';
print ' &nbsp; &nbsp; ';
}
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';

View File

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

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);