Merge remote-tracking branch 'Upstream/develop' into develop-54

This commit is contained in:
aspangaro 2015-07-05 05:59:10 +02:00
commit 627429326e
19 changed files with 581 additions and 332 deletions

View File

@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@ -115,6 +116,7 @@ $object = new Account($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$societestatic = new Societe($db);
$userstatic = new User($db);
$chargestatic = new ChargeSociales($db);
$paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db);
@ -127,8 +129,8 @@ if ($result) {
// Variables
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef"));
$accountancy_account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"));
$accountancy_account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef"));
$tabpay = array ();
$tabbq = array ();
@ -175,7 +177,6 @@ if ($result) {
{
$tabtype[$obj->rowid] = $links[$key]['type'];
if ($links[$key]['type'] == 'payment')
{
$paymentstatic->id = $links[$key]['url_id'];
@ -194,6 +195,13 @@ if ($result) {
$tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
$tabtp[$obj->rowid][$compta_soc] += $obj->amount;
}
else if ($links[$key]['type'] == 'user')
{
$userstatic->id = $links[$key]['url_id'];
$userstatic->name = $links[$key]['label'];
$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, '', 30);
// $tabtp[$obj->rowid][$compta_user] += $obj->amount;
}
else if ($links[$key]['type'] == 'sc')
{
$chargestatic->id = $links[$key]['url_id'];
@ -232,8 +240,8 @@ if ($result) {
{
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat");
$tabtp[$obj->rowid][$accountancy_account_pay_vat] += $obj->amount;
}
else if ($links[$key]['type'] == 'payment_salary')
{
@ -427,7 +435,6 @@ if ($action == 'export_csv')
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
@ -680,6 +687,7 @@ else
print "<td>" . $reflabel . "</td>";
print "<td>" . $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . "</td>";
print "<td>" . $langs->trans('ThirdParty') . "</td>";
print "<td>&nbsp;</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";

View File

@ -2,7 +2,8 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,6 +34,11 @@ if (!$user->admin) accessforbidden();
$action = GETPOST('action','alpha');
// Other parameters ACCOUNTING_*
$list = array (
'ACCOUNTING_VAT_PAY_ACCOUNT'
);
/*
* Actions
*/
@ -51,9 +57,11 @@ $action = GETPOST('action','alpha');
$tax_mode = empty($conf->global->TAX_MODE)?0:$conf->global->TAX_MODE;
if ($action == 'settaxmode')
{
$tax_mode = GETPOST('tax_mode','alpha');
if ($action == 'update') {
$error = 0;
// Tax mode
$tax_mode = GETPOST('tax_mode','alpha');
$db->begin();
@ -79,38 +87,24 @@ if ($action == 'settaxmode')
$res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
// Others options
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (! $error) {
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
} else {
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
}
}
/*
if ($_POST['action'] == 'update' || $_POST['action'] == 'add')
{
if (! dolibarr_set_const($db, $_POST['constname'], $_POST['constvalue'], $typeconst[$_POST['consttype']], 0, isset($_POST['constnote']) ? $_POST['constnote'] : '',$conf->entity));
{
print $db->error();
}
}
if ($_GET['action'] == 'delete')
{
if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
{
print $db->error();
}
}
*/
/*
* View
@ -122,7 +116,8 @@ $form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
print '<br>';
dol_fiche_head();
if (empty($mysoc->tva_assuj))
{
print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
@ -134,29 +129,28 @@ else
// Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="settaxmode">';
print '<input type="hidden" name="action" value="update">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
print '<td colspan="2">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
print "</tr>\n";
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
print "</td></tr>\n";
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
print '</form>';
print "</table>\n";
print '<br><br>';
print '<br>';
print_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'','');
//print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
print '<table class="border" width="100%">';
print '<tr><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
// Products
print '<tr><td>'.$langs->trans("Product").'</td>';
print '<tr '.$bc[false].'><td>'.$langs->trans("Product").'</td>';
print '<td>';
print $langs->trans("OnDelivery");
print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
@ -167,7 +161,7 @@ else
print '</td></tr>';
// Services
print '<tr><td>'.$langs->trans("Services").'</td>';
print '<tr '.$bc[true].'><td>'.$langs->trans("Services").'</td>';
print '<td>';
if ($tax_mode == 0)
{
@ -196,6 +190,42 @@ else
print '</table>';
}
print "<br>\n";
/*
* Others params
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
print "</tr>\n";
foreach ($list as $key)
{
$var=!$var;
print '<tr '.$bc[$var].' class="value">';
// Param
$label = $langs->trans($key);
print '<td><label for="'.$key.'">'.$label.'</label></td>';
// Value
print '<td>';
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td></tr>';
}
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="button">';
print '</div>';
print '</form>';
$db->close();
llxFooter();

View File

@ -292,10 +292,12 @@ if ($resql)
}
if (! empty($moreforfilter))
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="10">';
print $moreforfilter;
print '</td></tr>';
print '<div class="liste_titre">';
print $moreforfilter;
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
print '<tr class="liste_titre">';
@ -305,6 +307,9 @@ if ($resql)
print_liste_field_titre($langs->trans('OrderDate'),$_SERVER["PHP_SELF"],'c.date_commande','',$param, 'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('DeliveryDate'),$_SERVER["PHP_SELF"],'c.date_livraison','',$param, 'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('AmountHT'),$_SERVER["PHP_SELF"],'c.total_ht','',$param, 'align="right"',$sortfield,$sortorder);
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'c.fk_statut','',$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
print '</tr>';

View File

@ -220,7 +220,7 @@ abstract class DoliDB implements Database
/**
* Define sort criteria of request
*
* @param string $sortfield List of sort fields
* @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb'
* @param string $sortorder Sort order
* @return string String to provide syntax of a sort sql string
*/
@ -236,7 +236,8 @@ abstract class DoliDB implements Database
else $return.=',';
$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
if (isset($sortorder)) {
if (isset($sortorder))
{
$return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder);
}
}

View File

@ -4644,7 +4644,8 @@ function dol_osencode($str)
/**
* Return an id or code from a code or id. Store also Code-Id into a cache for next use.
* Return an id or code from a code or id.
* Store also Code-Id into a cache to speed up next request on same key.
*
* @param DoliDB $db Database handler
* @param string $key Code to get Id

View File

@ -872,13 +872,15 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
* Return HTML table with list of projects and number of opened tasks
*
* @param DoliDB $db Database handler
* @param Form $form Object form
* @param int $socid Id thirdparty
* @param int $projectsListId Id of project i have permission on
* @param int $mytasks Limited to task i am contact to
* @param int $statut -1=No filter on statut, 0 or 1 = Filter on status
* @param array $listofoppstatus List of opportunity status
* @return void
*/
function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $statut=-1)
function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=0, $statut=-1, $listofoppstatus=array())
{
global $langs,$conf,$user,$bc;
@ -890,18 +892,22 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
$sortorder='';
$project_year_filter=0;
$title=$langs->trans("Project");
if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Project").' ('.$langs->trans($projectstatic->statuts_long[$statut]).')';
$title=$langs->trans("Projects");
if (strcmp($statut, '') && $statut >= 0) $title=$langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$statut]);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($title,"index.php","","","","",$sortfield,$sortorder);
//if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print_liste_field_titre($langs->trans("OpportunityStatus"),"","","","",'align="right"',$sortfield,$sortorder);
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print_liste_field_titre($langs->trans("OpportunityAmount"),"","","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OpportunityStatus"),"","","","",'align="right"',$sortfield,$sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) print_liste_field_titre($langs->trans("Tasks"),"","","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, COUNT(t.rowid) as nb";
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount, COUNT(DISTINCT t.rowid) as nb"; // We use DISTINCT here because line can be doubled if task has 2 links to same user
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
if ($mytasks)
{
@ -928,24 +934,31 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
{
$sql.= " AND p.fk_statut = ".$statut;
}
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
{
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
if ($project_year_filter != "*") {
if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { //
if ($project_year_filter != "*")
{
if (empty($project_year_filter) || !ctype_digit($project_year_filter))
{
$project_year_filter = date("Y");
}
$sql.= " AND (p.dateo IS NULL OR p.dateo <= ".$db->idate(dol_get_last_day($project_year_filter,12,false)).")";
$sql.= " AND (p.datee IS NULL OR p.datee >= ".$db->idate(dol_get_first_day($project_year_filter,1,false)).")";
}
}
$sql.= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status";
$sql.= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount";
$sql.= " ORDER BY p.title, p.ref";
$var=true;
$resql = $db->query($sql);
if ( $resql )
{
$total_task = 0;
$total_opp_amount = 0;
$ponderated_opp_amount = 0;
$num = $db->num_rows($resql);
$i = 0;
@ -967,22 +980,34 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
$projectstatic->ref=$objp->ref;
print $projectstatic->getNomUrl(1);
print ' - '.dol_trunc($objp->title,24).'</td>';
/*if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<td align="right">';
if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
print '</td>';
print '<td align="right">';
$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
if ($code) print $langs->trans("OppStatus".$code);
print '</td>';
}*/
if (empty($conf->global->PROJECT_HIDE_TASKS)) print '<td align="right">'.$objp->nb.'</td>';
}
$projectstatic->statut = $objp->status;
if (empty($conf->global->PROJECT_HIDE_TASKS)) print '<td align="right">'.$objp->nb.'</td>';
print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>';
print "</tr>\n";
$total_task = $total_task + $objp->nb;
$total_opp_amount = $total_opp_amount + $objp->opp_amount;
$ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100);
}
$i++;
}
print '<tr><td>'.$langs->trans("Total")."</td>";
print '<td align="right">'.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).'</td>';
print '<td align="right">'.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmount"), 1).'</td>';
if (empty($conf->global->PROJECT_HIDE_TASKS)) print '<td align="right">'.$total_task.'</td>';
$db->free($resql);
}
else

View File

@ -8,7 +8,7 @@
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
* Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1987,8 +1987,8 @@ class SupplierInvoiceLine extends CommonObjectLine
/**
* Retrieves a supplier invoice line
*
* @param int $rowid Line id
* @return int <0 KO; 0 NOT FOUND; 1 OK
* @param int $rowid Line id
* @return int <0 KO; 0 NOT FOUND; 1 OK
*/
public function fetch($rowid)
{
@ -2052,8 +2052,8 @@ class SupplierInvoiceLine extends CommonObjectLine
/**
* Deletes a line
*
* @param bool|int $notrigger
* @return int -1 KO; 1 OK
* @param bool|int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int 0 if KO, 1 if OK
*/
public function delete($notrigger = 0)
{

View File

@ -199,7 +199,8 @@ TurnoverPerProductInCommitmentAccountingNotRelevant=Turnover report per product,
CalculationMode=Calculation mode
AccountancyJournal=Accountancy code journal
ACCOUNTING_VAT_SOLD_ACCOUNT=Default accountancy code for collecting VAT
ACCOUNTING_VAT_BUY_ACCOUNT=Default accountancy code for paying VAT
ACCOUNTING_VAT_BUY_ACCOUNT=Default accountancy code for recovered VAT
ACCOUNTING_VAT_PAY_ACCOUNT=Default accountancy code for paying VAT
ACCOUNTING_ACCOUNT_CUSTOMER=Accountancy code by default for customer thirdparties
ACCOUNTING_ACCOUNT_SUPPLIER=Accountancy code by default for supplier thirdparties
CloneTax=Clone a social/fiscal tax

View File

@ -23,6 +23,7 @@ Language_en_US=English (United States)
Language_en_ZA=English (South Africa)
Language_es_ES=Spanish
Language_es_AR=Spanish (Argentina)
Language_es_BO=Spanish (Bolivia)
Language_es_CL=Spanish (Chile)
Language_es_CO=Spanish (Colombia)
Language_es_DO=Spanish (Dominican Republic)
@ -40,6 +41,7 @@ Language_fr_CA=French (Canada)
Language_fr_CH=French (Switzerland)
Language_fr_FR=French
Language_fr_NC=French (New Caledonia)
Language_fy_NL=Frisian
Language_he_IL=Hebrew
Language_hr_HR=Croatian
Language_hu_HU=Hungarian

View File

@ -26,6 +26,8 @@ ConfirmDeleteATask=Are you sure you want to delete this task ?
OfficerProject=Officer project
LastProjects=Last %s projects
AllProjects=All projects
OpenedProjects=Opened projects
OpportunitiesStatusForOpenedProjects=Opportunities status for opened projects
ProjectsList=List of projects
ShowProject=Show project
SetProject=Set project
@ -78,6 +80,8 @@ ListDonationsAssociatedProject=List of donations associated with the project
ListActionsAssociatedProject=List of events associated with the project
ListTaskTimeUserProject=List of time consumed on tasks of project
TaskTimeUserProject=Time consumed on tasks of project
ActivityOnProjectToday=Activity on project today
ActivityOnProjectYesterday=Activity on project yesterday
ActivityOnProjectThisWeek=Activity on project this week
ActivityOnProjectThisMonth=Activity on project this month
ActivityOnProjectThisYear=Activity on project this year
@ -93,6 +97,7 @@ ReOpenAProject=Open project
ConfirmReOpenAProject=Are you sure you want to re-open this project ?
ProjectContact=Project contacts
ActionsOnProject=Events on project
OpenedProjects=Opened projects
YouAreNotContactOfProject=You are not a contact of this private project
DeleteATimeSpent=Delete time spent
ConfirmDeleteATimeSpent=Are you sure you want to delete this time spent ?
@ -142,6 +147,7 @@ PlannedWorkloadShort=Workload
WorkloadOccupation=Workload assignation
ProjectReferers=Refering objects
SearchAProject=Search a project
SearchATask=Search a task
ProjectMustBeValidatedFirst=Project must be validated first
ProjectDraft=Draft projects
FirstAddRessourceToAllocateTime=Associate a resource to allocate time
@ -161,3 +167,5 @@ ManageOpportunitiesStatus=Use projects to follow leads/opportinuties
ProjectNbProjectByMonth=Nb of created projects by month
ProjectsStatistics=Statistics on projects/leads
TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible.
OpenedProjectsByThirdparties=Opened projects by thirdparties
OpportunityPonderatedAmount=Opportunities ponderated amount

View File

@ -0,0 +1,21 @@
# Dolibarr language file - Source file is en_US - main
DIRECTION=ltr
FONTFORPDF=helvetica
FONTSIZEFORPDF=10
SeparatorDecimal=.
SeparatorThousand=,
FormatDateShort=%m/%d/%Y
FormatDateShortInput=%m/%d/%Y
FormatDateShortJava=MM/dd/yyyy
FormatDateShortJavaInput=MM/dd/yyyy
FormatDateShortJQuery=mm/dd/yy
FormatDateShortJQueryInput=mm/dd/yy
FormatHourShortJQuery=HH:MI
FormatHourShort=%I:%M %p
FormatHourShortDuration=%H:%M
FormatDateTextShort=%b %d, %Y
FormatDateText=%B %d, %Y
FormatDateHourShort=%m/%d/%Y %I:%M %p
FormatDateHourSecShort=%m/%d/%Y %I:%M:%S %p
FormatDateHourTextShort=%b %d, %Y, %I:%M %p
FormatDateHourText=%B %d, %Y, %I:%M %p

View File

@ -49,6 +49,7 @@ $now = dol_now();
$projectstatic=new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
$tasktmp=new Task($db);
$title=$langs->trans("Activities");
if ($mine) $title=$langs->trans("MyActivities");
@ -68,13 +69,31 @@ else
print '<div class="fichecenter"><div class="fichethirdleft">';
print_projecttasks_array($db,$socid,$projectsListId,$mine,1);
// Search task
if (! empty($conf->projet->enabled) && $user->rights->projet->lire)
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/projet/tasks/index.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="mode" value="'.$mine.'">';
print '<input type="hidden" name="search_status" value="-1">'; // All status
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchATask").'</td></tr>';
print '<tr '.$bc[$var].'>';
print '<td class="nowrap"><label for="sf_ref">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="search_task_ref" id="sf_ref" size="18"></td>';
print '<td rowspan="3"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
//print '<tr '.$bc[$var].'><td class="nowrap"><label for="syear">'.$langs->trans("Year").'</label>:</td><td><input type="text" class="flat" name="search_year" id="search_year" size="18"></td>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="sall">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="search_task_label" id="search_task_label" size="18"></td>';
print '</tr>';
print "</table></form>\n";
print "<br>\n";
}
/* Affichage de la liste des projets d'aujourd'hui */
print '<br><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="50%">'.$langs->trans('Today').'</td>';
print '<td width="50%">'.$langs->trans('ActivityOnProjectToday').'</td>';
print '<td width="50%" align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
@ -127,67 +146,64 @@ print "</table>";
if ($db->type != 'pgsql')
{
/* Affichage de la liste des projets d'hier */
print '<br><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Yesterday').'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
/* Affichage de la liste des projets d'hier */
print '<br><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('ActivityOnProjectYesterday').'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, sum(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND date_format(date_add(task_date, INTERVAL 1 DAY),'%y-%m-%d') = '".strftime("%y-%m-%d",$now)."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$sql = "SELECT p.rowid, p.ref, p.title, sum(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND date_format(date_add(task_date, INTERVAL 1 DAY),'%y-%m-%d') = '".strftime("%y-%m-%d",$now)."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$resql = $db->query($sql);
if ( $resql )
{
$var=true;
$total=0;
while ($row = $db->fetch_object($resql))
$resql = $db->query($sql);
if ( $resql )
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$total += $row->nb;
$var=true;
$total=0;
while ($row = $db->fetch_object($resql))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
$db->free($resql);
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table>";
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table>";
}
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// TODO Do not use week function to be compatible with all database
if ($db->type != 'pgsql')
{
print '<br>';
/* Affichage de la liste des projets de la semaine */
print '<table class="noborder" width="100%">';
@ -293,52 +309,190 @@ print "</tr>\n";
print "</table>";
/* Affichage de la liste des projets de l'annee */
print '<br><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND YEAR(task_date) = '".strftime("%Y",$now)."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$var=false;
$resql = $db->query($sql);
if ( $resql )
if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
{
while ($row = $db->fetch_object($resql))
print '<br><table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND YEAR(task_date) = '".strftime("%Y",$now)."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$var=false;
$resql = $db->query($sql);
if ( $resql )
{
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$var=!$var;
while ($row = $db->fetch_object($resql))
{
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$var=!$var;
}
$db->free($resql);
}
$db->free($resql);
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table>";
}
else
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
dol_print_error($db);
// Tasks for all resources of all opened projects and time spent for each task/resource
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " AND p.fk_statut=1";
$sql.= " GROUP BY p.ref, p.title, p.rowid, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
$sql.= " ORDER BY t.dateo desc, t.rowid desc, t.datee";
$sql.= $db->plimit($max+1); // We want more to know if we have more than limit
$var=true;
dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
$i = 0;
//print_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
//print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
print '<th>'.$langs->trans('OpenedProjects').'</th>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '<th>'.$langs->trans('OpportunityStatus').'</th>';
print '<th>'.$langs->trans('Task').'</th>';
print '<th align="center">'.$langs->trans('DateStart').'</th>';
print '<th align="center">'.$langs->trans('DateEnd').'</th>';
print '<th align="right">'.$langs->trans('PlannedWorkload').'</th>';
print '<th align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<th align="right">'.$langs->trans('TimeSpent').'</th>';
print '<th align="right">'.$langs->trans("ProgressCalculated").'</td>';
print '</tr>';
while ($i < $num && $i < $max)
{
$obj = $db->fetch_object($resql);
$var=!$var;
$username='';
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
{
$result=$userstatic->fetch($obj->userid);
if (! $result) $userstatic->id=0;
}
if ($userstatic->id) $username = $userstatic->getNomUrl(0,0);
print "<tr ".$bc[$var].">";
//print '<td>'.$username.'</td>';
print '<td>';
$projectstatic->id=$obj->projectid;
$projectstatic->ref=$obj->ref;
$projectstatic->title=$obj->title;
print $projectstatic->getNomUrl(1,'',16,'','<br>');
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->projectid.'">'.$obj->title.'</a>';
print '</td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<td>';
$code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code');
if ($code) print $langs->trans("OppStatus".$code);
print '</td>';
}
print '<td>';
if (! empty($obj->taskid))
{
$tasktmp->id = $obj->taskid;
$tasktmp->ref = $obj->ref;
$tasktmp->label = $obj->label;
print $tasktmp->getNomUrl(1,'withproject','task',1,'<br>');
}
else print $langs->trans("NoTasks");
print '</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->dateo),'day').'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->datee),'day').'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
print convertSecondToTime($obj->planned_workload, 'all');
print '</a></td>';
print '<td align="right">';
print ($obj->taskid>0)?$obj->progress.'%':'';
print '</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
print convertSecondToTime($obj->timespent, 'all');
print '</a></td>';
print '<td align="right">';
if (! empty($obj->taskid))
{
if (empty($obj->planned_workload) > 0) {
$percentcompletion = $langs->trans("WorkloadNotDefined");
} else {
$percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%';
}
}
print $percentcompletion;
print '</td>';
print "</tr>\n";
$i++;
}
if ($num > $max)
{
$colspan=6;
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++;
print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
}
print "</table>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table>";
print '</div></div></div>';

View File

@ -871,10 +871,11 @@ class Project extends CommonObject
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option Variant ('', 'nolink')
* @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string
* @param string $moreinpopup Text to add into popu
* @param string $moreinpopup Text to add into popup
* @param string $sep Separator between ref and label if option addlabel is set
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0, $option='', $addlabel=0, $moreinpopup='')
function getNomUrl($withpicto=0, $option='', $addlabel=0, $moreinpopup='', $sep=' - ')
{
global $langs;
@ -905,7 +906,7 @@ class Project extends CommonObject
if ($withpicto) $result.=($link . img_object($label, $picto, 'class="classfortooltip"') . $linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link . $this->ref . $linkend . (($addlabel && $this->title) ? ' - ' . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : '');
if ($withpicto != 2) $result.=$link . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : '');
return $result;
}

