2008-05-07 03:10:27 +02:00
< ? php
2014-07-19 22:37:18 +02:00
/* Copyright ( C ) 2008 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ inodbox . com >
2011-03-08 20:39:21 +01:00
* Copyright ( C ) 2011 Juanjo Menent < jmenent @ 2 byte . es >
2025-01-25 09:04:43 +01:00
* Copyright ( C ) 2022 - 2025 Frédéric France < frederic . france @ free . fr >
2025-02-10 21:20:09 +01:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2008-05-07 03:10:27 +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-05-07 03:10:27 +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 />.
* or see https :// www . gnu . org /
2008-05-07 03:10:27 +02:00
*/
/**
2022-09-15 20:23:37 +02:00
* \file htdocs / core / lib / agenda . lib . php
* \brief Set of function for the agenda module
2009-03-28 20:11:38 +01:00
*/
2008-05-07 03:10:27 +02:00
2010-01-19 10:44:52 +01:00
/**
* Show filter form in agenda view
2012-01-20 20:21:23 +01:00
*
2024-02-09 15:58:49 +01:00
* @ param Form $form Form object
* @ param int $canedit Can edit filter fields
2025-01-25 09:04:43 +01:00
* @ param string $status Status see FormActions :: form_select_status_action
2024-02-09 15:58:49 +01:00
* @ param int $year Year
* @ param int $month Month
* @ param int $day Day
* @ param int $showbirthday Show birthday
* @ param string $filtera Filter on create by user
* @ param string $filtert Filter on assigned to user
* @ param string $filtered Filter of done by user
* @ param int $pid Product id
* @ param int $socid Third party id
* @ param string $action Action string
2024-11-04 12:32:13 +01:00
* @ param array < array { type : string , sr : string , name : string , offsettz : int , color : string , default : string , buggedfile : string } >| int <- 1 , - 1 > $showextcals Array with list of external calendars ( used to show links to select calendar ), or - 1 to show no legend
* @ param string | string [] $actioncode Preselected value ( s ) of actioncode for filter on event type
2024-02-09 15:58:49 +01:00
* @ param int $usergroupid Id of group to filter on users
* @ param string $excludetype A type to exclude ( 'systemauto' , 'system' , '' )
* @ param int $resourceid Preselected value of resource for filter on resource
2024-02-29 15:26:53 +01:00
* @ param int $search_categ_cus Tag id
2012-01-22 20:16:11 +01:00
* @ return void
2010-01-19 10:44:52 +01:00
*/
2024-01-12 17:15:39 +01:00
function print_actions_filter (
$form ,
$canedit ,
$status ,
$year ,
$month ,
$day ,
$showbirthday ,
$filtera ,
$filtert ,
2024-01-13 19:48:20 +01:00
$filtered ,
2024-01-12 17:15:39 +01:00
$pid ,
$socid ,
$action ,
$showextcals = array (),
$actioncode = '' ,
$usergroupid = 0 ,
$excludetype = '' ,
2024-02-09 15:58:49 +01:00
$resourceid = 0 ,
$search_categ_cus = 0
2024-01-12 17:15:39 +01:00
) {
2024-01-04 15:00:56 +01:00
global $user , $langs , $db , $hookmanager ;
2020-07-11 12:21:53 +02:00
global $massaction ;
2014-01-26 18:30:45 +01:00
2015-01-31 19:00:00 +01:00
$langs -> load ( " companies " );
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
2017-09-19 01:39:22 +02:00
2010-01-19 10:44:52 +01:00
// Filters
2017-11-25 00:12:45 +01:00
//print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
2020-04-10 10:59:32 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2021-07-26 00:37:47 +02:00
print '<input type="hidden" name="year" value="' . (( int ) $year ) . '">' ;
print '<input type="hidden" name="month" value="' . (( int ) $month ) . '">' ;
print '<input type="hidden" name="day" value="' . (( int ) $day ) . '">' ;
2020-12-24 14:35:40 +01:00
if ( $massaction != 'predelete' && $massaction != 'preaffecttag' ) { // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
2020-07-11 12:21:53 +02:00
print '<input type="hidden" name="action" value="' . $action . '">' ;
}
2021-07-26 00:37:47 +02:00
print '<input type="hidden" name="search_showbirthday" value="' . (( int ) $showbirthday ) . '">' ;
2014-01-26 18:30:45 +01:00
2023-07-16 12:14:18 +02:00
print '<div class="divsearchfield">' ;
// Type
$multiselect = 0 ;
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAIN_ENABLE_MULTISELECT_TYPE' )) { // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
$multiselect = ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' ));
2023-07-16 12:14:18 +02:00
}
2023-07-19 01:50:18 +02:00
print img_picto ( $langs -> trans ( " ActionType " ), 'square' , 'class="pictofixedwidth inline-block" style="color: #ddd;"' );
2024-10-17 22:20:39 +02:00
print $formactions -> select_type_actions ( $actioncode , " search_actioncode " , $excludetype , ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' ) ? - 1 : 1 ), 0 , $multiselect , 0 , 'minwidth150 maxwidth200 widthcentpercentminusx' , 1 );
2023-07-16 12:14:18 +02:00
print '</div>' ;
2020-04-13 03:14:01 +02:00
2023-07-16 12:14:18 +02:00
if ( $canedit ) {
2021-06-23 10:22:51 +02:00
// Assigned to user
2020-07-09 11:55:16 +02:00
print '<div class="divsearchfield">' ;
2022-05-22 16:16:17 +02:00
print img_picto ( $langs -> trans ( " ActionsToDoBy " ), 'user' , 'class="pictofixedwidth inline-block"' );
2024-06-21 19:58:38 +02:00
print $form -> select_dolusers ( $filtert , 'search_filtert' , 1 , '' , ! $canedit , '' , '' , 0 , 0 , 0 , '' , 0 , '' , 'minwidth100 maxwidth250 widthcentpercentminusx' );
2020-07-09 11:55:16 +02:00
print '</div>' ;
2021-06-26 16:10:56 +02:00
2021-06-23 10:22:51 +02:00
// Assigned to user group
2020-07-09 11:55:16 +02:00
print '<div class="divsearchfield">' ;
2022-05-22 16:16:17 +02:00
print img_picto ( $langs -> trans ( " ToUserOfGroup " ), 'object_group' , 'class="pictofixedwidth inline-block"' );
2024-11-04 12:32:13 +01:00
print $form -> select_dolgroups ( $usergroupid , 'usergroup' , 1 , '' , ! $canedit , '' , array (), '0' , false , 'minwidth100 maxwidth250 widthcentpercentminusx' );
2020-07-09 11:55:16 +02:00
print '</div>' ;
2014-01-26 18:30:45 +01:00
2022-06-09 22:10:51 +02:00
if ( isModEnabled ( 'resource' )) {
2020-10-31 14:32:18 +01:00
include_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php' ;
$formresource = new FormResource ( $db );
// Resource
print '<div class="divsearchfield">' ;
2022-05-22 16:16:17 +02:00
print img_picto ( $langs -> trans ( " Resource " ), 'object_resource' , 'class="pictofixedwidth inline-block"' );
2024-11-04 12:32:13 +01:00
print $formresource -> select_resource_list ( $resourceid , " search_resourceid " , '' , 1 , 0 , 0 , [], '' , 2 , 0 , 'minwidth100 maxwidth250 widthcentpercentminusx' );
2020-10-31 14:32:18 +01:00
print '</div>' ;
2016-06-06 13:05:36 +02:00
}
2013-11-22 14:43:15 +01:00
}
2014-01-26 18:30:45 +01:00
2022-09-10 11:13:02 +02:00
if ( isModEnabled ( 'societe' ) && $user -> hasRight ( 'societe' , 'lire' )) {
2020-07-09 11:55:16 +02:00
print '<div class="divsearchfield">' ;
2022-05-22 16:16:17 +02:00
print img_picto ( $langs -> trans ( " ThirdParty " ), 'company' , 'class="pictofixedwidth inline-block"' );
2024-11-04 12:32:13 +01:00
print $form -> select_company ( $socid , 'search_socid' , '' , ' ' , 0 , 0 , array (), 0 , 'minwidth100 maxwidth250 widthcentpercentminusx' );
2020-07-09 11:55:16 +02:00
print '</div>' ;
2014-06-29 02:45:55 +02:00
}
2024-02-27 15:30:37 +01:00
if ( isModEnabled ( 'project' ) && $user -> hasRight ( 'projet' , 'lire' )) {
2013-11-28 15:54:12 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2020-04-10 10:59:32 +02:00
$formproject = new FormProjets ( $db );
2014-01-26 18:30:45 +01:00
2020-07-09 11:55:16 +02:00
print '<div class="divsearchfield">' ;
2022-05-22 16:16:17 +02:00
print img_picto ( $langs -> trans ( " Project " ), 'project' , 'class="pictofixedwidth inline-block"' );
2025-02-10 21:20:09 +01:00
print $formproject -> select_projects ( $socid ? $socid : - 1 , ( string ) $pid , 'search_projectid' , 0 , 0 , 1 , 0 , 0 , 0 , 0 , '' , 1 , 0 , 'minwidth100 maxwidth250 widthcentpercentminusx' );
2020-07-09 11:55:16 +02:00
print '</div>' ;
2013-11-22 14:43:15 +01:00
}
2014-01-26 18:30:45 +01:00
2024-02-27 15:30:37 +01:00
if ( isModEnabled ( 'category' ) && $user -> hasRight ( 'categorie' , 'lire' )) {
2024-02-09 15:58:49 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
$formother = new FormOther ( $db );
$langs -> load ( 'categories' );
print '<div class="divsearchfield">' ;
print img_picto ( $langs -> trans ( 'Categories' ), 'category' , 'class="pictofixedwidth"' );
2024-06-10 15:01:45 +02:00
print $formother -> select_categories ( 'actioncomm' , $search_categ_cus , 'search_categ_cus' , 1 , $langs -> trans ( 'ActionCommCategoriesArea' ), 'minwidth100 maxwidth250 widthcentpercentminusx' );
2024-02-09 15:58:49 +01:00
print '</div>' ;
}
2021-02-23 22:03:23 +01:00
if ( $canedit && ! preg_match ( '/list/' , $_SERVER [ " PHP_SELF " ])) {
2016-04-23 16:51:22 +02:00
// Status
2020-07-09 11:55:16 +02:00
print '<div class="divsearchfield">' ;
2024-06-22 01:18:10 +02:00
print img_picto ( $langs -> trans ( " Status " ), 'status' , 'class="pictofixedwidth inline-block"' );
2018-11-19 14:25:34 +01:00
$formactions -> form_select_status_action ( 'formaction' , $status , 1 , 'search_status' , 1 , 2 , 'minwidth100' );
2020-07-09 11:55:16 +02:00
print '</div>' ;
2016-04-23 16:51:22 +02:00
}
2014-06-29 02:45:55 +02:00
// Hooks
2024-09-23 00:37:30 +02:00
$parameters = array ( 'canedit' => $canedit , 'pid' => $pid , 'socid' => $socid );
2024-11-04 12:32:13 +01:00
$object = null ; // Null on purpose: @phan-suppress-next-line PhanPluginConstantVariableNull
2014-06-29 02:45:55 +02:00
$reshook = $hookmanager -> executeHooks ( 'searchAgendaFrom' , $parameters , $object , $action ); // Note that $action and $object may have been
2014-06-28 18:04:32 +02:00
2023-02-18 14:00:25 +01:00
print '<div class="clearboth"></div>' ;
2010-01-19 10:44:52 +01:00
}
2008-05-07 03:10:27 +02:00
/**
2011-06-06 19:31:16 +02:00
* Show actions to do array
2012-01-22 20:16:11 +01:00
*
* @ param int $max Max nb of records
* @ return void
2009-03-28 20:11:38 +01:00
*/
2019-01-27 15:20:16 +01:00
function show_array_actions_to_do ( $max = 5 )
2008-05-07 03:10:27 +02:00
{
2020-10-06 13:15:52 +02:00
global $langs , $conf , $user , $db , $socid ;
2009-03-28 20:11:38 +01:00
2020-04-10 10:59:32 +02:00
$now = dol_now ();
2011-06-06 19:31:16 +02:00
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php' ;
2008-05-07 03:10:27 +02:00
2020-12-08 15:56:42 +01:00
$sql = " SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent " ;
$sql .= " , c.code, c.libelle as type_label " ;
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.logo, s.email, s.entity " ;
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a LEFT JOIN " ;
$sql .= " " . MAIN_DB_PREFIX . " c_actioncomm as c ON c.id = a.fk_action " ;
2020-10-31 14:32:18 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON a.fk_soc = s.rowid " ;
2024-01-09 13:08:22 +01:00
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2021-02-23 22:03:23 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
}
2020-10-04 13:58:46 +02:00
$sql .= " WHERE a.entity IN ( " . getEntity ( 'agenda' ) . " ) " ;
2020-10-31 14:32:18 +01:00
$sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > ' " . $db -> idate ( $now ) . " ')) " ;
2024-01-09 13:08:22 +01:00
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2021-08-23 17:41:11 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . (( int ) $user -> id );
2021-02-23 22:03:23 +01:00
}
if ( $socid ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2021-02-23 22:03:23 +01:00
}
2020-04-10 10:59:32 +02:00
$sql .= " ORDER BY a.datep DESC, a.id DESC " ;
$sql .= $db -> plimit ( $max , 0 );
$resql = $db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2020-10-31 14:32:18 +01:00
$num = $db -> num_rows ( $resql );
2008-05-07 03:10:27 +02:00
2019-10-24 22:44:51 +02:00
print '<div class="div-table-responsive-no-min">' ;
2020-10-31 14:32:18 +01:00
print '<table class="noborder centpercent">' ;
print '<tr class="liste_titre"><th colspan="2">' . $langs -> trans ( " LastActionsToDo " , $max ) . '</th>' ;
2021-12-11 13:17:31 +01:00
print '<th colspan="2" class="right"><a class="commonlink" href="' . DOL_URL_ROOT . '/comm/action/list.php?mode=show_list&status=todo">' . $langs -> trans ( " FullList " ) . '</a></th>' ;
2011-06-15 10:39:03 +02:00
print '</tr>' ;
2020-10-31 14:32:18 +01:00
$i = 0 ;
2008-05-07 03:10:27 +02:00
2020-04-10 10:59:32 +02:00
$staticaction = new ActionComm ( $db );
2020-10-31 14:32:18 +01:00
$customerstatic = new Client ( $db );
2012-01-20 20:21:23 +01:00
2021-02-23 22:03:23 +01:00
while ( $i < $num ) {
2020-10-31 14:32:18 +01:00
$obj = $db -> fetch_object ( $resql );
2017-06-27 10:37:00 +02:00
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
print '<tr class="oddeven">' ;
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
$staticaction -> type_code = $obj -> code ;
$staticaction -> label = ( $obj -> label ? $obj -> label : $obj -> type_label );
$staticaction -> id = $obj -> id ;
print '<td>' . $staticaction -> getNomUrl ( 1 , 34 ) . '</td>' ;
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
// print '<td>'.dol_trunc($obj->label,22).'</td>';
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
print '<td>' ;
2021-02-23 22:03:23 +01:00
if ( $obj -> socid > 0 ) {
2020-12-08 15:56:42 +01:00
$customerstatic -> id = $obj -> socid ;
$customerstatic -> name = $obj -> name ;
//$customerstatic->name_alias = $obj->name_alias;
$customerstatic -> code_client = $obj -> code_client ;
$customerstatic -> code_compta = $obj -> code_compta ;
2024-08-14 16:51:53 +02:00
$customerstatic -> code_compta_client = $obj -> code_compta ;
2020-10-31 14:32:18 +01:00
$customerstatic -> client = $obj -> client ;
2020-12-08 15:56:42 +01:00
$customerstatic -> logo = $obj -> logo ;
$customerstatic -> email = $obj -> email ;
$customerstatic -> entity = $obj -> entity ;
print $customerstatic -> getNomUrl ( 1 , '' , 40 );
2020-10-31 14:32:18 +01:00
}
print '</td>' ;
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
$datep = $db -> jdate ( $obj -> dp );
$datep2 = $db -> jdate ( $obj -> dp2 );
2011-06-15 10:39:03 +02:00
2020-10-31 14:32:18 +01:00
// Date
2020-10-16 15:40:52 +02:00
print '<td width="100" class="right tddate">' . dol_print_date ( $datep , 'day' ) . ' ' ;
2020-04-10 10:59:32 +02:00
$late = 0 ;
2021-02-23 22:03:23 +01:00
if ( $obj -> percent == 0 && $datep && $datep < time ()) {
$late = 1 ;
}
if ( $obj -> percent == 0 && ! $datep && $datep2 && $datep2 < time ()) {
$late = 1 ;
}
if ( $obj -> percent > 0 && $obj -> percent < 100 && $datep2 && $datep2 < time ()) {
$late = 1 ;
}
if ( $obj -> percent > 0 && $obj -> percent < 100 && ! $datep2 && $datep && $datep < time ()) {
$late = 1 ;
}
if ( $late ) {
print img_warning ( $langs -> trans ( " Late " ));
}
2011-06-15 10:39:03 +02:00
print " </td> " ;
2010-05-08 18:45:47 +02:00
2011-06-15 10:39:03 +02:00
// Statut
2019-02-19 17:42:12 +01:00
print '<td class="right" width="14">' . $staticaction -> LibStatut ( $obj -> percent , 3 ) . " </td> \n " ;
2008-05-07 03:10:27 +02:00
2011-06-15 10:39:03 +02:00
print " </tr> \n " ;
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
$i ++ ;
}
print " </table></div><br> " ;
2009-03-28 20:11:38 +01:00
2020-10-31 14:32:18 +01:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
dol_print_error ( $db );
2008-05-07 03:10:27 +02:00
}
}
/**
2011-06-06 19:31:16 +02:00
* Show last actions array
2012-01-22 20:16:11 +01:00
*
* @ param int $max Max nb of records
* @ return void
2011-06-06 19:31:16 +02:00
*/
2019-01-27 15:20:16 +01:00
function show_array_last_actions_done ( $max = 5 )
2008-05-07 03:10:27 +02:00
{
2020-10-06 13:15:52 +02:00
global $langs , $conf , $user , $db , $socid ;
2009-03-28 20:11:38 +01:00
2020-04-10 10:59:32 +02:00
$now = dol_now ();
2011-06-06 19:31:16 +02:00
2020-12-08 15:56:42 +01:00
$sql = " SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label " ;
$sql .= " , c.code, c.libelle " ;
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.logo, s.email, s.entity " ;
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a LEFT JOIN " ;
$sql .= " " . MAIN_DB_PREFIX . " c_actioncomm as c ON c.id = a.fk_action " ;
2020-10-31 14:32:18 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON a.fk_soc = s.rowid " ;
2024-01-09 13:08:22 +01:00
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2021-02-23 22:03:23 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
}
2020-10-04 13:58:46 +02:00
$sql .= " WHERE a.entity IN ( " . getEntity ( 'agenda' ) . " ) " ;
2020-10-31 14:32:18 +01:00
$sql .= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= ' " . $db -> idate ( $now ) . " ')) " ;
2024-01-09 13:08:22 +01:00
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2021-08-23 17:41:11 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . (( int ) $user -> id );
2021-02-23 22:03:23 +01:00
}
if ( $socid ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2021-02-23 22:03:23 +01:00
}
2008-05-07 03:10:27 +02:00
$sql .= " ORDER BY a.datep2 DESC " ;
$sql .= $db -> plimit ( $max , 0 );
2020-04-10 10:59:32 +02:00
$resql = $db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2008-05-07 03:10:27 +02:00
$num = $db -> num_rows ( $resql );
2019-10-24 22:44:51 +02:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2019-01-27 11:55:16 +01:00
print '<tr class="liste_titre"><th colspan="2">' . $langs -> trans ( " LastDoneTasks " , $max ) . '</th>' ;
2021-12-11 13:17:31 +01:00
print '<th colspan="2" class="right"><a class="commonlink" href="' . DOL_URL_ROOT . '/comm/action/list.php?mode=show_list&status=done">' . $langs -> trans ( " FullList " ) . '</a></th>' ;
2008-05-07 03:10:27 +02:00
print '</tr>' ;
2020-12-08 17:09:48 +01:00
2008-05-07 03:10:27 +02:00
$i = 0 ;
2020-10-31 14:32:18 +01:00
$staticaction = new ActionComm ( $db );
$customerstatic = new Societe ( $db );
2008-05-07 03:10:27 +02:00
2021-02-23 22:03:23 +01:00
while ( $i < $num ) {
2008-05-07 03:10:27 +02:00
$obj = $db -> fetch_object ( $resql );
2017-06-27 10:37:00 +02:00
2008-05-07 03:10:27 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2009-03-28 20:11:38 +01:00
2020-04-10 10:59:32 +02:00
$staticaction -> type_code = $obj -> code ;
2022-09-15 20:23:37 +02:00
$staticaction -> label = $obj -> label ;
2020-04-10 10:59:32 +02:00
$staticaction -> id = $obj -> id ;
2019-01-27 11:55:16 +01:00
print '<td>' . $staticaction -> getNomUrl ( 1 , 34 ) . '</td>' ;
2008-05-07 03:10:27 +02:00
2020-10-31 14:32:18 +01:00
//print '<td>'.dol_trunc($obj->label,24).'</td>';
2008-05-07 03:10:27 +02:00
2011-06-06 19:55:19 +02:00
print '<td>' ;
2021-02-23 22:03:23 +01:00
if ( $obj -> socid > 0 ) {
2020-12-08 15:56:42 +01:00
$customerstatic -> id = $obj -> socid ;
$customerstatic -> name = $obj -> name ;
//$customerstatic->name_alias = $obj->name_alias;
$customerstatic -> code_client = $obj -> code_client ;
$customerstatic -> code_compta = $obj -> code_compta ;
2024-08-14 16:51:53 +02:00
$customerstatic -> code_compta_client = $obj -> code_compta ;
2020-10-31 14:32:18 +01:00
$customerstatic -> client = $obj -> client ;
2020-12-08 15:56:42 +01:00
$customerstatic -> logo = $obj -> logo ;
$customerstatic -> email = $obj -> email ;
$customerstatic -> entity = $obj -> entity ;
print $customerstatic -> getNomUrl ( 1 , '' , 30 );
2011-06-06 19:55:19 +02:00
}
print '</td>' ;
2008-05-07 03:10:27 +02:00
// Date
2020-10-16 15:40:52 +02:00
print '<td width="100" class="right tddate">' . dol_print_date ( $db -> jdate ( $obj -> da2 ), 'day' );
2009-03-28 20:11:38 +01:00
print " </td> " ;
2008-05-07 03:10:27 +02:00
2020-10-16 15:40:52 +02:00
// Status
print '<td class="right" width="14">' . $staticaction -> LibStatut ( $obj -> percent , 3 ) . " </td> \n " ;
2008-05-07 03:10:27 +02:00
print " </tr> \n " ;
$i ++ ;
}
2010-05-08 18:45:47 +02:00
// TODO Ajouter rappel pour "il y a des contrats a mettre en service"
// TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration"
2019-10-24 22:44:51 +02:00
print " </table></div><br> " ;
2008-05-07 03:10:27 +02:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2008-05-07 03:10:27 +02:00
}
}
/**
2012-02-04 10:48:47 +01:00
* Prepare array with list of tabs
2012-01-22 20:16:11 +01:00
*
2024-09-23 00:37:30 +02:00
* @ return array < array { 0 : string , 1 : string , 2 : string } > Array of tabs to show
2009-12-16 19:57:51 +01:00
*/
2008-05-07 03:10:27 +02:00
function agenda_prepare_head ()
{
2022-09-15 20:15:40 +02:00
global $langs , $conf , $user , $db ;
$extrafields = new ExtraFields ( $db );
$extrafields -> fetch_name_optionals_label ( 'actioncomm' );
2008-05-07 03:10:27 +02:00
$h = 0 ;
$head = array ();
2014-06-29 23:35:00 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /admin/agenda_other.php " ;
$head [ $h ][ 1 ] = $langs -> trans ( " Miscellaneous " );
$head [ $h ][ 2 ] = 'other' ;
$h ++ ;
2008-05-07 03:10:27 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /admin/agenda.php " ;
$head [ $h ][ 1 ] = $langs -> trans ( " AutoActions " );
$head [ $h ][ 2 ] = 'autoactions' ;
$h ++ ;
2020-11-21 14:14:53 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /admin/agenda_reminder.php " ;
$head [ $h ][ 1 ] = $langs -> trans ( " Reminders " );
$head [ $h ][ 2 ] = 'reminders' ;
$h ++ ;
2017-08-20 16:07:22 +02:00
2008-05-07 03:10:27 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /admin/agenda_xcal.php " ;
2012-01-20 20:21:23 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ExportCal " );
2008-05-07 03:10:27 +02:00
$head [ $h ][ 2 ] = 'xcal' ;
$h ++ ;
2011-05-10 00:33:50 +02:00
2011-07-22 08:51:30 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /admin/agenda_extsites.php " ;
$head [ $h ][ 1 ] = $langs -> trans ( " ExtSites " );
$head [ $h ][ 2 ] = 'extsites' ;
$h ++ ;
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'agenda_admin' );
2013-01-19 14:32:37 +01:00
2012-12-08 12:49:20 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /admin/agenda_extrafields.php " ;
$head [ $h ][ 1 ] = $langs -> trans ( " ExtraFields " );
2022-09-16 09:35:28 +02:00
$nbExtrafields = $extrafields -> attributes [ 'actioncomm' ][ 'count' ];
2022-09-15 20:15:40 +02:00
if ( $nbExtrafields > 0 ) {
2022-09-22 14:42:58 +02:00
$head [ $h ][ 1 ] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>' ;
2022-09-15 20:15:40 +02:00
}
2012-12-08 12:49:20 +01:00
$head [ $h ][ 2 ] = 'attributes' ;
$h ++ ;
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'agenda_admin' , 'remove' );
2012-12-08 12:49:20 +01:00
2008-05-07 03:10:27 +02:00
return $head ;
}
2009-12-16 19:57:51 +01:00
/**
2012-02-04 10:48:47 +01:00
* Prepare array with list of tabs
*
2013-11-07 21:23:29 +01:00
* @ param object $object Object related to tabs
2024-09-23 00:37:30 +02:00
* @ return array < array { 0 : string , 1 : string , 2 : string } > Array of tabs to show
2009-12-16 19:57:51 +01:00
*/
2012-02-04 10:48:47 +01:00
function actions_prepare_head ( $object )
2009-12-16 19:57:51 +01:00
{
2016-01-23 17:19:34 +01:00
global $db , $langs , $conf , $user ;
2009-12-16 19:57:51 +01:00
$h = 0 ;
$head = array ();
2014-09-18 21:18:25 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/card.php?id=' . $object -> id ;
2009-12-16 19:57:51 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " CardAction " );
$head [ $h ][ 2 ] = 'card' ;
$h ++ ;
2020-10-31 14:32:18 +01:00
// Tab to link resources
2022-06-09 22:10:51 +02:00
if ( isModEnabled ( 'resource' )) {
2020-10-31 14:32:18 +01:00
include_once DOL_DOCUMENT_ROOT . '/resource/class/dolresource.class.php' ;
2023-08-04 04:28:45 +02:00
$resource = new Dolresource ( $db );
2017-06-27 10:37:00 +02:00
2015-05-31 02:05:39 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/resource/element_resource.php?element=action&element_id=' . $object -> id ;
2020-10-31 14:32:18 +01:00
$listofresourcelinked = $resource -> getElementResources ( $object -> element , $object -> id );
2023-12-04 12:05:28 +01:00
$nbResources = ( is_array ( $listofresourcelinked ) ? count ( $listofresourcelinked ) : 0 );
2015-05-31 02:05:39 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Resources " );
2021-02-23 22:03:23 +01:00
if ( $nbResources > 0 ) {
2023-11-27 11:39:32 +01:00
$head [ $h ][ 1 ] .= ( ! getDolGlobalString ( 'MAIN_OPTIMIZEFORTEXTBROWSER' ) ? '<span class="badge marginleftonlyshort">' . ( $nbResources ) . '</span>' : '' );
2021-02-23 22:03:23 +01:00
}
2015-05-31 02:05:39 +02:00
$head [ $h ][ 2 ] = 'resources' ;
$h ++ ;
}
2020-10-31 14:32:18 +01:00
// Attached files
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php' ;
$upload_dir = $conf -> agenda -> dir_output . " / " . $object -> id ;
$nbFiles = count ( dol_dir_list ( $upload_dir , 'files' , 0 , '' , '(\.meta|_preview.*\.png)$' ));
$nbLinks = Link :: count ( $db , $object -> element , $object -> id );
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/document.php?id=' . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Documents " );
2021-02-23 22:03:23 +01:00
if (( $nbFiles + $nbLinks ) > 0 ) {
2023-11-27 11:39:32 +01:00
$head [ $h ][ 1 ] .= ( ! getDolGlobalString ( 'MAIN_OPTIMIZEFORTEXTBROWSER' ) ? '<span class="badge marginleftonlyshort">' . ( $nbFiles + $nbLinks ) . '</span>' : '' );
2021-02-23 22:03:23 +01:00
}
2020-10-31 14:32:18 +01:00
$head [ $h ][ 2 ] = 'documents' ;
$h ++ ;
2009-12-16 19:57:51 +01:00
2012-02-04 10:48:47 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/info.php?id=' . $object -> id ;
2009-12-16 19:57:51 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( 'Info' );
$head [ $h ][ 2 ] = 'info' ;
$h ++ ;
2014-05-23 04:28:57 +02:00
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'action' );
2014-05-23 04:28:57 +02:00
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'action' , 'remove' );
2009-12-16 19:57:51 +01:00
return $head ;
}
2011-05-16 19:27:20 +02:00
/**
* Define head array for tabs of agenda setup pages
2012-01-20 20:21:23 +01:00
*
2012-02-04 14:39:47 +01:00
* @ param string $param Parameters to add to url
2024-10-14 01:59:44 +02:00
* @ return array < array { 0 : string , 1 : string , 2 : string } > Array of tabs to show
2011-05-16 19:27:20 +02:00
*/
function calendars_prepare_head ( $param )
{
2020-10-31 14:32:18 +01:00
global $langs , $conf , $user ;
$h = 0 ;
$head = array ();
2021-12-11 13:17:31 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/list.php?mode=show_list' . ( $param ? '&' . $param : '' );
2020-10-31 14:32:18 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ViewList " );
$head [ $h ][ 2 ] = 'cardlist' ;
$h ++ ;
2021-12-11 13:17:31 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/index.php?mode=show_month' . ( $param ? '&' . $param : '' );
2020-10-31 14:32:18 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ViewCal " );
$head [ $h ][ 2 ] = 'cardmonth' ;
$h ++ ;
2021-12-11 13:17:31 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/index.php?mode=show_week' . ( $param ? '&' . $param : '' );
2020-10-31 14:32:18 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ViewWeek " );
$head [ $h ][ 2 ] = 'cardweek' ;
$h ++ ;
2021-12-11 13:17:31 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/index.php?mode=show_day' . ( $param ? '&' . $param : '' );
2020-10-31 14:32:18 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ViewDay " );
$head [ $h ][ 2 ] = 'cardday' ;
$h ++ ;
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'AGENDA_SHOW_PERTYPE' )) {
2020-10-31 14:32:18 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/pertype.php' . ( $param ? '?' . $param : '' );
$head [ $h ][ 1 ] = $langs -> trans ( " ViewPerType " );
$head [ $h ][ 2 ] = 'cardpertype' ;
$h ++ ;
}
$newparam = $param ;
$newparam = preg_replace ( '/&?search_filtert=\d+/' , '' , $newparam );
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/action/peruser.php' . ( $newparam ? '?' . $newparam : '' );
$head [ $h ][ 1 ] = $langs -> trans ( " ViewPerUser " );
$head [ $h ][ 2 ] = 'cardperuser' ;
$h ++ ;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'agenda' );
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'agenda' , 'remove' );
return $head ;
2011-05-16 19:27:20 +02:00
}