diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php index 1d0163e07d8..6ba2c1e06df 100644 --- a/htdocs/compta/facture/facture-rec.class.php +++ b/htdocs/compta/facture/facture-rec.class.php @@ -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 = ''; + $lienfin=''; + + $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; + } + } ?> diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 556cac31575..7439c19e287 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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.'
'; - + $facture = new Facture($db); if ($facture->fetch($_GET["facid"]) > 0) @@ -152,15 +152,15 @@ if ($_GET["action"] == 'create') print '
'; 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 ''; print '
'; @@ -293,10 +293,10 @@ else print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre); print '
'; - + /* - * Facture - */ + * Facture + */ print ''; print ''; print "
'.$langs->trans("Customer").'"; @@ -336,9 +336,9 @@ else print "

"; /* - * Lignes - * - */ + * Lignes + * + */ print_titre($langs->trans("Products")); print ''; @@ -380,8 +380,8 @@ else /** - * Barre d'actions - */ + * Barre d'actions + */ print '
'; 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 "
"; + print ''; + print ''; + print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socid=$socid","",$sortfiled,$sortorder); + print ''; + print ''; + print "\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 "
'.$langs->trans("Ref").''.$langs->trans("Amount").' 
"; - print ''; - print ''; - print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socid=$socid","",$sortfiled,$sortorder); - print ''; - print ''; - print "\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 ""; + + print '\n"; + print ''; + + print "\n"; + + if (! $objp->paye) { - $objp = $db->fetch_object($result); - $var=!$var; - - print ""; - - print '\n"; - print ''; - - print "\n"; - - if (! $objp->paye) + if ($objp->fk_statut == 0) { - if ($objp->fk_statut == 0) - { - print ''; - } - else - { - print ''; - } + print ''; } else { - print ''; + print ''; } - - print "\n"; - $i++; } + else + { + print ''; + } + + print "\n"; + $i++; } + } - print "
'.$langs->trans("Ref").''.$langs->trans("Amount").' 
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; + print "'.$objp->nom.'".price($objp->total)."
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; - print "'.$objp->nom.'".price($objp->total)."brouillonimpayéebrouillon impayée
 
"; - $db->free(); - } - else - { - dolibarr_print_error($db); - } + print "
"; + $db->free(); + } + else + { + dolibarr_print_error($db); } - } - $db->close(); +} - llxFooter('$Date$ - $Revision$'); - ?> +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/html.formother.class.php b/htdocs/html.formother.class.php index fa13cccc454..f78a7cc0298 100644 --- a/htdocs/html.formother.class.php +++ b/htdocs/html.formother.class.php @@ -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 ''; } + else + { + print '
'.$langs->trans("NoProject").'
'; + } } } /** - * 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 ''; + print '\n"; + + $lastprojectid=$lines[$i]->projectid; + $inc++; + } + } + + // Print task + if ($lines[$i]->id > 0) + { + print '\n"; - - $lastprojectid=$lines[$i]->projectid; + if ($lines[$i]->id) print ' > '; + for ($k = 0 ; $k < $level ; $k++) + { + print "   "; + } + print $lines[$i]->title."\n"; $inc++; } - print '\n"; - - $inc++; - $level++; if ($lines[$i]->id) PLineSelect($inc, $lines[$i]->id, $lines, $level); $level--; diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 639c739afa4..dcb9136be6e 100755 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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 diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 2444423e1c4..0d69eebb46c 100755 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -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 diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 387053e82ce..7828151a74b 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -242,15 +242,6 @@ function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1) print "\n"; - if ($showproject) - { - print ""; - $projectstatic->id=$lines[$i]->projectid; - $projectstatic->ref=$lines[$i]->projectref; - print $projectstatic->getNomUrl(1); - print ""; - } - print "".$lines[$i]->id.""; print ""; @@ -261,10 +252,18 @@ function PLines(&$inc, $parent, $lines, &$level, $var, $showproject=1) print ''.$lines[$i]->title."\n"; + if ($showproject) + { + print ""; + $projectstatic->id=$lines[$i]->projectid; + $projectstatic->ref=$lines[$i]->projectref; + print $projectstatic->getNomUrl(1); + print ""; + } + $heure = intval($lines[$i]->duration); $minutes = round((($lines[$i]->duration - $heure) * 60),0); $minutes = substr("00"."$minutes", -2); - print ''.$heure." h ".$minutes."\n"; print "\n"; diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 56e1798ab6b..c9db0aa62b0 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -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); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index dc2b72eed70..91819876833 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -258,7 +258,7 @@ print "
"; /* Affichage de la liste des projets du mois */ print ''; print ''; -print ''; +print ''; print ''; print "\n"; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3dd6fe43c02..53f9a2991fd 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -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', diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php index fc6180e7421..1826bfa0b85 100644 --- a/htdocs/projet/liste.php +++ b/htdocs/projet/liste.php @@ -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 ''; print ''; print ''; + $project=new Project($db); + $tasksarray=$project->getTasksArray(0, $user, 1); print ''; diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index 713d1ea43ca..ca7d725cb1c 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -85,9 +85,9 @@ $tasksarray=$projet->getTasksArray($_GET["mode"]=='mine'?$user:0); print '
'.$langs->trans("ActivityOnProjectThisMonth").': '.strftime("%B %Y", $now).''.$langs->trans("ActivityOnProjectThisMonth").': '.dolibarr_print_date($now,"%B %Y").''.$langs->trans("Time").'
'; if ($objp->fk_user_resp > 0) print $userstatic->getNomUrl(1); else print $langs->trans("SharedProject"); diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index a94c329087c..b604b2994f0 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -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 '
'.$langs->trans("ChildOfTaks").''; - print $htmlother->selectProjectTasks($projet->id, 'task_parent', 1, 0); + print $htmlother->selectProjectTasks($projet->id, 'task_parent', $user->admin?0:1, 0, 1); print '
'.$langs->trans("AffectedTo").''; print $form->select_users($user->id,'userid',1); print '
'; - print ''; - print '     '; + if (sizeof($tasksarray)) + { + print ''; + print '     '; + } print ''; print '
'; print ''; -print ''; print ''; print ''; +print ''; print ''; print "\n"; diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index 6cb36fc9515..56940f50c77 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -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); diff --git a/mysql/tables/llx_projet_task.key.sql b/mysql/tables/llx_projet_task.key.sql new file mode 100644 index 00000000000..96d963493f9 --- /dev/null +++ b/mysql/tables/llx_projet_task.key.sql @@ -0,0 +1,26 @@ +-- ============================================================================ +-- Copyright (C) 2009 Laurent Destailleur +-- +-- 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); + + +
'.$langs->trans("Project").''.$langs->trans("Task").''.$langs->trans("Label").''.$langs->trans("Project").''.$langs->trans("TimeSpent").'