View File

@ -499,9 +499,11 @@ class Task extends CommonObject
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option 'withproject' or ''
* @param string $mode Mode 'task', 'time', 'contact', 'note', document' define page to link to.
* @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string
* @param string $sep Separator between ref and label if option addlabel is set
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='',$mode='task')
function getNomUrl($withpicto=0,$option='',$mode='task', $addlabel=0, $sep=' - ')
{
global $langs;
@ -525,7 +527,7 @@ class Task extends CommonObject
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$this->ref.$linkend;
if ($withpicto != 2) $result.=$link.$this->ref.$linkend . (($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
return $result;
}
@ -585,12 +587,14 @@ class Task extends CommonObject
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND t.fk_projet = p.rowid";
}
if ($mode == 1)
elseif ($mode == 1)
{
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
}
else return 'BadValueForParameterMode';
if ($filteronprojuser)
{
// TODO
@ -603,7 +607,7 @@ class Task extends CommonObject
if ($projectid) $sql.= " AND p.rowid in (".$projectid.")";
if ($filteronprojref) $sql.= " AND p.ref LIKE '%".$filteronprojref."%'";
if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus;
if ($morewherefilter) $sql.=" AND (".$morewherefilter.")";
if ($morewherefilter) $sql.=$morewherefilter;
$sql.= " ORDER BY p.ref, t.rang, t.dateo";
//print $sql;exit;
@ -948,7 +952,7 @@ class Task extends CommonObject
$sql.=" AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)";
}
//print $sql;
dol_syslog(get_class($this)."::getSumOfAmount", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
@ -957,7 +961,7 @@ class Task extends CommonObject
$result['amount'] = $obj->amount;
$result['nblinesnull'] = $obj->nblinesnull;
$this->db->free($resql);
return $result;
}

View File

@ -51,7 +51,7 @@ $sortorder = GETPOST("sortorder",'alpha');
$socstatic=new Societe($db);
$projectstatic=new Project($db);
$userstatic=new User($db);
$tasktmp=new Task($db);
$form=new Form($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)),1);
//var_dump($projectsListId);
@ -73,6 +73,28 @@ else
}
// Get list of ponderated percent for each status
$listofoppstatus=array(); $listofopplabel=array(); $listofoppcode=array();
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls";
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$listofoppstatus[$objp->rowid]=$objp->percent;
$listofopplabel[$objp->rowid]=$objp->label;
$listofoppcode[$objp->rowid]=$objp->code;
$i++;
}
}
else dol_print_error($db);
print '<div class="fichecenter"><div class="fichethirdleft">';
@ -94,8 +116,92 @@ if (! empty($conf->projet->enabled) && $user->rights->projet->lire)
print "<br>\n";
}
/*
* Statistics
*/
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
$sql = "SELECT count(p.rowid), p.fk_opp_status as status";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = 1";
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " GROUP BY p.fk_opp_status";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total=0;
$totalinprocess=0;
$dataseries=array();
$vals=array();
// -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
while ($i < $num)
{
$row = $db->fetch_row($resql);
if ($row)
{
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{
$vals[$row[1]]=$row[0];
$totalinprocess+=$row[0];
}
$total+=$row[0];
}
$i++;
}
$db->free($resql);
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'</td></tr>'."\n";
$var=true;
$listofstatus=array_keys($listofoppstatus);
foreach ($listofstatus as $status)
{
$labelstatus = '';
$code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code');
if ($code) $labelstatus = $langs->trans("OppStatus".$code);
if (empty($labelstatus)) $labelstatus=$listofopplabel[$status];
$labelstatus .= ' ('.$langs->trans("Coeff").': '.$listofoppstatus[$status].')';
$dataseries[]=array('label'=>$labelstatus,'data'=>(isset($vals[$status])?(int) $vals[$status]:0));
if (! $conf->use_javascript_ajax)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$labelstatus.'</td>';
print '<td align="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status])?$vals[$status]:0).'</a></td>';
print "</tr>\n";
}
}
if ($conf->use_javascript_ajax)
{
print '<tr class="impair"><td align="center" colspan="2">';
$data=array('series'=>$dataseries);
dol_print_graph('stats',400,180,$data,1,'pie',1);
print '</td></tr>';
}
//if ($totalinprocess != $total)
//print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td align="right">'.$totalinprocess.'</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'.$total.'</td></tr>';
print "</table><br>";
}
else
{
dol_print_error($db);
}
}
// List of draft projects
print_projecttasks_array($db,$socid,$projectsListId,0,0);
print_projecttasks_array($db,$form,$socid,$projectsListId,0,0,$listofoppstatus);
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
@ -103,15 +209,16 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("ThirdParties"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("OpenedProjectsByThirdparties"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
$sql = "SELECT count(p.rowid) as nb";
$sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)";
$sql.= ", s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = 1";
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " GROUP BY s.nom, s.rowid";
@ -140,7 +247,7 @@ if ( $resql )
print $langs->trans("OthersNotLinkedToThirdParty");
}
print '</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/list.php?socid='.$obj->socid.'">'.$obj->nb.'</a></td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/list.php?socid='.$obj->socid.'&search_status=1">'.$obj->nb.'</a></td>';
print "</tr>\n";
$i++;
@ -155,143 +262,16 @@ else
print "</table>";
print '<br>';
print_projecttasks_array($db,$form,$socid,$projectsListId,0,1,$listofoppstatus);
print '</div></div></div>';
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
// Tasks for all resources of all opened projects and time spent for each task/resource
print '<div class="fichecenter">';
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
$sql.= " WHERE p.entity = ".$conf->entity;
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " AND p.fk_statut=1";
$sql.= " GROUP BY p.ref, p.title, p.rowid, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";
$sql.= " ORDER BY t.dateo desc, t.rowid desc, t.datee";
$sql.= $db->plimit($max+1); // We want more to know if we have more than limit
$var=true;
dol_syslog('projet:index.php: affectationpercent', LOG_DEBUG);
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
$i = 0;
print '<br>';
print_fiche_titre($langs->trans("TasksOnOpenedProject"),'','').'<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
//print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
print '<th>'.$langs->trans('Projects').'</th>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '<th>'.$langs->trans('OpportunityStatus').'</th>';
print '<th>'.$langs->trans('Task').'</th>';
print '<th>'.$langs->trans('DateStart').'</th>';
print '<th>'.$langs->trans('DateEnd').'</th>';
print '<th align="right">'.$langs->trans('PlannedWorkload').'</th>';
print '<th align="right">'.$langs->trans("ProgressDeclared").'</td>';
print '<th align="right">'.$langs->trans('TimeSpent').'</th>';
print '<th align="right">'.$langs->trans("ProgressCalculated").'</td>';
print '</tr>';
while ($i < $num && $i < $max)
{
$obj = $db->fetch_object($resql);
$var=!$var;
$username='';
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
{
$result=$userstatic->fetch($obj->userid);
if (! $result) $userstatic->id=0;
}
if ($userstatic->id) $username = $userstatic->getNomUrl(0,0);
print "<tr ".$bc[$var].">";
//print '<td>'.$username.'</td>';
print '<td>';
$projectstatic->id=$obj->projectid;
$projectstatic->ref=$obj->ref;
$projectstatic->title=$obj->title;
print $projectstatic->getNomUrl(1,'',16);
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$obj->projectid.'">'.$obj->title.'</a>';
print '</td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<td>';
$code = dol_getIdFromCode($db, $obj->opp_status, 'c_lead_status', 'rowid', 'code');
if ($code) print $langs->trans("OppStatus".$code);
print '</td>';
}
print '<td>';
if (! empty($obj->taskid))
{
$tasktmp->id = $obj->taskid;
$tasktmp->ref = $obj->label;
print $tasktmp->getNomUrl(1,'withproject');
}
else print $langs->trans("NoTasks");
print '</td>';
print '<td>'.dol_print_date($db->jdate($obj->dateo),'day').'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datee),'day').'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
print convertSecondToTime($obj->planned_workload, 'all');
print '</a></td>';
print '<td align="right">';
print ($obj->taskid>0)?$obj->progress.'%':'';
print '</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
print convertSecondToTime($obj->timespent, 'all');
print '</a></td>';
print '<td align="right">';
if (! empty($obj->taskid))
{
if (empty($obj->planned_workload) > 0) {
$percentcompletion = $langs->trans("WorkloadNotDefined");
} else {
$percentcompletion = intval($obj->duration_effective*100/$obj->planned_workload).'%';
}
}
print $percentcompletion;
print '</td>';
print "</tr>\n";
$i++;
}
if ($num > $max)
{
$colspan=6;
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $colspan++;
print '<tr><td colspan="'.$colspan.'">'.$langs->trans("WarningTooManyDataPleaseUseMoreFilters").'</td></tr>';
}
print "</table>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
print '</div>';
}
llxFooter();
$db->close();

