From 8f906b93621da3cfe3227e88aaa83f512e273c89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Jan 2008 08:30:05 +0000 Subject: [PATCH] Qual: Mutualisation code redondant --- htdocs/comm/fiche.php | 236 +-------------------------------- htdocs/compta/fiche.php | 243 +--------------------------------- htdocs/fourn/fiche.php | 243 ++-------------------------------- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + htdocs/lib/company.lib.php | 250 ++++++++++++++++++++++++++++++++++- 6 files changed, 260 insertions(+), 714 deletions(-) diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index e815ca8438d..76bcccd936d 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -728,244 +728,12 @@ if ($socid > 0) /* * Listes des actions a faire */ - if ($conf->agenda->enabled) - { - print_titre($langs->trans("ActionsOnCompany")); - - print ''; - print ''; - print ''; - print ''; + show_actions_todo($conf,$langs,$db,$objsoc); - $sql = "SELECT a.id, a.label,"; - $sql.= " ".$db->pdate("a.datep")." as dp,"; - $sql.= " ".$db->pdate("a.datea")." as da,"; - $sql.= " a.percent,"; - $sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,"; - $sql.= " u.login, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$objsoc->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent < 100"; - $sql.= " ORDER BY a.datep DESC, a.id DESC"; - - dolibarr_syslog("comm/fiche.php sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - if ($num) - { - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - print '\n"; - $oldyear = strftime("%Y",$obj->dp); - - print '\n"; - $oldmonth = strftime("%Y%b",$obj->dp); - - print '\n"; - print ''; - - // Picto warning - print ''; - - // Status/Percent - print ''; - - if ($obj->propalrowid) - { - print ''; - } - else - { - $actionstatic->code=$obj->acode; - $actionstatic->libelle=$obj->libelle; - $actionstatic->id=$obj->id; - print ''; - } - print ''; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - print ''; - - // Statut - print ''; - - print "\n"; - $i++; - } - } - else - { - // Aucun action a faire - - } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - print "
'.$langs->trans("ActionsToDoShort").' 
'.strftime("%Y",$obj->dp)."' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; - if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); - else print ' '; - print ' '.img_object($langs->trans("ShowAction"),"task"); - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - print $libelle; - print ''.$actionstatic->getNomUrl(1,16).''.$obj->label.''.$contactstatic->getNomUrl(1).' '; - $userstatic->id=$obj->fk_user_author; - $userstatic->login=$obj->login; - print $userstatic->getLoginUrl(1); - print ''.$actionstatic->LibStatut($obj->percent,3).'
"; - - print "
"; - } - /* * Listes des actions effectuees */ - if ($conf->agenda->enabled) - { - print ''; - print ''; - print ''; - print ''; - - $sql = "SELECT a.id, a.label,"; - $sql.= " ".$db->pdate("a.datep")." as dp,"; - $sql.= " ".$db->pdate("a.datea")." as da,"; - $sql.= " a.percent,"; - $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; - $sql.= " c.code as acode, c.libelle,"; - $sql.= " u.login, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$objsoc->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent = 100"; - $sql.= " ORDER BY a.datea DESC, a.id DESC"; - - dolibarr_syslog("comm/fiche.php sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $oldyear=''; - $oldmonth=''; - $var=true; - - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - // Champ date - print '\n"; - $oldyear = strftime("%Y",$obj->da); - print '\n"; - $oldmonth = strftime("%Y%b",$obj->da); - print '\n"; - print '\n"; - - // Picto - print ''; - - // Espace - print ''; - - // Action - print ''; - - // Objet lie - print ''; - - // Libelle - print ''; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - // Auteur - print ''; - - // Statut - print ''; - - print "\n"; - $i++; - } - - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - - print "
'.$langs->trans("ActionsDoneShort").'
'.strftime("%Y",$obj->da)."'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)."  '; - $actionstatic->code=$obj->acode; - $actionstatic->libelle=$obj->libelle; - $actionstatic->id=$obj->id; - print $actionstatic->getNomUrl(1,16); - print ''; - if ($obj->propalrowid) - { - print ''.img_object($langs->trans("ShowPropal"),"propal"); - print $langs->trans("Propal"); - print ''; - } - if ($obj->fk_facture) - { - $facturestatic->ref=$langs->trans("Invoice"); - $facturestatic->id=$obj->fk_facture; - $facturestatic->type=$obj->type; - print $facturestatic->getNomUrl(1,'compta'); - } - else print ' '; - print ''.$obj->label.''.$contactstatic->getNomUrl(1).' '; - $userstatic->id=$obj->rowid; - $userstatic->login=$obj->login; - print $userstatic->getLoginUrl(1); - print ''.$actionstatic->LibStatut($obj->percent,3).'

