2010-02-27 21:19:55 +01:00
< ? php
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2005 Brice Davoleau < brice . davoleau @ gmail . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2019-10-07 16:01:36 +02:00
* Copyright ( C ) 2006 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2010-02-27 21:19:55 +01:00
* Copyright ( C ) 2007 Patrick Raguin < patrick . raguin @ gmail . com >
2010-06-30 17:39:47 +02:00
* Copyright ( C ) 2010 Juanjo Menent < jmenent @ 2 byte . es >
2015-02-27 15:08:08 +01:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2010-02-27 21:19:55 +01: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
2010-02-27 21:19:55 +01: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 />.
2010-02-27 21:19:55 +01:00
*/
/**
* \file htdocs / societe / agenda . php
* \ingroup societe
* \brief Page of third party events
*/
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 . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2016-04-08 14:28:49 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2010-02-27 21:19:55 +01:00
2019-07-16 00:12:22 +02:00
$langs -> loadLangs ( array ( " companies " , " bills " , " propal " , " orders " ));
2010-02-27 21:19:55 +01:00
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'actioncode' , 'array' ))
2016-10-17 17:52:58 +02:00
{
2020-04-10 10:59:32 +02:00
$actioncode = GETPOST ( 'actioncode' , 'array' , 3 );
if ( ! count ( $actioncode )) $actioncode = '0' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$actioncode = GETPOST ( " actioncode " , " alpha " , 3 ) ? GETPOST ( " actioncode " , " alpha " , 3 ) : ( GETPOST ( " actioncode " ) == '0' ? '0' : ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT ));
2016-10-17 17:52:58 +02:00
}
2020-04-10 10:59:32 +02:00
$search_agenda_label = GETPOST ( 'search_agenda_label' );
2016-10-17 17:52:58 +02:00
2010-02-27 21:19:55 +01:00
// Security check
2019-01-27 11:55:16 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2020-04-10 10:59:32 +02:00
if ( $user -> socid ) $socid = $user -> socid ;
2012-11-10 08:19:33 +01:00
$result = restrictedArea ( $user , 'societe' , $socid , '&societe' );
2010-02-27 21:19:55 +01:00
2020-04-10 10:59:32 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2019-01-27 11:55:16 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2016-10-30 12:39:51 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2019-11-13 19:37:08 +01:00
if ( ! $sortfield ) $sortfield = 'a.datep,a.id' ;
if ( ! $sortorder ) $sortorder = 'DESC,DESC' ;
2016-10-30 12:39:51 +01:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2013-01-13 19:33:54 +01:00
$hookmanager -> initHooks ( array ( 'agendathirdparty' ));
2013-01-12 14:34:16 +01:00
2010-02-27 21:19:55 +01:00
/*
* Actions
*/
2019-11-13 19:37:08 +01:00
$parameters = array ( 'id' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2014-09-28 03:41:32 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2010-02-27 21:19:55 +01:00
2016-12-19 16:22:41 +01:00
if ( empty ( $reshook ))
2016-10-17 17:52:58 +02:00
{
2016-12-19 16:22:41 +01:00
// Cancel
2019-11-13 19:37:08 +01:00
if ( GETPOST ( 'cancel' , 'alpha' ) && ! empty ( $backtopage ))
2016-12-19 16:22:41 +01:00
{
header ( " Location: " . $backtopage );
exit ;
}
// Purge search criteria
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All tests are required to be compatible with all browsers
2016-12-19 16:22:41 +01:00
{
2019-11-13 19:37:08 +01:00
$actioncode = '' ;
$search_agenda_label = '' ;
2016-12-19 16:22:41 +01:00
}
2016-10-17 17:52:58 +02:00
}
2010-02-27 21:19:55 +01:00
/*
* View
*/
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2010-02-27 21:19:55 +01:00
2016-12-19 16:22:41 +01:00
if ( $socid > 0 )
2010-02-27 21:19:55 +01:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php' ;
2010-02-27 21:19:55 +01:00
2015-01-15 03:11:06 +01:00
$object = new Societe ( $db );
$result = $object -> fetch ( $socid );
2015-03-12 17:29:52 +01:00
2020-04-10 10:59:32 +02:00
$title = $langs -> trans ( " Agenda " );
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/thirdpartynameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) $title = $object -> name . " - " . $title ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $title );
2010-02-27 21:19:55 +01:00
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> notification -> enabled )) $langs -> load ( " mails " );
2015-01-15 03:11:06 +01:00
$head = societe_prepare_head ( $object );
2010-02-27 21:19:55 +01:00
2017-03-23 13:06:38 +01:00
dol_fiche_head ( $head , 'agenda' , $langs -> trans ( " ThirdParty " ), - 1 , 'company' );
2010-02-27 21:19:55 +01:00
2017-07-01 14:18:09 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2020-04-10 10:59:32 +02:00
dol_banner_tab ( $object , 'socid' , $linkback , ( $user -> socid ? 0 : 1 ), 'rowid' , 'nom' );
2017-07-01 14:18:09 +02:00
2015-10-13 13:06:32 +02:00
print '<div class="fichecenter">' ;
2017-07-01 14:18:09 +02:00
2015-10-13 13:06:32 +02:00
print '<div class="underbanner clearboth"></div>' ;
2017-07-01 14:18:09 +02:00
2016-09-18 13:58:17 +02:00
$object -> info ( $socid );
2019-05-19 09:14:29 +02:00
dol_print_object_info ( $object , 1 );
2017-07-01 14:18:09 +02:00
2010-02-27 21:19:55 +01:00
print '</div>' ;
2015-10-13 13:06:32 +02:00
dol_fiche_end ();
2012-02-13 01:43:35 +01:00
2015-10-24 16:09:26 +02:00
2017-07-01 14:18:09 +02:00
2016-10-17 17:52:58 +02:00
// Actions buttons
2017-07-01 14:18:09 +02:00
2019-11-13 19:37:08 +01:00
$objthirdparty = $object ;
$objcon = new stdClass ();
2017-07-01 14:18:09 +02:00
2019-11-13 19:37:08 +01:00
$out = '' ;
$permok = $user -> rights -> agenda -> myactions -> create ;
if (( ! empty ( $objthirdparty -> id ) || ! empty ( $objcon -> id )) && $permok )
2015-10-24 16:09:26 +02:00
{
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
2019-11-13 19:37:08 +01:00
if ( get_class ( $objthirdparty ) == 'Societe' ) $out .= '&socid=' . $objthirdparty -> id ;
$out .= ( ! empty ( $objcon -> id ) ? '&contactid=' . $objcon -> id : '' ) . '&backtopage=1&percentage=-1' ;
2015-10-24 16:09:26 +02:00
//$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
//$out.="</a>";
}
2017-07-01 14:18:09 +02:00
2017-10-04 12:58:13 +02:00
//print '<div class="tabsAction">';
//print '</div>';
2010-09-19 14:50:53 +02:00
2017-10-04 12:58:13 +02:00
2020-04-10 10:59:32 +02:00
$newcardbutton = '' ;
if ( ! empty ( $conf -> agenda -> enabled ))
2010-09-19 14:50:53 +02:00
{
2020-04-10 10:59:32 +02:00
if ( ! empty ( $user -> rights -> agenda -> myactions -> create ) || ! empty ( $user -> rights -> agenda -> allactions -> create ))
2014-01-06 17:14:13 +01:00
{
2020-04-10 10:59:32 +02:00
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'AddAction' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out );
2014-01-06 17:14:13 +01:00
}
2010-09-19 14:50:53 +02:00
}
2020-04-10 10:59:32 +02:00
if ( ! empty ( $conf -> agenda -> enabled ) && ( ! empty ( $user -> rights -> agenda -> myactions -> read ) || ! empty ( $user -> rights -> agenda -> allactions -> read )))
2016-04-08 14:28:49 +02:00
{
2017-10-04 12:58:13 +02:00
print '<br>' ;
2020-04-10 10:59:32 +02:00
$param = '&socid=' . $socid ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
2016-10-30 12:39:51 +01:00
2018-04-18 03:26:15 +02:00
print load_fiche_titre ( $langs -> trans ( " ActionsOnCompany " ), $newcardbutton , '' );
2018-04-15 16:35:18 +02:00
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
2017-07-01 14:18:09 +02:00
2016-10-17 17:52:58 +02:00
// List of all actions
2020-04-10 10:59:32 +02:00
$filters = array ();
$filters [ 'search_agenda_label' ] = $search_agenda_label ;
2016-10-30 12:39:51 +01:00
2017-11-16 12:18:25 +01:00
// TODO Replace this with same code than into list.php
2019-01-27 11:55:16 +01:00
show_actions_done ( $conf , $langs , $db , $object , null , 0 , $actioncode , '' , $filters , $sortfield , $sortorder );
2016-04-08 14:28:49 +02:00
}
2010-02-27 21:19:55 +01:00
}
2018-08-05 17:21:59 +02:00
// End of page
2012-02-13 01:43:35 +01:00
llxFooter ();
2010-02-27 21:19:55 +01:00
$db -> close ();