View File

@ -242,16 +242,19 @@ if ($resql)
if ($user->rights->societe->client->voir || $socid)
{
$langs->load("commercial");
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user);
$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
$moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300');
$moreforfilter.='</div>';
}
// If the user can view prospects other than his'
if (($user->rights->societe->client->voir || $socid) && !$mine)
{
$moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': ';
$moreforfilter.=$form->select_dolusers($search_user,'search_user',1);
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': ';
$moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
$moreforfilter.='</div>';
}
if (! empty($moreforfilter))
{
@ -274,12 +277,10 @@ if ($resql)
if (! empty($conf->global->PROJECT_LIST_SHOW_STARTDATE)) print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Visibility"),$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder);
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print_liste_field_titre($langs->trans("OpportunityStatus"),$_SERVER["PHP_SELF"],'p.fk_opp_statut',"",$param,'',$sortfield,$sortorder);
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print_liste_field_titre($langs->trans("OpportunityStatus"),$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],'p.fk_statut',"",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
@ -401,6 +402,7 @@ if ($resql)
$userstatic->id=$val['id'];
$userstatic->lastname=$val['lastname'];
$userstatic->firstname=$val['firstname'];
$userstatic->email=$val['email'];
print $userstatic->getNomUrl(1);
$j++;
if ($j < $nbofsalesrepresentative) print ', ';

View File

@ -41,7 +41,6 @@ $search_task_label=GETPOST('search_task_label');
$search_project_user=GETPOST('search_project_user');
$search_task_user=GETPOST('search_task_user');
// Security check
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
@ -63,7 +62,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_task_ref="";
$search_task_label="";
}
if (empty($search_status)) $search_status=1;
if (empty($search_status) && $search_status == '') $search_status=1;
/*
@ -108,8 +107,8 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$so
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents).
$morewherefilter='';
if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref, 0, 1);
if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label, 0, 1);
if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref);
if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label);
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status, $morewherefilter, $search_project_user, $search_task_user);
// We load also tasks limited to a particular user
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
@ -121,22 +120,26 @@ print '<table class="noborder" width="100%">';
// If the user can view users
if ($user->rights->user->user->lire)
{
$moreforfilter.=($moreforfilter?' &nbsp; ':'');
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' ';
$moreforfilter.=$form->select_dolusers($search_project_user,'search_project_user',1);
$moreforfilter.=$form->select_dolusers($search_project_user, 'search_project_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
$moreforfilter.='</div>';
}
if ($user->rights->user->user->lire)
{
$moreforfilter.=($moreforfilter?' &nbsp; ':'');
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ' ';
$moreforfilter.=$form->select_dolusers($search_task_user,'search_task_user',1);
$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
$moreforfilter.='</div>';
}
if (! empty($moreforfilter))
{
print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="10">';
print $moreforfilter;
print '</td></tr>';
print '<div class="liste_titre">';
print $moreforfilter;
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</div>';
}
print '<tr class="liste_titre">';
@ -165,10 +168,10 @@ foreach($projectstatic->statuts_short as $key => $val) $listofstatus[$key]=$lang
print $form->selectarray('search_status', $listofstatus, $search_status);
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_task_ref" value="'.$search_task_ref.'" size="4">';
print '<input type="text" class="flat" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'" size="4">';
print '</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_task_label" value="'.$search_task_label.'" size="8">';
print '<input type="text" class="flat" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'" size="8">';
print '</td>';
print '<td class="liste_titre" colspan="5">';
print '&nbsp;';

View File

@ -1652,7 +1652,7 @@ class Societe extends CommonObject
$reparray=array();
$sql = "SELECT u.rowid, u.lastname, u.firstname";
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.rowid = sc.fk_user AND sc.fk_soc =".$this->id;
$sql.= " AND entity in (0, ".$conf->entity.")";
@ -1668,6 +1668,7 @@ class Societe extends CommonObject
$reparray[$i]['id']=$obj->rowid;
$reparray[$i]['lastname']=$obj->lastname;
$reparray[$i]['firstname']=$obj->firstname;
$reparray[$i]['email']=$obj->email;
$i++;
}
return $reparray;

View File

@ -2547,6 +2547,8 @@ a.impayee:hover { font-weight: bold; color: #550000; }
.legendColorBox, .legendLabel { border: none !important; }
div.dolgraph div.legend, div.dolgraph div.legend div { background-color: rgba(255,255,255,0) !important; }
div.dolgraph div.legend table tbody tr { height: auto; }
td.legendColorBox { padding: 2px 2px 2px 0 !important; }
td.legendLabel { padding: 2px 2px 2px 0 !important; }
.photo {
border: 0px;