"; - } + show_actions_done($conf,$langs,$db,$objsoc); } else { diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index 483f22dde90..da328ec7a59 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -300,7 +300,7 @@ if ($socid > 0) } /* - * Derniers projets associ�s + * Derniers projets associes */ if ($conf->projet->enabled) { @@ -471,250 +471,13 @@ if ($socid > 0) /* * Listes des actions a faire - * */ - if ($conf->agenda->enabled) - { - print_titre($langs->trans("ActionsOnCompany")); - print ''; - print ''; - print ''; - print ''; + show_actions_todo($conf,$langs,$db,$societe); - $sql = "SELECT a.id, a.label,"; - $sql.= " ".$db->pdate("a.datep")." as dp,"; - $sql.= " ".$db->pdate("a.datea")." as da,"; - $sql.= " a.percent,"; - $sql.= " c.code as acode, c.libelle, u.login, a.propalrowid, a.fk_user_author, a.fk_contact,"; - $sql.= " u.login, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$societe->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent < 100"; - $sql.= " ORDER BY a.datea DESC, a.id DESC"; - - dolibarr_syslog("compta/fiche.php sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - if ($oldyear == strftime("%Y",$obj->dp) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) - { - print ''; - } - else - { - print '\n"; - $oldyear = strftime("%Y",$obj->dp); - } - - if ($oldmonth == strftime("%Y%b",$obj->dp) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) - { - print ''; - } - else - { - print '\n"; - $oldmonth = strftime("%Y%b",$obj->dp); - } - - print '\n"; - print ''; - - // Picto warning - print ''; - - // Status/Percent - print ''; - - if ($obj->propalrowid) - { - print ''; - } - else - { - $actionstatic->code=$obj->acode; - $actionstatic->libelle=$obj->libelle; - $actionstatic->id=$obj->id; - print ''; - } - - print ''; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - // Auteur - print ''; - - // Statut - print ''; - - print "\n"; - $i++; - } - - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - print "
'.$langs->trans("ActionsToDoShort").' 
|'.strftime("%Y",$obj->dp)."|' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; - if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); - else print ' '; - print ' '.img_object($langs->trans("ShowAction"),"task"); - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - print $libelle; - print ''.$actionstatic->getNomUrl(1,16).''.$obj->label.''.$contactstatic->getNomUrl(1).' '.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.''.$actionstatic->LibStatut($obj->percent,3).'

