2008-04-19 19:26:41 +02:00
< ? php
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2020-04-13 14:23:57 +02:00
* Copyright ( C ) 2004 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2010 Regis Houssin < regis . houssin @ inodbox . com >
2016-07-18 18:44:05 +02:00
* Copyright ( C ) 2012 - 2016 Juanjo Menent < jmenent @ 2 byte . es >
2019-03-17 23:00:13 +01:00
* Copyright ( C ) 2015 - 2019 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2015-04-04 17:52:05 +02:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2016-10-11 16:37:44 +02:00
* Copyright ( C ) 2016 Josep Lluís Amador < joseplluis @ lliuretic . cat >
2021-02-04 17:21:08 +01:00
* Copyright ( C ) 2021 Gauthier VERDOL < gauthier . verdol @ atm - consulting . fr >
2021-04-15 09:59:08 +02:00
* Copyright ( C ) 2021 Noé Cendrier < noe . cendrier @ altairis . fr >
2008-04-19 19:26:41 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-04-19 19:26:41 +02:00
* ( 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2008-04-19 19:26:41 +02:00
*/
/**
2008-09-10 22:49:21 +02:00
* \file htdocs / projet / element . php
2016-10-17 20:10:53 +02:00
* \ingroup projet
2010-12-18 12:29:42 +01:00
* \brief Page of project referrers
2008-09-10 22:49:21 +02:00
*/
2008-04-19 19:26:41 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2015-06-03 21:01:50 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
2013-06-17 14:25:33 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php' ;
2014-10-29 20:21:24 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2015-02-24 18:20:19 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> propal -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
}
if ( ! empty ( $conf -> facture -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php' ;
}
if ( ! empty ( $conf -> commande -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
}
if ( ! empty ( $conf -> supplier_proposal -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php' ;
}
2021-04-11 04:24:21 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_invoice -> enabled )) {
2021-02-26 18:49:22 +01:00
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
}
2021-04-11 04:24:21 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD )) || ! empty ( $conf -> supplier_order -> enabled )) {
2021-02-26 18:49:22 +01:00
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
}
if ( ! empty ( $conf -> contrat -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
}
if ( ! empty ( $conf -> ficheinter -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php' ;
}
if ( ! empty ( $conf -> expedition -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php' ;
}
if ( ! empty ( $conf -> deplacement -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/compta/deplacement/class/deplacement.class.php' ;
}
if ( ! empty ( $conf -> expensereport -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
}
if ( ! empty ( $conf -> agenda -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
}
if ( ! empty ( $conf -> don -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php' ;
}
if ( ! empty ( $conf -> loan -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/loan/class/loan.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/loan/class/loanschedule.class.php' ;
}
if ( ! empty ( $conf -> stock -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php' ;
}
if ( ! empty ( $conf -> tax -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php' ;
}
if ( ! empty ( $conf -> banque -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php' ;
}
if ( ! empty ( $conf -> salaries -> enabled )) {
2021-03-01 11:12:03 +01:00
require_once DOL_DOCUMENT_ROOT . '/salaries/class/salary.class.php' ;
2021-02-26 18:49:22 +01:00
}
if ( ! empty ( $conf -> categorie -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
}
if ( ! empty ( $conf -> mrp -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php' ;
}
2008-04-19 19:26:41 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'projects' , 'companies' , 'suppliers' , 'compta' ));
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> facture -> enabled )) {
$langs -> load ( " bills " );
}
if ( ! empty ( $conf -> commande -> enabled )) {
$langs -> load ( " orders " );
}
if ( ! empty ( $conf -> propal -> enabled )) {
$langs -> load ( " propal " );
}
if ( ! empty ( $conf -> ficheinter -> enabled )) {
$langs -> load ( " interventions " );
}
if ( ! empty ( $conf -> deplacement -> enabled )) {
$langs -> load ( " trips " );
}
if ( ! empty ( $conf -> expensereport -> enabled )) {
$langs -> load ( " trips " );
}
if ( ! empty ( $conf -> don -> enabled )) {
$langs -> load ( " donations " );
}
if ( ! empty ( $conf -> loan -> enabled )) {
$langs -> load ( " loan " );
}
if ( ! empty ( $conf -> salaries -> enabled )) {
$langs -> load ( " salaries " );
}
if ( ! empty ( $conf -> mrp -> enabled )) {
$langs -> load ( " mrp " );
}
2021-03-11 19:09:42 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
$langs -> load ( " eventorganization " );
}
2020-03-06 11:21:34 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-03-06 11:21:34 +01:00
$datesrfc = GETPOST ( 'datesrfc' );
$dateerfc = GETPOST ( 'dateerfc' );
$dates = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'datesmonth' ), GETPOST ( 'datesday' ), GETPOST ( 'datesyear' ));
$datee = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'dateemonth' ), GETPOST ( 'dateeday' ), GETPOST ( 'dateeyear' ));
2021-02-26 18:49:22 +01:00
if ( empty ( $dates ) && ! empty ( $datesrfc )) {
$dates = dol_stringtotime ( $datesrfc );
}
if ( empty ( $datee ) && ! empty ( $dateerfc )) {
$datee = dol_stringtotime ( $dateerfc );
}
2020-11-30 14:47:07 +01:00
if ( ! GETPOSTISSET ( 'datesrfc' ) && ! GETPOSTISSET ( 'datesday' ) && ! empty ( $conf -> global -> PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR )) {
2020-03-06 11:21:34 +01:00
$new = dol_now ();
$tmp = dol_getdate ( $new );
2014-10-29 20:21:24 +01:00
//$datee=$now
//$dates=dol_time_plus_duree($datee, -1, 'y');
2020-03-06 11:21:34 +01:00
$dates = dol_get_first_day ( $tmp [ 'year' ], 1 );
2014-10-29 20:21:24 +01:00
}
2021-02-26 18:49:22 +01:00
if ( $id == '' && $ref == '' ) {
2019-10-29 16:40:47 +01:00
setEventMessage ( $langs -> trans ( 'ErrorBadParameters' ), 'errors' );
header ( 'Location: list.php' );
exit ();
2010-05-23 22:01:10 +02:00
}
2008-04-19 19:26:41 +02:00
2020-03-06 11:21:34 +01:00
$mine = $_REQUEST [ 'mode' ] == 'mine' ? 1 : 0 ;
2010-05-29 01:26:08 +02:00
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
2010-05-30 14:21:32 +02:00
2015-03-02 17:54:35 +01:00
$object = new Project ( $db );
2020-03-06 14:52:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be include, not include_once
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) {
$object -> fetchComments ();
}
2012-05-23 14:34:44 +02:00
2010-05-30 14:21:32 +02:00
// Security check
2020-03-06 11:21:34 +01:00
$socid = $object -> socid ;
2019-10-31 20:46:31 +01:00
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2020-03-06 11:21:34 +01:00
$result = restrictedArea ( $user , 'projet' , $object -> id , 'projet&project' );
2008-04-19 19:26:41 +02:00
2016-06-13 16:25:27 +02:00
$hookmanager -> initHooks ( array ( 'projectOverview' ));
2018-02-01 19:15:50 +01:00
2008-04-19 19:26:41 +02:00
/*
2009-08-12 14:59:14 +02:00
* View
*/
2008-04-19 19:26:41 +02:00
2021-04-19 18:13:06 +02:00
$title = $langs -> trans ( 'ProjectReferers' ) . ' - ' . $object -> ref . ' ' . $object -> name ;
2021-04-19 18:15:07 +02:00
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/projectnameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) {
2021-04-19 18:13:06 +02:00
$title = $object -> ref . ' ' . $object -> name . ' - ' . $langs -> trans ( 'ProjectReferers' );
2021-02-26 18:49:22 +01:00
}
2021-04-19 18:13:06 +02:00
$help_url = 'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte' ;
llxHeader ( '' , $title , $help_url );
2008-04-19 19:26:41 +02:00
2009-01-12 21:26:06 +01:00
$form = new Form ( $db );
2019-11-13 19:37:08 +01:00
$formproject = new FormProjets ( $db );
2015-02-24 18:20:19 +01:00
$formfile = new FormFile ( $db );
2009-01-12 21:26:06 +01:00
2019-11-13 19:37:08 +01:00
$userstatic = new User ( $db );
2010-01-26 14:28:25 +01:00
2010-02-04 11:40:18 +01:00
// To verify role of users
2015-03-02 17:54:35 +01:00
$userAccess = $object -> restrictedProjectArea ( $user );
2010-02-04 11:40:18 +01:00
2019-11-13 19:37:08 +01:00
$head = project_prepare_head ( $object );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'element' , $langs -> trans ( " Project " ), - 1 , ( $object -> public ? 'projectpub' : 'project' ));
2008-04-19 19:26:41 +02:00
2016-10-17 20:10:53 +02:00
// Project card
2008-04-19 19:26:41 +02:00
2017-05-19 00:52:13 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2012-07-28 21:49:47 +02:00
2019-11-13 19:37:08 +01:00
$morehtmlref = '<div class="refidno">' ;
2016-10-17 20:10:53 +02:00
// Title
2019-11-13 19:37:08 +01:00
$morehtmlref .= $object -> title ;
2016-10-17 20:10:53 +02:00
// Thirdparty
2021-02-26 18:49:22 +01:00
if ( $object -> thirdparty -> id > 0 ) {
2020-10-31 14:32:18 +01:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 , 'project' );
2016-10-17 20:10:53 +02:00
}
2019-11-13 19:37:08 +01:00
$morehtmlref .= '</div>' ;
2016-10-17 20:10:53 +02:00
// Define a complementary filter for search of next/prev ref.
2021-02-26 18:49:22 +01:00
if ( ! $user -> rights -> projet -> all -> lire ) {
2020-10-31 14:32:18 +01:00
$objectsListId = $object -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2021-03-22 12:47:23 +01:00
$object -> next_prev_filter = " te.rowid IN ( " . $db -> sanitize ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2016-10-17 20:10:53 +02:00
}
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2019-09-01 01:40:51 +02:00
print '<table class="border tableforfield centpercent">' ;
// Usage
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) || empty ( $conf -> global -> PROJECT_HIDE_TASKS ) || ! empty ( $conf -> eventorganization -> enabled )) {
2021-03-18 11:07:48 +01:00
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Usage " );
print '</td>' ;
print '<td>' ;
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2021-03-18 11:07:48 +01:00
print '<input type="checkbox" disabled name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_opportunity ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectFollowOpportunity " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowOpportunity " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
2021-03-18 11:07:48 +01:00
print '<input type="checkbox" disabled name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_task ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectFollowTasks " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowTasks " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && ! empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT )) {
2021-03-18 11:07:48 +01:00
print '<input type="checkbox" disabled name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_bill_time ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectBillTimeDescription " );
print $form -> textwithpicto ( $langs -> trans ( " BillTime " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
print '<input type="checkbox" disabled name="usage_organize_event"' . ( GETPOSTISSET ( 'usage_organize_event' ) ? ( GETPOST ( 'usage_organize_event' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $object -> usage_organize_event ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " EventOrganizationDescriptionLong " );
print $form -> textwithpicto ( $langs -> trans ( " ManageOrganizeEvent " ), $htmltext );
}
2021-03-18 11:07:48 +01:00
print '</td></tr>' ;
2021-03-11 19:09:42 +01:00
}
2016-10-17 20:10:53 +02:00
2010-02-03 23:34:12 +01:00
// Visibility
2016-10-17 20:10:53 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( $object -> public ) {
print $langs -> trans ( 'SharedProject' );
} else {
print $langs -> trans ( 'PrivateProject' );
}
2009-01-15 00:36:51 +01:00
print '</td></tr>' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2020-10-31 14:32:18 +01:00
// Opportunity status
print '<tr><td>' . $langs -> trans ( " OpportunityStatus " ) . '</td><td>' ;
$code = dol_getIdFromCode ( $db , $object -> opp_status , 'c_lead_status' , 'rowid' , 'code' );
2021-02-26 18:49:22 +01:00
if ( $code ) {
print $langs -> trans ( " OppStatus " . $code );
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
// Opportunity percent
print '<tr><td>' . $langs -> trans ( " OpportunityProbability " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> opp_percent , '' )) {
print price ( $object -> opp_percent , '' , $langs , 1 , 0 ) . ' %' ;
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
// Opportunity Amount
print '<tr><td>' . $langs -> trans ( " OpportunityAmount " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> opp_amount , '' )) {
print price ( $object -> opp_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency );
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2016-06-20 10:54:02 +02:00
}
2015-06-30 01:34:17 +02:00
2016-10-18 12:16:12 +02:00
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
$start = dol_print_date ( $object -> date_start , 'day' );
2019-11-13 19:37:08 +01:00
print ( $start ? $start : '?' );
2019-01-27 11:55:16 +01:00
$end = dol_print_date ( $object -> date_end , 'day' );
2017-04-05 14:48:24 +02:00
print ' - ' ;
2019-11-13 19:37:08 +01:00
print ( $end ? $end : '?' );
2021-02-26 18:49:22 +01:00
if ( $object -> hasDelay ()) {
print img_warning ( " Late " );
}
2016-10-17 20:10:53 +02:00
print '</td></tr>' ;
2015-06-30 01:34:17 +02:00
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $object -> budget_amount , '' )) {
print price ( $object -> budget_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency );
}
2015-06-30 01:34:17 +02:00
print '</td></tr>' ;
2016-10-17 20:10:53 +02:00
// Other attributes
$cols = 2 ;
2019-11-13 19:37:08 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2016-10-17 20:10:53 +02:00
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="ficheaddleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2019-03-22 14:32:15 +01:00
print '<table class="border tableforfield" width="100%">' ;
2016-10-17 20:10:53 +02:00
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
print nl2br ( $object -> description );
print '</td></tr>' ;
// Categories
2019-11-13 19:37:08 +01:00
if ( $conf -> categorie -> enabled ) {
2020-10-31 14:32:18 +01:00
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
print $form -> showCategories ( $object -> id , Categorie :: TYPE_PROJECT , 1 );
print " </td></tr> " ;
2016-10-17 20:10:53 +02:00
}
2008-04-19 19:26:41 +02:00
print '</table>' ;
2016-10-17 20:10:53 +02:00
print '</div>' ;
print '</div>' ;
print '</div>' ;
print '<div class="clearboth"></div>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2008-04-19 19:26:41 +02:00
2017-05-18 12:12:36 +02:00
print '<br>' ;
2008-04-19 19:26:41 +02:00
/*
2010-06-28 23:26:36 +02:00
* Referers types
2008-04-19 19:26:41 +02:00
*/
2010-01-04 22:45:59 +01:00
2019-11-13 19:37:08 +01:00
$listofreferent = array (
2021-04-15 09:59:08 +02:00
'entrepot' => array (
'name' => " Warehouse " ,
'title' => " ListWarehouseAssociatedProject " ,
'class' => 'Entrepot' ,
'table' => 'entrepot' ,
'datefieldname' => 'date_entrepot' ,
2021-04-15 10:31:18 +02:00
'urlnew' => DOL_URL_ROOT . '/product/stock/card.php?action=create&projectid=' . $id ,
2021-04-15 09:59:08 +02:00
'lang' => 'entrepot' ,
'buttonnew' => 'AddWarehouse' ,
'project_field' => 'fk_project' ,
'testnew' => $user -> rights -> stock -> creer ,
'test' => $conf -> stock -> enabled && $user -> rights -> stock -> lire ),
2008-04-19 19:26:41 +02:00
'propal' => array (
2015-01-23 02:21:43 +01:00
'name' => " Proposals " ,
2008-04-19 19:26:41 +02:00
'title' => " ListProposalsAssociatedProject " ,
'class' => 'Propal' ,
2013-04-29 11:54:29 +02:00
'table' => 'propal' ,
2020-10-31 14:32:18 +01:00
'datefieldname' => 'datep' ,
'urlnew' => DOL_URL_ROOT . '/comm/propal/card.php?action=create&origin=project&originid=' . $id . '&socid=' . $socid ,
'lang' => 'propal' ,
'buttonnew' => 'AddProp' ,
'testnew' => $user -> rights -> propal -> creer ,
2013-07-23 05:49:30 +02:00
'test' => $conf -> propal -> enabled && $user -> rights -> propale -> lire ),
2008-04-19 19:26:41 +02:00
'order' => array (
2015-01-23 02:21:43 +01:00
'name' => " CustomersOrders " ,
2008-04-19 19:26:41 +02:00
'title' => " ListOrdersAssociatedProject " ,
'class' => 'Commande' ,
2013-04-29 11:54:29 +02:00
'table' => 'commande' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'date_commande' ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/commande/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'orders' ,
'buttonnew' => 'CreateOrder' ,
'testnew' => $user -> rights -> commande -> creer ,
'test' => $conf -> commande -> enabled && $user -> rights -> commande -> lire ),
2008-04-19 19:26:41 +02:00
'invoice' => array (
2015-01-23 02:21:43 +01:00
'name' => " CustomersInvoices " ,
2008-04-19 19:26:41 +02:00
'title' => " ListInvoicesAssociatedProject " ,
'class' => 'Facture' ,
2014-04-19 13:00:42 +02:00
'margin' => 'add' ,
2013-04-29 11:54:29 +02:00
'table' => 'facture' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'datef' ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/compta/facture/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'bills' ,
'buttonnew' => 'CreateBill' ,
'testnew' => $user -> rights -> facture -> creer ,
'test' => $conf -> facture -> enabled && $user -> rights -> facture -> lire ),
2009-02-04 21:38:07 +01:00
'invoice_predefined' => array (
2014-12-04 11:53:44 +01:00
'name' => " PredefinedInvoices " ,
2009-02-04 21:38:07 +01:00
'title' => " ListPredefinedInvoicesAssociatedProject " ,
'class' => 'FactureRec' ,
2013-04-29 11:54:29 +02:00
'table' => 'facture_rec' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'datec' ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/compta/facture/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'bills' ,
'buttonnew' => 'CreateBill' ,
'testnew' => $user -> rights -> facture -> creer ,
'test' => $conf -> facture -> enabled && $user -> rights -> facture -> lire ),
2016-04-04 15:20:21 +02:00
'proposal_supplier' => array (
2016-08-09 17:28:02 +02:00
'name' => " SuppliersProposals " ,
'title' => " ListSupplierProposalsAssociatedProject " ,
'class' => 'SupplierProposal' ,
'table' => 'supplier_proposal' ,
2019-01-13 14:09:40 +01:00
'datefieldname' => 'date_valid' ,
2019-11-13 19:37:08 +01:00
'urlnew' => DOL_URL_ROOT . '/supplier_proposal/card.php?action=create&projectid=' . $id , // No socid parameter here, the socid is often the customer and we create a supplier object
2020-10-31 14:32:18 +01:00
'lang' => 'supplier_proposal' ,
'buttonnew' => 'AddSupplierProposal' ,
'testnew' => $user -> rights -> supplier_proposal -> creer ,
'test' => $conf -> supplier_proposal -> enabled && $user -> rights -> supplier_proposal -> lire ),
2008-04-19 19:26:41 +02:00
'order_supplier' => array (
2015-01-23 02:21:43 +01:00
'name' => " SuppliersOrders " ,
2008-04-19 19:26:41 +02:00
'title' => " ListSupplierOrdersAssociatedProject " ,
'class' => 'CommandeFournisseur' ,
2013-04-29 11:54:29 +02:00
'table' => 'commande_fournisseur' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'date_commande' ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/fourn/commande/card.php?action=create&projectid=' . $id , // No socid parameter here, the socid is often the customer and we create a supplier object
'lang' => 'suppliers' ,
'buttonnew' => 'AddSupplierOrder' ,
2021-04-12 09:47:16 +02:00
'testnew' => ( $user -> rights -> fournisseur -> commande -> creer || $user -> rights -> supplier_order -> creer ),
2021-04-12 08:59:25 +02:00
'test' => $conf -> supplier_order -> enabled && ( $user -> rights -> fournisseur -> commande -> lire || $user -> rights -> supplier_order -> lire )),
2008-04-19 19:26:41 +02:00
'invoice_supplier' => array (
2014-12-04 11:53:44 +01:00
'name' => " BillsSuppliers " ,
2008-04-19 19:26:41 +02:00
'title' => " ListSupplierInvoicesAssociatedProject " ,
'class' => 'FactureFournisseur' ,
2014-04-19 13:00:42 +02:00
'margin' => 'minus' ,
2013-04-29 11:54:29 +02:00
'table' => 'facture_fourn' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'datef' ,
2019-11-13 19:37:08 +01:00
'urlnew' => DOL_URL_ROOT . '/fourn/facture/card.php?action=create&projectid=' . $id , // No socid parameter here, the socid is often the customer and we create a supplier object
2020-10-31 14:32:18 +01:00
'lang' => 'suppliers' ,
'buttonnew' => 'AddSupplierInvoice' ,
2021-04-12 07:37:34 +02:00
'testnew' => ( $user -> rights -> fournisseur -> facture -> creer || $user -> rights -> supplier_invoice -> creer ),
2021-04-12 08:59:25 +02:00
'test' => $conf -> supplier_invoice -> enabled && ( $user -> rights -> fournisseur -> facture -> lire || $user -> rights -> supplier_invoice -> lire )),
2008-12-31 16:10:21 +01:00
'contract' => array (
2014-12-04 11:53:44 +01:00
'name' => " Contracts " ,
2008-12-31 16:10:21 +01:00
'title' => " ListContractAssociatedProject " ,
'class' => 'Contrat' ,
2013-04-29 11:54:29 +02:00
'table' => 'contrat' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'date_contrat' ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/contrat/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'contracts' ,
'buttonnew' => 'AddContract' ,
'testnew' => $user -> rights -> contrat -> creer ,
'test' => $conf -> contrat -> enabled && $user -> rights -> contrat -> lire ),
2010-03-21 15:01:39 +01:00
'intervention' => array (
2014-12-04 11:53:44 +01:00
'name' => " Interventions " ,
2010-03-21 15:01:39 +01:00
'title' => " ListFichinterAssociatedProject " ,
'class' => 'Fichinter' ,
2013-04-29 11:54:29 +02:00
'table' => 'fichinter' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'date_valid' ,
2017-05-09 22:24:24 +02:00
'disableamount' => 0 ,
2017-07-29 00:28:41 +02:00
'margin' => 'minus' ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/fichinter/card.php?action=create&origin=project&originid=' . $id . '&socid=' . $socid ,
'lang' => 'interventions' ,
'buttonnew' => 'AddIntervention' ,
'testnew' => $user -> rights -> ficheinter -> creer ,
'test' => $conf -> ficheinter -> enabled && $user -> rights -> ficheinter -> lire ),
2017-05-19 08:50:10 +02:00
'shipping' => array (
2020-10-31 14:32:18 +01:00
'name' => " Shippings " ,
2017-05-19 08:50:10 +02:00
'title' => " ListShippingAssociatedProject " ,
'class' => 'Expedition' ,
'table' => 'expedition' ,
'datefieldname' => 'date_valid' ,
'urlnew' => DOL_URL_ROOT . '/expedition/card.php?action=create&origin=project&originid=' . $id . '&socid=' . $socid ,
'lang' => 'sendings' ,
'buttonnew' => 'CreateShipment' ,
'testnew' => 0 ,
'test' => $conf -> expedition -> enabled && $user -> rights -> expedition -> lire ),
2020-03-06 11:21:34 +01:00
'mrp' => array (
'name' => " MO " ,
'title' => " ListMOAssociatedProject " ,
'class' => 'Mo' ,
'table' => 'mrp_mo' ,
'datefieldname' => 'date_valid' ,
'urlnew' => DOL_URL_ROOT . '/mrp/mo_card.php?action=create&origin=project&originid=' . $id . '&socid=' . $socid ,
'lang' => 'mrp' ,
'buttonnew' => 'CreateMO' ,
'testnew' => '$user->rights->mrp->write' ,
'project_field' => 'fk_project' ,
'test' => $conf -> mrp -> enabled && $user -> rights -> mrp -> read ),
2010-03-21 15:01:39 +01:00
'trip' => array (
2015-01-23 02:21:43 +01:00
'name' => " TripsAndExpenses " ,
2015-02-15 22:49:23 +01:00
'title' => " ListExpenseReportsAssociatedProject " ,
2010-03-21 15:01:39 +01:00
'class' => 'Deplacement' ,
2013-04-29 11:54:29 +02:00
'table' => 'deplacement' ,
2014-10-29 20:21:24 +01:00
'datefieldname' => 'dated' ,
2014-04-19 13:00:42 +02:00
'margin' => 'minus' ,
2010-03-21 15:01:39 +01:00
'disableamount' => 1 ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/deplacement/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'trips' ,
'buttonnew' => 'AddTrip' ,
'testnew' => $user -> rights -> deplacement -> creer ,
'test' => $conf -> deplacement -> enabled && $user -> rights -> deplacement -> lire ),
2015-02-15 22:49:23 +01:00
'expensereport' => array (
'name' => " ExpenseReports " ,
'title' => " ListExpenseReportsAssociatedProject " ,
'class' => 'ExpenseReportLine' ,
2015-02-21 15:18:05 +01:00
'table' => 'expensereport_det' ,
2015-02-15 22:49:23 +01:00
'datefieldname' => 'date' ,
'margin' => 'minus' ,
2015-02-21 15:18:05 +01:00
'disableamount' => 0 ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/expensereport/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'trips' ,
'buttonnew' => 'AddTrip' ,
'testnew' => $user -> rights -> expensereport -> creer ,
'test' => $conf -> expensereport -> enabled && $user -> rights -> expensereport -> lire ),
2015-03-18 21:56:00 +01:00
'donation' => array (
'name' => " Donation " ,
'title' => " ListDonationsAssociatedProject " ,
'class' => 'Don' ,
2015-04-02 06:36:32 +02:00
'margin' => 'add' ,
2015-03-18 21:56:00 +01:00
'table' => 'don' ,
2015-06-03 21:01:50 +02:00
'datefieldname' => 'datedon' ,
2015-04-02 06:36:32 +02:00
'disableamount' => 0 ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/don/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'donations' ,
'buttonnew' => 'AddDonation' ,
'testnew' => $user -> rights -> don -> creer ,
'test' => $conf -> don -> enabled && $user -> rights -> don -> lire ),
2016-11-16 09:38:13 +01:00
'loan' => array (
'name' => " Loan " ,
'title' => " ListLoanAssociatedProject " ,
'class' => 'Loan' ,
'margin' => 'add' ,
2017-01-07 17:54:47 +01:00
'table' => 'loan' ,
2016-11-16 09:38:13 +01:00
'datefieldname' => 'datestart' ,
'disableamount' => 0 ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/loan/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'loan' ,
'buttonnew' => 'AddLoan' ,
'testnew' => $user -> rights -> loan -> write ,
'test' => $conf -> loan -> enabled && $user -> rights -> loan -> read ),
2017-03-23 16:10:38 +01:00
'chargesociales' => array (
2020-10-31 14:32:18 +01:00
'name' => " SocialContribution " ,
'title' => " ListSocialContributionAssociatedProject " ,
'class' => 'ChargeSociales' ,
'margin' => 'minus' ,
'table' => 'chargesociales' ,
'datefieldname' => 'date_ech' ,
'disableamount' => 0 ,
'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $id ,
'lang' => 'compta' ,
'buttonnew' => 'AddSocialContribution' ,
'testnew' => $user -> rights -> tax -> charges -> lire ,
'test' => $conf -> tax -> enabled && $user -> rights -> tax -> charges -> lire ),
2017-01-02 12:17:27 +01:00
'project_task' => array (
2017-07-29 00:28:41 +02:00
'name' => " TaskTimeSpent " ,
2017-01-02 12:17:27 +01:00
'title' => " ListTaskTimeUserProject " ,
'class' => 'Task' ,
'margin' => 'minus' ,
'table' => 'projet_task' ,
'datefieldname' => 'task_date' ,
'disableamount' => 0 ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/projet/tasks/time.php?withproject=1&action=createtime&projectid=' . $id ,
'buttonnew' => 'AddTimeSpent' ,
'testnew' => $user -> rights -> projet -> creer ,
'test' => ( $conf -> projet -> enabled && $user -> rights -> projet -> lire && empty ( $conf -> global -> PROJECT_HIDE_TASKS ))),
2017-01-29 13:36:33 +01:00
'stock_mouvement' => array (
'name' => " MouvementStockAssociated " ,
'title' => " ListMouvementStockProject " ,
'class' => 'MouvementStock' ,
'margin' => 'minus' ,
'table' => 'stock_mouvement' ,
'datefieldname' => 'datem' ,
'disableamount' => 0 ,
2019-11-13 19:37:08 +01:00
'test' => ( $conf -> stock -> enabled && $user -> rights -> stock -> mouvement -> lire && ! empty ( $conf -> global -> STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW ))),
2018-07-31 07:45:03 +02:00
'salaries' => array (
'name' => " Salaries " ,
'title' => " ListSalariesAssociatedProject " ,
2021-02-04 17:21:08 +01:00
'class' => 'Salary' ,
2018-07-31 07:45:03 +02:00
'table' => 'payment_salary' ,
'datefieldname' => 'datev' ,
'margin' => 'minus' ,
'disableamount' => 0 ,
2019-07-19 23:08:24 +02:00
'urlnew' => DOL_URL_ROOT . '/salaries/card.php?action=create&projectid=' . $id ,
2018-07-31 07:45:03 +02:00
'lang' => 'salaries' ,
2018-10-26 19:00:24 +02:00
'buttonnew' => 'AddSalaryPayment' ,
2018-07-31 07:45:03 +02:00
'testnew' => $user -> rights -> salaries -> write ,
'test' => $conf -> salaries -> enabled && $user -> rights -> salaries -> read ),
2017-09-01 07:21:27 +02:00
'variouspayment' => array (
'name' => " VariousPayments " ,
'title' => " ListVariousPaymentsAssociatedProject " ,
'class' => 'PaymentVarious' ,
'table' => 'payment_various' ,
'datefieldname' => 'datev' ,
'margin' => 'minus' ,
'disableamount' => 0 ,
2020-10-31 14:32:18 +01:00
'urlnew' => DOL_URL_ROOT . '/compta/bank/various_payment/card.php?action=create&projectid=' . $id ,
'lang' => 'banks' ,
'buttonnew' => 'AddVariousPayment' ,
'testnew' => $user -> rights -> banque -> modifier ,
'test' => $conf -> banque -> enabled && $user -> rights -> banque -> lire && empty ( $conf -> global -> BANK_USE_OLD_VARIOUS_PAYMENT )),
2017-01-02 12:34:23 +01:00
/* No need for this , available on dedicated tab " Agenda/Events "
2016-04-04 15:20:21 +02:00
'agenda' => array (
'name' => " Agenda " ,
'title' => " ListActionsAssociatedProject " ,
'class' => 'ActionComm' ,
'table' => 'actioncomm' ,
'datefieldname' => 'datep' ,
'disableamount' => 1 ,
2021-02-26 18:49:22 +01:00
'urlnew' => DOL_URL_ROOT . '/comm/action/card.php?action=create&projectid=' . $id . '&socid=' . $socid ,
'lang' => 'agenda' ,
'buttonnew' => 'AddEvent' ,
'testnew' => $user -> rights -> agenda -> myactions -> create ,
'test' => $conf -> agenda -> enabled && $user -> rights -> agenda -> myactions -> read ),
2017-01-02 12:34:23 +01:00
*/
2008-04-19 19:26:41 +02:00
);
2020-06-08 17:00:58 +02:00
// Change rules for profit/benefit calculation
2020-10-31 14:32:18 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ELEMENTS_FOR_PLUS_MARGIN )) {
2020-05-21 02:02:54 +02:00
foreach ( $listofreferent as $key => $element ) {
2020-05-05 20:51:29 +02:00
if ( $listofreferent [ $key ][ 'margin' ] == 'add' ) {
unset ( $listofreferent [ $key ][ 'margin' ]);
}
}
$newelementforplusmargin = explode ( ',' , $conf -> global -> PROJECT_ELEMENTS_FOR_PLUS_MARGIN );
2020-05-21 02:02:54 +02:00
foreach ( $newelementforplusmargin as $value ) {
2020-10-31 14:32:18 +01:00
$listofreferent [ trim ( $value )][ 'margin' ] = 'add' ;
2020-05-05 20:51:29 +02:00
}
}
2020-10-31 14:32:18 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ELEMENTS_FOR_MINUS_MARGIN )) {
2020-05-21 02:02:54 +02:00
foreach ( $listofreferent as $key => $element ) {
2020-06-23 15:52:17 +02:00
if ( $listofreferent [ $key ][ 'margin' ] == 'minus' ) {
2020-05-05 20:51:29 +02:00
unset ( $listofreferent [ $key ][ 'margin' ]);
}
}
2020-06-23 15:52:17 +02:00
$newelementforminusmargin = explode ( ',' , $conf -> global -> PROJECT_ELEMENTS_FOR_MINUS_MARGIN );
2020-06-24 09:59:08 +02:00
foreach ( $newelementforminusmargin as $value ) {
2020-10-31 14:32:18 +01:00
$listofreferent [ trim ( $value )][ 'margin' ] = 'minus' ;
2020-05-05 20:51:29 +02:00
}
}
2020-03-06 11:21:34 +01:00
$parameters = array ( 'listofreferent' => $listofreferent );
2018-02-01 19:15:50 +01:00
$resHook = $hookmanager -> executeHooks ( 'completeListOfReferent' , $parameters , $object , $action );
2016-06-13 16:25:27 +02:00
2020-03-06 11:21:34 +01:00
if ( ! empty ( $hookmanager -> resArray )) {
2016-06-13 16:25:27 +02:00
$listofreferent = array_merge ( $listofreferent , $hookmanager -> resArray );
}
2021-02-26 18:49:22 +01:00
if ( $action == " addelement " ) {
2013-04-29 11:54:29 +02:00
$tablename = GETPOST ( " tablename " );
$elementselectid = GETPOST ( " elementselect " );
2020-03-06 11:21:34 +01:00
$result = $object -> update_element ( $tablename , $elementselectid );
2021-02-26 18:49:22 +01:00
if ( $result < 0 ) {
2015-12-17 14:14:44 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2013-06-13 18:11:23 +02:00
}
2021-02-26 18:49:22 +01:00
} elseif ( $action == " unlink " ) {
2019-09-27 12:36:15 +02:00
$tablename = GETPOST ( " tablename " , " aZ09 " );
2020-10-31 14:32:18 +01:00
$projectField = GETPOSTISSET ( 'projectfield' ) ? GETPOST ( 'projectfield' , 'aZ09' ) : 'fk_projet' ;
2019-09-27 12:36:15 +02:00
$elementselectid = GETPOST ( " elementselect " , " int " );
2014-10-29 20:21:24 +01:00
2019-09-23 17:36:18 +02:00
$result = $object -> remove_element ( $tablename , $elementselectid , $projectField );
2021-02-26 18:49:22 +01:00
if ( $result < 0 ) {
2015-12-17 14:14:44 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-09-20 10:14:26 +02:00
}
2013-04-29 11:54:29 +02:00
}
2015-06-03 21:01:50 +02:00
$elementuser = new User ( $db );
2015-06-22 11:55:21 +02:00
2019-11-13 19:37:08 +01:00
$showdatefilter = 0 ;
2015-06-22 11:55:21 +02:00
// Show the filter on date on top of element list
2021-02-26 18:49:22 +01:00
if ( ! $showdatefilter ) {
2016-04-23 17:35:33 +02:00
print '<div class="center centpercent">' ;
2020-10-31 14:32:18 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="POST">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="tablename" value="' . $tablename . '">' ;
2015-06-22 11:55:21 +02:00
print '<input type="hidden" name="action" value="view">' ;
2020-10-13 10:51:51 +02:00
print '<div class="inline-block">' ;
print $form -> selectDate ( $dates , 'dates' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( " From " ));
print '</div>' ;
print '<div class="inline-block">' ;
print $form -> selectDate ( $datee , 'datee' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( " to " ));
print '</div>' ;
print '<div class="inline-block">' ;
2015-06-22 11:55:21 +02:00
print '<input type="submit" name="refresh" value="' . $langs -> trans ( " Refresh " ) . '" class="button">' ;
2020-10-13 10:51:51 +02:00
print '</div>' ;
2015-06-22 11:55:21 +02:00
print '</form>' ;
2016-04-23 17:35:33 +02:00
print '</div>' ;
2016-08-10 11:34:10 +02:00
2015-06-22 11:55:21 +02:00
$showdatefilter ++ ;
}
// Show balance for whole project
2018-10-01 08:22:23 +02:00
$langs -> loadLangs ( array ( " suppliers " , " bills " , " orders " , " proposals " , " margins " ));
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$langs -> load ( 'stocks' );
}
2015-06-22 11:55:21 +02:00
2016-04-09 22:54:13 +02:00
print load_fiche_titre ( $langs -> trans ( " Profit " ), '' , 'title_accountancy' );
2015-06-22 11:55:21 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2015-06-22 11:55:21 +02:00
print '<tr class="liste_titre">' ;
2020-06-08 17:00:58 +02:00
print '<td class="left" width="200">' ;
$tooltiponprofit = $langs -> trans ( " ProfitIsCalculatedWith " ) . " <br> \n " ;
$tooltiponprofitplus = $tooltiponprofitminus = '' ;
2021-02-26 18:49:22 +01:00
foreach ( $listofreferent as $key => $value ) {
2020-06-08 17:00:58 +02:00
$name = $langs -> trans ( $value [ 'name' ]);
$qualified = $value [ 'test' ];
$margin = $value [ 'margin' ];
2021-02-26 18:49:22 +01:00
if ( $qualified && isset ( $margin )) { // If this element must be included into profit calculation ($margin is 'minus' or 'add')
2020-06-08 17:00:58 +02:00
if ( $margin == 'add' ) {
2020-10-31 14:32:18 +01:00
$tooltiponprofitplus .= ' > ' . $name . " (+)<br> \n " ;
2020-06-08 17:00:58 +02:00
}
if ( $margin == 'minus' ) {
2020-10-31 14:32:18 +01:00
$tooltiponprofitminus .= ' > ' . $name . " (-)<br> \n " ;
2020-06-08 17:00:58 +02:00
}
}
}
$tooltiponprofit .= $tooltiponprofitplus ;
$tooltiponprofit .= $tooltiponprofitminus ;
print $form -> textwithpicto ( $langs -> trans ( " Element " ), $tooltiponprofit );
print '</td>' ;
2019-02-23 22:24:26 +01:00
print '<td class="right" width="100">' . $langs -> trans ( " Number " ) . '</td>' ;
print '<td class="right" width="100">' . $langs -> trans ( " AmountHT " ) . '</td>' ;
print '<td class="right" width="100">' . $langs -> trans ( " AmountTTC " ) . '</td>' ;
2015-06-22 11:55:21 +02:00
print '</tr>' ;
2020-06-23 16:05:00 +02:00
$total_revenue_ht = 0 ;
2020-12-16 16:25:30 +01:00
$balance_ht = 0 ;
$balance_ttc = 0 ;
2020-06-23 16:05:00 +02:00
2021-02-26 18:49:22 +01:00
foreach ( $listofreferent as $key => $value ) {
2020-12-16 16:25:30 +01:00
$parameters = array (
'total_revenue_ht' =>& $total_revenue_ht ,
'balance_ht' =>& $balance_ht ,
'balance_ttc' =>& $balance_ttc ,
'key' => $key ,
'value' =>& $value ,
'dates' => $dates ,
'datee' => $datee
);
$reshook = $hookmanager -> executeHooks ( 'printOverviewProfit' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2020-12-17 14:01:42 +01:00
} elseif ( $reshook > 0 ) {
2020-12-16 16:25:30 +01:00
print $hookmanager -> resPrint ;
continue ;
}
2020-03-06 11:21:34 +01:00
$name = $langs -> trans ( $value [ 'name' ]);
$title = $value [ 'title' ];
$classname = $value [ 'class' ];
$tablename = $value [ 'table' ];
$datefieldname = $value [ 'datefieldname' ];
$qualified = $value [ 'test' ];
2015-06-22 11:55:21 +02:00
$margin = $value [ 'margin' ];
2018-07-26 15:05:32 +02:00
$project_field = $value [ 'project_field' ];
2020-12-17 14:01:42 +01:00
if ( $qualified && isset ( $margin )) { // If this element must be included into profit calculation ($margin is 'minus' or 'add')
2015-06-22 11:55:21 +02:00
$element = new $classname ( $db );
2020-03-06 14:52:29 +01:00
$elementarray = $object -> get_element_list ( $key , $tablename , $datefieldname , $dates , $datee , ! empty ( $project_field ) ? $project_field : 'fk_projet' );
2016-11-16 09:38:13 +01:00
2020-12-17 14:01:42 +01:00
if ( is_array ( $elementarray ) && count ( $elementarray ) > 0 ) {
2015-06-22 11:55:21 +02:00
$total_ht = 0 ;
$total_ttc = 0 ;
2020-03-06 11:21:34 +01:00
$num = count ( $elementarray );
2020-12-17 14:01:42 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2020-03-06 11:21:34 +01:00
$tmp = explode ( '_' , $elementarray [ $i ]);
$idofelement = $tmp [ 0 ];
$idofelementuser = $tmp [ 1 ];
2015-06-22 11:55:21 +02:00
$element -> fetch ( $idofelement );
2021-02-26 18:49:22 +01:00
if ( $idofelementuser ) {
$elementuser -> fetch ( $idofelementuser );
}
2015-06-22 11:55:21 +02:00
2019-03-18 10:16:08 +01:00
// Define if record must be used for total or not
2020-03-06 11:21:34 +01:00
$qualifiedfortotal = true ;
2020-12-17 14:01:42 +01:00
if ( $key == 'invoice' ) {
2021-02-26 18:49:22 +01:00
if ( ! empty ( $element -> close_code ) && $element -> close_code == 'replaced' ) {
$qualifiedfortotal = false ; // Replacement invoice, do not include into total
}
if ( ! empty ( $conf -> global -> FACTURE_DEPOSITS_ARE_JUST_PAYMENTS ) && $element -> type == Facture :: TYPE_DEPOSIT ) {
$qualifiedfortotal = false ; // If hidden option to use deposits as payment (deprecated, not recommended to use this), deposits are not included
}
2019-03-18 09:08:53 +01:00
}
2020-12-17 14:01:42 +01:00
if ( $key == 'propal' ) {
2021-02-26 18:49:22 +01:00
if ( $element -> status != Propal :: STATUS_SIGNED && $element -> status != Propal :: STATUS_BILLED ) {
$qualifiedfortotal = false ; // Only signed proposal must not be included in total
}
2019-03-18 09:08:53 +01:00
}
2021-02-26 18:49:22 +01:00
if ( $tablename != 'expensereport_det' && method_exists ( $element , 'fetch_thirdparty' )) {
$element -> fetch_thirdparty ();
}
2019-03-18 09:08:53 +01:00
// Define $total_ht_by_line
2021-02-26 18:49:22 +01:00
if ( $tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary' ) {
$total_ht_by_line = $element -> amount ;
} elseif ( $tablename == 'fichinter' ) {
$total_ht_by_line = $element -> getAmount ();
} elseif ( $tablename == 'stock_mouvement' ) {
$total_ht_by_line = $element -> price * abs ( $element -> qty );
} elseif ( $tablename == 'projet_task' ) {
2020-12-17 14:01:42 +01:00
if ( $idofelementuser ) {
2015-06-22 11:55:21 +02:00
$tmp = $element -> getSumOfAmount ( $elementuser , $dates , $datee );
2019-01-27 11:55:16 +01:00
$total_ht_by_line = price2num ( $tmp [ 'amount' ], 'MT' );
2020-12-17 14:01:42 +01:00
} else {
2015-06-22 11:55:21 +02:00
$tmp = $element -> getSumOfAmount ( '' , $dates , $datee );
2019-01-27 11:55:16 +01:00
$total_ht_by_line = price2num ( $tmp [ 'amount' ], 'MT' );
2015-06-22 11:55:21 +02:00
}
2020-05-21 15:05:19 +02:00
} elseif ( $key == 'loan' ) {
2020-10-31 14:32:18 +01:00
if (( empty ( $dates ) && empty ( $datee )) || ( intval ( $dates ) <= $element -> datestart && intval ( $datee ) >= $element -> dateend )) {
// Get total loan
$total_ht_by_line = - $element -> capital ;
} else {
// Get loan schedule according to date filter
$total_ht_by_line = 0 ;
$loanScheduleStatic = new LoanSchedule ( $element -> db );
$loanScheduleStatic -> fetchAll ( $element -> id );
if ( ! empty ( $loanScheduleStatic -> lines )) {
foreach ( $loanScheduleStatic -> lines as $loanSchedule ) {
/**
* @ var $loanSchedule LoanSchedule
*/
if (( $loanSchedule -> datep >= $dates && $loanSchedule -> datep <= $datee ) // dates filter is defined
|| ! empty ( $dates ) && empty ( $datee ) && $loanSchedule -> datep >= $dates && $loanSchedule -> datep <= dol_now ()
|| empty ( $dates ) && ! empty ( $datee ) && $loanSchedule -> datep <= $datee
) {
$total_ht_by_line -= $loanSchedule -> amount_capital ;
}
}
}
}
2021-02-26 18:49:22 +01:00
} else {
$total_ht_by_line = $element -> total_ht ;
}
2015-06-22 11:55:21 +02:00
2019-03-18 09:08:53 +01:00
// Define $total_ttc_by_line
2021-02-26 18:49:22 +01:00
if ( $tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary' ) {
$total_ttc_by_line = $element -> amount ;
} elseif ( $tablename == 'fichinter' ) {
$total_ttc_by_line = $element -> getAmount ();
} elseif ( $tablename == 'stock_mouvement' ) {
$total_ttc_by_line = $element -> price * abs ( $element -> qty );
} elseif ( $tablename == 'projet_task' ) {
2015-06-22 11:55:21 +02:00
$defaultvat = get_default_tva ( $mysoc , $mysoc );
2019-01-27 11:55:16 +01:00
$total_ttc_by_line = price2num ( $total_ht_by_line * ( 1 + ( $defaultvat / 100 )), 'MT' );
2020-12-17 14:01:42 +01:00
} elseif ( $key == 'loan' ) {
2020-10-31 14:32:18 +01:00
$total_ttc_by_line = $total_ht_by_line ; // For loan there is actually no taxe managed in Dolibarr
2021-02-26 18:49:22 +01:00
} else {
$total_ttc_by_line = $element -> total_ttc ;
}
2015-06-22 11:55:21 +02:00
2019-03-18 10:16:08 +01:00
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
2020-12-17 14:01:42 +01:00
if ( $tablename == 'payment_various' ) {
2020-12-17 14:05:04 +01:00
if ( $element -> sens == 1 ) {
2020-10-31 14:32:18 +01:00
$total_ht_by_line = - $total_ht_by_line ;
$total_ttc_by_line = - $total_ttc_by_line ;
}
2019-03-18 10:16:08 +01:00
}
2019-03-18 09:08:53 +01:00
// Add total if we have to
2020-12-17 14:05:04 +01:00
if ( $qualifiedfortotal ) {
2020-10-31 14:32:18 +01:00
$total_ht = $total_ht + $total_ht_by_line ;
$total_ttc = $total_ttc + $total_ttc_by_line ;
2019-03-18 09:08:53 +01:00
}
2015-06-22 11:55:21 +02:00
}
2017-10-06 15:48:48 +02:00
// Each element with at least one line is output
2019-11-13 19:37:08 +01:00
$qualifiedforfinalprofit = true ;
2021-02-26 18:49:22 +01:00
if ( $key == 'intervention' && empty ( $conf -> global -> PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT )) {
$qualifiedforfinalprofit = false ;
}
2020-06-24 12:58:10 +02:00
//var_dump($key.' '.$qualifiedforfinalprofit);
2017-10-06 15:48:48 +02:00
2015-06-22 11:55:21 +02:00
// Calculate margin
2020-12-17 14:01:42 +01:00
if ( $qualifiedforfinalprofit ) {
2020-06-23 16:05:00 +02:00
if ( $margin == 'add' ) {
$total_revenue_ht += $total_ht ;
}
2021-02-08 23:37:32 +01:00
if ( $margin != " add " ) { // Revert sign
2017-10-06 15:48:48 +02:00
$total_ht = - $total_ht ;
$total_ttc = - $total_ttc ;
}
2019-03-18 10:16:08 +01:00
$balance_ht += $total_ht ;
$balance_ttc += $total_ttc ;
2015-06-22 11:55:21 +02:00
}
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-06-22 11:55:21 +02:00
// Module
2019-01-21 10:04:43 +01:00
print '<td class="left">' . $name . '</td>' ;
2015-06-22 11:55:21 +02:00
// Nb
2019-02-23 22:24:26 +01:00
print '<td class="right">' . $i . '</td>' ;
2015-06-22 11:55:21 +02:00
// Amount HT
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $key == 'intervention' && ! $qualifiedforfinalprofit ) {
print '<span class="opacitymedium">' . $form -> textwithpicto ( $langs -> trans ( " NA " ), $langs -> trans ( " AmountOfInteventionNotIncludedByDefault " )) . '</span>' ;
} else {
2020-06-24 12:58:10 +02:00
print price ( $total_ht );
2021-02-26 18:49:22 +01:00
if ( $key == 'propal' ) {
print '<span class="opacitymedium">' . $form -> textwithpicto ( '' , $langs -> trans ( " SignedOnly " )) . '</span>' ;
}
2020-06-24 12:58:10 +02:00
}
2017-10-06 15:48:48 +02:00
print '</td>' ;
2015-06-22 11:55:21 +02:00
// Amount TTC
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $key == 'intervention' && ! $qualifiedforfinalprofit ) {
print '<span class="opacitymedium">' . $form -> textwithpicto ( $langs -> trans ( " NA " ), $langs -> trans ( " AmountOfInteventionNotIncludedByDefault " )) . '</span>' ;
} else {
2020-06-24 12:58:10 +02:00
print price ( $total_ttc );
2021-02-26 18:49:22 +01:00
if ( $key == 'propal' ) {
print '<span class="opacitymedium">' . $form -> textwithpicto ( '' , $langs -> trans ( " SignedOnly " )) . '</span>' ;
}
2020-06-24 12:58:10 +02:00
}
2017-10-06 15:48:48 +02:00
print '</td>' ;
2015-06-22 11:55:21 +02:00
print '</tr>' ;
}
}
}
// and the final balance
print '<tr class="liste_total">' ;
2020-06-23 16:05:00 +02:00
print '<td class="right" colspan="2">' . $langs -> trans ( " Profit " ) . '</td>' ;
print '<td class="right">' . price ( price2num ( $balance_ht , 'MT' )) . '</td>' ;
print '<td class="right">' . price ( price2num ( $balance_ttc , 'MT' )) . '</td>' ;
2015-06-22 11:55:21 +02:00
print '</tr>' ;
2020-06-23 16:05:00 +02:00
// and the margin (profit / revenues)
if ( $total_revenue_ht ) {
print '<tr class="liste_total">' ;
print '<td class="right" colspan="2">' . $langs -> trans ( " Margin " ) . '</td>' ;
2020-06-23 16:08:31 +02:00
print '<td class="right">' . round ( 100 * $balance_ht / $total_revenue_ht , 1 ) . '%</td>' ;
2020-06-23 16:05:00 +02:00
print '<td class="right"></td>' ;
print '</tr>' ;
}
2015-06-22 11:55:21 +02:00
print " </table> " ;
print '<br><br>' ;
print '<br>' ;
2020-03-06 14:52:29 +01:00
2015-06-22 11:55:21 +02:00
// Detail
2021-02-26 18:49:22 +01:00
foreach ( $listofreferent as $key => $value ) {
2020-12-16 16:25:30 +01:00
$parameters = array (
'key' => $key ,
'value' =>& $value ,
'dates' => $dates ,
'datee' => $datee
);
$reshook = $hookmanager -> executeHooks ( 'printOverviewDetail' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2020-12-17 14:01:42 +01:00
} elseif ( $reshook > 0 ) {
2020-12-16 16:25:30 +01:00
print $hookmanager -> resPrint ;
continue ;
}
2019-11-13 19:37:08 +01:00
$title = $value [ 'title' ];
$classname = $value [ 'class' ];
$tablename = $value [ 'table' ];
$datefieldname = $value [ 'datefieldname' ];
$qualified = $value [ 'test' ];
$langtoload = $value [ 'lang' ];
$urlnew = $value [ 'urlnew' ];
$buttonnew = $value [ 'buttonnew' ];
2020-10-31 14:32:18 +01:00
$testnew = $value [ 'testnew' ];
2019-11-13 19:37:08 +01:00
$project_field = $value [ 'project_field' ];
2016-08-10 11:34:10 +02:00
2018-08-27 10:17:18 +02:00
$exclude_select_element = array ( 'payment_various' );
2021-02-26 18:49:22 +01:00
if ( ! empty ( $value [ 'exclude_select_element' ])) {
$exclude_select_element [] = $value [ 'exclude_select_element' ];
}
2018-08-27 10:17:18 +02:00
2020-12-17 14:01:42 +01:00
if ( $qualified ) {
2015-06-03 21:01:50 +02:00
// If we want the project task array to have details of users
//if ($key == 'project_task') $key = 'project_task_time';
2016-08-10 11:34:10 +02:00
2021-02-26 18:49:22 +01:00
if ( $langtoload ) {
$langs -> load ( $langtoload );
}
2016-08-10 11:34:10 +02:00
2015-02-02 21:12:43 +01:00
$element = new $classname ( $db );
2020-03-06 11:21:34 +01:00
$addform = '' ;
2015-06-30 01:34:17 +02:00
2020-03-06 11:21:34 +01:00
$idtofilterthirdparty = 0 ;
2016-12-22 16:52:03 +01:00
$array_of_element_linkable_with_different_thirdparty = array ( 'facture_fourn' , 'commande_fournisseur' );
2021-02-26 18:49:22 +01:00
if ( ! in_array ( $tablename , $array_of_element_linkable_with_different_thirdparty )) {
2020-10-31 14:32:18 +01:00
$idtofilterthirdparty = $object -> thirdparty -> id ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS )) {
$idtofilterthirdparty .= ',' . $conf -> global -> PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS ;
}
2016-12-22 16:52:03 +01:00
}
2015-06-30 01:34:17 +02:00
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_LINK_ON_OVERWIEW_DISABLED ) && $idtofilterthirdparty && ! in_array ( $tablename , $exclude_select_element )) {
2020-07-06 10:59:23 +02:00
$selectList = $formproject -> select_element ( $tablename , $idtofilterthirdparty , 'minwidth300 minwidth75imp' , - 2 , ! empty ( $project_field ) ? $project_field : 'fk_projet' );
2021-02-26 18:49:22 +01:00
if ( $selectList < 0 ) {
2019-01-27 11:55:16 +01:00
setEventMessages ( $formproject -> error , $formproject -> errors , 'errors' );
2021-02-26 18:49:22 +01:00
} elseif ( $selectList ) {
2015-11-25 18:58:47 +01:00
// Define form with the combo list of elements to link
2020-10-31 14:32:18 +01:00
$addform .= '<div class="inline-block valignmiddle">' ;
$addform .= '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post">' ;
$addform .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$addform .= '<input type="hidden" name="tablename" value="' . $tablename . '">' ;
2020-03-06 11:25:02 +01:00
$addform .= '<input type="hidden" name="action" value="addelement">' ;
$addform .= '<input type="hidden" name="datesrfc" value="' . dol_print_date ( $dates , 'dayhourrfc' ) . '">' ;
$addform .= '<input type="hidden" name="dateerfc" value="' . dol_print_date ( $datee , 'dayhourrfc' ) . '">' ;
2020-07-06 10:59:23 +02:00
$addform .= '<table><tr><td><span class="hideonsmartphone opacitymedium">' . $langs -> trans ( " SelectElement " ) . '</span></td>' ;
2020-03-06 11:25:02 +01:00
$addform .= '<td>' . $selectList . '</td>' ;
2020-07-06 10:59:23 +02:00
$addform .= '<td><input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " LinkToElementShort " )) . '"></td>' ;
2020-03-06 11:25:02 +01:00
$addform .= '</tr></table>' ;
$addform .= '</form>' ;
$addform .= '</div>' ;
2015-11-25 18:58:47 +01:00
}
2013-04-29 11:54:29 +02:00
}
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_CREATE_ON_OVERVIEW_DISABLED ) && $urlnew ) {
2020-03-06 11:21:34 +01:00
$addform .= '<div class="inline-block valignmiddle">' ;
2021-02-26 18:49:22 +01:00
if ( $testnew ) {
$addform .= '<a class="buttonxxx" href="' . $urlnew . '"><span class="valignmiddle text-plus-circle hideonsmartphone">' . ( $buttonnew ? $langs -> trans ( $buttonnew ) : $langs -> trans ( " Create " )) . '</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>' ;
} elseif ( empty ( $conf -> global -> MAIN_BUTTON_HIDE_UNAUTHORIZED )) {
2020-07-06 10:59:23 +02:00
$addform .= '<a class="buttonxxx buttonRefused" disabled="disabled" href="#"><span class="valignmiddle text-plus-circle hideonsmartphone">' . ( $buttonnew ? $langs -> trans ( $buttonnew ) : $langs -> trans ( " Create " )) . '</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>' ;
2017-03-13 20:17:31 +01:00
}
2020-10-31 14:32:18 +01:00
$addform .= '<div>' ;
2016-04-04 15:20:21 +02:00
}
2016-08-10 11:34:10 +02:00
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( $title ), $addform , '' );
2015-06-22 11:55:21 +02:00
2016-09-23 10:32:19 +02:00
print " \n " . '<!-- Table for tablename = ' . $tablename . ' -->' . " \n " ;
2020-07-06 10:59:23 +02:00
print '<div class="div-table-responsive">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2014-08-21 23:43:11 +02:00
2008-04-19 19:26:41 +02:00
print '<tr class="liste_titre">' ;
2017-09-21 11:54:37 +02:00
// Remove link column
2015-02-21 15:18:05 +01:00
print '<td style="width: 24px"></td>' ;
2020-03-06 14:52:29 +01:00
// Ref
print '<td' . (( $tablename != 'actioncomm' && $tablename != 'projet_task' ) ? ' style="width: 200px"' : '' ) . '>' . $langs -> trans ( " Ref " ) . '</td>' ;
// Date
print '<td' . (( $tablename != 'actioncomm' && $tablename != 'projet_task' ) ? ' style="width: 200px"' : '' ) . ' class="center">' ;
2021-02-26 18:49:22 +01:00
if ( in_array ( $tablename , array ( 'projet_task' ))) {
print $langs -> trans ( " TimeSpent " );
}
if ( ! in_array ( $tablename , array ( 'projet_task' ))) {
print $langs -> trans ( " Date " );
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
// Thirdparty or user
print '<td>' ;
2021-02-26 18:49:22 +01:00
if ( in_array ( $tablename , array ( 'projet_task' )) && $key == 'project_task' ) {
print '' ; // if $key == 'project_task', we don't want details per user
} elseif ( in_array ( $tablename , array ( 'payment_various' ))) {
print '' ; // if $key == 'payment_various', we don't have any thirdparty
} elseif ( in_array ( $tablename , array ( 'expensereport_det' , 'don' , 'projet_task' , 'stock_mouvement' , 'payment_salary' ))) {
print $langs -> trans ( " User " );
} else {
print $langs -> trans ( " ThirdParty " );
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
2020-10-31 14:32:18 +01:00
// Duration of intervention
2021-02-26 18:49:22 +01:00
if ( $tablename == 'fichinter' ) {
2020-03-06 14:52:29 +01:00
print '<td>' ;
print $langs -> trans ( " TotalDuration " );
$total_duration = 0 ;
print '</td>' ;
}
// Amount HT
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("AmountHT").'</td>';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("Amount").'</td>';
2021-02-26 18:49:22 +01:00
if ( $key == 'loan' ) {
print '<td class="right" width="120">' . $langs -> trans ( " LoanCapital " ) . '</td>' ;
} elseif ( empty ( $value [ 'disableamount' ])) {
print '<td class="right" width="120">' . $langs -> trans ( " AmountHT " ) . '</td>' ;
} else {
print '<td width="120"></td>' ;
}
2020-03-06 14:52:29 +01:00
// Amount TTC
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="120">'.$langs->trans("AmountTTC").'</td>';
2021-02-26 18:49:22 +01:00
if ( $key == 'loan' ) {
print '<td class="right" width="120">' . $langs -> trans ( " RemainderToPay " ) . '</td>' ;
} elseif ( empty ( $value [ 'disableamount' ])) {
print '<td class="right" width="120">' . $langs -> trans ( " AmountTTC " ) . '</td>' ;
} else {
print '<td width="120"></td>' ;
}
2020-03-06 14:52:29 +01:00
// Status
2021-02-26 18:49:22 +01:00
if ( in_array ( $tablename , array ( 'projet_task' ))) {
print '<td class="right" width="200">' . $langs -> trans ( " ProgressDeclared " ) . '</td>' ;
} else {
print '<td class="right" width="200">' . $langs -> trans ( " Status " ) . '</td>' ;
}
2008-04-19 19:34:24 +02:00
print '</tr>' ;
2015-06-03 21:01:50 +02:00
2019-11-13 19:37:08 +01:00
$elementarray = $object -> get_element_list ( $key , $tablename , $datefieldname , $dates , $datee , ! empty ( $project_field ) ? $project_field : 'fk_projet' );
2021-02-26 18:49:22 +01:00
if ( is_array ( $elementarray ) && count ( $elementarray ) > 0 ) {
2011-04-15 01:24:34 +02:00
$total_ht = 0 ;
$total_ttc = 0 ;
2015-01-22 21:31:00 +01:00
$total_ht_by_third = 0 ;
$total_ttc_by_third = 0 ;
2015-02-02 21:12:43 +01:00
$saved_third_id = 0 ;
$breakline = '' ;
2021-02-26 18:49:22 +01:00
if ( canApplySubtotalOn ( $tablename )) {
2019-10-20 11:59:21 +02:00
// Sort
$elementarray = sortElementsByClientName ( $elementarray );
2015-01-22 21:31:00 +01:00
}
2019-11-13 19:37:08 +01:00
$num = count ( $elementarray );
2021-02-26 18:49:22 +01:00
for ( $i = 0 ; $i < $num ; $i ++ ) {
2019-11-13 19:37:08 +01:00
$tmp = explode ( '_' , $elementarray [ $i ]);
$idofelement = $tmp [ 0 ];
$idofelementuser = $tmp [ 1 ];
2020-03-06 11:45:35 +01:00
2015-06-03 21:01:50 +02:00
$element -> fetch ( $idofelement );
2021-02-26 18:49:22 +01:00
if ( $idofelementuser ) {
$elementuser -> fetch ( $idofelementuser );
}
2015-02-21 15:18:05 +01:00
2016-11-08 11:23:40 +01:00
// Special cases
2021-02-26 18:49:22 +01:00
if ( $tablename != 'expensereport_det' ) {
if ( method_exists ( $element , 'fetch_thirdparty' )) {
$element -> fetch_thirdparty ();
}
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:37:08 +01:00
$expensereport = new ExpenseReport ( $db );
2015-02-21 15:18:05 +01:00
$expensereport -> fetch ( $element -> fk_expensereport );
}
2020-03-06 11:45:35 +01:00
2019-03-18 10:16:08 +01:00
//print 'xxx'.$tablename.'yyy'.$classname;
2020-03-06 11:45:35 +01:00
2021-02-26 18:49:22 +01:00
if ( $breakline && $saved_third_id != $element -> thirdparty -> id ) {
2015-02-02 21:12:43 +01:00
print $breakline ;
2020-03-06 11:45:35 +01:00
2015-02-02 21:12:43 +01:00
$saved_third_id = $element -> thirdparty -> id ;
$breakline = '' ;
2020-03-06 11:45:35 +01:00
2019-11-13 19:37:08 +01:00
$total_ht_by_third = 0 ;
$total_ttc_by_third = 0 ;
2015-02-02 21:12:43 +01:00
}
2015-02-02 21:33:09 +01:00
$saved_third_id = $element -> thirdparty -> id ;
2020-03-06 11:45:35 +01:00
2019-11-13 19:37:08 +01:00
$qualifiedfortotal = true ;
2021-02-26 18:49:22 +01:00
if ( $key == 'invoice' ) {
if ( ! empty ( $element -> close_code ) && $element -> close_code == 'replaced' ) {
$qualifiedfortotal = false ; // Replacement invoice, do not include into total
}
2014-06-24 15:37:10 +02:00
}
2020-03-06 11:45:35 +01:00
2020-03-06 14:52:29 +01:00
print '<tr class="oddeven">' ;
// Remove link
print '<td style="width: 24px">' ;
2021-02-26 18:49:22 +01:00
if ( $tablename != 'projet_task' && $tablename != 'stock_mouvement' ) {
if ( empty ( $conf -> global -> PROJECT_DISABLE_UNLINK_FROM_OVERVIEW ) || $user -> admin ) { // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true
2020-03-06 14:52:29 +01:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element -> id . ( $project_field ? '&projectfield=' . $project_field : '' ) . '" class="reposition">' ;
print img_picto ( $langs -> trans ( 'Unlink' ), 'unlink' );
print '</a>' ;
}
}
print " </td> \n " ;
2014-08-21 23:43:11 +02:00
2010-01-05 00:33:23 +01:00
// Ref
2020-07-06 10:59:23 +02:00
print '<td class="left nowraponall">' ;
2021-02-26 18:49:22 +01:00
if ( $tablename == 'expensereport_det' ) {
2020-03-06 14:52:29 +01:00
print $expensereport -> getNomUrl ( 1 );
2020-05-21 15:05:19 +02:00
} else {
2018-08-01 07:46:17 +02:00
// Show ref with link
2021-02-26 18:49:22 +01:00
if ( $element instanceof Task ) {
2020-03-06 14:52:29 +01:00
print $element -> getNomUrl ( 1 , 'withproject' , 'time' );
print ' - ' . dol_trunc ( $element -> label , 48 );
2020-05-21 15:05:19 +02:00
} elseif ( $key == 'loan' ) {
2020-10-31 14:32:18 +01:00
print $element -> getNomUrl ( 1 );
print ' - ' . dol_trunc ( $element -> label , 48 );
2021-02-26 18:49:22 +01:00
} else {
print $element -> getNomUrl ( 1 );
}
2016-11-16 09:38:13 +01:00
2015-02-24 18:20:19 +01:00
$element_doc = $element -> element ;
2019-11-13 19:37:08 +01:00
$filename = dol_sanitizeFileName ( $element -> ref );
$filedir = $conf -> { $element_doc } -> multidir_output [ $element -> entity ] . '/' . dol_sanitizeFileName ( $element -> ref );
2015-03-02 02:14:18 +01:00
2016-11-08 11:23:40 +01:00
if ( $element_doc === 'order_supplier' ) {
2019-11-13 19:37:08 +01:00
$element_doc = 'commande_fournisseur' ;
2018-10-29 12:30:36 +01:00
$filedir = $conf -> fournisseur -> commande -> multidir_output [ $element -> entity ] . '/' . dol_sanitizeFileName ( $element -> ref );
2020-05-21 15:05:19 +02:00
} elseif ( $element_doc === 'invoice_supplier' ) {
2019-11-13 19:37:08 +01:00
$element_doc = 'facture_fournisseur' ;
2019-01-27 11:55:16 +01:00
$filename = get_exdir ( $element -> id , 2 , 0 , 0 , $element , 'product' ) . dol_sanitizeFileName ( $element -> ref );
$filedir = $conf -> fournisseur -> facture -> multidir_output [ $element -> entity ] . '/' . get_exdir ( $element -> id , 2 , 0 , 0 , $element , 'invoice_supplier' ) . dol_sanitizeFileName ( $element -> ref );
2015-02-24 18:20:19 +01:00
}
2015-03-02 02:14:18 +01:00
2020-03-06 14:52:29 +01:00
print '<div class="inline-block valignmiddle">' . $formfile -> getDocumentsLink ( $element_doc , $filename , $filedir ) . '</div>' ;
2016-11-16 09:38:13 +01:00
2016-11-08 11:23:40 +01:00
// Show supplier ref
2021-02-26 18:49:22 +01:00
if ( ! empty ( $element -> ref_supplier )) {
print ' - ' . $element -> ref_supplier ;
}
2016-11-08 11:23:40 +01:00
// Show customer ref
2021-02-26 18:49:22 +01:00
if ( ! empty ( $element -> ref_customer )) {
print ' - ' . $element -> ref_customer ;
}
2015-03-02 02:14:18 +01:00
}
2020-03-06 14:52:29 +01:00
print " </td> \n " ;
2010-01-05 00:33:23 +01:00
2017-01-02 12:17:27 +01:00
// Date or TimeSpent
2019-11-13 19:37:08 +01:00
$date = '' ; $total_time_by_line = null ;
2021-02-26 18:49:22 +01:00
if ( $tablename == 'expensereport_det' ) {
$date = $element -> date ; // No draft status on lines
} elseif ( $tablename == 'stock_mouvement' ) {
$date = $element -> datem ;
} elseif ( $tablename == 'payment_salary' ) {
$date = $element -> datev ;
} elseif ( $tablename == 'payment_various' ) {
$date = $element -> datev ;
} elseif ( $tablename == 'chargesociales' ) {
$date = $element -> date_ech ;
} elseif ( ! empty ( $element -> status ) || ! empty ( $element -> statut ) || ! empty ( $element -> fk_status )) {
if ( $tablename == 'don' ) {
$date = $element -> datedon ;
}
if ( $tablename == 'commande_fournisseur' || $tablename == 'supplier_order' ) {
2020-10-31 14:32:18 +01:00
$date = ( $element -> date_commande ? $element -> date_commande : $element -> date_valid );
2021-02-26 18:49:22 +01:00
} elseif ( $tablename == 'supplier_proposal' ) {
$date = $element -> date_validation ; // There is no other date for this
} elseif ( $tablename == 'fichinter' ) {
$date = $element -> datev ; // There is no other date for this
} elseif ( $tablename == 'projet_task' ) {
$date = '' ; // We show no date. Showing date of beginning of task make user think it is date of time consumed
} else {
2020-10-31 14:32:18 +01:00
$date = $element -> date ; // invoice, ...
2021-02-26 18:49:22 +01:00
if ( empty ( $date )) {
$date = $element -> date_contrat ;
}
if ( empty ( $date )) {
$date = $element -> datev ;
}
2020-10-31 14:32:18 +01:00
if ( empty ( $date ) && ! empty ( $datefieldname )) {
$date = $element -> $datefieldname ;
}
}
2020-05-21 15:05:19 +02:00
} elseif ( $key == 'loan' ) {
2020-10-31 14:32:18 +01:00
$date = $element -> datestart ;
2016-09-22 18:47:31 +02:00
}
2020-02-02 06:36:06 +01:00
2020-03-06 14:52:29 +01:00
print '<td class="center">' ;
2021-02-26 18:49:22 +01:00
if ( $tablename == 'actioncomm' ) {
2020-10-31 14:32:18 +01:00
print dol_print_date ( $element -> datep , 'dayhour' );
2021-02-26 18:49:22 +01:00
if ( $element -> datef && $element -> datef > $element -> datep ) {
print " - " . dol_print_date ( $element -> datef , 'dayhour' );
}
} elseif ( in_array ( $tablename , array ( 'projet_task' ))) {
2020-10-31 14:32:18 +01:00
$tmpprojtime = $element -> getSumOfAmount ( $elementuser , $dates , $datee ); // $element is a task. $elementuser may be empty
print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $idofelement . '&withproject=1">' ;
print convertSecondToTime ( $tmpprojtime [ 'nbseconds' ], 'allhourmin' );
print '</a>' ;
$total_time_by_line = $tmpprojtime [ 'nbseconds' ];
2021-02-26 18:49:22 +01:00
} else {
print dol_print_date ( $date , 'day' );
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
2010-01-05 00:33:23 +01:00
2015-02-21 15:18:05 +01:00
// Third party or user
2020-10-31 14:32:18 +01:00
print '<td class="left">' ;
if ( is_object ( $element -> thirdparty )) {
print $element -> thirdparty -> getNomUrl ( 1 , '' , 48 );
} elseif ( $tablename == 'expensereport_det' ) {
$tmpuser = new User ( $db );
$tmpuser -> fetch ( $expensereport -> fk_user_author );
print $tmpuser -> getNomUrl ( 1 , '' , 48 );
2021-02-26 18:49:22 +01:00
} elseif ( $tablename == 'payment_salary' ) {
2019-11-13 19:37:08 +01:00
$tmpuser = new User ( $db );
2018-08-01 07:46:17 +02:00
$tmpuser -> fetch ( $element -> fk_user );
2020-03-06 14:52:29 +01:00
print $tmpuser -> getNomUrl ( 1 , '' , 48 );
2021-02-26 18:49:22 +01:00
} elseif ( $tablename == 'don' || $tablename == 'stock_mouvement' ) {
if ( $element -> fk_user_author > 0 ) {
2020-10-31 14:32:18 +01:00
$tmpuser2 = new User ( $db );
$tmpuser2 -> fetch ( $element -> fk_user_author );
print $tmpuser2 -> getNomUrl ( 1 , '' , 48 );
}
2021-02-26 18:49:22 +01:00
} elseif ( $tablename == 'projet_task' && $key == 'project_task_time' ) { // if $key == 'project_task', we don't want details per user
2020-10-31 14:32:18 +01:00
print $elementuser -> getNomUrl ( 1 );
2018-07-31 07:45:03 +02:00
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
// Add duration and store it in counter for fichinter
2021-02-26 18:49:22 +01:00
if ( $tablename == 'fichinter' ) {
2020-03-06 14:52:29 +01:00
print '<td>' ;
print convertSecondToTime ( $element -> duration , 'all' , $conf -> global -> MAIN_DURATION_OF_WORKDAY );
$total_duration += $element -> duration ;
print '</td>' ;
2020-01-28 19:33:01 +01:00
}
2020-01-28 19:28:09 +01:00
2020-10-31 14:32:18 +01:00
// Amount without tax
2019-11-13 19:37:08 +01:00
$warning = '' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $value [ 'disableamount' ])) {
2020-10-31 14:32:18 +01:00
$total_ht_by_line = null ;
$othermessage = '' ;
2021-02-26 18:49:22 +01:00
if ( $tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary' ) {
$total_ht_by_line = $element -> amount ;
} elseif ( $tablename == 'fichinter' ) {
$total_ht_by_line = $element -> getAmount ();
} elseif ( $tablename == 'stock_mouvement' ) {
$total_ht_by_line = $element -> price * abs ( $element -> qty );
} elseif ( in_array ( $tablename , array ( 'projet_task' ))) {
if ( ! empty ( $conf -> salaries -> enabled )) {
2020-10-31 14:32:18 +01:00
// TODO Permission to read daily rate to show value
$total_ht_by_line = price2num ( $tmpprojtime [ 'amount' ], 'MT' );
2021-02-26 18:49:22 +01:00
if ( $tmpprojtime [ 'nblinesnull' ] > 0 ) {
2020-10-31 14:32:18 +01:00
$langs -> load ( " errors " );
$warning = $langs -> trans ( " WarningSomeLinesWithNullHourlyRate " , $conf -> currency );
}
} else {
$othermessage = $form -> textwithpicto ( $langs -> trans ( " NotAvailable " ), $langs -> trans ( " ModuleSalaryToDefineHourlyRateMustBeEnabled " ));
}
2021-02-26 18:49:22 +01:00
} elseif ( $key == 'loan' ) {
$total_ht_by_line = $element -> capital ;
} else {
2019-11-13 19:37:08 +01:00
$total_ht_by_line = $element -> total_ht ;
2015-04-02 06:36:32 +02:00
}
2019-03-18 10:16:08 +01:00
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
2021-02-26 18:49:22 +01:00
if ( $tablename == 'payment_various' ) {
if ( $element -> sens == 0 ) {
2020-10-31 14:32:18 +01:00
$total_ht_by_line = - $total_ht_by_line ;
}
2019-03-18 10:16:08 +01:00
}
2020-03-06 14:52:29 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $othermessage ) {
print $othermessage ;
}
if ( isset ( $total_ht_by_line )) {
if ( ! $qualifiedfortotal ) {
print '<strike>' ;
}
2020-03-06 14:52:29 +01:00
print price ( $total_ht_by_line );
2021-02-26 18:49:22 +01:00
if ( ! $qualifiedfortotal ) {
print '</strike>' ;
}
}
if ( $warning ) {
print ' ' . img_warning ( $warning );
2016-12-03 15:54:06 +01:00
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
} else {
print '<td></td>' ;
}
2010-01-05 00:33:23 +01:00
2020-10-31 14:32:18 +01:00
// Amount inc tax
2021-02-26 18:49:22 +01:00
if ( empty ( $value [ 'disableamount' ])) {
2020-10-31 14:32:18 +01:00
$total_ttc_by_line = null ;
2021-02-26 18:49:22 +01:00
if ( $tablename == 'don' || $tablename == 'chargesociales' || $tablename == 'payment_various' || $tablename == 'payment_salary' ) {
$total_ttc_by_line = $element -> amount ;
} elseif ( $tablename == 'fichinter' ) {
$total_ttc_by_line = $element -> getAmount ();
} elseif ( $tablename == 'stock_mouvement' ) {
$total_ttc_by_line = $element -> price * abs ( $element -> qty );
} elseif ( $tablename == 'projet_task' ) {
if ( ! empty ( $conf -> salaries -> enabled )) {
2020-10-31 14:32:18 +01:00
// TODO Permission to read daily rate
$defaultvat = get_default_tva ( $mysoc , $mysoc );
$total_ttc_by_line = price2num ( $total_ht_by_line * ( 1 + ( $defaultvat / 100 )), 'MT' );
} else {
$othermessage = $form -> textwithpicto ( $langs -> trans ( " NotAvailable " ), $langs -> trans ( " ModuleSalaryToDefineHourlyRateMustBeEnabled " ));
}
2021-02-26 18:49:22 +01:00
} elseif ( $key == 'loan' ) {
$total_ttc_by_line = $element -> capital - $element -> getSumPayment ();
} else {
2019-11-13 19:37:08 +01:00
$total_ttc_by_line = $element -> total_ttc ;
2015-04-02 06:36:32 +02:00
}
2019-03-18 10:16:08 +01:00
// Change sign of $total_ht_by_line and $total_ttc_by_line for some cases
2021-02-26 18:49:22 +01:00
if ( $tablename == 'payment_various' ) {
if ( $element -> sens == 0 ) {
2020-10-31 14:32:18 +01:00
$total_ttc_by_line = - $total_ttc_by_line ;
}
2019-03-18 10:16:08 +01:00
}
2020-03-06 14:52:29 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $othermessage ) {
print $othermessage ;
}
if ( isset ( $total_ttc_by_line )) {
if ( ! $qualifiedfortotal ) {
print '<strike>' ;
}
2020-03-06 14:52:29 +01:00
print price ( $total_ttc_by_line );
2021-02-26 18:49:22 +01:00
if ( ! $qualifiedfortotal ) {
print '</strike>' ;
}
}
if ( $warning ) {
print ' ' . img_warning ( $warning );
2016-12-03 15:54:06 +01:00
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
} else {
print '<td></td>' ;
}
2012-02-04 18:34:52 +01:00
2010-01-05 00:33:23 +01:00
// Status
2020-03-06 14:52:29 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $tablename == 'expensereport_det' ) {
2020-03-06 14:52:29 +01:00
print $expensereport -> getLibStatut ( 5 );
2021-02-26 18:49:22 +01:00
} elseif ( $element instanceof CommonInvoice ) {
2015-04-12 20:59:58 +02:00
//This applies for Facture and FactureFournisseur
2020-03-06 14:52:29 +01:00
print $element -> getLibStatut ( 5 , $element -> getSommePaiement ());
2021-02-26 18:49:22 +01:00
} elseif ( $element instanceof Task ) {
if ( $element -> progress != '' ) {
2020-03-06 14:52:29 +01:00
print $element -> progress . ' %' ;
2015-06-03 21:01:50 +02:00
}
2021-02-26 18:49:22 +01:00
} elseif ( $tablename == 'stock_mouvement' ) {
2020-03-06 14:52:29 +01:00
print $element -> getLibStatut ( 3 );
2020-05-21 15:05:19 +02:00
} else {
2020-03-06 14:52:29 +01:00
print $element -> getLibStatut ( 5 );
2015-04-12 20:59:58 +02:00
}
2020-03-06 14:52:29 +01:00
print '</td>' ;
print '</tr>' ;
2008-04-19 19:26:41 +02:00
2021-02-26 18:49:22 +01:00
if ( $qualifiedfortotal ) {
2015-04-02 06:36:32 +02:00
$total_ht = $total_ht + $total_ht_by_line ;
$total_ttc = $total_ttc + $total_ttc_by_line ;
2015-01-22 21:31:00 +01:00
2015-04-02 06:36:32 +02:00
$total_ht_by_third += $total_ht_by_line ;
$total_ttc_by_third += $total_ttc_by_line ;
2017-07-29 00:28:41 +02:00
$total_time = $total_time + $total_time_by_line ;
2015-01-22 21:31:00 +01:00
}
2021-02-26 18:49:22 +01:00
if ( canApplySubtotalOn ( $tablename )) {
2020-03-06 14:52:29 +01:00
$breakline = '<tr class="liste_total liste_sub_total">' ;
$breakline .= '<td colspan="2">' ;
$breakline .= '</td>' ;
$breakline .= '<td>' ;
$breakline .= '</td>' ;
$breakline .= '<td class="right">' ;
$breakline .= $langs -> trans ( 'SubTotal' ) . ' : ' ;
2021-02-26 18:49:22 +01:00
if ( is_object ( $element -> thirdparty )) {
$breakline .= $element -> thirdparty -> getNomUrl ( 0 , '' , 48 );
}
2020-03-06 14:52:29 +01:00
$breakline .= '</td>' ;
$breakline .= '<td class="right">' . price ( $total_ht_by_third ) . '</td>' ;
$breakline .= '<td class="right">' . price ( $total_ttc_by_third ) . '</td>' ;
$breakline .= '<td></td>' ;
$breakline .= '</tr>' ;
2014-06-24 15:37:10 +02:00
}
2015-02-02 21:33:09 +01:00
2020-03-06 14:52:29 +01:00
//var_dump($element->thirdparty->name.' - '.$saved_third_id.' - '.$element->thirdparty->id);
2020-03-05 14:16:56 +01:00
}
2021-02-26 18:49:22 +01:00
if ( $breakline ) {
print $breakline ;
}
2015-02-02 21:12:43 +01:00
2016-12-03 15:54:06 +01:00
// Total
2019-11-13 19:37:08 +01:00
$colspan = 4 ;
2021-02-26 18:49:22 +01:00
if ( in_array ( $tablename , array ( 'projet_task' ))) {
$colspan = 2 ;
}
2017-01-02 12:27:34 +01:00
print '<tr class="liste_total"><td colspan="' . $colspan . '">' . $langs -> trans ( " Number " ) . ': ' . $i . '</td>' ;
2021-02-26 18:49:22 +01:00
if ( in_array ( $tablename , array ( 'projet_task' ))) {
2020-10-31 14:32:18 +01:00
print '<td class="center">' ;
print convertSecondToTime ( $total_time , 'allhourmin' );
print '</td>' ;
print '<td>' ;
print '</td>' ;
2017-01-02 12:27:34 +01:00
}
2019-02-23 22:24:26 +01:00
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("Total").' : '.price($total_ht).'</td>';
2020-10-31 14:32:18 +01:00
// If fichinter add the total_duration
2021-02-26 18:49:22 +01:00
if ( $tablename == 'fichinter' ) {
print '<td class="left">' . convertSecondToTime ( $total_duration , 'all' , $conf -> global -> MAIN_DURATION_OF_WORKDAY ) . '</td>' ;
}
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $value [ 'disableamount' ])) {
if ( $key == 'loan' ) {
print $langs -> trans ( " Total " ) . ' ' . $langs -> trans ( " LoanCapital " ) . ' : ' . price ( $total_ttc );
} elseif ( $tablename != 'projet_task' || ! empty ( $conf -> salaries -> enabled )) {
print '' . $langs -> trans ( " TotalHT " ) . ' : ' . price ( $total_ht );
}
2016-12-03 15:54:06 +01:00
}
print '</td>' ;
2019-02-23 22:24:26 +01:00
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td class="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>';
//elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print '<td class="right" width="100"></td>';
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $value [ 'disableamount' ])) {
if ( $key == 'loan' ) {
print $langs -> trans ( " Total " ) . ' ' . $langs -> trans ( " RemainderToPay " ) . ' : ' . price ( $total_ttc );
} elseif ( $tablename != 'projet_task' || ! empty ( $conf -> salaries -> enabled )) {
print $langs -> trans ( " TotalTTC " ) . ' : ' . price ( $total_ttc );
}
2016-12-03 15:54:06 +01:00
}
print '</td>' ;
2009-08-12 14:59:14 +02:00
print '<td> </td>' ;
print '</tr>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 18:49:22 +01:00
if ( ! is_array ( $elementarray )) { // error
2018-03-13 15:29:52 +01:00
print $elementarray ;
}
2014-10-29 20:21:24 +01:00
}
2009-08-12 14:59:14 +02:00
print " </table> " ;
2020-07-06 10:59:23 +02:00
print '</div>' ;
2015-06-30 01:34:17 +02:00
print " <br> \n " ;
2008-04-19 19:26:41 +02:00
}
}
2015-06-29 16:57:32 +02:00
// Enhance with select2
2021-02-26 18:49:22 +01:00
if ( $conf -> use_javascript_ajax ) {
2019-11-13 19:37:08 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php' ;
2015-06-29 16:57:32 +02:00
$comboenhancement = ajax_combobox ( '.elementselect' );
print $comboenhancement ;
}
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-04 18:34:52 +01:00
$db -> close ();
2015-01-22 21:31:00 +01:00
/**
* Return if we should do a group by customer with sub - total
*
* @ param string $tablename Name of table
* @ return boolean True to tell to make a group by sub - total
*/
function canApplySubtotalOn ( $tablename )
{
global $conf ;
2021-02-26 18:49:22 +01:00
if ( empty ( $conf -> global -> PROJECT_ADD_SUBTOTAL_LINES )) {
return false ;
}
2015-01-22 21:31:00 +01:00
return in_array ( $tablename , array ( 'facture_fourn' , 'commande_fournisseur' ));
}
/**
2015-01-23 02:11:10 +01:00
* sortElementsByClientName
2015-01-22 21:31:00 +01:00
*
2015-01-23 02:11:10 +01:00
* @ param array $elementarray Element array
* @ return array Element array sorted
2015-01-22 21:31:00 +01:00
*/
2015-01-23 02:11:10 +01:00
function sortElementsByClientName ( $elementarray )
{
global $db , $classname ;
2015-01-22 21:31:00 +01:00
2015-01-23 02:11:10 +01:00
$element = new $classname ( $db );
2015-01-22 21:31:00 +01:00
2015-01-23 02:11:10 +01:00
$clientname = array ();
2021-02-26 18:49:22 +01:00
foreach ( $elementarray as $key => $id ) { // id = id of object
if ( empty ( $clientname [ $id ])) {
2015-02-02 21:12:43 +01:00
$element -> fetch ( $id );
2015-01-23 02:11:10 +01:00
$element -> fetch_thirdparty ();
2015-02-02 21:12:43 +01:00
2015-01-23 02:11:10 +01:00
$clientname [ $id ] = $element -> thirdparty -> name ;
}
}
2015-01-22 21:31:00 +01:00
2015-02-02 21:12:43 +01:00
//var_dump($clientname);
2019-11-13 19:37:08 +01:00
asort ( $clientname ); // sort on name
2015-01-23 02:11:10 +01:00
$elementarray = array ();
2021-02-26 18:49:22 +01:00
foreach ( $clientname as $id => $name ) {
2015-01-23 02:11:10 +01:00
$elementarray [] = $id ;
}
2015-01-22 21:31:00 +01:00
2015-01-23 02:11:10 +01:00
return $elementarray ;
2015-01-22 21:31:00 +01:00
}