"; - } - /* * Listes des actions effectuees */ - if ($conf->agenda->enabled) - { - print ''; - print ''; - print ''; - - $sql = "SELECT a.id, a.label,"; - $sql.= " ".$db->pdate("a.datep")." as dp,"; - $sql.= " ".$db->pdate("a.datea")." as da,"; - $sql.= " a.percent,"; - $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; - $sql.= " c.code as acode, c.libelle,"; - $sql.= " u.login, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$societe->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent = 100"; - $sql.= " ORDER BY a.datea DESC, a.id DESC"; - - dolibarr_syslog("compta/fiche.php sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - if ($oldyear == strftime("%Y",$obj->da) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) { - print ''; - } else { - print '\n"; - $oldyear = strftime("%Y",$obj->da); - } - - if ($oldmonth == strftime("%Y%b",$obj->da) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) { - print ''; - } else { - print '\n"; - $oldmonth = strftime("%Y%b",$obj->da); - } - - print '\n"; - print '\n"; - - // Picto - print ''; - - // Espace - print ''; - - // Action - print ''; - - // Objet li� - print ''; - - // Libell� - print ""; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - // Auteur - print ''; - - // Statut - print ''; - - print "\n"; - $i++; - } - - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - print "
'.$langs->trans("ActionsDoneShort").''; - print '
|'.strftime("%Y",$obj->da)."|'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)."  '; - $actionstatic->code=$obj->acode; - $actionstatic->libelle=$obj->libelle; - $actionstatic->id=$obj->id; - print $actionstatic->getNomUrl(1,16); - print ''; - if ($obj->propalrowid) - { - print ''.img_object($langs->trans("ShowPropal"),"propal"); - print $langs->trans("Propal"); - print ''; - } - if ($obj->fk_facture) - { - $facturestatic->ref=$langs->trans("Invoice"); - $facturestatic->id=$obj->rowid; - $facturestatic->type=$obj->type; - print $facturestatic->getNomUrl(1,'compta'); - } - else print ' '; - print '$obj->label'.$contactstatic->getNomUrl(1).' '.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''.$actionstatic->LibStatut($obj->percent,3).'

"; - } + show_actions_done($conf,$langs,$db,$societe); } else { diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index e5f06ac663e..94748a78cb3 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -367,242 +367,15 @@ if ( $societe->fetch($socid) ) print ''; print '
'; - /* - * Listes des actions a faire - * \TODO Mutualise ce code avec page compta et client de tiers - */ - if ($conf->agenda->enabled) - { - print_titre($langs->trans("ActionsOnCompany")); - print ''; - print ''; + /* + * Listes des actions a faire + */ + show_actions_todo($conf,$langs,$db,$societe); - $sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp, c.code as acode, c.libelle, u.login,"; - $sql.= " a.propalrowid, a.fk_user_author, a.fk_contact, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$societe->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent < 100"; - $sql.= " ORDER BY a.datep DESC, a.id DESC"; - - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - if ($oldyear == strftime("%Y",$obj->dp) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) - { - print ''; - } - else - { - print '\n"; - $oldyear = strftime("%Y",$obj->dp); - } - - if ($oldmonth == strftime("%Y%b",$obj->dp) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) - { - print ''; - } - else - { - print '\n"; - $oldmonth = strftime("%Y%b",$obj->dp); - } - - print '\n"; - print ''; - - // Picto warning - print ''; - - // Status/Percent - print ''; - - if ($obj->propalrowid) - { - print ''; - } - else - { - print ''; - } - - print ''; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - // Auteur - print ''; - - // Statut - print ''; - - print "\n"; - $i++; - } - - $db->free($result); - } else { - dolibarr_print_error($db); - } - print "
'.$langs->trans("ActionsToDoShort").' 
|'.strftime("%Y",$obj->dp)."|' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; - if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); - else print ' '; - print ' '.img_object($langs->trans("ShowAction"),"task"); - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - print $libelle; - print ''.img_object($langs->trans("ShowAction"),"task"); - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - print $libelle; - print ''.$obj->label.''.$contactstatic->getNomUrl(1).' '.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.''.$actionstatic->LibStatut($obj->percent,3).'

"; - } - - /* - * Listes des actions effectuees - */ - if ($conf->agenda->enabled) - { - print ''; - print ''; - print ''; - - $sql = "SELECT a.id, a.label, ".$db->pdate("a.datea")." as da, a.percent,"; - $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; - $sql.= " c.code as acode, c.libelle,"; - $sql.= " u.login, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$societe->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent = 100"; - $sql.= " ORDER BY a.datea DESC, a.id DESC"; - - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - if ($oldyear == strftime("%Y",$obj->da) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) - { - print ''; - } else { - print '\n"; - $oldyear = strftime("%Y",$obj->da); - } - - if ($oldmonth == strftime("%Y%b",$obj->da) && !$conf->global->COMPANY_VIEW_FULL_DATE_ACTIONS) - { - print ''; - } else { - print '\n"; - $oldmonth = strftime("%Y%b",$obj->da); - } - - print '\n"; - print '\n"; - - // Picto - print ''; - - // Espace - print ''; - - // Action - print ''; - - // Objet lie - print ''; - - // Libelle - print ""; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - // Auteur - print ''; - - // Statut - print ''; - - print "\n"; - $i++; - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } - - - print "
'.$langs->trans("ActionsDoneShort").'
|'.strftime("%Y",$obj->da)."|'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)."  '; - print ''.img_object($langs->trans("ShowTask"),"task"); - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - print $libelle; - print ''; - print ''; - if ($obj->propalrowid) - { - print ''.img_object($langs->trans("ShowPropal"),"propal"); - print $langs->trans("Propal"); - print ''; - } - if ($obj->fk_facture) - { - print ''.img_object($langs->trans("ShowBill"),"bill"); - print $langs->trans("Invoice"); - print ''; - } - else print ' '; - print '$obj->label'.$contactstatic->getNomUrl(1).' '.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''.$actionstatic->LibStatut($obj->percent,3).'
"; - } + /* + * Listes des actions effectuees + */ + show_actions_done($conf,$langs,$db,$societe); } else { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index cc5225c9017..5d33324b14c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -405,6 +405,7 @@ PartialWoman=Partial PartialMan=Partial TotalWoman=Total TotalMan=Total +YouCanChangeValuesForThisListFromDictionnarySetup=You can change values for this list from menu setup - dictionnary # Week day Monday=Monday Tuesday=Tuesday diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 5fdd6a91699..4e65d7298a8 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -406,6 +406,7 @@ PartialWoman=Partielle PartialMan=Partiel TotalWoman=Totale TotalMan=Total +YouCanChangeValuesForThisListFromDictionnarySetup=Vous pouvez changer ces valeurs depuis le menu configuration - dictionnaires # Week day Monday=Lundi Tuesday=Mardi diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index bc8c21d5f72..27260082074 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -1,7 +1,7 @@ - * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007 Patrick Raguin +/* Copyright (C) 2006-2008 Laurent Destailleur + * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -19,7 +19,6 @@ * or see http://www.gnu.org/ * * $Id$ - * $Source$ */ /** @@ -71,7 +70,7 @@ function societe_prepare_head($objsoc) $head[$h][2] = 'compta'; $h++; } - //affichage onglet catégorie + //affichage onglet cat�gorie if ($conf->categorie->enabled) { $head[$h][0] = DOL_URL_ROOT.'/categories/categorie.php?socid='.$objsoc->id; @@ -129,4 +128,245 @@ function societe_prepare_head($objsoc) return $head; } +function show_actions_todo($conf,$langs,$db,$objsoc) +{ + if ($conf->agenda->enabled) + { + print_titre($langs->trans("ActionsOnCompany")); + + print ''; + print ''; + print ''; + print ''; + + $sql = "SELECT a.id, a.label,"; + $sql.= " ".$db->pdate("a.datep")." as dp,"; + $sql.= " ".$db->pdate("a.datea")." as da,"; + $sql.= " a.percent,"; + $sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,"; + $sql.= " u.login, u.rowid,"; + $sql.= " sp.name, sp.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + $sql.= " WHERE a.fk_soc = ".$objsoc->id; + $sql.= " AND u.rowid = a.fk_user_author"; + $sql.= " AND c.id=a.fk_action AND a.percent < 100"; + $sql.= " ORDER BY a.datep DESC, a.id DESC"; + + dolibarr_syslog("company.lib::show_actions_todo sql=".$sql); + $result=$db->query($sql); + if ($result) + { + $i = 0 ; + $num = $db->num_rows($result); + $var=true; + + if ($num) + { + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($result); + print ""; + + print '\n"; + $oldyear = strftime("%Y",$obj->dp); + + print '\n"; + $oldmonth = strftime("%Y%b",$obj->dp); + + print '\n"; + print ''; + + // Picto warning + print ''; + + // Status/Percent + print ''; + + if ($obj->propalrowid) + { + print ''; + } + else + { + $actionstatic->code=$obj->acode; + $actionstatic->libelle=$obj->libelle; + $actionstatic->id=$obj->id; + print ''; + } + print ''; + + // Contact pour cette action + if ($obj->fk_contact > 0) + { + $contactstatic->name=$obj->name; + $contactstatic->firstname=$obj->firstname; + $contactstatic->id=$obj->fk_contact; + print ''; + } + else + { + print ''; + } + + print ''; + + // Statut + print ''; + + print "\n"; + $i++; + } + } + else + { + // Aucun action a faire + + } + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + print "
'.$langs->trans("ActionsToDoShort").' 
'.strftime("%Y",$obj->dp)."' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; + if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); + else print ' '; + print ' '.img_object($langs->trans("ShowAction"),"task"); + $transcode=$langs->trans("Action".$obj->acode); + $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); + print $libelle; + print ''.$actionstatic->getNomUrl(1,16).''.$obj->label.''.$contactstatic->getNomUrl(1).' '; + $userstatic->id=$obj->fk_user_author; + $userstatic->login=$obj->login; + print $userstatic->getLoginUrl(1); + print ''.$actionstatic->LibStatut($obj->percent,3).'
"; + + print "
"; + } +} + +function show_actions_done($conf,$langs,$db,$objsoc) +{ + if ($conf->agenda->enabled) + { + print ''; + print ''; + print ''; + print ''; + + $sql = "SELECT a.id, a.label,"; + $sql.= " ".$db->pdate("a.datep")." as dp,"; + $sql.= " ".$db->pdate("a.datea")." as da,"; + $sql.= " a.percent,"; + $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; + $sql.= " c.code as acode, c.libelle,"; + $sql.= " u.login, u.rowid,"; + $sql.= " sp.name, sp.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + $sql.= " WHERE a.fk_soc = ".$objsoc->id; + $sql.= " AND u.rowid = a.fk_user_author"; + $sql.= " AND c.id=a.fk_action AND a.percent = 100"; + $sql.= " ORDER BY a.datea DESC, a.id DESC"; + + dolibarr_syslog("comm/fiche.php sql=".$sql); + $result=$db->query($sql); + if ($result) + { + $i = 0 ; + $num = $db->num_rows($result); + $oldyear=''; + $oldmonth=''; + $var=true; + + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($result); + print ""; + + // Champ date + print '\n"; + $oldyear = strftime("%Y",$obj->da); + print '\n"; + $oldmonth = strftime("%Y%b",$obj->da); + print '\n"; + print '\n"; + + // Picto + print ''; + + // Espace + print ''; + + // Action + print ''; + + // Objet lie + print ''; + + // Libelle + print ''; + + // Contact pour cette action + if ($obj->fk_contact > 0) + { + $contactstatic->name=$obj->name; + $contactstatic->firstname=$obj->firstname; + $contactstatic->id=$obj->fk_contact; + print ''; + } + else + { + print ''; + } + + // Auteur + print ''; + + // Statut + print ''; + + print "\n"; + $i++; + } + + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + + print "
'.$langs->trans("ActionsDoneShort").'
'.strftime("%Y",$obj->da)."'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)."  '; + $actionstatic->code=$obj->acode; + $actionstatic->libelle=$obj->libelle; + $actionstatic->id=$obj->id; + print $actionstatic->getNomUrl(1,16); + print ''; + if ($obj->propalrowid) + { + print ''.img_object($langs->trans("ShowPropal"),"propal"); + print $langs->trans("Propal"); + print ''; + } + if ($obj->fk_facture) + { + $facturestatic->ref=$langs->trans("Invoice"); + $facturestatic->id=$obj->fk_facture; + $facturestatic->type=$obj->type; + print $facturestatic->getNomUrl(1,'compta'); + } + else print ' '; + print ''.$obj->label.''.$contactstatic->getNomUrl(1).' '; + $userstatic->id=$obj->rowid; + $userstatic->login=$obj->login; + print $userstatic->getLoginUrl(1); + print ''.$actionstatic->LibStatut($obj->percent,3).'

"; + } +} ?>