2004-10-20 23:06:45 +02:00
< ? php
2018-10-15 21:53:54 +02:00
/* Copyright ( C ) 2002 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2018-10-15 21:53:54 +02:00
* Copyright ( C ) 2011 - 2017 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
* Copyright ( C ) 2018 Nicolas ZABOURI < info @ inovea - conseil . com >
2025-01-22 08:50:53 +01:00
* Copyright ( C ) 2018 - 2025 Frédéric France < frederic . france @ free . fr >
2024-03-14 13:48:44 +01:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
* Copyright ( C ) 2024 William Mead < william . mead @ manchenumerique . fr >
2018-08-13 17:26:32 +02:00
*
2011-11-03 11:49:22 +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
2011-11-03 11:49:22 +01:00
* ( at your option ) any later version .
2011-12-07 00:16:19 +01:00
*
2011-11-03 11:49:22 +01:00
* 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 .
2011-12-07 00:16:19 +01:00
*
2011-11-03 11:49:22 +01:00
* 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 />.
2011-11-03 11:49:22 +01:00
*/
2002-05-11 20:53:13 +02:00
2004-12-28 16:36:40 +01:00
/**
2010-06-05 17:32:18 +02:00
* \file htdocs / comm / action / class / actioncomm . class . php
2012-10-03 00:39:34 +02:00
* \ingroup agenda
2010-10-28 00:41:40 +02:00
* \brief File of class to manage agenda events ( actions )
2008-11-11 20:32:48 +01:00
*/
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php' ;
2020-08-27 15:49:56 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncommreminder.class.php' ;
2012-10-03 00:39:34 +02:00
/**
* Class to manage agenda events ( actions )
2008-11-11 20:32:48 +01:00
*/
2010-06-09 20:25:20 +02:00
class ActionComm extends CommonObject
2003-05-15 21:30:01 +02:00
{
2020-09-07 10:18:17 +02:00
/**
* @ var string ID to identify managed object
*/
public $element = 'action' ;
2018-09-02 09:27:59 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Name of table without prefix where object is stored
*/
public $table_element = 'actioncomm' ;
2018-09-02 09:27:59 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Name of id column
*/
public $table_rowid = 'id' ;
2018-09-04 14:46:10 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Name of icon for actioncomm object . Filename of icon is object_action . png
*/
public $picto = 'action' ;
2018-09-02 09:27:59 +02:00
2020-09-07 10:18:17 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var int < 0 , 2 > 0 = Default
* 1 = View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* 2 = Same than 1 but accept record if fksoc is empty
2020-09-07 10:18:17 +02:00
*/
public $restrictiononfksoc = 2 ;
2017-07-04 10:29:38 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var int Id of the event
*/
public $id ;
2013-03-09 20:34:38 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-03-03 18:55:30 +01:00
* @ var string Id of the event . Use $id as possible
2020-09-07 10:18:17 +02:00
*/
public $ref ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var int Id into parent table llx_c_actioncomm ( used only if option to use type is set )
2021-04-09 13:34:19 +02:00
* This field is stored info fk_action . It contains the id into table llx_ac_actioncomm .
2020-09-07 10:18:17 +02:00
*/
public $type_id ;
2019-11-01 17:12:07 +01:00
2021-02-18 12:46:42 +01:00
/**
* @ var string Calendar of event ( Type of type of event ) . 'system' = Default calendar , 'systemauto' = Auto calendar , 'birthdate' , 'holiday' , 'module' = Calendar specific to a module
2021-04-09 13:34:19 +02:00
* This field contains the type into table llx_ac_actioncomm ( 'system' , 'systemauto' , ... ) . It should be named 'type_type' .
2021-02-18 12:46:42 +01:00
*/
public $type ;
2020-09-07 10:18:17 +02:00
/**
* @ var string Code into parent table llx_c_actioncomm ( used only if option to use type is set ) . With default setup , should be AC_OTH_AUTO or AC_OTH .
2021-04-09 13:34:19 +02:00
* This field contains the code into table llx_ac_actioncomm .
2020-09-07 10:18:17 +02:00
*/
public $type_code ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Type label
*/
public $type_label ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2021-02-18 12:46:42 +01:00
* @ var string Color into parent table llx_c_actioncomm ( used only if option to use type is set )
2020-09-07 10:18:17 +02:00
*/
2021-02-18 12:46:42 +01:00
public $type_color ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2021-02-18 12:46:42 +01:00
* @ var string Picto for type of event ( used only if option to use type is set )
2020-09-07 10:18:17 +02:00
*/
2021-02-18 12:46:42 +01:00
public $type_picto ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Free code to identify action . Ie : Agenda trigger add here AC_TRIGGERNAME ( 'AC_COMPANY_CREATE' , 'AC_PROPAL_VALIDATE' , ... )
2021-04-09 13:34:19 +02:00
* This field is stored into field 'code' into llx_actioncomm .
2020-09-07 10:18:17 +02:00
*/
public $code ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Agenda event label
*/
public $label ;
2019-04-25 12:11:32 +02:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Date creation record ( datec )
2020-09-07 10:18:17 +02:00
*/
public $datec ;
2019-05-18 16:18:14 +02:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Duration ( duree )
2020-09-07 10:18:17 +02:00
*/
public $duree ;
2019-05-18 16:18:14 +02:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Date modification record ( tms )
2020-09-07 10:18:17 +02:00
*/
public $datem ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var User Object user that create action
2020-09-07 10:18:17 +02:00
* @ deprecated
* @ see $authorid
*/
public $author ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var User Object user that modified action
2020-09-07 10:18:17 +02:00
* @ deprecated
* @ see $usermodid
*/
public $usermod ;
2008-02-11 16:51:03 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Id user that create action
2020-09-07 10:18:17 +02:00
*/
public $authorid ;
2018-10-15 21:53:54 +02:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Id user that modified action
2020-09-07 10:18:17 +02:00
*/
public $usermodid ;
2019-04-25 12:11:32 +02:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Date action start ( datep )
2020-09-07 10:18:17 +02:00
*/
public $datep ;
2019-04-25 12:11:32 +02:00
2022-01-18 13:52:09 +01:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Date action end ( datef )
2022-01-18 13:52:09 +01:00
*/
public $datef ;
/**
2024-10-31 19:48:54 +01:00
* @ var int This is date start action ( datep ) but modified to not be outside calendar view .
2022-01-18 13:52:09 +01:00
*/
public $date_start_in_calendar ;
/**
2024-10-31 19:48:54 +01:00
* @ var int This is date end action ( datef ) but modified to not be outside calendar view .
2022-01-18 13:52:09 +01:00
*/
public $date_end_in_calendar ;
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int Date action end ( datep2 )
2020-09-07 10:18:17 +02:00
*/
public $datep2 ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int - 1 = Unknown duration
2024-04-02 01:48:30 +02:00
* @ deprecated Use ( $datef - $datep )
2020-09-07 10:18:17 +02:00
*/
public $durationp = - 1 ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int 1 = Event on full day
2020-09-07 10:18:17 +02:00
*/
public $fulldayevent = 0 ;
2019-11-01 17:12:07 +01:00
2022-01-18 13:52:09 +01:00
/**
2024-10-31 19:48:54 +01:00
* @ var int 1 = ? ? ?
2022-01-18 13:52:09 +01:00
*/
public $ponctuel ;
2020-09-07 10:18:17 +02:00
/**
2024-04-02 13:52:51 +02:00
* @ var int <- 1 , 100 > Percentage
2020-09-07 10:18:17 +02:00
*/
public $percentage ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var string Location
2020-09-07 10:18:17 +02:00
*/
public $location ;
2009-05-04 22:39:17 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var int Transparency ( ical standard ) . Used to say if people assigned to event are busy or not by event . 0 = available , 1 = busy , 2 = busy ( refused events )
*/
public $transparency ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
2022-12-31 12:39:42 +01:00
* @ var int ( 0 By default )
2020-09-07 10:18:17 +02:00
*/
public $priority ;
2017-11-22 14:42:47 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var array < int , array { id : int , transparency : int < 0 , 1 > } > Array of users
2020-09-07 10:18:17 +02:00
*/
public $userassigned = array ();
2017-11-22 14:42:47 +01:00
2020-09-07 10:18:17 +02:00
/**
2022-12-31 12:39:42 +01:00
* @ var int Id of user owner = fk_user_action into table
2020-09-07 10:18:17 +02:00
*/
public $userownerid ;
2017-11-22 14:42:47 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-30 21:33:30 +01:00
* @ var array < int , array { id : int , mandatory : int < 0 , 1 > , answer_status : int , transparency : int < 0 , 1 > } | int > Array of contact ids
2020-09-07 10:18:17 +02:00
*/
public $socpeopleassigned = array ();
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int [] Array of other contact emails ( not user , not contact )
2020-09-07 10:18:17 +02:00
*/
public $otherassigned = array ();
2019-11-01 17:12:07 +01:00
2020-09-14 20:53:42 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var array < int , ActionCommReminder > Array of reminders
2020-09-14 20:53:42 +02:00
*/
public $reminders = array ();
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int thirdparty id linked to action
2020-09-07 10:18:17 +02:00
*/
public $socid ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-10-31 19:48:54 +01:00
* @ var int socpeople id linked to action
2020-09-07 10:18:17 +02:00
*/
2021-08-06 18:45:25 +02:00
public $contact_id ;
2015-02-10 11:38:13 +01:00
2024-10-31 19:48:54 +01:00
/**
2024-11-04 23:53:20 +01:00
* @ var ? int task ID
2024-10-31 19:48:54 +01:00
*/
public $fk_task ;
2022-11-08 03:01:32 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var ? Societe Company linked to action ( optional )
2020-09-07 10:18:17 +02:00
* @ deprecated
* @ see $socid
*/
public $societe ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var ? Contact Contact linked to action ( optional )
2020-09-07 10:18:17 +02:00
* @ deprecated
2021-08-06 18:45:25 +02:00
* @ see $contact_id
2020-09-07 10:18:17 +02:00
*/
public $contact ;
2015-02-10 11:38:13 +01:00
2020-09-07 10:18:17 +02:00
// Properties for links to other objects
/**
2022-07-12 11:58:32 +02:00
* @ var int Id of linked object
2024-10-24 01:12:58 +02:00
* @ deprecated Use $elementid
2020-09-07 10:18:17 +02:00
*/
public $fk_element ; // Id of record
2011-06-06 13:37:59 +02:00
2020-09-07 10:18:17 +02:00
/**
2023-11-22 12:46:09 +01:00
* @ var int Id of linked object , alternative for API or other
2020-09-07 10:18:17 +02:00
*/
public $elementid ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2022-07-12 11:58:32 +02:00
* @ var string Type of record . This if property -> element of object linked to .
2020-09-07 10:18:17 +02:00
*/
public $elementtype ;
2019-11-01 17:12:07 +01:00
2023-09-05 16:32:02 +02:00
/**
2023-11-21 23:12:44 +01:00
* @ var int id of calendar
2023-09-05 16:32:02 +02:00
*/
2023-11-21 23:12:44 +01:00
public $fk_bookcal_calendar ;
2023-09-05 16:32:02 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Ical name
*/
public $icalname ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-04-02 13:52:51 +02:00
* @ var string Ical color ( Hex value for color on 6 nibles )
2020-09-07 10:18:17 +02:00
*/
public $icalcolor ;
2011-06-30 09:49:26 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Extraparam
*/
public $extraparams ;
2019-11-14 12:01:01 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var array < int , array { id : int , type : string , actionparam : string , status : int } > Actions
2020-09-07 10:18:17 +02:00
*/
public $actions = array ();
2010-09-12 22:27:40 +02:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email msgid
*/
public $email_msgid ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email from
*/
public $email_from ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email sender
*/
public $email_sender ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email to
*/
public $email_to ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email tocc
*/
public $email_tocc ;
/**
* @ var string Email tobcc
*/
public $email_tobcc ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email subject
*/
public $email_subject ;
2019-11-01 17:12:07 +01:00
2020-09-07 10:18:17 +02:00
/**
* @ var string Email errors to
*/
public $errors_to ;
2016-01-08 13:05:56 +01:00
2021-03-02 22:23:54 +01:00
/**
* @ var int number of vote for an event
*/
public $num_vote ;
/**
* @ var int if event is paid
*/
public $event_paid ;
/**
* @ var int status use but Event organisation module
*/
public $status ;
2022-07-11 20:05:49 +02:00
/**
2024-04-02 01:48:30 +02:00
* @ var string IP address
*/
public $ip ;
/*
2022-07-11 20:05:49 +02:00
* Properties to manage the recurring events
*/
2024-04-02 01:48:30 +02:00
/** @var string A string YYYYMMDDHHMMSS shared by allevent of same series */
public $recurid ;
/** @var string Rule of recurring */
public $recurrule ;
/** @var string Repeat until this date */
public $recurdateend ;
2022-07-11 20:05:49 +02:00
2024-04-02 01:48:30 +02:00
/** @var int Duration of phone call when the event is a phone call */
2022-07-11 20:05:49 +02:00
public $calling_duration ;
2020-05-19 08:07:21 +02:00
/**
* Typical value for a event that is in a todo state
*/
const EVENT_TODO = 0 ;
/**
* Typical value for a event that is in a progress state
*/
const EVENT_IN_PROGRESS = 50 ;
/**
* Typical value for a event that is in a finished state
*/
const EVENT_FINISHED = 100 ;
2017-07-04 10:29:38 +02:00
2021-06-22 11:38:02 +02:00
2022-06-01 12:51:40 +02:00
public $fields = array ();
2020-09-07 10:18:17 +02:00
/**
* Constructor
*
* @ param DoliDB $db Database handler
*/
public function __construct ( DoliDB $db )
{
$this -> db = $db ;
2024-05-05 00:34:19 +02:00
$this -> ismultientitymanaged = 1 ;
2020-09-07 10:18:17 +02:00
}
2004-10-30 00:31:33 +02:00
2020-09-07 10:18:17 +02:00
/**
* Add an action / event into database .
* $this -> type_id OR $this -> type_code must be set .
*
2024-04-02 01:48:30 +02:00
* @ param User $user Object user making action
* @ param int < 0 , 1 > $notrigger 1 = disable triggers , 0 = enable triggers
* @ return int Id of created event , < 0 if KO
2020-09-07 10:18:17 +02:00
*/
public function create ( User $user , $notrigger = 0 )
{
2022-11-29 14:45:35 +01:00
global $langs , $conf ;
2013-03-09 20:34:38 +01:00
2020-09-07 10:18:17 +02:00
$error = 0 ;
$now = dol_now ();
2010-01-19 11:47:26 +01:00
2020-09-07 10:18:17 +02:00
// Check parameters
2022-12-31 12:39:42 +01:00
if ( ! isset ( $this -> userownerid ) || ( string ) $this -> userownerid === '' ) { // $this->userownerid may be 0 (anonymous event) or > 0
2023-11-22 12:46:09 +01:00
dol_syslog ( " You tried to create an event but mandatory property userownerid was empty (you can define it to 0 for anonymous event) " , LOG_WARNING );
2021-03-26 19:00:56 +01:00
$this -> errors [] = 'ErrorActionCommPropertyUserowneridNotDefined' ;
2020-09-07 10:18:17 +02:00
return - 1 ;
}
2015-02-25 15:01:25 +01:00
2020-09-07 10:18:17 +02:00
// Clean parameters
$this -> label = dol_trunc ( trim ( $this -> label ), 128 );
2024-01-30 15:00:14 +01:00
$this -> location = ( ! empty ( $this -> location ) ? dol_trunc ( trim ( $this -> location ), 128 ) : " " );
2020-09-07 10:18:17 +02:00
$this -> note_private = dol_htmlcleanlastbr ( trim ( empty ( $this -> note_private ) ? $this -> note : $this -> note_private ));
2021-02-23 18:59:19 +01:00
if ( empty ( $this -> percentage )) {
$this -> percentage = 0 ;
}
if ( empty ( $this -> priority ) || ! is_numeric ( $this -> priority )) {
$this -> priority = 0 ;
}
if ( empty ( $this -> fulldayevent )) {
$this -> fulldayevent = 0 ;
}
if ( empty ( $this -> transparency )) {
$this -> transparency = 0 ;
}
if ( $this -> percentage > 100 ) {
$this -> percentage = 100 ;
}
2023-05-12 13:06:36 +02:00
if ( empty ( $this -> datep ) && $this -> datep != '0' ) { // We should not insert event in calendar without a start date
$this -> datep = $now ;
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $this -> datep ) && ! empty ( $this -> datef )) {
$this -> durationp = ( $this -> datef - $this -> datep ); // deprecated
}
if ( ! empty ( $this -> datep ) && ! empty ( $this -> datef ) && $this -> datep > $this -> datef ) {
$this -> datef = $this -> datep ;
}
if ( ! isset ( $this -> fk_project ) || $this -> fk_project < 0 ) {
$this -> fk_project = 0 ;
}
2024-10-31 19:48:54 +01:00
if ( ! isset ( $this -> fk_task ) || $this -> fk_task < 0 ) {
$this -> fk_task = 0 ;
}
2020-09-07 10:18:17 +02:00
// For backward compatibility
2021-02-23 18:59:19 +01:00
if ( $this -> elementtype == 'facture' ) {
$this -> elementtype = 'invoice' ;
}
if ( $this -> elementtype == 'commande' ) {
$this -> elementtype = 'order' ;
}
if ( $this -> elementtype == 'contrat' ) {
$this -> elementtype = 'contract' ;
}
2023-11-22 12:46:09 +01:00
if ( empty ( $this -> fk_element ) && ! empty ( $this -> elementid )) {
$this -> fk_element = $this -> elementid ;
}
2024-10-24 01:12:58 +02:00
if ( empty ( $this -> elementid ) && ! empty ( $this -> fk_element )) {
$this -> elementid = $this -> fk_element ;
}
2020-09-07 10:18:17 +02:00
2022-12-30 01:52:41 +01:00
if ( ! is_array ( $this -> userassigned ) && ! empty ( $this -> userassigned )) { // For backward compatibility when userassigned was an int instead of an array
$tmpid = ( int ) $this -> userassigned ;
2020-09-07 10:18:17 +02:00
$this -> userassigned = array ();
2024-03-09 16:32:02 +01:00
$this -> userassigned [ $tmpid ] = array ( 'id' => $tmpid , 'transparency' => $this -> transparency );
2020-09-07 10:18:17 +02:00
}
2015-01-18 11:48:52 +01:00
2020-09-07 10:18:17 +02:00
$userownerid = $this -> userownerid ;
2014-09-26 12:27:18 +02:00
2020-09-07 10:18:17 +02:00
// Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...).
2021-02-23 18:59:19 +01:00
if ( empty ( $this -> userassigned ) || count ( $this -> userassigned ) == 0 || ! is_array ( $this -> userassigned )) {
2024-03-09 16:32:02 +01:00
$this -> userassigned = array ( $userownerid => array ( 'id' => $userownerid , 'transparency' => $this -> transparency ));
2021-02-23 18:59:19 +01:00
}
2015-01-15 02:06:04 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $this -> type_id || ! $this -> type_code ) {
2020-09-07 10:18:17 +02:00
$key = empty ( $this -> type_id ) ? $this -> type_code : $this -> type_id ;
2014-10-05 04:51:34 +02:00
2020-09-07 10:18:17 +02:00
// Get id from code
$cactioncomm = new CActionComm ( $this -> db );
$result = $cactioncomm -> fetch ( $key );
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( $result > 0 ) {
2020-09-07 10:18:17 +02:00
$this -> type_id = $cactioncomm -> id ;
$this -> type_code = $cactioncomm -> code ;
2021-02-23 18:59:19 +01:00
} elseif ( $result == 0 ) {
2021-03-26 19:00:56 +01:00
$this -> error = $langs -> trans ( 'ErrorActionCommBadType' , $this -> type_id , $this -> type_code );
2020-09-07 10:18:17 +02:00
return - 1 ;
} else {
$this -> error = $cactioncomm -> error ;
return - 1 ;
}
}
$code = empty ( $this -> code ) ? $this -> type_code : $this -> code ;
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
// Check parameters
2021-02-23 18:59:19 +01:00
if ( ! $this -> type_id ) {
2020-09-07 10:18:17 +02:00
$this -> error = " ErrorWrongParameters " ;
return - 1 ;
}
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$this -> db -> begin ();
2008-02-29 17:26:38 +01:00
2020-09-07 10:18:17 +02:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm " ;
2021-03-04 07:53:32 +01:00
$sql .= " (ref, " ;
$sql .= " datec, " ;
2020-09-07 10:18:17 +02:00
$sql .= " datep, " ;
$sql .= " datep2, " ;
$sql .= " durationp, " ; // deprecated
$sql .= " fk_action, " ;
$sql .= " code, " ;
2021-02-23 18:59:19 +01:00
$sql .= " ref_ext, " ;
2020-09-07 10:18:17 +02:00
$sql .= " fk_soc, " ;
$sql .= " fk_project, " ;
$sql .= " note, " ;
$sql .= " fk_contact, " ;
$sql .= " fk_user_author, " ;
$sql .= " fk_user_action, " ;
$sql .= " label,percent,priority,fulldayevent,location, " ;
$sql .= " transparency, " ;
$sql .= " fk_element, " ;
$sql .= " elementtype, " ;
2023-11-21 23:12:44 +01:00
$sql .= " fk_bookcal_calendar, " ;
2020-09-07 10:18:17 +02:00
$sql .= " entity, " ;
$sql .= " extraparams, " ;
2018-11-19 14:25:34 +01:00
// Fields emails
2020-09-07 10:18:17 +02:00
$sql .= " email_msgid, " ;
$sql .= " email_from, " ;
$sql .= " email_sender, " ;
$sql .= " email_to, " ;
$sql .= " email_tocc, " ;
$sql .= " email_tobcc, " ;
$sql .= " email_subject, " ;
2021-03-02 22:23:54 +01:00
$sql .= " errors_to, " ;
2022-11-08 03:01:32 +01:00
$sql .= " recurid, " ;
$sql .= " recurrule, " ;
$sql .= " recurdateend, " ;
2021-03-02 22:23:54 +01:00
$sql .= " num_vote, " ;
$sql .= " event_paid, " ;
2022-11-23 19:51:17 +01:00
$sql .= " status, " ;
$sql .= " ip " ;
2020-09-07 10:18:17 +02:00
$sql .= " ) VALUES ( " ;
2021-03-04 07:53:32 +01:00
$sql .= " '(PROV)', " ;
2023-05-12 13:06:36 +02:00
$sql .= " ' " . $this -> db -> idate ( $now ) . " ', " ; // date creation
$sql .= " ' " . $this -> db -> idate ( $this -> datep ) . " ', " ; // date start event
2020-09-07 10:18:17 +02:00
$sql .= ( strval ( $this -> datef ) != '' ? " ' " . $this -> db -> idate ( $this -> datef ) . " ' " : " null " ) . " , " ;
$sql .= (( isset ( $this -> durationp ) && $this -> durationp >= 0 && $this -> durationp != '' ) ? " ' " . $this -> db -> escape ( $this -> durationp ) . " ' " : " null " ) . " , " ; // deprecated
$sql .= ( isset ( $this -> type_id ) ? $this -> type_id : " null " ) . " , " ;
$sql .= ( $code ? ( " ' " . $this -> db -> escape ( $code ) . " ' " ) : " null " ) . " , " ;
2020-09-29 19:56:22 +02:00
$sql .= ( ! empty ( $this -> ref_ext ) ? " ' " . $this -> db -> escape ( $this -> ref_ext ) . " ' " : " null " ) . " , " ;
2021-08-27 22:42:04 +02:00
$sql .= (( isset ( $this -> socid ) && $this -> socid > 0 ) ? (( int ) $this -> socid ) : " null " ) . " , " ;
$sql .= (( isset ( $this -> fk_project ) && $this -> fk_project > 0 ) ? (( int ) $this -> fk_project ) : " null " ) . " , " ;
2020-09-07 10:18:17 +02:00
$sql .= " ' " . $this -> db -> escape ( $this -> note_private ) . " ', " ;
2021-08-27 22:42:04 +02:00
$sql .= (( isset ( $this -> contact_id ) && $this -> contact_id > 0 ) ? (( int ) $this -> contact_id ) : " null " ) . " , " ; // deprecated, use ->socpeopleassigned
2020-09-07 10:18:17 +02:00
$sql .= ( isset ( $user -> id ) && $user -> id > 0 ? $user -> id : " null " ) . " , " ;
$sql .= ( $userownerid > 0 ? $userownerid : " null " ) . " , " ;
2022-01-29 00:39:20 +01:00
$sql .= " ' " . $this -> db -> escape ( $this -> label ) . " ', " ;
$sql .= " ' " . $this -> db -> escape ( $this -> percentage ) . " ', " ;
$sql .= " ' " . $this -> db -> escape ( $this -> priority ) . " ', " ;
$sql .= " ' " . $this -> db -> escape ( $this -> fulldayevent ) . " ', " ;
$sql .= " ' " . $this -> db -> escape ( $this -> location ) . " ', " ;
2020-09-07 10:18:17 +02:00
$sql .= " ' " . $this -> db -> escape ( $this -> transparency ) . " ', " ;
2021-08-27 22:42:04 +02:00
$sql .= ( ! empty ( $this -> fk_element ) ? (( int ) $this -> fk_element ) : " null " ) . " , " ;
2020-09-07 10:18:17 +02:00
$sql .= ( ! empty ( $this -> elementtype ) ? " ' " . $this -> db -> escape ( $this -> elementtype ) . " ' " : " null " ) . " , " ;
2023-11-21 23:12:44 +01:00
$sql .= ( ! empty ( $this -> fk_bookcal_calendar ) ? " ' " . $this -> db -> escape ( $this -> fk_bookcal_calendar ) . " ' " : " null " ) . " , " ;
2021-08-27 22:42:04 +02:00
$sql .= (( int ) $conf -> entity ) . " , " ;
2020-09-07 10:18:17 +02:00
$sql .= ( ! empty ( $this -> extraparams ) ? " ' " . $this -> db -> escape ( $this -> extraparams ) . " ' " : " null " ) . " , " ;
// Fields emails
$sql .= ( ! empty ( $this -> email_msgid ) ? " ' " . $this -> db -> escape ( $this -> email_msgid ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> email_from ) ? " ' " . $this -> db -> escape ( $this -> email_from ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> email_sender ) ? " ' " . $this -> db -> escape ( $this -> email_sender ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> email_to ) ? " ' " . $this -> db -> escape ( $this -> email_to ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> email_tocc ) ? " ' " . $this -> db -> escape ( $this -> email_tocc ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> email_tobcc ) ? " ' " . $this -> db -> escape ( $this -> email_tobcc ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> email_subject ) ? " ' " . $this -> db -> escape ( $this -> email_subject ) . " ' " : " null " ) . " , " ;
2021-03-02 22:23:54 +01:00
$sql .= ( ! empty ( $this -> errors_to ) ? " ' " . $this -> db -> escape ( $this -> errors_to ) . " ' " : " null " ) . " , " ;
2022-11-08 03:01:32 +01:00
$sql .= ( ! empty ( $this -> recurid ) ? " ' " . $this -> db -> escape ( $this -> recurid ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> recurrule ) ? " ' " . $this -> db -> escape ( $this -> recurrule ) . " ' " : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> recurdateend ) ? " ' " . $this -> db -> idate ( $this -> recurdateend ) . " ' " : " null " ) . " , " ;
2021-03-02 22:23:54 +01:00
$sql .= ( ! empty ( $this -> num_vote ) ? ( int ) $this -> num_vote : " null " ) . " , " ;
$sql .= ( ! empty ( $this -> event_paid ) ? ( int ) $this -> event_paid : 0 ) . " , " ;
2022-11-23 19:51:17 +01:00
$sql .= ( ! empty ( $this -> status ) ? ( int ) $this -> status : " 0 " ) . " , " ;
$sql .= ( ! empty ( $this -> ip ) ? " ' " . $this -> db -> escape ( $this -> ip ) . " ' " : " null " );
2020-09-07 10:18:17 +02:00
$sql .= " ) " ;
dol_syslog ( get_class ( $this ) . " ::add " , LOG_DEBUG );
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2024-03-03 18:55:30 +01:00
$this -> id = $this -> db -> last_insert_id ( MAIN_DB_PREFIX . " actioncomm " , " id " );
$this -> ref = ( string ) $this -> id ;
2021-03-03 16:28:14 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " actioncomm SET ref=' " . $this -> db -> escape ( $this -> ref ) . " ' WHERE id= " . $this -> id ;
2021-03-02 22:23:54 +01:00
$resql = $this -> db -> query ( $sql );
if ( ! $resql ) {
$error ++ ;
dol_syslog ( 'Error to process ref: ' . $this -> db -> lasterror (), LOG_ERR );
$this -> errors [] = $this -> db -> lasterror ();
}
2020-09-07 10:18:17 +02:00
// Now insert assigned users
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-01-01 12:47:01 +01:00
//dol_syslog(var_export($this->userassigned, true));
2021-04-07 09:49:20 +02:00
$already_inserted = array ();
2021-02-23 18:59:19 +01:00
foreach ( $this -> userassigned as $key => $val ) {
2021-08-28 05:24:53 +02:00
// Common value with new behavior is to have $val = array('id'=>iduser, 'transparency'=>0|1) and $this->userassigned is an array of iduser => $val.
if ( ! is_array ( $val )) { // For backward compatibility when $val='id'.
2024-03-09 16:32:02 +01:00
$val = array ( 'id' => $val );
2020-09-07 10:18:17 +02:00
}
2015-02-25 15:01:25 +01:00
2021-02-23 18:59:19 +01:00
if ( $val [ 'id' ] > 0 ) {
2021-08-28 05:24:53 +02:00
if ( ! empty ( $already_inserted [ $val [ 'id' ]])) {
continue ;
}
2021-04-07 09:49:20 +02:00
2020-01-01 12:47:01 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status) " ;
2021-08-27 22:42:04 +02:00
$sql .= " VALUES( " . (( int ) $this -> id ) . " , 'user', " . (( int ) $val [ 'id' ]) . " , " . ( empty ( $val [ 'mandatory' ]) ? '0' : (( int ) $val [ 'mandatory' ])) . " , " . ( empty ( $val [ 'transparency' ]) ? '0' : (( int ) $val [ 'transparency' ])) . " , " . ( empty ( $val [ 'answer_status' ]) ? '0' : (( int ) $val [ 'answer_status' ])) . " ) " ;
2014-09-23 12:18:42 +02:00
2020-01-01 12:47:01 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( ! $resql ) {
2021-04-07 09:49:20 +02:00
$error ++ ;
dol_syslog ( 'Error to process userassigned: ' . $this -> db -> lasterror (), LOG_ERR );
$this -> errors [] = $this -> db -> lasterror ();
} else {
$already_inserted [ $val [ 'id' ]] = true ;
2020-01-01 12:47:01 +01:00
}
2021-03-03 21:11:04 +01:00
//var_dump($sql);exit;
2020-09-07 10:18:17 +02:00
}
2014-09-23 12:18:42 +02:00
}
}
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
if ( ! empty ( $this -> socpeopleassigned )) {
2021-04-07 09:49:20 +02:00
$already_inserted = array ();
2021-02-23 18:59:19 +01:00
foreach ( $this -> socpeopleassigned as $id => $val ) {
2023-08-16 17:55:44 +02:00
// Common value with new behavior is to have $this->socpeopleassigned an array of idcontact => dummyvalue
2021-08-28 05:24:53 +02:00
if ( ! empty ( $already_inserted [ $id ])) {
continue ;
}
2021-04-07 09:49:20 +02:00
2019-11-14 12:09:15 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status) " ;
2021-08-27 22:42:04 +02:00
$sql .= " VALUES( " . (( int ) $this -> id ) . " , 'socpeople', " . (( int ) $id ) . " , 0, 0, 0) " ;
2017-11-22 14:42:47 +01:00
2017-06-06 17:43:22 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( ! $resql ) {
2021-04-07 09:49:20 +02:00
$error ++ ;
dol_syslog ( 'Error to process socpeopleassigned: ' . $this -> db -> lasterror (), LOG_ERR );
$this -> errors [] = $this -> db -> lasterror ();
} else {
2021-08-28 05:24:53 +02:00
$already_inserted [ $id ] = true ;
2017-06-06 17:43:22 +02:00
}
}
}
}
2017-11-22 14:42:47 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-07 10:18:17 +02:00
// Actions on extra fields
2021-02-23 18:59:19 +01:00
$result = $this -> insertExtraFields ();
if ( $result < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
}
2012-12-10 19:06:59 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error && ! $notrigger ) {
2020-09-07 10:18:17 +02:00
// Call trigger
$result = $this -> call_trigger ( 'ACTION_CREATE' , $user );
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
// End call triggers
}
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-07 10:18:17 +02:00
$this -> db -> commit ();
return $this -> id ;
} else {
$this -> db -> rollback ();
return - 1 ;
}
} else {
$this -> db -> rollback ();
$this -> error = $this -> db -> lasterror ();
return - 1 ;
}
}
2004-10-30 00:31:33 +02:00
2020-09-07 10:18:17 +02:00
/**
* Load an object from its id and create a new one in database
*
* @ param User $fuser Object user making action
2019-02-27 20:45:07 +01:00
* @ param int $socid Id of thirdparty
2020-09-07 10:18:17 +02:00
* @ return int New id of clone
*/
public function createFromClone ( User $fuser , $socid )
{
2022-11-29 14:45:35 +01:00
global $hookmanager ;
2015-06-19 11:21:36 +02:00
2020-09-07 10:18:17 +02:00
$error = 0 ;
2015-06-08 12:39:25 +02:00
2020-09-07 10:18:17 +02:00
$this -> db -> begin ();
2015-06-08 12:39:25 +02:00
2015-09-24 16:32:48 +02:00
// Load source object
$objFrom = clone $this ;
2015-06-19 11:21:36 +02:00
2020-10-23 20:08:35 +02:00
// Retrieve all extrafield
2018-02-20 19:38:18 +01:00
// fetch optionals attributes and labels
2015-06-08 15:06:43 +02:00
$this -> fetch_optionals ();
2018-02-20 19:38:18 +01:00
2019-02-27 20:45:07 +01:00
//$this->fetch_userassigned();
2017-06-06 17:43:22 +02:00
$this -> fetchResources ();
2015-06-19 11:21:36 +02:00
2020-09-08 21:27:28 +02:00
$this -> id = 0 ;
2022-11-08 03:01:32 +01:00
$this -> recurid = '' ;
$this -> recurrule = '' ;
$this -> recurdateend = '' ;
2015-06-08 12:39:25 +02:00
2020-09-08 21:27:28 +02:00
// Create clone
2019-11-14 12:09:15 +01:00
$this -> context [ 'createfromclone' ] = 'createfromclone' ;
$result = $this -> create ( $fuser );
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-09-08 21:27:28 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-08 21:27:28 +02:00
// Hook of thirdparty module
2021-02-23 18:59:19 +01:00
if ( is_object ( $hookmanager )) {
2024-03-09 16:32:02 +01:00
$parameters = array ( 'objFrom' => $objFrom );
2020-09-08 21:27:28 +02:00
$action = '' ;
$reshook = $hookmanager -> executeHooks ( 'createFrom' , $parameters , $this , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 18:59:19 +01:00
if ( $reshook < 0 ) {
2023-02-24 16:50:41 +01:00
$this -> setErrorsFromObject ( $hookmanager );
2021-02-23 18:59:19 +01:00
$error ++ ;
}
2020-09-08 21:27:28 +02:00
}
// Call trigger
$result = $this -> call_trigger ( 'ACTION_CLONE' , $fuser );
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-09-08 21:27:28 +02:00
// End call triggers
}
unset ( $this -> context [ 'createfromclone' ]);
// End
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-08 21:27:28 +02:00
$this -> db -> commit ();
return $this -> id ;
} else {
$this -> db -> rollback ();
return - 1 ;
}
}
/**
* Load object from database
*
2024-04-02 01:48:30 +02:00
* @ param int $id Id of action to get
* @ param string $ref Ref of action to get
* @ param string $ref_ext Ref ext to get
* @ param string $email_msgid Email msgid
* @ param int < 0 , 1 > $loadresources 1 = Load also resources
* @ return int <- 1 , 1 > Return integer < 0 if KO , > 0 if OK
2021-09-17 12:29:58 +02:00
*/
public function fetch ( $id , $ref = '' , $ref_ext = '' , $email_msgid = '' , $loadresources = 1 )
2020-09-08 21:27:28 +02:00
{
global $langs ;
2021-06-14 20:06:52 +02:00
if ( empty ( $id ) && empty ( $ref ) && empty ( $ref_ext ) && empty ( $email_msgid )) {
2021-06-14 20:13:27 +02:00
dol_syslog ( get_class ( $this ) . " ::fetch Bad parameters " , LOG_WARNING );
2021-06-14 20:06:52 +02:00
return - 1 ;
}
2020-09-08 21:27:28 +02:00
$sql = " SELECT a.id, " ;
2021-03-02 22:23:54 +01:00
$sql .= " a.ref as ref, " ;
2020-09-08 21:27:28 +02:00
$sql .= " a.entity, " ;
$sql .= " a.ref_ext, " ;
$sql .= " a.datep, " ;
$sql .= " a.datep2, " ;
$sql .= " a.durationp, " ; // deprecated
$sql .= " a.datec, " ;
$sql .= " a.tms as datem, " ;
2021-06-22 11:38:02 +02:00
$sql .= " a.code, a.label, a.note as note_private, " ;
2020-09-08 21:27:28 +02:00
$sql .= " a.fk_soc, " ;
$sql .= " a.fk_project, " ;
$sql .= " a.fk_user_author, a.fk_user_mod, " ;
2024-03-14 13:39:43 +01:00
$sql .= " a.fk_user_action, " ;
2020-09-08 21:27:28 +02:00
$sql .= " a.fk_contact, a.percent as percentage, " ;
$sql .= " a.fk_element as elementid, a.elementtype, " ;
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency, " ;
2022-04-09 03:26:38 +02:00
$sql .= " a.email_msgid, a.email_subject, a.email_from, a.email_sender, a.email_to, a.email_tocc, a.email_tobcc, a.errors_to, " ;
2021-03-17 11:34:19 +01:00
$sql .= " c.id as type_id, c.type as type_type, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto, " ;
2020-09-08 21:27:28 +02:00
$sql .= " s.nom as socname, " ;
2021-03-03 21:40:37 +01:00
$sql .= " u.firstname, u.lastname as lastname, " ;
2021-03-03 22:18:42 +01:00
$sql .= " num_vote, event_paid, a.status " ;
2020-09-08 21:27:28 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_actioncomm as c ON a.fk_action=c.id " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user as u on u.rowid = a.fk_user_author " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on s.rowid = a.fk_soc " ;
$sql .= " WHERE " ;
2021-02-23 18:59:19 +01:00
if ( $ref ) {
2021-03-02 22:23:54 +01:00
$sql .= " a.ref = ' " . $this -> db -> escape ( $ref ) . " ' " ;
2021-02-23 18:59:19 +01:00
} elseif ( $ref_ext ) {
$sql .= " a.ref_ext = ' " . $this -> db -> escape ( $ref_ext ) . " ' " ;
} elseif ( $email_msgid ) {
$sql .= " a.email_msgid = ' " . $this -> db -> escape ( $email_msgid ) . " ' " ;
} else {
$sql .= " a.id = " . (( int ) $id );
}
2020-09-08 21:27:28 +02:00
dol_syslog ( get_class ( $this ) . " ::fetch " , LOG_DEBUG );
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2020-09-08 21:27:28 +02:00
$num = $this -> db -> num_rows ( $resql );
2021-02-23 18:59:19 +01:00
if ( $num ) {
2020-09-08 21:27:28 +02:00
$obj = $this -> db -> fetch_object ( $resql );
$this -> id = $obj -> id ;
2020-09-07 10:18:17 +02:00
$this -> entity = $obj -> entity ;
2020-09-08 21:27:28 +02:00
$this -> ref = $obj -> ref ;
$this -> ref_ext = $obj -> ref_ext ;
// Properties of parent table llx_c_actioncomm
$this -> type_id = $obj -> type_id ;
$this -> type_code = $obj -> type_code ;
$this -> type_color = $obj -> type_color ;
$this -> type_picto = $obj -> type_picto ;
2021-03-17 11:34:19 +01:00
$this -> type = $obj -> type_type ;
2024-09-26 17:47:49 +02:00
$this -> type_label = $obj -> type_label ;
2013-03-09 20:34:38 +01:00
2019-11-14 12:09:15 +01:00
$this -> code = $obj -> code ;
2020-09-08 21:27:28 +02:00
$this -> label = $obj -> label ;
$this -> datep = $this -> db -> jdate ( $obj -> datep );
$this -> datef = $this -> db -> jdate ( $obj -> datep2 );
$this -> datec = $this -> db -> jdate ( $obj -> datec );
$this -> datem = $this -> db -> jdate ( $obj -> datem );
2021-06-22 11:38:02 +02:00
$this -> note = $obj -> note_private ; // deprecated
$this -> note_private = $obj -> note_private ;
2020-09-08 21:27:28 +02:00
$this -> percentage = $obj -> percentage ;
$this -> authorid = $obj -> fk_user_author ;
$this -> usermodid = $obj -> fk_user_mod ;
2021-02-23 18:59:19 +01:00
if ( ! is_object ( $this -> author )) {
2022-01-18 14:00:38 +01:00
$this -> author = new User ( $this -> db ); // To avoid warning
2021-02-23 18:59:19 +01:00
}
2020-09-08 21:27:28 +02:00
$this -> author -> id = $obj -> fk_user_author ; // deprecated
$this -> author -> firstname = $obj -> firstname ; // deprecated
$this -> author -> lastname = $obj -> lastname ; // deprecated
2021-02-23 18:59:19 +01:00
if ( ! is_object ( $this -> usermod )) {
2022-01-18 14:00:38 +01:00
$this -> usermod = new User ( $this -> db ); // To avoid warning
2021-02-23 18:59:19 +01:00
}
2020-09-08 21:27:28 +02:00
$this -> usermod -> id = $obj -> fk_user_mod ; // deprecated
$this -> userownerid = $obj -> fk_user_action ;
$this -> priority = $obj -> priority ;
$this -> fulldayevent = $obj -> fulldayevent ;
$this -> location = $obj -> location ;
$this -> transparency = $obj -> transparency ;
$this -> socid = $obj -> fk_soc ; // To have fetch_thirdparty method working
$this -> contact_id = $obj -> fk_contact ; // To have fetch_contact method working
$this -> fk_project = $obj -> fk_project ; // To have fetch_projet method working
//$this->societe->id = $obj->fk_soc; // deprecated
//$this->contact->id = $obj->fk_contact; // deprecated
$this -> fk_element = $obj -> elementid ;
$this -> elementid = $obj -> elementid ;
$this -> elementtype = $obj -> elementtype ;
2021-03-02 22:23:54 +01:00
$this -> num_vote = $obj -> num_vote ;
$this -> event_paid = $obj -> event_paid ;
$this -> status = $obj -> status ;
2022-04-07 13:28:24 +02:00
//email information
2024-03-09 16:32:02 +01:00
$this -> email_msgid = $obj -> email_msgid ;
$this -> email_from = $obj -> email_from ;
$this -> email_sender = $obj -> email_sender ;
$this -> email_to = $obj -> email_to ;
$this -> email_tocc = $obj -> email_tocc ;
$this -> email_tobcc = $obj -> email_tobcc ;
$this -> email_subject = $obj -> email_subject ;
$this -> errors_to = $obj -> errors_to ;
2022-04-07 13:28:24 +02:00
2021-09-17 19:42:41 +02:00
$this -> fetch_optionals ();
2021-09-17 12:21:25 +02:00
2021-09-17 19:42:41 +02:00
if ( $loadresources ) {
$this -> fetchResources ();
}
2020-09-08 21:27:28 +02:00
}
2021-09-30 16:28:42 +02:00
2020-09-08 21:27:28 +02:00
$this -> db -> free ( $resql );
} else {
$this -> error = $this -> db -> lasterror ();
return - 1 ;
}
return $num ;
}
/**
* Initialize $this -> userassigned & this -> socpeopleassigned array with list of id of user and contact assigned to event
*
2024-04-02 01:48:30 +02:00
* @ return int <- 1 , 1 > Return integer < 0 if KO , > 0 if OK
2020-09-08 21:27:28 +02:00
*/
public function fetchResources ()
{
$this -> userassigned = array ();
$this -> socpeopleassigned = array ();
$sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency' ;
2019-11-14 12:09:15 +01:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm_resources' ;
2021-08-23 19:33:24 +02:00
$sql .= ' WHERE fk_actioncomm = ' . (( int ) $this -> id );
2019-11-14 12:09:15 +01:00
$sql .= " AND element_type IN ('user', 'socpeople') " ;
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2017-06-06 17:43:22 +02:00
// If owner is known, we must but id first into list
2021-02-23 18:59:19 +01:00
if ( $this -> userownerid > 0 ) {
2024-03-09 16:32:02 +01:00
$this -> userassigned [ $this -> userownerid ] = array ( 'id' => $this -> userownerid ); // Set first so will be first into list.
2021-02-23 18:59:19 +01:00
}
2017-06-06 17:43:22 +02:00
2021-02-23 18:59:19 +01:00
while ( $obj = $this -> db -> fetch_object ( $resql )) {
if ( $obj -> fk_element > 0 ) {
2017-06-06 17:43:22 +02:00
switch ( $obj -> element_type ) {
case 'user' :
2024-03-09 16:32:02 +01:00
$this -> userassigned [ $obj -> fk_element ] = array ( 'id' => $obj -> fk_element , 'mandatory' => $obj -> mandatory , 'answer_status' => $obj -> answer_status , 'transparency' => $obj -> transparency );
2021-02-23 18:59:19 +01:00
if ( empty ( $this -> userownerid )) {
$this -> userownerid = $obj -> fk_element ; // If not defined (should not happened, we fix this)
}
2017-06-06 17:43:22 +02:00
break ;
case 'socpeople' :
2024-03-09 16:32:02 +01:00
$this -> socpeopleassigned [ $obj -> fk_element ] = array ( 'id' => $obj -> fk_element , 'mandatory' => $obj -> mandatory , 'answer_status' => $obj -> answer_status , 'transparency' => $obj -> transparency );
2017-06-06 17:43:22 +02:00
break ;
}
}
2020-09-07 10:18:17 +02:00
}
2017-06-06 17:43:22 +02:00
2020-09-07 10:18:17 +02:00
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2017-06-06 17:43:22 +02:00
dol_print_error ( $this -> db );
return - 1 ;
}
}
2014-09-23 16:15:15 +02:00
2020-09-07 10:18:17 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Initialize this -> userassigned array with list of id of user assigned to event
*
* @ param bool $override Override $this -> userownerid when empty . TODO This should be false by default . True is here to fix corrupted data .
2024-04-02 01:48:30 +02:00
* @ return int <- 1 , 1 > Return integer < 0 if KO , > 0 if OK
2020-09-07 10:18:17 +02:00
*/
public function fetch_userassigned ( $override = true )
{
// phpcs:enable
$sql = " SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm_resources " ;
2021-08-23 17:41:11 +02:00
$sql .= " WHERE element_type = 'user' AND fk_actioncomm = " . (( int ) $this -> id );
2014-09-26 12:27:18 +02:00
2020-09-07 10:18:17 +02:00
$resql2 = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql2 ) {
2020-09-07 10:18:17 +02:00
$this -> userassigned = array ();
2019-11-07 15:45:34 +01:00
2020-09-07 10:18:17 +02:00
// If owner is known, we must but id first into list
2021-02-23 18:59:19 +01:00
if ( $this -> userownerid > 0 ) {
2020-09-07 10:18:17 +02:00
// Set first so will be first into list.
2024-03-09 16:32:02 +01:00
$this -> userassigned [ $this -> userownerid ] = array ( 'id' => $this -> userownerid );
2020-09-07 10:18:17 +02:00
}
2014-09-26 12:27:18 +02:00
2021-02-23 18:59:19 +01:00
while ( $obj = $this -> db -> fetch_object ( $resql2 )) {
if ( $obj -> fk_element > 0 ) {
2024-03-09 16:32:02 +01:00
$this -> userassigned [ $obj -> fk_element ] = array ( 'id' => $obj -> fk_element ,
'mandatory' => $obj -> mandatory ,
'answer_status' => $obj -> answer_status ,
'transparency' => $obj -> transparency );
2020-09-07 10:18:17 +02:00
}
2014-10-03 18:25:38 +02:00
2021-02-23 18:59:19 +01:00
if ( $override === true ) {
2020-09-07 10:18:17 +02:00
// If not defined (should not happened, we fix this)
2021-02-23 18:59:19 +01:00
if ( empty ( $this -> userownerid )) {
2020-09-07 10:18:17 +02:00
$this -> userownerid = $obj -> fk_element ;
}
}
}
2014-09-23 16:15:15 +02:00
2020-09-07 10:18:17 +02:00
return 1 ;
} else {
dol_print_error ( $this -> db );
return - 1 ;
}
}
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
/**
* Delete event from database
*
2024-04-02 01:48:30 +02:00
* @ param User $user User making the delete
* @ param int < 0 , 1 > $notrigger 1 = disable triggers , 0 = enable triggers
2024-04-02 13:52:51 +02:00
* @ return int <- 2 , 1 > Return integer < 0 if KO , > 0 if OK
2020-09-07 10:18:17 +02:00
*/
2024-03-07 17:58:02 +01:00
public function delete ( $user , $notrigger = 0 )
2020-09-07 10:18:17 +02:00
{
$error = 0 ;
2020-04-12 17:05:12 +02:00
2020-09-07 10:18:17 +02:00
dol_syslog ( get_class ( $this ) . " ::delete " , LOG_DEBUG );
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$this -> db -> begin ();
// remove categorie association
if ( ! $error ) {
2020-04-12 17:08:44 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " categorie_actioncomm " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE fk_actioncomm= " . (( int ) $this -> id );
2020-04-12 17:08:44 +02:00
$res = $this -> db -> query ( $sql );
if ( ! $res ) {
$this -> error = $this -> db -> lasterror ();
$error ++ ;
}
2020-09-07 10:18:17 +02:00
}
2020-04-12 17:08:44 +02:00
2020-09-07 10:18:17 +02:00
// remove actioncomm_resources
if ( ! $error ) {
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " actioncomm_resources " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE fk_actioncomm= " . (( int ) $this -> id );
2019-02-27 20:45:07 +01:00
2020-09-07 10:18:17 +02:00
$res = $this -> db -> query ( $sql );
if ( ! $res ) {
$this -> error = $this -> db -> lasterror ();
$error ++ ;
}
}
2017-07-04 10:29:38 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-24 15:26:35 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " actioncomm_reminder " ;
2021-08-23 19:33:24 +02:00
$sql .= " WHERE fk_actioncomm = " . (( int ) $this -> id );
2020-09-24 15:26:35 +02:00
$res = $this -> db -> query ( $sql );
if ( ! $res ) {
$this -> error = $this -> db -> lasterror ();
$error ++ ;
}
}
2020-09-07 10:18:17 +02:00
// Removed extrafields
if ( ! $error ) {
2023-12-04 12:01:45 +01:00
$result = $this -> deleteExtraFields ();
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
$error ++ ;
dol_syslog ( get_class ( $this ) . " ::delete error -3 " . $this -> error , LOG_ERR );
}
2020-09-07 10:18:17 +02:00
}
2012-12-10 19:06:59 +01:00
2020-09-07 10:18:17 +02:00
// remove actioncomm
if ( ! $error ) {
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " actioncomm " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE id= " . (( int ) $this -> id );
2020-04-12 17:07:57 +02:00
2020-09-07 10:18:17 +02:00
$res = $this -> db -> query ( $sql );
if ( ! $res ) {
$this -> error = $this -> db -> lasterror ();
$error ++ ;
}
}
2020-04-12 17:07:57 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
if ( ! $notrigger ) {
2020-09-07 10:18:17 +02:00
// Call trigger
$result = $this -> call_trigger ( 'ACTION_DELETE' , $user );
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
// End call triggers
}
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-07 10:18:17 +02:00
$this -> db -> commit ();
return 1 ;
} else {
$this -> db -> rollback ();
return - 2 ;
}
} else {
$this -> db -> rollback ();
$this -> error = $this -> db -> lasterror ();
return - 1 ;
}
}
2004-10-30 00:31:33 +02:00
2020-09-07 10:18:17 +02:00
/**
* Update action into database
* If percentage = 100 , on met a jour date 100 %
*
2024-04-02 01:48:30 +02:00
* @ param User $user Object user making change
* @ param int < 0 , 1 > $notrigger 1 = disable triggers , 0 = enable triggers
2024-04-02 13:52:51 +02:00
* @ return int <- 2 , 1 > Return integer < 0 if KO , > 0 if OK
2020-09-07 10:18:17 +02:00
*/
2021-03-11 19:09:42 +01:00
public function update ( User $user , $notrigger = 0 )
2020-09-07 10:18:17 +02:00
{
$error = 0 ;
// Clean parameters
$this -> label = trim ( $this -> label );
2020-11-22 02:32:47 +01:00
$this -> note_private = dol_htmlcleanlastbr ( trim ( ! isset ( $this -> note_private ) ? $this -> note : $this -> note_private ));
2021-02-23 18:59:19 +01:00
if ( empty ( $this -> percentage )) {
$this -> percentage = 0 ;
}
if ( empty ( $this -> priority ) || ! is_numeric ( $this -> priority )) {
$this -> priority = 0 ;
}
if ( empty ( $this -> transparency )) {
$this -> transparency = 0 ;
}
if ( empty ( $this -> fulldayevent )) {
$this -> fulldayevent = 0 ;
}
if ( $this -> percentage > 100 ) {
$this -> percentage = 100 ;
}
2020-09-07 10:18:17 +02:00
//if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date;
2021-02-23 18:59:19 +01:00
if ( $this -> datep && $this -> datef ) {
$this -> durationp = ( $this -> datef - $this -> datep ); // deprecated
}
2020-09-07 10:18:17 +02:00
//if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date);
2021-02-23 18:59:19 +01:00
if ( $this -> datep && $this -> datef && $this -> datep > $this -> datef ) {
$this -> datef = $this -> datep ;
}
2020-09-07 10:18:17 +02:00
//if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date;
2021-02-23 18:59:19 +01:00
if ( $this -> fk_project < 0 ) {
$this -> fk_project = 0 ;
}
2020-09-07 10:18:17 +02:00
$socid = (( $this -> socid > 0 ) ? $this -> socid : 0 );
$contactid = (( $this -> contact_id > 0 ) ? $this -> contact_id : 0 );
2019-11-14 12:09:15 +01:00
$userownerid = ( $this -> userownerid ? $this -> userownerid : 0 );
2014-10-03 15:58:08 +02:00
2022-11-29 13:04:13 +01:00
// If a type_id is set, we must also have the type_code set
2021-02-23 18:59:19 +01:00
if ( $this -> type_id > 0 ) {
2022-06-02 21:28:17 +02:00
if ( empty ( $this -> type_code )) {
$cactioncomm = new CActionComm ( $this -> db );
$result = $cactioncomm -> fetch ( $this -> type_id );
2022-06-02 21:29:27 +02:00
if ( $result >= 0 && ! empty ( $cactioncomm -> code )) {
2022-06-02 21:28:17 +02:00
$this -> type_code = $cactioncomm -> code ;
}
2022-06-02 15:20:00 +02:00
}
2021-02-23 18:59:19 +01:00
}
2022-11-29 13:04:13 +01:00
$code = $this -> code ;
2022-11-29 14:45:35 +01:00
if ( empty ( $code ) || ( ! empty ( $this -> oldcopy ) && $this -> oldcopy -> type_code != $this -> type_code )) { // If code unknown or if we change the type, we reset $code too
2022-11-29 13:04:13 +01:00
$code = $this -> type_code ;
}
$this -> db -> begin ();
$sql = " UPDATE " . MAIN_DB_PREFIX . " actioncomm " ;
$sql .= " SET percent = ' " . $this -> db -> escape ( $this -> percentage ) . " ' " ;
$sql .= " , fk_action = " . ( int ) $this -> type_id ;
$sql .= " , code = " . ( $code ? " ' " . $this -> db -> escape ( $code ) . " ' " : " null " );
2020-09-07 10:18:17 +02:00
$sql .= " , label = " . ( $this -> label ? " ' " . $this -> db -> escape ( $this -> label ) . " ' " : " null " );
$sql .= " , datep = " . ( strval ( $this -> datep ) != '' ? " ' " . $this -> db -> idate ( $this -> datep ) . " ' " : 'null' );
$sql .= " , datep2 = " . ( strval ( $this -> datef ) != '' ? " ' " . $this -> db -> idate ( $this -> datef ) . " ' " : 'null' );
$sql .= " , durationp = " . ( isset ( $this -> durationp ) && $this -> durationp >= 0 && $this -> durationp != '' ? " ' " . $this -> db -> escape ( $this -> durationp ) . " ' " : " null " ); // deprecated
$sql .= " , note = ' " . $this -> db -> escape ( $this -> note_private ) . " ' " ;
2022-01-18 14:00:38 +01:00
$sql .= " , fk_project = " . ( $this -> fk_project > 0 ? (( int ) $this -> fk_project ) : " null " );
$sql .= " , fk_soc = " . ( $socid > 0 ? (( int ) $socid ) : " null " );
$sql .= " , fk_contact = " . ( $contactid > 0 ? (( int ) $contactid ) : " null " );
2020-09-07 10:18:17 +02:00
$sql .= " , priority = ' " . $this -> db -> escape ( $this -> priority ) . " ' " ;
$sql .= " , fulldayevent = ' " . $this -> db -> escape ( $this -> fulldayevent ) . " ' " ;
$sql .= " , location = " . ( $this -> location ? " ' " . $this -> db -> escape ( $this -> location ) . " ' " : " null " );
$sql .= " , transparency = ' " . $this -> db -> escape ( $this -> transparency ) . " ' " ;
2022-01-18 14:00:38 +01:00
$sql .= " , fk_user_mod = " . (( int ) $user -> id );
$sql .= " , fk_user_action = " . ( $userownerid > 0 ? (( int ) $userownerid ) : " null " );
2021-02-23 18:59:19 +01:00
if ( ! empty ( $this -> fk_element )) {
2022-01-18 14:00:38 +01:00
$sql .= " , fk_element= " . ( $this -> fk_element ? (( int ) $this -> fk_element ) : " null " );
2021-02-23 18:59:19 +01:00
}
if ( ! empty ( $this -> elementtype )) {
$sql .= " , elementtype= " . ( $this -> elementtype ? " ' " . $this -> db -> escape ( $this -> elementtype ) . " ' " : " null " );
}
2021-03-02 22:23:54 +01:00
if ( ! empty ( $this -> num_vote )) {
$sql .= " , num_vote= " . ( $this -> num_vote ? ( int ) $this -> num_vote : null );
}
if ( ! empty ( $this -> event_paid )) {
$sql .= " , event_paid= " . ( $this -> event_paid ? ( int ) $this -> event_paid : 0 );
}
if ( ! empty ( $this -> status )) {
$sql .= " , status= " . ( $this -> status ? ( int ) $this -> status : 0 );
}
2022-11-29 13:04:13 +01:00
$sql .= " WHERE id= " . (( int ) $this -> id );
2020-09-07 10:18:17 +02:00
dol_syslog ( get_class ( $this ) . " ::update " , LOG_DEBUG );
2021-02-23 18:59:19 +01:00
if ( $this -> db -> query ( $sql )) {
2019-11-14 12:09:15 +01:00
$action = 'update' ;
2012-12-10 19:06:59 +01:00
2020-09-07 10:18:17 +02:00
// Actions on extra fields
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
$result = $this -> insertExtraFields ();
if ( $result < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
}
// Now insert assignedusers
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2021-08-23 19:33:24 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " actioncomm_resources where fk_actioncomm = " . (( int ) $this -> id ) . " AND element_type = 'user' " ;
2014-09-23 16:15:15 +02:00
$resql = $this -> db -> query ( $sql );
2021-04-07 09:49:20 +02:00
$already_inserted = array ();
2021-02-23 18:59:19 +01:00
foreach ( $this -> userassigned as $key => $val ) {
if ( ! is_array ( $val )) { // For backward compatibility when val=id
2024-03-09 16:32:02 +01:00
$val = array ( 'id' => $val );
2020-09-07 10:18:17 +02:00
}
2023-12-04 12:01:45 +01:00
if ( ! empty ( $already_inserted [ $val [ 'id' ]])) {
continue ;
}
2021-04-07 09:49:20 +02:00
2019-11-14 12:09:15 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status) " ;
2021-08-27 22:42:04 +02:00
$sql .= " VALUES( " . (( int ) $this -> id ) . " , 'user', " . (( int ) $val [ 'id' ]) . " , " . ( empty ( $val [ 'mandatory' ]) ? '0' : (( int ) $val [ 'mandatory' ])) . " , " . ( empty ( $val [ 'transparency' ]) ? '0' : (( int ) $val [ 'transparency' ])) . " , " . ( empty ( $val [ 'answer_status' ]) ? '0' : (( int ) $val [ 'answer_status' ])) . " ) " ;
2014-09-23 16:15:15 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( ! $resql ) {
2021-04-07 09:49:20 +02:00
$error ++ ;
$this -> errors [] = $this -> db -> lasterror ();
} else {
$already_inserted [ $val [ 'id' ]] = true ;
2014-09-23 16:15:15 +02:00
}
//var_dump($sql);exit;
}
}
2017-11-22 14:42:47 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2021-08-23 19:33:24 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " actioncomm_resources where fk_actioncomm = " . (( int ) $this -> id ) . " AND element_type = 'socpeople' " ;
2017-06-06 17:43:22 +02:00
$resql = $this -> db -> query ( $sql );
2017-11-22 14:42:47 +01:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $this -> socpeopleassigned )) {
2021-04-07 09:49:20 +02:00
$already_inserted = array ();
2024-06-08 19:48:16 +02:00
foreach ( $this -> socpeopleassigned as $val ) {
2022-05-23 00:49:59 +02:00
if ( ! is_array ( $val )) { // For backward compatibility when val=id
2024-03-09 16:32:02 +01:00
$val = array ( 'id' => $val );
2022-05-23 00:49:59 +02:00
}
2023-12-04 12:01:45 +01:00
if ( ! empty ( $already_inserted [ $val [ 'id' ]])) {
continue ;
}
2021-04-07 09:49:20 +02:00
2019-11-14 12:09:15 +01:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status) " ;
2022-05-23 00:49:59 +02:00
$sql .= " VALUES( " . (( int ) $this -> id ) . " , 'socpeople', " . (( int ) $val [ 'id' ]) . " , 0, 0, 0) " ;
2017-11-22 14:42:47 +01:00
2017-06-06 17:43:22 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( ! $resql ) {
2021-04-07 09:49:20 +02:00
$error ++ ;
$this -> errors [] = $this -> db -> lasterror ();
} else {
$already_inserted [ $val [ 'id' ]] = true ;
2017-06-06 17:43:22 +02:00
}
}
}
}
2014-09-23 16:15:15 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error && ! $notrigger ) {
2020-09-07 10:18:17 +02:00
// Call trigger
$result = $this -> call_trigger ( 'ACTION_MODIFY' , $user );
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
// End call triggers
}
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2020-09-07 10:18:17 +02:00
$this -> db -> commit ();
return 1 ;
} else {
$this -> db -> rollback ();
Qual: Apply automatic phan fixes (deprecations, unneeded imports) (#28154)
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
* Qual: Apply automatic phan fixes (deprecations, unneeded imports)
# Qual: Apply automatic phan fixes (deprecations, unneeded imports)
This applies automatic fixes by phan for deprecated functions, unneeded imports).
2024-02-13 21:46:12 +01:00
dol_syslog ( get_class ( $this ) . " ::update " . implode ( ',' , $this -> errors ), LOG_ERR );
2020-09-07 10:18:17 +02:00
return - 2 ;
}
} else {
$this -> db -> rollback ();
$this -> error = $this -> db -> lasterror ();
return - 1 ;
}
}
2009-05-04 22:39:17 +02:00
2020-09-07 10:18:17 +02:00
/**
* Load all objects with filters .
2024-08-13 04:37:19 +02:00
* @ TODO WARNING : This make a fetch on all records instead of making one request with a join , like done into show_actions_done .
2020-09-07 10:18:17 +02:00
*
* @ param int $socid Filter by thirdparty
* @ param int $fk_element Id of element action is linked to
* @ param string $elementtype Type of element action is linked to
* @ param string $filter Other filter
* @ param string $sortfield Sort on this field
* @ param string $sortorder ASC or DESC
2023-12-20 14:22:45 +01:00
* @ param int $limit Limit number of answers
2023-09-08 11:57:11 +02:00
* @ return ActionComm [] | string Error string if KO , array with actions if OK
2020-09-07 10:18:17 +02:00
*/
2021-09-27 15:41:58 +02:00
public function getActions ( $socid = 0 , $fk_element = 0 , $elementtype = '' , $filter = '' , $sortfield = 'a.datep' , $sortorder = 'DESC' , $limit = 0 )
2020-09-07 10:18:17 +02:00
{
2024-05-01 23:58:12 +02:00
global $hookmanager ;
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$resarray = array ();
2012-12-01 15:45:05 +01:00
2024-11-15 14:11:03 +01:00
dol_syslog ( get_class ( $this ) . " ::getActions " , LOG_DEBUG );
2019-06-13 22:48:31 +02:00
2024-06-30 21:02:50 +02:00
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
2023-03-26 17:59:28 +02:00
if ( ! is_object ( $hookmanager )) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php' ;
2023-10-20 02:28:51 +02:00
$hookmanager = new HookManager ( $this -> db );
2023-03-26 17:59:28 +02:00
}
2022-11-04 17:46:32 +01:00
$hookmanager -> initHooks ( array ( 'agendadao' ));
2020-09-07 10:18:17 +02:00
$sql = " SELECT a.id " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
2022-11-04 17:46:32 +01:00
// Fields from hook
$parameters = array ( 'sql' => & $sql , 'socid' => $socid , 'fk_element' => $fk_element , 'elementtype' => $elementtype );
$reshook = $hookmanager -> executeHooks ( 'getActionsListFrom' , $parameters ); // Note that $action and $object may have been modified by hook
2023-12-04 12:01:45 +01:00
if ( ! empty ( $hookmanager -> resPrint )) {
2024-03-09 16:32:02 +01:00
$sql .= $hookmanager -> resPrint ;
2023-12-04 12:01:45 +01:00
}
2020-09-07 10:18:17 +02:00
$sql .= " WHERE a.entity IN ( " . getEntity ( 'agenda' ) . " ) " ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $socid )) {
2021-03-22 13:31:06 +01:00
$sql .= " AND a.fk_soc = " . (( int ) $socid );
2021-02-23 18:59:19 +01:00
}
if ( ! empty ( $elementtype )) {
2020-09-07 10:18:17 +02:00
if ( $elementtype == 'project' ) {
2021-03-22 13:31:06 +01:00
$sql .= ' AND a.fk_project = ' . (( int ) $fk_element );
2021-02-23 18:59:19 +01:00
} elseif ( $elementtype == 'contact' ) {
2024-08-13 04:37:19 +02:00
$sql .= ' AND EXISTS' ;
$sql .= " (SELECT r.rowid FROM " . MAIN_DB_PREFIX . " actioncomm_resources as r WHERE " ;
$sql .= " r.element_type = 'socpeople' AND r.fk_element = " . (( int ) $fk_element ) . ' AND r.fk_actioncomm = a.id)' ;
} elseif ( $elementtype == 'user' ) {
$sql .= " AND (a.fk_user_action = " . (( int ) $fk_element ) . " OR EXISTS " ;
$sql .= " (SELECT r.rowid FROM " . MAIN_DB_PREFIX . " actioncomm_resources as r WHERE " ;
$sql .= " r.element_type = 'user' AND r.fk_element = " . (( int ) $fk_element ) . ' AND r.fk_actioncomm = a.id)' ;
$sql .= " ) " ;
2021-02-23 18:59:19 +01:00
} else {
2021-09-27 15:41:58 +02:00
$sql .= " AND a.fk_element = " . (( int ) $fk_element ) . " AND a.elementtype = ' " . $this -> db -> escape ( $elementtype ) . " ' " ;
2020-09-07 10:18:17 +02:00
}
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $filter )) {
$sql .= $filter ;
}
2022-11-04 17:46:32 +01:00
// Fields where hook
$parameters = array ( 'sql' => & $sql , 'socid' => $socid , 'fk_element' => $fk_element , 'elementtype' => $elementtype );
$reshook = $hookmanager -> executeHooks ( 'getActionsListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
2023-12-04 12:01:45 +01:00
if ( ! empty ( $hookmanager -> resPrint )) {
2024-03-09 16:32:02 +01:00
$sql .= $hookmanager -> resPrint ;
2023-12-04 12:01:45 +01:00
}
2021-02-23 18:59:19 +01:00
if ( $sortorder && $sortfield ) {
2021-09-27 15:41:58 +02:00
$sql .= $this -> db -> order ( $sortfield , $sortorder );
2021-02-23 18:59:19 +01:00
}
2021-09-27 15:41:58 +02:00
$sql .= $this -> db -> plimit ( $limit , 0 );
2011-11-01 13:22:39 +01:00
2021-09-27 15:41:58 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2021-09-27 15:41:58 +02:00
$num = $this -> db -> num_rows ( $resql );
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( $num ) {
for ( $i = 0 ; $i < $num ; $i ++ ) {
2021-09-27 15:41:58 +02:00
$obj = $this -> db -> fetch_object ( $resql );
$actioncommstatic = new ActionComm ( $this -> db );
2020-09-07 10:18:17 +02:00
$actioncommstatic -> fetch ( $obj -> id );
$resarray [ $i ] = $actioncommstatic ;
}
}
2021-09-27 15:41:58 +02:00
$this -> db -> free ( $resql );
2020-09-07 10:18:17 +02:00
return $resarray ;
} else {
2021-09-27 15:41:58 +02:00
return $this -> db -> lasterror ();
2020-09-07 10:18:17 +02:00
}
}
2017-10-17 10:44:18 +02:00
2020-09-07 10:18:17 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators for dashboard ( this -> nbtodo and this -> nbtodolate )
*
2024-01-14 12:26:37 +01:00
* @ param User $user Object user
2020-11-21 16:49:54 +01:00
* @ param int $load_state_board Load indicator array this -> nb
2024-03-20 14:18:37 +01:00
* @ return WorkboardResponse | int <- 1 , 1 > Return integer < 0 if KO , WorkboardResponse if OK
2020-09-07 10:18:17 +02:00
*/
public function load_board ( $user , $load_state_board = 0 )
{
// phpcs:enable
global $conf , $langs ;
2005-07-15 00:29:49 +02:00
2020-11-21 16:49:54 +01:00
if ( empty ( $load_state_board )) {
$sql = " SELECT a.id, a.datep as dp " ;
} else {
2020-09-07 10:18:17 +02:00
$this -> nb = array ();
$sql = " SELECT count(a.id) as nb " ;
}
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
2023-06-20 18:16:19 +02:00
if ( ! $user -> hasRight ( 'agenda' , 'allactions' , 'read' )) {
2021-08-23 17:41:11 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = " . (( int ) $user -> id );
2021-02-23 18:59:19 +01:00
}
2020-09-07 10:18:17 +02:00
$sql .= " WHERE 1 = 1 " ;
2021-02-23 18:59:19 +01:00
if ( empty ( $load_state_board )) {
$sql .= " AND a.percent >= 0 AND a.percent < 100 " ;
}
2020-09-07 10:18:17 +02:00
$sql .= " AND a.entity IN ( " . getEntity ( 'agenda' ) . " ) " ;
2023-06-20 18:16:19 +02:00
if ( ! $user -> hasRight ( 'agenda' , 'allactions' , 'read' )) {
2024-03-14 13:39:43 +01:00
$sql .= " AND (a.fk_user_author = " . (( int ) $user -> id ) . " OR a.fk_user_action = " . (( int ) $user -> id );
2021-08-23 19:33:24 +02:00
$sql .= " OR ar.fk_element = " . (( int ) $user -> id );
2021-02-23 18:59:19 +01:00
$sql .= " ) " ;
2021-01-31 19:11:34 +01:00
}
2024-01-09 13:08:22 +01:00
// If the internal user must only see his customers, force searching by him
$search_sale = 0 ;
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
$search_sale = $user -> id ;
}
// Search on sale representative
if ( $search_sale && $search_sale != '-1' ) {
if ( $search_sale == - 2 ) {
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM " . MAIN_DB_PREFIX . " societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc) " ;
} elseif ( $search_sale > 0 ) {
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM " . MAIN_DB_PREFIX . " societe_commerciaux as sc WHERE sc.fk_soc = a.fk_soc AND sc.fk_user = " . (( int ) $search_sale ) . " ) " ;
}
}
2006-03-19 00:20:21 +01:00
2020-09-07 10:18:17 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2024-04-02 01:48:30 +02:00
$response = null ; // Ensure the variable is defined
2020-09-07 10:18:17 +02:00
if ( empty ( $load_state_board )) {
$agenda_static = new ActionComm ( $this -> db );
$response = new WorkboardResponse ();
$response -> warning_delay = $conf -> agenda -> warning_delay / 60 / 60 / 24 ;
$response -> label = $langs -> trans ( " ActionsToDo " );
$response -> labelShort = $langs -> trans ( " ActionsToDoShort " );
2021-12-11 13:17:31 +01:00
$response -> url = DOL_URL_ROOT . '/comm/action/list.php?mode=show_list&actioncode=0&status=todo&mainmenu=agenda' ;
2022-12-09 14:27:43 +01:00
if ( $user -> hasRight ( " agenda " , " allactions " , " read " )) {
2021-02-23 18:59:19 +01:00
$response -> url .= '&filtert=-1' ;
}
2020-09-07 10:18:17 +02:00
$response -> img = img_object ( '' , " action " , 'class="inline-block valigntextmiddle"' );
}
// This assignment in condition is not a bug. It allows walking the results.
2020-11-21 16:49:54 +01:00
while ( $obj = $this -> db -> fetch_object ( $resql )) {
2020-09-07 10:18:17 +02:00
if ( empty ( $load_state_board )) {
2024-04-02 01:48:30 +02:00
' @ phan - var - force WorkboardResponse $response
@ phan - var - force ActionComm $agenda_static ' ;
2020-09-07 10:18:17 +02:00
$response -> nbtodo ++ ;
$agenda_static -> datep = $this -> db -> jdate ( $obj -> dp );
2021-02-23 18:59:19 +01:00
if ( $agenda_static -> hasDelay ()) {
$response -> nbtodolate ++ ;
}
2020-11-21 16:49:54 +01:00
} else {
$this -> nb [ " actionscomm " ] = $obj -> nb ;
}
2020-09-07 10:18:17 +02:00
}
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$this -> db -> free ( $resql );
2024-03-20 14:18:37 +01:00
if ( empty ( $load_state_board ) && $response instanceof WorkboardResponse ) {
2021-02-23 18:59:19 +01:00
return $response ;
} else {
return 1 ;
}
2020-09-07 10:18:17 +02:00
} else {
dol_print_error ( $this -> db );
$this -> error = $this -> db -> error ();
return - 1 ;
}
}
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
/**
2024-01-14 12:26:37 +01:00
* Charge les information d 'ordre info dans l' objet facture
2020-09-07 10:18:17 +02:00
*
* @ param int $id Id de la facture a charger
* @ return void
*/
public function info ( $id )
{
$sql = 'SELECT ' ;
$sql .= ' a.id,' ;
$sql .= ' datec,' ;
$sql .= ' tms as datem,' ;
$sql .= ' fk_user_author,' ;
$sql .= ' fk_user_mod' ;
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm as a' ;
2021-03-30 11:36:50 +02:00
$sql .= ' WHERE a.id = ' . (( int ) $id );
2020-09-07 10:18:17 +02:00
dol_syslog ( get_class ( $this ) . " ::info " , LOG_DEBUG );
$result = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $result ) {
if ( $this -> db -> num_rows ( $result )) {
2020-09-07 10:18:17 +02:00
$obj = $this -> db -> fetch_object ( $result );
2023-10-24 11:37:29 +02:00
2020-09-07 10:18:17 +02:00
$this -> id = $obj -> id ;
2023-10-24 11:37:29 +02:00
2022-06-28 13:09:53 +02:00
$this -> user_creation_id = $obj -> fk_user_author ;
$this -> user_modification_id = $obj -> fk_user_mod ;
$this -> date_creation = $this -> db -> jdate ( $obj -> datec );
$this -> date_modification = empty ( $obj -> datem ) ? '' : $this -> db -> jdate ( $obj -> datem );
2020-09-07 10:18:17 +02:00
}
$this -> db -> free ( $result );
} else {
dol_print_error ( $this -> db );
}
}
2011-11-01 13:22:39 +01:00
2016-07-18 15:07:35 +02:00
2020-09-07 10:18:17 +02:00
/**
2022-01-18 13:44:52 +01:00
* Return the label of the status
2020-09-07 10:18:17 +02:00
*
2024-04-02 01:48:30 +02:00
* @ param int < 0 , 7 > $mode 0 = Long label , 1 = Short label , 2 = Picto + Short label , 3 = Picto , 4 = Picto + Short label , 5 = Short label + Picto , 6 = Picto + Long label , 7 = Very short label + Picto
* @ param int < 0 , 1 > $hidenastatus 1 = Show nothing if status is " Not applicable "
2020-09-07 10:18:17 +02:00
* @ return string String with status
*/
public function getLibStatut ( $mode , $hidenastatus = 0 )
{
return $this -> LibStatut ( $this -> percentage , $mode , $hidenastatus , $this -> datep );
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return label of action status
*
2024-04-02 01:48:30 +02:00
* @ param int < 0 , 100 > $percent Percent
* @ param int < 0 , 7 > $mode 0 = Long label , 1 = Short label , 2 = Picto + Short label , 3 = Picto , 4 = Picto + Short label , 5 = Short label + Picto , 6 = Picto + Long label , 7 = Very short label + Picto
* @ param int < 0 , 1 > $hidenastatus 1 = Show nothing if status is " Not applicable "
* @ param int | string $datestart Date start of event
* @ return string Label
2020-09-07 10:18:17 +02:00
*/
public function LibStatut ( $percent , $mode , $hidenastatus = 0 , $datestart = '' )
{
// phpcs:enable
global $langs ;
2021-10-16 19:37:57 +02:00
$labelStatus = $langs -> transnoentitiesnoconv ( 'StatusNotApplicable' );
2021-02-23 18:59:19 +01:00
if ( $percent == - 1 && ! $hidenastatus ) {
2021-10-16 19:37:57 +02:00
$labelStatus = $langs -> transnoentitiesnoconv ( 'StatusNotApplicable' );
2021-02-23 18:59:19 +01:00
} elseif ( $percent == 0 ) {
2021-10-16 19:37:57 +02:00
$labelStatus = $langs -> transnoentitiesnoconv ( 'StatusActionToDo' ) . ' (0%)' ;
2021-02-23 18:59:19 +01:00
} elseif ( $percent > 0 && $percent < 100 ) {
2021-10-16 19:37:57 +02:00
$labelStatus = $langs -> transnoentitiesnoconv ( 'StatusActionInProcess' ) . ' (' . $percent . '%)' ;
2021-02-23 18:59:19 +01:00
} elseif ( $percent >= 100 ) {
2021-10-16 19:37:57 +02:00
$labelStatus = $langs -> transnoentitiesnoconv ( 'StatusActionDone' ) . ' (100%)' ;
2021-02-23 18:59:19 +01:00
}
2020-09-07 10:18:17 +02:00
2021-10-16 19:37:57 +02:00
$labelStatusShort = $langs -> transnoentitiesnoconv ( 'StatusNotApplicable' );
2021-02-23 18:59:19 +01:00
if ( $percent == - 1 && ! $hidenastatus ) {
$labelStatusShort = $langs -> trans ( 'NA' );
} elseif ( $percent == 0 ) {
$labelStatusShort = '0%' ;
} elseif ( $percent > 0 && $percent < 100 ) {
$labelStatusShort = $percent . '%' ;
} elseif ( $percent >= 100 ) {
$labelStatusShort = '100%' ;
}
2020-09-07 10:18:17 +02:00
$statusType = 'status9' ;
2021-02-23 18:59:19 +01:00
if ( $percent == - 1 && ! $hidenastatus ) {
2024-05-30 13:37:17 +02:00
$statusType = 'status9' ;
2021-02-23 18:59:19 +01:00
}
if ( $percent == 0 ) {
$statusType = 'status1' ;
}
if ( $percent > 0 && $percent < 100 ) {
$statusType = 'status3' ;
}
if ( $percent >= 100 ) {
$statusType = 'status6' ;
}
2020-09-07 10:18:17 +02:00
return dolGetStatus ( $labelStatus , $labelStatusShort , '' , $statusType , $mode );
}
2023-02-02 23:47:01 +01:00
/**
* getTooltipContentArray
2024-04-02 01:48:30 +02:00
* @ param array < string , mixed > $params params to construct tooltip data
2023-02-02 23:47:01 +01:00
* @ since v18
2024-04-02 01:48:30 +02:00
* @ return array { picto : string , ref ? : string , title ? : string , labeltype ? : string , location ? : string , transparency ? : string , space ? : string , mailtopic ? : string , mailfrom ? : string , mailto ? : string , mailcc ? : string , description ? : string , note ? : string , categories ? : string }
2023-02-02 23:47:01 +01:00
*/
public function getTooltipContentArray ( $params )
{
2024-07-30 12:06:59 +02:00
global $langs , $form ;
2023-02-02 23:47:01 +01:00
$langs -> load ( 'agenda' );
2023-02-22 01:09:23 +01:00
$datas = array ();
$nofetch = ! empty ( $params [ 'nofetch' ]);
2023-02-02 23:47:01 +01:00
// Set label of type
$labeltype = '' ;
if ( $this -> type_code ) {
2023-10-29 13:55:30 +01:00
$langs -> load ( " commercial " );
2023-02-02 23:47:01 +01:00
$labeltype = ( $langs -> transnoentities ( " Action " . $this -> type_code ) != " Action " . $this -> type_code ) ? $langs -> transnoentities ( " Action " . $this -> type_code ) : $this -> type_label ;
}
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' )) {
2023-02-02 23:47:01 +01:00
if ( $this -> type_code != 'AC_OTH_AUTO' ) {
$labeltype = $langs -> trans ( 'ActionAC_MANUAL' );
}
}
$datas [ 'picto' ] = img_picto ( '' , $this -> picto ) . ' <u>' . $langs -> trans ( 'Action' ) . '</u>' ;
if ( ! empty ( $this -> ref )) {
$datas [ 'ref' ] = '<br><b>' . $langs -> trans ( 'Ref' ) . ':</b> ' . dol_escape_htmltag ( $this -> ref );
}
if ( ! empty ( $this -> label )) {
$datas [ 'title' ] = '<br><b>' . $langs -> trans ( 'Title' ) . ':</b> ' . dol_escape_htmltag ( $this -> label );
}
if ( ! empty ( $labeltype )) {
$datas [ 'labeltype' ] = '<br><b>' . $langs -> trans ( 'Type' ) . ':</b> ' . dol_escape_htmltag ( $labeltype );
}
if ( ! empty ( $this -> location )) {
$datas [ 'location' ] = '<br><b>' . $langs -> trans ( 'Location' ) . ':</b> ' . dol_escape_htmltag ( $this -> location );
}
if ( isset ( $this -> transparency )) {
$datas [ 'transparency' ] = '<br><b>' . $langs -> trans ( 'Busy' ) . ':</b> ' . yn ( $this -> transparency );
}
if ( ! empty ( $this -> email_msgid )) {
$langs -> load ( " mails " );
$datas [ 'space' ] = '<br>' ;
// $datas['email'] = '<br><b>'.img_picto('', 'email').' '.$langs->trans("Email").'</b>';
$datas [ 'mailtopic' ] = '<br><b>' . $langs -> trans ( 'MailTopic' ) . ':</b> ' . dol_escape_htmltag ( $this -> email_subject );
$datas [ 'mailfrom' ] = '<br><b>' . $langs -> trans ( 'MailFrom' ) . ':</b> ' . str_replace ( array ( '<' , '>' ), array ( '&lt' , '&gt' ), $this -> email_from );
$datas [ 'mailto' ] = '<br><b>' . $langs -> trans ( 'MailTo' ) . ':</b> ' . str_replace ( array ( '<' , '>' ), array ( '&lt' , '&gt' ), $this -> email_to );
if ( ! empty ( $this -> email_tocc )) {
$datas [ 'mailcc' ] = '<br><b>' . $langs -> trans ( 'MailCC' ) . ':</b> ' . str_replace ( array ( '<' , '>' ), array ( '&lt' , '&gt' ), $this -> email_tocc );
}
2024-01-14 12:26:37 +01:00
/* Disabled because bcc must remain by definition not visible
2023-02-02 23:47:01 +01:00
if ( ! empty ( $this -> email_tobcc )) {
$datas [ 'mailccc' ] = '<br><b>' . $langs -> trans ( 'MailCCC' ) . ':</b> ' . $this -> email_tobcc ;
} */
}
if ( ! empty ( $this -> note_private )) {
2024-07-23 10:00:54 +02:00
$datas [ 'description' ] = '<br><hr>' ;
2023-02-02 23:47:01 +01:00
// Try to limit length of content
$texttoshow = dolGetFirstLineOfText ( $this -> note_private , 10 );
// Restrict height of content into the tooltip
$datas [ 'note' ] = '<div class="tenlinesmax">' ;
$datas [ 'note' ] .= ( dol_textishtml ( $texttoshow ) ? str_replace ( array ( " \r " , " \n " ), " " , $texttoshow ) : str_replace ( array ( " \r " , " \n " ), '<br>' , $texttoshow ));
$datas [ 'note' ] .= '</div>' ;
}
2025-01-08 17:41:45 +01:00
2023-02-12 23:19:03 +01:00
// show categories for this record only in ajax to not overload lists
2024-02-27 15:30:37 +01:00
if ( isModEnabled ( 'category' ) && ! $nofetch ) {
2023-02-12 23:19:03 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2024-07-30 12:06:59 +02:00
if ( empty ( $form )) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
$form = new Form ( $this -> db );
}
$tmpcategstring = $form -> showCategories ( $this -> id , Categorie :: TYPE_ACTIONCOMM , 1 );
if ( $tmpcategstring ) {
$datas [ 'categories' ] = '<br>' . $tmpcategstring ;
}
2023-02-12 23:19:03 +01:00
}
2023-02-02 23:47:01 +01:00
return $datas ;
}
2020-09-07 10:18:17 +02:00
/**
* Return URL of event
* Use $this -> id , $this -> type_code , $this -> label and $this -> type_label
*
2024-04-02 01:48:30 +02:00
* @ param int < 0 , 2 > $withpicto 0 = No picto , 1 = Include picto into link , 2 = Only picto
* @ param int $maxlength Max number of characters into label . If negative , use the ref as label .
* @ param string $classname Force style class on a link
* @ param string $option '' = Link to action , 'birthday' = Link to contact , 'holiday' = Link to leave
* @ param int < 0 , 1 > $overwritepicto 1 = Overwrite picto with this one
* @ param int < 0 , 1 > $notooltip 1 = Disable tooltip
* @ param int <- 1 , 1 > $save_lastsearch_value - 1 = Auto , 0 = No save of lastsearch_values when clicking , 1 = Save lastsearch_values whenclicking
2020-09-07 10:18:17 +02:00
* @ return string Chaine avec URL
*/
public function getNomUrl ( $withpicto = 0 , $maxlength = 0 , $classname = '' , $option = '' , $overwritepicto = 0 , $notooltip = 0 , $save_lastsearch_value = - 1 )
{
global $conf , $langs , $user , $hookmanager , $action ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> dol_no_mouse_hover )) {
$notooltip = 1 ; // Force disable tooltips
}
2017-07-04 10:29:38 +02:00
2020-01-22 13:34:07 +01:00
$canread = 0 ;
2023-04-08 14:44:01 +02:00
if ( $user -> hasRight ( 'agenda' , 'myactions' , 'read' ) && ( $this -> authorid == $user -> id || $this -> userownerid == $user -> id )) {
2021-02-23 18:59:19 +01:00
$canread = 1 ; // Can read my event
}
2023-06-12 20:10:42 +02:00
if ( $user -> hasRight ( 'agenda' , 'myactions' , 'read' ) && array_key_exists ( $user -> id , $this -> userassigned )) {
2021-02-23 18:59:19 +01:00
$canread = 1 ; // Can read my event i am assigned
}
2023-06-12 20:10:42 +02:00
if ( $user -> hasRight ( 'agenda' , 'allactions' , 'read' )) {
2021-02-23 18:59:19 +01:00
$canread = 1 ; // Can read all event of other
}
if ( ! $canread ) {
2020-09-07 10:18:17 +02:00
$option = 'nolink' ;
2019-08-18 01:24:54 +02:00
}
2018-08-13 17:26:32 +02:00
2020-09-07 10:18:17 +02:00
$label = $this -> label ;
2016-11-08 12:58:07 +01:00
2019-11-14 12:09:15 +01:00
$result = '' ;
2017-07-04 10:29:38 +02:00
2018-03-07 11:53:30 +01:00
// Set label of type
2024-07-23 11:49:06 +02:00
$labeltype = $this -> getTypeLabel ( 1 );
2017-07-04 10:29:38 +02:00
2020-09-11 13:32:40 +02:00
$tooltip = img_picto ( '' , $this -> picto ) . ' <u>' . $langs -> trans ( 'Action' ) . '</u>' ;
2024-07-23 11:49:06 +02:00
$tooltip .= ' - ' . $this -> getTypePicto ( 'pictofixedwidth paddingright valignmiddle' ) . $labeltype ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $this -> ref )) {
2022-10-20 16:45:08 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'Ref' ) . ':</b> ' . dol_escape_htmltag ( $this -> ref );
2021-02-23 18:59:19 +01:00
}
if ( ! empty ( $label )) {
2022-10-20 16:45:08 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'Title' ) . ':</b> ' . dol_escape_htmltag ( $label );
2021-02-23 18:59:19 +01:00
}
if ( ! empty ( $this -> location )) {
2022-10-20 16:45:08 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'Location' ) . ':</b> ' . dol_escape_htmltag ( $this -> location );
2021-02-23 18:59:19 +01:00
}
2024-07-23 11:49:06 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'Date' ) . ':</b> ' . dol_print_date ( $this -> datep , 'dayhourreduceformat' , 'tzuserrel' );
if ( $this -> datef ) {
$tmpa = dol_getdate ( $this -> datep );
$tmpb = dol_getdate ( $this -> datef );
if ( $tmpa [ 'mday' ] == $tmpb [ 'mday' ] && $tmpa [ 'mon' ] == $tmpb [ 'mon' ] && $tmpa [ 'year' ] == $tmpb [ 'year' ]) {
if ( $tmpa [ 'hours' ] != $tmpb [ 'hours' ] || $tmpa [ 'minutes' ] != $tmpb [ 'minutes' ]) {
$tooltip .= '-' . dol_print_date ( $this -> datef , 'hour' , 'tzuserrel' );
}
} else {
$tooltip .= '-' . dol_print_date ( $this -> datef , 'dayhourreduceformat' , 'tzuserrel' );
}
}
if ( $this -> datef && $this -> datep != $this -> datef && isset ( $this -> transparency )) {
2020-08-29 03:52:27 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'Busy' ) . ':</b> ' . yn ( $this -> transparency );
2021-02-23 18:59:19 +01:00
}
2022-04-07 13:28:24 +02:00
if ( ! empty ( $this -> email_msgid )) {
$langs -> load ( " mails " );
$tooltip .= '<br>' ;
//$tooltip .= '<br><b>'.img_picto('', 'email').' '.$langs->trans("Email").'</b>';
2022-10-20 16:45:08 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'MailTopic' ) . ':</b> ' . dol_escape_htmltag ( $this -> email_subject );
2023-06-13 16:01:52 +02:00
$tooltip .= '<br><b>' . $langs -> trans ( 'MailFrom' ) . ':</b> ' . str_replace ( array ( '<' , '>' ), array ( '&lt' , '&gt' ), ! empty ( $this -> email_from ) ? $this -> email_from : '' );
$tooltip .= '<br><b>' . $langs -> trans ( 'MailTo' ) . ':</b> ' . str_replace ( array ( '<' , '>' ), array ( '&lt' , '&gt' ), ! empty ( $this -> email_to ) ? $this -> email_to : '' );
2022-04-07 13:28:24 +02:00
if ( ! empty ( $this -> email_tocc )) {
$tooltip .= '<br><b>' . $langs -> trans ( 'MailCC' ) . ':</b> ' . str_replace ( array ( '<' , '>' ), array ( '&lt' , '&gt' ), $this -> email_tocc );
}
2024-01-14 12:26:37 +01:00
/* Disabled because bcc must remain by definition not visible
2022-04-07 13:28:24 +02:00
if ( ! empty ( $this -> email_tobcc )) {
$tooltip .= '<br><b>' . $langs -> trans ( 'MailCCC' ) . ':</b> ' . $this -> email_tobcc ;
} */
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $this -> note_private )) {
2024-07-23 10:00:54 +02:00
$tooltip .= '<br><hr>' ;
2023-08-17 18:41:17 +02:00
$texttoshow = dolGetFirstLineOfText ( $this -> note_private , 8 ); // Try to limit length of content
2022-11-23 11:57:53 +01:00
$tooltip .= '<div class="tenlinesmax">' ; // Restrict height of content into the tooltip
2022-04-07 13:28:24 +02:00
$tooltip .= ( dol_textishtml ( $texttoshow ) ? str_replace ( array ( " \r " , " \n " ), " " , $texttoshow ) : str_replace ( array ( " \r " , " \n " ), '<br>' , $texttoshow ));
2022-11-23 11:57:53 +01:00
$tooltip .= '</div>' ;
2021-02-23 18:59:19 +01:00
}
2025-01-08 17:41:45 +01:00
2019-11-14 12:09:15 +01:00
$linkclose = '' ;
2023-02-05 20:41:29 +01:00
$classfortooltip = 'classfortooltip' ;
$dataparams = '' ;
if ( getDolGlobalInt ( 'MAIN_ENABLE_AJAX_TOOLTIP' )) {
$params = [
'id' => $this -> id ,
'objecttype' => $this -> element ,
'option' => $option ,
2023-02-12 23:19:03 +01:00
'nofetch' => 1 ,
2023-02-05 20:41:29 +01:00
];
$classfortooltip = 'classforajaxtooltip' ;
2023-04-03 19:51:40 +02:00
$dataparams = ' data-params="' . dol_escape_htmltag ( json_encode ( $params )) . '"' ;
$tooltip = '' ;
2023-02-05 20:41:29 +01:00
}
2021-02-23 18:59:19 +01:00
if ( empty ( $notooltip )) {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'MAIN_OPTIMIZEFORTEXTBROWSER' )) {
2020-09-07 10:18:17 +02:00
$label = $langs -> trans ( " ShowAction " );
2025-01-08 17:41:45 +01:00
$linkclose .= ' alt="' . dolPrintHTMLForAttribute ( $tooltip ) . '"' ;
2020-09-07 10:18:17 +02:00
}
2025-01-08 17:41:45 +01:00
$linkclose .= ( $tooltip ? ' title="' . dolPrintHTMLForAttribute ( $tooltip ) . '"' : ' title="tocomplete"' );
2023-02-05 20:41:29 +01:00
$linkclose .= $dataparams . ' class="' . $classname . ' ' . $classfortooltip . '"' ;
2021-02-23 18:59:19 +01:00
} else {
$linkclose .= ' class="' . $classname . '"' ;
}
2017-07-04 10:29:38 +02:00
2019-11-14 12:09:15 +01:00
$url = '' ;
2021-02-23 18:59:19 +01:00
if ( $option == 'birthday' ) {
2016-10-25 10:53:25 +02:00
$url = DOL_URL_ROOT . '/contact/perso.php?id=' . $this -> id ;
2021-02-23 18:59:19 +01:00
} elseif ( $option == 'holiday' ) {
2020-09-07 10:18:17 +02:00
$url = DOL_URL_ROOT . '/holiday/card.php?id=' . $this -> id ;
2021-02-23 18:59:19 +01:00
} else {
$url = DOL_URL_ROOT . '/comm/action/card.php?id=' . $this -> id ;
}
2021-02-18 12:46:42 +01:00
2021-02-23 18:59:19 +01:00
if ( $option !== 'nolink' ) {
2018-05-16 20:59:45 +02:00
// Add param to save lastsearch_values or not
2019-11-14 12:09:15 +01:00
$add_save_lastsearch_values = ( $save_lastsearch_value == 1 ? 1 : 0 );
2023-09-10 17:41:22 +02:00
if ( $save_lastsearch_value == - 1 && isset ( $_SERVER [ " PHP_SELF " ]) && preg_match ( '/list\.php/' , $_SERVER [ " PHP_SELF " ])) {
2021-02-23 18:59:19 +01:00
$add_save_lastsearch_values = 1 ;
}
if ( $add_save_lastsearch_values ) {
$url .= '&save_lastsearch_values=1' ;
}
2018-05-16 20:59:45 +02:00
}
2017-07-04 10:29:38 +02:00
2016-10-25 10:53:25 +02:00
$linkstart = '<a href="' . $url . '"' ;
2019-11-14 12:09:15 +01:00
$linkstart .= $linkclose . '>' ;
$linkend = '</a>' ;
2017-07-04 10:29:38 +02:00
2018-11-19 15:14:46 +01:00
if ( $option == 'nolink' ) {
$linkstart = '' ;
$linkend = '' ;
}
2012-12-01 15:45:05 +01:00
2021-02-23 18:59:19 +01:00
if ( $withpicto == 2 ) {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' )) {
2022-01-18 13:44:52 +01:00
$label = $labeltype ;
2021-02-23 18:59:19 +01:00
}
2022-01-18 13:44:52 +01:00
$labelshort = '' ;
2020-09-07 10:18:17 +02:00
} else {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' ) && empty ( $label )) {
2022-01-18 13:44:52 +01:00
$label = $labeltype ;
2021-02-23 18:59:19 +01:00
}
if ( $maxlength < 0 ) {
2022-01-18 13:44:52 +01:00
$labelshort = $this -> ref ;
2021-02-23 18:59:19 +01:00
} else {
2022-01-18 13:44:52 +01:00
$labelshort = dol_trunc ( $label , $maxlength );
2021-02-23 18:59:19 +01:00
}
2020-09-07 10:18:17 +02:00
}
2009-05-04 22:39:17 +02:00
2021-02-23 18:59:19 +01:00
if ( $withpicto ) {
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' )) { // Add code into ()
2021-02-23 18:59:19 +01:00
if ( $labeltype ) {
2022-01-18 13:44:52 +01:00
$label .= ( preg_match ( '/' . preg_quote ( $labeltype , '/' ) . '/' , $label ) ? '' : ' (' . $langs -> transnoentities ( " Action " . $this -> type_code ) . ')' );
2020-09-07 10:18:17 +02:00
}
}
}
2017-11-02 15:03:09 +01:00
2020-09-07 10:18:17 +02:00
$result .= $linkstart ;
2021-02-23 18:59:19 +01:00
if ( $withpicto ) {
2023-08-29 12:07:38 +02:00
$result .= img_object (( $notooltip ? '' : $langs -> trans ( " ShowAction " ) . ': ' . $label ), ( $overwritepicto ? $overwritepicto : 'action' ), (( $this -> type_color && $overwritepicto ) ? 'style="color: #' . $this -> type_color . ' !important;" ' : '' ) . ( $notooltip ? (( $withpicto != 2 ) ? 'class="paddingright"' : '' ) : ' class="' . (( $withpicto != 2 ) ? 'paddingright ' : '' ) . '"' ), 0 , 0 , $notooltip ? 0 : 1 );
2021-02-23 18:59:19 +01:00
}
2022-10-20 16:45:08 +02:00
$result .= dol_escape_htmltag ( $labelshort );
2020-09-07 10:18:17 +02:00
$result .= $linkend ;
2017-11-02 15:03:09 +01:00
2020-09-07 10:18:17 +02:00
global $action ;
$hookmanager -> initHooks ( array ( 'actiondao' ));
2024-03-09 16:32:02 +01:00
$parameters = array ( 'id' => $this -> id , 'getnomurl' => & $result );
2020-09-07 10:18:17 +02:00
$reshook = $hookmanager -> executeHooks ( 'getNomUrl' , $parameters , $this , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 18:59:19 +01:00
if ( $reshook > 0 ) {
$result = $hookmanager -> resPrint ;
} else {
$result .= $hookmanager -> resPrint ;
}
2018-03-15 20:46:55 +01:00
2020-09-07 10:18:17 +02:00
return $result ;
}
2006-10-24 01:07:46 +02:00
2021-02-14 20:12:43 +01:00
/**
* Return Picto of type of event
*
2023-09-18 18:41:52 +02:00
* @ param string $morecss More CSS
* @ param string $titlealt Title alt
2021-02-14 20:12:43 +01:00
* @ return string HTML String
*/
2024-06-21 19:58:38 +02:00
public function getTypePicto ( $morecss = 'pictofixedwidth paddingright valignmiddle' , $titlealt = '' )
2021-02-14 20:12:43 +01:00
{
$imgpicto = '' ;
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' )) {
2021-02-18 12:46:42 +01:00
$color = '' ;
if ( $this -> type_color ) {
$color = 'style="color: #' . $this -> type_color . ' !important;"' ;
}
2021-02-14 20:12:43 +01:00
if ( $this -> type_picto ) {
2025-01-22 08:50:53 +01:00
$imgpicto = img_picto ( $titlealt , $this -> type_picto , '' , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-14 20:12:43 +01:00
} else {
2021-02-23 18:59:19 +01:00
if ( $this -> type_code == 'AC_RDV' ) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'meeting' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
} elseif ( $this -> type_code == 'AC_TEL' ) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'object_phoning' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
} elseif ( $this -> type_code == 'AC_FAX' ) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'object_phoning_fax' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2025-01-21 14:08:52 +01:00
} elseif ( $this -> type_code == 'AC_EMAIL' || $this -> type_code == 'AC_EMAIL_IN' || $this -> type_code == 'AC_EMAILING' || ( ! empty ( $this -> code ) && preg_match ( '/_SENTBYMAIL/' , $this -> code ))) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'object_email' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
} elseif ( $this -> type_code == 'AC_INT' ) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'object_intervention' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2023-06-08 21:34:19 +02:00
} elseif ( ! empty ( $this -> code ) && preg_match ( '/^TICKET_MSG/' , $this -> code )) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'object_conversation' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
} elseif ( $this -> type != 'systemauto' ) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'user-cog' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
} else {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'cog' , $color , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
}
2021-02-14 20:12:43 +01:00
}
2021-02-14 20:47:57 +01:00
} else {
// 2 picto: 1 for auto, 1 for manual
2021-02-23 18:59:19 +01:00
if ( $this -> type != 'systemauto' ) {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'user-cog' , '' , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
} else {
2024-09-25 22:21:31 +02:00
$imgpicto = img_picto ( $titlealt , 'cog' , '' , 0 , 0 , 0 , '' , ( $morecss ? ' ' . $morecss : '' ));
2021-02-23 18:59:19 +01:00
}
2021-02-14 20:12:43 +01:00
}
2023-09-18 18:41:52 +02:00
2021-02-14 20:12:43 +01:00
return $imgpicto ;
}
2024-07-23 11:49:06 +02:00
/**
* Return label of type of event
*
2024-07-24 18:03:53 +02:00
* @ param int $mode 0 = Mode short , 1 = Mode long
2024-07-23 11:49:06 +02:00
* @ return string HTML String
*/
public function getTypeLabel ( $mode = 0 )
{
global $conf , $langs ;
// If cache for array of types unknown, we load it
if ( ! empty ( $conf -> cache [ 'actioncommgetypelabel' ])) {
$arraylist = $conf -> cache [ 'actioncommgetypelabel' ];
} else {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php' ;
$caction = new CActionComm ( $this -> db );
$arraylist = $caction -> liste_array ( 1 , 'code' , '' , ( getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' ) ? 0 : 1 ), '' , 1 );
$conf -> cache [ 'actioncommgetypelabel' ] = $arraylist ;
}
$labeltype = $this -> type_code ;
if ( ! getDolGlobalString ( 'AGENDA_USE_EVENT_TYPE' ) && empty ( $arraylist [ $labeltype ])) {
$labeltype = 'AC_OTH' ;
}
2024-11-15 15:58:43 +01:00
if ( ! empty ( $this -> code ) && preg_match ( '/^TICKET_MSG/' , $this -> code )) {
2024-07-23 11:49:06 +02:00
$labeltype = $langs -> trans ( " Message " );
} else {
if ( ! empty ( $arraylist [ $labeltype ])) {
$labeltype = $arraylist [ $labeltype ];
}
if ( $this -> type_code == 'AC_OTH_AUTO' && ( $this -> type_code != $this -> code ) && $labeltype && ! empty ( $arraylist [ $this -> code ])) {
$labeltype .= ' - ' . $arraylist [ $this -> code ]; // Use code in priority over type_code
}
}
if ( $this -> type == 'systemauto' && $mode == 1 ) {
$labeltype .= ' (' . $langs -> trans ( " auto " ) . ')' ;
}
return $labeltype ;
}
2020-09-07 10:18:17 +02:00
/**
* Sets object to supplied categories .
*
* Deletes object from existing categories not supplied .
* Adds it to non existing supplied categories .
* Existing categories are left untouch .
*
2022-12-31 14:01:03 +01:00
* @ param int [] | int $categories Category or categories IDs
2024-04-02 01:48:30 +02:00
* @ return int <- 1 , 1 > Return integer < 0 if KO , > 0 if OK
2020-09-07 10:18:17 +02:00
*/
public function setCategories ( $categories )
{
// Handle single category
if ( ! is_array ( $categories )) {
$categories = array ( $categories );
}
2019-11-13 21:18:34 +01:00
2020-09-07 10:18:17 +02:00
// Get current categories
include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
$c = new Categorie ( $this -> db );
$existing = $c -> containing ( $this -> id , Categorie :: TYPE_ACTIONCOMM , 'id' );
2019-11-13 21:18:34 +01:00
2020-09-07 10:18:17 +02:00
// Diff
if ( is_array ( $existing )) {
$to_del = array_diff ( $existing , $categories );
$to_add = array_diff ( $categories , $existing );
} else {
$to_del = array (); // Nothing to delete
$to_add = $categories ;
}
2019-11-13 21:18:34 +01:00
2020-09-07 10:18:17 +02:00
// Process
foreach ( $to_del as $del ) {
if ( $c -> fetch ( $del ) > 0 ) {
$c -> del_type ( $this , Categorie :: TYPE_ACTIONCOMM );
}
}
foreach ( $to_add as $add ) {
if ( $c -> fetch ( $add ) > 0 ) {
$c -> add_type ( $this , Categorie :: TYPE_ACTIONCOMM );
}
}
2022-12-31 14:01:03 +01:00
return 1 ;
2020-09-07 10:18:17 +02:00
}
2009-05-04 22:39:17 +02:00
2020-09-07 10:18:17 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Export events from database into a cal file .
*
2024-05-01 23:58:12 +02:00
* @ param string $format The format of the export 'vcal' , 'ical/ics' or 'rss'
* @ param string $type The type of the export 'event' or 'journal'
* @ param integer $cachedelay Do not rebuild file if date older than cachedelay seconds
* @ param string $filename The name for the exported file .
* @ param array < string , int | string > $filters Array of filters . Example array ( 'notolderthan' => 99 , 'year' =>... , 'idfrom' =>... , 'actiontype' => 'systemauto' , 'actioncode' => 'AC_PRODUCT_MODIFY' , 'project' => 123 , ... )
* @ param int < 0 , 1 > $exportholiday 0 = don ' t integrate holidays into the export , 1 = integrate holidays into the export
* @ return int <- 1 , 1 > - 1 = error on build export file , 0 = export okay
2020-09-07 10:18:17 +02:00
*/
public function build_exportfile ( $format , $type , $cachedelay , $filename , $filters , $exportholiday = 0 )
{
global $hookmanager ;
2019-03-14 16:13:32 +01:00
2020-09-07 10:18:17 +02:00
// phpcs:enable
global $conf , $langs , $dolibarr_main_url_root , $mysoc ;
2008-10-31 03:03:26 +01:00
2020-09-07 10:18:17 +02:00
require_once DOL_DOCUMENT_ROOT . " /core/lib/xcal.lib.php " ;
require_once DOL_DOCUMENT_ROOT . " /core/lib/date.lib.php " ;
require_once DOL_DOCUMENT_ROOT . " /core/lib/files.lib.php " ;
2014-02-10 01:30:48 +01:00
2020-09-07 10:18:17 +02:00
dol_syslog ( get_class ( $this ) . " ::build_exportfile Build export file format= " . $format . " , type= " . $type . " , cachedelay= " . $cachedelay . " , filename= " . $filename . " , filters size= " . count ( $filters ), LOG_DEBUG );
2008-04-08 00:11:22 +02:00
2020-09-07 10:18:17 +02:00
// Check parameters
2021-02-23 18:59:19 +01:00
if ( empty ( $format )) {
return - 1 ;
}
2008-04-08 00:11:22 +02:00
2020-09-07 10:18:17 +02:00
// Clean parameters
2021-02-23 18:59:19 +01:00
if ( ! $filename ) {
2020-09-07 10:18:17 +02:00
$extension = 'vcs' ;
2021-02-23 18:59:19 +01:00
if ( $format == 'ical' ) {
$extension = 'ics' ;
}
2020-09-07 10:18:17 +02:00
$filename = $format . '.' . $extension ;
}
2010-01-17 21:39:32 +01:00
2020-09-07 10:18:17 +02:00
// Create dir and define output file (definitive and temporary)
$result = dol_mkdir ( $conf -> agenda -> dir_temp );
$outputfile = $conf -> agenda -> dir_temp . '/' . $filename ;
2010-01-17 21:39:32 +01:00
2020-09-07 10:18:17 +02:00
$result = 0 ;
2008-04-08 03:09:10 +02:00
2020-09-07 10:18:17 +02:00
$buildfile = true ;
2023-12-04 12:01:45 +01:00
$login = '' ;
$logina = '' ;
$logint = '' ;
2024-02-18 01:46:44 +01:00
$eventorganization = '' ;
2009-05-04 22:39:17 +02:00
2020-09-07 10:18:17 +02:00
$now = dol_now ();
2010-05-22 11:50:32 +02:00
2021-02-23 18:59:19 +01:00
if ( $cachedelay ) {
2020-09-07 10:18:17 +02:00
$nowgmt = dol_now ();
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2021-02-23 18:59:19 +01:00
if ( dol_filemtime ( $outputfile ) > ( $nowgmt - $cachedelay )) {
2020-09-07 10:18:17 +02:00
dol_syslog ( get_class ( $this ) . " ::build_exportfile file " . $outputfile . " is not older than now - cachedelay ( " . $nowgmt . " - " . $cachedelay . " ). Build is canceled " );
$buildfile = false ;
}
}
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( $buildfile ) {
2020-09-07 10:18:17 +02:00
// Build event array
$eventarray = array ();
2024-05-01 23:58:12 +02:00
if ( ! empty ( $filters [ 'module' ]) && $filters [ 'module' ] == 'project@eventorganization' ) {
2024-02-18 01:46:44 +01:00
$sql = " SELECT p.rowid as id, " ;
$sql .= " p.date_start_event as datep, " ; // Start
$sql .= " p.date_end_event as datep2, " ; // End
$sql .= " p.datec, p.tms as datem, " ;
2024-06-20 17:33:40 +02:00
$sql .= " p.title as label, '' as code, p.note_public, p.note_private, 0 as type_id, " ;
2024-02-18 01:46:44 +01:00
$sql .= " p.fk_soc, " ;
$sql .= " p.fk_user_creat as fk_user_author, p.fk_user_modif as fk_user_mod, " ;
$sql .= " 0 as fk_user_action, " ;
$sql .= " 0 as fk_contact, 100 as percentage, " ;
$sql .= " 0 as fk_element, '' as elementtype, " ;
$sql .= " 1 as priority, 0 as fulldayevent, p.location, 0 as transparency, " ;
2024-06-20 17:33:40 +02:00
$sql .= " u.firstname, u.lastname, ' " . $this -> db -> escape ( getDolGlobalString ( " MAIN_INFO_SOCIETE_MAIL " )) . " ' as email, " ;
2024-02-18 01:46:44 +01:00
$sql .= " s.nom as socname, " ;
$sql .= " 0 as type_id, '' as type_code, '' as type_label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " projet as p " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user as u on u.rowid = p.fk_user_creat " ; // Link to get author of event for export
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on s.rowid = p.fk_soc " ;
$parameters = array ( 'filters' => $filters );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFrom' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= " WHERE p.entity IN ( " . getEntity ( 'project' ) . " ) " ;
foreach ( $filters as $key => $value ) {
if ( $key == 'notolderthan' && $value != '' ) {
$sql .= " AND p.date_start_event >= ' " . $this -> db -> idate ( $now - ( $value * 24 * 60 * 60 )) . " ' " ;
}
if ( $key == 'year' ) {
$sql .= " AND p.date_start_event BETWEEN ' " . $this -> db -> idate ( dol_get_first_day ( $value , 1 )) . " ' AND ' " . $this -> db -> idate ( dol_get_last_day ( $value , 12 )) . " ' " ;
}
if ( $key == 'id' ) {
$sql .= " AND p.id = " . ( is_numeric ( $value ) ? $value : 0 );
}
if ( $key == 'idfrom' ) {
$sql .= " AND p.id >= " . ( is_numeric ( $value ) ? $value : 0 );
}
if ( $key == 'idto' ) {
$sql .= " AND p.id <= " . ( is_numeric ( $value ) ? $value : 0 );
}
if ( $key == 'project' ) {
$sql .= " AND p.rowid = " . ( is_numeric ( $value ) ? $value : 0 );
}
if ( $key == 'status' ) {
$sql .= " AND p.fk_statut = " . (( int ) $value );
}
2024-04-30 16:34:44 +02:00
// TODO Add filters on event code of meetings/talks only
2021-02-23 18:59:19 +01:00
}
2024-02-18 01:46:44 +01:00
2024-05-01 23:58:12 +02:00
$sql .= " ORDER by date_start_event " ;
2024-02-18 01:46:44 +01:00
$eventorganization = 'project' ;
} else {
$sql = " SELECT a.id, " ;
$sql .= " a.datep, " ; // Start
$sql .= " a.datep2, " ; // End
$sql .= " a.datec, a.tms as datem, " ;
2024-06-20 17:33:40 +02:00
$sql .= " a.label, a.code, '' as note_public, a.note as note_private, a.fk_action as type_id, " ;
2024-02-18 01:46:44 +01:00
$sql .= " a.fk_soc, " ;
$sql .= " a.fk_user_author, a.fk_user_mod, " ;
$sql .= " a.fk_user_action, " ;
$sql .= " a.fk_contact, a.percent as percentage, " ;
$sql .= " a.fk_element, a.elementtype, " ;
$sql .= " a.priority, a.fulldayevent, a.location, a.transparency, " ;
$sql .= " u.firstname, u.lastname, u.email, " ;
$sql .= " s.nom as socname, " ;
$sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, " ;
$sql .= " num_vote, event_paid, a.status " ;
$sql .= " FROM ( " . MAIN_DB_PREFIX . " c_actioncomm as c, " . MAIN_DB_PREFIX . " actioncomm as a) " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user as u on u.rowid = a.fk_user_author " ; // Link to get author of event for export
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on s.rowid = a.fk_soc " ;
$parameters = array ( 'filters' => $filters );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFrom' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2024-01-14 12:26:37 +01:00
// We must filter on assignment table
2024-05-01 23:58:12 +02:00
if ( ! empty ( $filters [ 'logint' ]) && $filters [ 'logint' ]) {
2024-02-18 01:46:44 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " actioncomm_resources as ar " ;
2021-02-23 18:59:19 +01:00
}
2024-02-18 01:46:44 +01:00
$sql .= " WHERE a.fk_action = c.id " ;
$sql .= " AND a.entity IN ( " . getEntity ( 'agenda' ) . " ) " ;
foreach ( $filters as $key => $value ) {
if ( $key == 'notolderthan' && $value != '' ) {
$sql .= " AND a.datep >= ' " . $this -> db -> idate ( $now - ( $value * 24 * 60 * 60 )) . " ' " ;
2020-09-07 10:18:17 +02:00
}
2024-02-18 01:46:44 +01:00
if ( $key == 'year' ) {
$sql .= " AND a.datep BETWEEN ' " . $this -> db -> idate ( dol_get_first_day ( $value , 1 )) . " ' AND ' " . $this -> db -> idate ( dol_get_last_day ( $value , 12 )) . " ' " ;
2021-02-23 18:59:19 +01:00
}
2024-02-18 01:46:44 +01:00
if ( $key == 'id' ) {
$sql .= " AND a.id = " . ( is_numeric ( $value ) ? $value : 0 );
2020-09-07 10:18:17 +02:00
}
2024-02-18 01:46:44 +01:00
if ( $key == 'idfrom' ) {
$sql .= " AND a.id >= " . ( is_numeric ( $value ) ? $value : 0 );
2021-02-23 18:59:19 +01:00
}
2024-02-18 01:46:44 +01:00
if ( $key == 'idto' ) {
$sql .= " AND a.id <= " . ( is_numeric ( $value ) ? $value : 0 );
}
if ( $key == 'project' ) {
$sql .= " AND a.fk_project = " . ( is_numeric ( $value ) ? $value : 0 );
}
2024-04-30 16:34:44 +02:00
if ( $key == 'notactiontype' ) { // deprecated
2024-02-18 01:46:44 +01:00
$sql .= " AND c.type <> ' " . $this -> db -> escape ( $value ) . " ' " ;
}
2024-04-30 16:34:44 +02:00
if ( $key == 'actiontype' ) { // 'system', 'systemauto', 'module', ...
$newvalue = $value ;
$usenotin = 0 ;
if ( preg_match ( '/^!/' , $newvalue )) {
$newvalue = preg_replace ( '/^!/' , '' , $value );
$usenotin = 1 ;
}
$arraynewvalue = explode ( ',' , $newvalue );
$newvalue = " " ;
foreach ( $arraynewvalue as $tmpval ) {
$newvalue .= ( $newvalue ? " , " : " " ) . " ' " . $tmpval . " ' " ;
}
if ( $usenotin ) {
$sql .= " AND c.type NOT IN ( " . $this -> db -> sanitize ( $newvalue , 1 ) . " ) " ;
} else {
$sql .= " AND c.type IN ( " . $this -> db -> sanitize ( $newvalue , 1 ) . " ) " ;
}
}
if ( $key == 'actioncode' ) { // 'AC_COMPANY_CREATE', 'AC_COMPANY_MODIFY', ...
$newvalue = $value ;
$usenotin = 0 ;
if ( preg_match ( '/^!/' , $newvalue )) {
$newvalue = preg_replace ( '/^!/' , '' , $value );
$usenotin = 1 ;
}
$arraynewvalue = explode ( ',' , $newvalue );
$newvalue = " " ;
foreach ( $arraynewvalue as $tmpval ) {
$newvalue .= ( $newvalue ? " , " : " " ) . " ' " . $tmpval . " ' " ;
}
if ( $usenotin ) {
$sql .= " AND a.code NOT IN ( " . $this -> db -> sanitize ( $newvalue , 1 ) . " ) " ;
} else {
$sql .= " AND a.code IN ( " . $this -> db -> sanitize ( $newvalue , 1 ) . " ) " ;
}
}
2024-02-18 01:46:44 +01:00
// We must filter on assignment table
if ( $key == 'logint' ) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user' " ;
}
if ( $key == 'logina' ) {
$logina = $value ;
$condition = '=' ;
if ( preg_match ( '/^!/' , $logina )) {
$logina = preg_replace ( '/^!/' , '' , $logina );
$condition = '<>' ;
}
$userforfilter = new User ( $this -> db );
2024-04-02 01:48:30 +02:00
$result = $userforfilter -> fetch ( 0 , $logina );
2024-02-18 01:46:44 +01:00
if ( $result > 0 ) {
$sql .= " AND a.fk_user_author " . $condition . " " . $userforfilter -> id ;
} elseif ( $result < 0 || $condition == '=' ) {
$sql .= " AND a.fk_user_author = 0 " ;
}
}
if ( $key == 'logint' ) {
$logint = $value ;
$condition = '=' ;
if ( preg_match ( '/^!/' , $logint )) {
$logint = preg_replace ( '/^!/' , '' , $logint );
$condition = '<>' ;
}
$userforfilter = new User ( $this -> db );
2024-04-02 01:48:30 +02:00
$result = $userforfilter -> fetch ( 0 , $logint );
2024-02-18 01:46:44 +01:00
if ( $result > 0 ) {
$sql .= " AND ar.fk_element = " . (( int ) $userforfilter -> id );
} elseif ( $result < 0 || $condition == '=' ) {
$sql .= " AND ar.fk_element = 0 " ;
}
}
if ( $key == 'module' ) {
if ( $value == 'conforbooth@eventorganization' ) {
$value = '@eventorganization' ;
}
$sql .= " AND c.module LIKE '% " . $this -> db -> escape ( $value ) . " ' " ;
}
if ( $key == 'status' ) {
$sql .= " AND a.status = " . (( int ) $value );
2024-02-18 00:25:00 +01:00
}
2021-05-10 16:57:48 +02:00
}
2019-03-14 15:19:38 +01:00
2024-02-18 01:46:44 +01:00
$sql .= " AND a.datep IS NOT NULL " ; // To exclude corrupted events and avoid errors in lightning/sunbird import
2019-03-14 15:19:38 +01:00
2024-02-18 01:46:44 +01:00
$parameters = array ( 'filters' => $filters );
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2019-03-14 15:19:38 +01:00
2024-02-18 01:46:44 +01:00
$sql .= " ORDER by datep " ;
}
2024-05-01 23:58:12 +02:00
if ( ! empty ( $filters [ 'limit' ])) {
2024-05-02 00:04:58 +02:00
$sql .= $this -> db -> plimit (( int ) $filters [ 'limit' ]);
2024-05-01 23:58:12 +02:00
}
2020-09-07 10:18:17 +02:00
//print $sql;exit;
2011-11-01 13:22:39 +01:00
2024-02-18 01:46:44 +01:00
dol_syslog ( get_class ( $this ) . " ::build_exportfile select event(s) " , LOG_DEBUG );
2020-09-07 10:18:17 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2017-10-20 12:57:32 +02:00
$diff = 0 ;
2021-02-23 18:59:19 +01:00
while ( $obj = $this -> db -> fetch_object ( $resql )) {
2020-09-07 10:18:17 +02:00
$qualified = true ;
// 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author'
$event = array ();
$event [ 'uid' ] = 'dolibarragenda-' . $this -> db -> database_name . '-' . $obj -> id . " @ " . $_SERVER [ " SERVER_NAME " ];
$event [ 'type' ] = $type ;
2022-02-11 12:46:45 +01:00
2024-08-07 11:35:52 +02:00
$datestart = ( int ) $this -> db -> jdate ( $obj -> datep ) - ( getDolGlobalInt ( 'AGENDA_EXPORT_FIX_TZ' ) * 3600 );
2020-09-07 10:18:17 +02:00
// fix for -> Warning: A non-numeric value encountered
2021-02-23 18:59:19 +01:00
if ( is_numeric ( $this -> db -> jdate ( $obj -> datep2 ))) {
2024-08-07 11:35:52 +02:00
$dateend = ( int ) $this -> db -> jdate ( $obj -> datep2 ) - ( getDolGlobalInt ( 'AGENDA_EXPORT_FIX_TZ' ) * 3600 );
2020-09-07 10:18:17 +02:00
} else {
2022-02-11 12:46:45 +01:00
// use start date as fall-back to avoid pb with empty end date on ICS readers
2020-09-07 10:18:17 +02:00
$dateend = $datestart ;
}
$duration = ( $datestart && $dateend ) ? ( $dateend - $datestart ) : 0 ;
$event [ 'summary' ] = $obj -> label . ( $obj -> socname ? " ( " . $obj -> socname . " ) " : " " );
2021-05-21 16:01:44 +02:00
2024-06-20 17:33:40 +02:00
if ( ! empty ( $filters [ 'module' ]) && $filters [ 'module' ] == 'project@eventorganization' ) {
$event [ 'desc' ] = $obj -> note_public ;
} else {
$event [ 'desc' ] = $obj -> note_private ;
}
2020-09-07 10:18:17 +02:00
$event [ 'startdate' ] = $datestart ;
$event [ 'enddate' ] = $dateend ; // Not required with type 'journal'
$event [ 'duration' ] = $duration ; // Not required with type 'journal'
$event [ 'author' ] = dolGetFirstLastname ( $obj -> firstname , $obj -> lastname );
$event [ 'priority' ] = $obj -> priority ;
$event [ 'fulldayevent' ] = $obj -> fulldayevent ;
$event [ 'location' ] = $obj -> location ;
$event [ 'transparency' ] = (( $obj -> transparency > 0 ) ? 'OPAQUE' : 'TRANSPARENT' ); // OPAQUE (busy) or TRANSPARENT (not busy)
$event [ 'category' ] = $obj -> type_label ;
$event [ 'email' ] = $obj -> email ;
2024-02-18 01:46:44 +01:00
2024-06-20 17:33:40 +02:00
// Public URL of event
2024-02-18 01:46:44 +01:00
if ( $eventorganization != '' ) {
2024-06-20 17:33:40 +02:00
$link_subscription = $dolibarr_main_url_root . '/public/eventorganization/attendee_new.php?id=' . (( int ) $obj -> id ) . '&type=global&noregistration=1' ;
$encodedsecurekey = dol_hash ( getDolGlobalString ( 'EVENTORGANIZATION_SECUREKEY' ) . 'conferenceorbooth' . (( int ) $obj -> id ), 'md5' );
$link_subscription .= '&securekey=' . urlencode ( $encodedsecurekey );
$event [ 'url' ] = $link_subscription ;
2024-02-18 01:46:44 +01:00
}
2024-08-07 11:45:03 +02:00
$event [ 'created' ] = ( int ) $this -> db -> jdate ( $obj -> datec ) - ( getDolGlobalInt ( 'AGENDA_EXPORT_FIX_TZ' ) * 3600 );
$event [ 'modified' ] = ( int ) $this -> db -> jdate ( $obj -> datem ) - ( getDolGlobalInt ( 'AGENDA_EXPORT_FIX_TZ' ) * 3600 );
2021-03-02 22:23:54 +01:00
$event [ 'num_vote' ] = $this -> num_vote ;
$event [ 'event_paid' ] = $this -> event_paid ;
$event [ 'status' ] = $this -> status ;
2009-05-04 22:39:17 +02:00
2020-09-07 10:18:17 +02:00
// TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties
$this -> id = $obj -> id ;
$this -> fetch_userassigned ( false );
2019-11-01 11:59:54 +01:00
2020-09-07 10:18:17 +02:00
$assignedUserArray = array ();
2019-11-01 11:59:54 +01:00
2021-02-23 18:59:19 +01:00
foreach ( $this -> userassigned as $key => $value ) {
2020-09-07 10:18:17 +02:00
$assignedUser = new User ( $this -> db );
$assignedUser -> fetch ( $value [ 'id' ]);
2019-11-01 11:59:54 +01:00
2020-09-07 10:18:17 +02:00
$assignedUserArray [ $key ] = $assignedUser ;
}
2019-11-01 11:59:54 +01:00
2024-08-07 11:45:03 +02:00
if ( $filters [ 'module' ] != 'project@eventorganization' ) {
$event [ 'assignedUsers' ] = $assignedUserArray ;
}
2019-11-01 11:59:54 +01:00
2021-02-23 18:59:19 +01:00
if ( $qualified && $datestart ) {
2020-09-07 10:18:17 +02:00
$eventarray [] = $event ;
}
$diff ++ ;
}
2019-12-11 15:33:36 +01:00
2020-01-30 01:48:28 +01:00
$parameters = array ( 'filters' => $filters , 'eventarray' => & $eventarray );
$reshook = $hookmanager -> executeHooks ( 'addMoreEventsExport' , $parameters ); // Note that $action and $object may have been modified by hook
2021-02-23 18:59:19 +01:00
if ( $reshook > 0 ) {
2019-12-11 15:33:36 +01:00
$eventarray = $hookmanager -> resArray ;
}
2020-09-07 10:18:17 +02:00
} else {
$this -> error = $this -> db -> lasterror ();
return - 1 ;
}
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
if ( $exportholiday == 1 ) {
2022-11-18 10:04:02 +01:00
$langs -> load ( " holiday " );
2023-06-07 18:10:28 +02:00
$title = $langs -> transnoentities ( " Holidays " );
2020-01-16 13:49:05 +01:00
2020-09-07 10:18:17 +02:00
$sql = " SELECT u.rowid as uid, u.lastname, u.firstname, u.email, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " holiday as x, " . MAIN_DB_PREFIX . " user as u " ;
$sql .= " WHERE u.rowid = x.fk_user " ;
$sql .= " AND u.statut = '1' " ; // Show only active users (0 = inactive user, 1 = active user)
$sql .= " AND (x.statut = '2' OR x.statut = '3') " ; // Show only public leaves (2 = leave wait for approval, 3 = leave approved)
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 18:59:19 +01:00
if ( $resql ) {
2020-09-07 10:18:17 +02:00
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
2011-11-01 13:22:39 +01:00
2021-02-23 18:59:19 +01:00
while ( $i < $num ) {
2020-09-07 10:18:17 +02:00
$obj = $this -> db -> fetch_object ( $resql );
$event = array ();
2011-06-30 09:49:26 +02:00
2023-06-22 10:48:22 +02:00
if ( $obj -> halfday == 1 ) {
2020-09-07 10:18:17 +02:00
$event [ 'fulldayevent' ] = false ;
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$timestampStart = dol_stringtotime ( $obj -> date_start . " 00:00:00 " , 0 );
$timestampEnd = dol_stringtotime ( $obj -> date_end . " 12:00:00 " , 0 );
2023-06-22 10:48:22 +02:00
} elseif ( $obj -> halfday == - 1 ) {
2020-09-07 10:18:17 +02:00
$event [ 'fulldayevent' ] = false ;
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$timestampStart = dol_stringtotime ( $obj -> date_start . " 12:00:00 " , 0 );
$timestampEnd = dol_stringtotime ( $obj -> date_end . " 23:59:59 " , 0 );
} else {
$event [ 'fulldayevent' ] = true ;
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$timestampStart = dol_stringtotime ( $obj -> date_start . " 00:00:00 " , 0 );
$timestampEnd = dol_stringtotime ( $obj -> date_end . " 23:59:59 " , 0 );
}
2011-11-01 13:22:39 +01:00
2023-11-27 11:39:32 +01:00
if ( getDolGlobalString ( 'AGENDA_EXPORT_FIX_TZ' )) {
2024-04-02 01:48:30 +02:00
$timestampStart -= ( $conf -> global -> AGENDA_EXPORT_FIX_TZ * 3600 );
$timestampEnd -= ( $conf -> global -> AGENDA_EXPORT_FIX_TZ * 3600 );
2020-09-07 10:18:17 +02:00
}
2011-11-01 13:22:39 +01:00
2020-09-07 10:18:17 +02:00
$urlwithouturlroot = preg_replace ( '/' . preg_quote ( DOL_URL_ROOT , '/' ) . '$/i' , '' , trim ( $dolibarr_main_url_root ));
$urlwithroot = $urlwithouturlroot . DOL_URL_ROOT ;
$url = $urlwithroot . '/holiday/card.php?id=' . $obj -> rowid ;
$event [ 'uid' ] = 'dolibarrholiday-' . $this -> db -> database_name . '-' . $obj -> rowid . " @ " . $_SERVER [ " SERVER_NAME " ];
$event [ 'author' ] = dolGetFirstLastname ( $obj -> firstname , $obj -> lastname );
$event [ 'type' ] = 'event' ;
$event [ 'category' ] = " Holiday " ;
$event [ 'transparency' ] = 'OPAQUE' ;
$event [ 'email' ] = $obj -> email ;
$event [ 'created' ] = $timestampStart ;
$event [ 'modified' ] = $timestampStart ;
$event [ 'startdate' ] = $timestampStart ;
$event [ 'enddate' ] = $timestampEnd ;
$event [ 'duration' ] = $timestampEnd - $timestampStart ;
$event [ 'url' ] = $url ;
2021-02-23 18:59:19 +01:00
if ( $obj -> status == 2 ) {
2020-09-07 10:18:17 +02:00
// 2 = leave wait for approval
$event [ 'summary' ] = $title . " - " . $obj -> lastname . " (wait for approval) " ;
} else {
// 3 = leave approved
$event [ 'summary' ] = $title . " - " . $obj -> lastname ;
}
$eventarray [] = $event ;
$i ++ ;
}
}
}
$langs -> load ( " agenda " );
// Define title and desc
2024-02-18 01:46:44 +01:00
$title = '' ;
2020-09-07 10:18:17 +02:00
$more = '' ;
2021-02-23 18:59:19 +01:00
if ( $login ) {
$more = $langs -> transnoentities ( " User " ) . ' ' . $login ;
}
if ( $logina ) {
$more = $langs -> transnoentities ( " ActionsAskedBy " ) . ' ' . $logina ;
}
if ( $logint ) {
$more = $langs -> transnoentities ( " ActionsToDoBy " ) . ' ' . $logint ;
}
2024-02-18 01:46:44 +01:00
if ( $eventorganization ) {
$langs -> load ( " eventorganization " );
$title = $langs -> transnoentities ( " OrganizedEvent " ) . ( empty ( $eventarray [ 0 ][ 'label' ]) ? '' : ' ' . $eventarray [ 0 ][ 'label' ]);
$more = 'ICS file - ' . $langs -> transnoentities ( " OrganizedEvent " ) . ( empty ( $eventarray [ 0 ][ 'label' ]) ? '' : ' ' . $eventarray [ 0 ][ 'label' ]);
}
2021-02-23 18:59:19 +01:00
if ( $more ) {
2024-02-18 01:46:44 +01:00
if ( empty ( $title )) {
$title = 'Dolibarr actions ' . $mysoc -> name . ' - ' . $more ;
}
2020-09-07 10:18:17 +02:00
$desc = $more ;
$desc .= ' (' . $mysoc -> name . ' - built by Dolibarr)' ;
} else {
2024-02-18 01:46:44 +01:00
if ( empty ( $title )) {
$title = 'Dolibarr actions ' . $mysoc -> name ;
}
2020-09-07 10:18:17 +02:00
$desc = $langs -> transnoentities ( 'ListOfActions' );
$desc .= ' (' . $mysoc -> name . ' - built by Dolibarr)' ;
}
// Create temp file
$outputfiletmp = tempnam ( $conf -> agenda -> dir_temp , 'tmp' ); // Temporary file (allow call of function by different threads
2023-02-17 19:30:50 +01:00
dolChmod ( $outputfiletmp );
2020-09-07 10:18:17 +02:00
// Write file
2021-02-23 18:59:19 +01:00
if ( $format == 'vcal' ) {
$result = build_calfile ( $format , $title , $desc , $eventarray , $outputfiletmp );
} elseif ( $format == 'ical' ) {
$result = build_calfile ( $format , $title , $desc , $eventarray , $outputfiletmp );
} elseif ( $format == 'rss' ) {
$result = build_rssfile ( $format , $title , $desc , $eventarray , $outputfiletmp );
}
if ( $result >= 0 ) {
2024-09-05 16:05:37 +02:00
if ( dol_move ( $outputfiletmp , $outputfile , '0' , 1 , 0 , 0 )) {
2021-02-23 18:59:19 +01:00
$result = 1 ;
} else {
2020-09-07 10:18:17 +02:00
$this -> error = 'Failed to rename ' . $outputfiletmp . ' into ' . $outputfile ;
dol_syslog ( get_class ( $this ) . " ::build_exportfile " . $this -> error , LOG_ERR );
dol_delete_file ( $outputfiletmp , 0 , 1 );
$result = - 1 ;
}
} else {
dol_syslog ( get_class ( $this ) . " ::build_exportfile build_xxxfile function fails to for format= " . $format . " outputfiletmp= " . $outputfile , LOG_ERR );
dol_delete_file ( $outputfiletmp , 0 , 1 );
$langs -> load ( " errors " );
$this -> error = $langs -> trans ( " ErrorFailToCreateFile " , $outputfile );
}
}
return $result ;
}
/**
* Initialise an instance with random values .
* Used to build previews or test instances .
* id must be 0 if object instance is a specimen .
*
2024-04-02 01:48:30 +02:00
* @ return int < 1 , 1 > > 0 if ok
2020-09-07 10:18:17 +02:00
*/
public function initAsSpecimen ()
{
global $user ;
$now = dol_now ();
2024-01-14 12:26:37 +01:00
// Initialise parameters
2020-09-07 10:18:17 +02:00
$this -> id = 0 ;
$this -> specimen = 1 ;
$this -> type_code = 'AC_OTH' ;
$this -> code = 'AC_SPECIMEN_CODE' ;
$this -> label = 'Label of event Specimen' ;
$this -> datec = $now ;
$this -> datem = $now ;
$this -> datep = $now ;
$this -> datef = $now ;
$this -> fulldayevent = 0 ;
$this -> percentage = 0 ;
2021-03-02 22:23:54 +01:00
$this -> status = 0 ;
2020-09-07 10:18:17 +02:00
$this -> location = 'Location' ;
$this -> transparency = 1 ; // 1 means opaque
$this -> priority = 1 ;
//$this->note_public = "This is a 'public' note.";
2019-12-21 14:01:40 +01:00
$this -> note_private = " This is a 'private' note. " ;
2014-12-07 21:22:43 +01:00
2020-09-07 10:18:17 +02:00
$this -> userownerid = $user -> id ;
2024-03-09 16:32:02 +01:00
$this -> userassigned [ $user -> id ] = array ( 'id' => $user -> id , 'transparency' => 1 );
2020-09-07 10:18:17 +02:00
return 1 ;
}
2011-11-01 04:58:47 +01:00
2015-04-18 18:11:01 +02:00
/**
2019-02-27 20:45:07 +01:00
* Function used to replace a thirdparty id with another one .
2015-04-18 18:11:01 +02:00
*
2022-12-28 13:27:13 +01:00
* @ param DoliDB $dbs Database handler , because function is static we name it $dbs not $db to avoid breaking coding test
* @ param int $origin_id Old thirdparty id
* @ param int $dest_id New thirdparty id
* @ return bool
2015-04-18 18:11:01 +02:00
*/
2022-12-28 13:27:13 +01:00
public static function replaceThirdparty ( DoliDB $dbs , $origin_id , $dest_id )
2015-04-18 18:11:01 +02:00
{
$tables = array (
'actioncomm'
);
2022-12-28 13:27:13 +01:00
return CommonObject :: commonReplaceThirdparty ( $dbs , $origin_id , $dest_id , $tables );
2015-04-18 18:11:01 +02:00
}
2021-11-24 18:16:48 +01:00
/**
* Function used to replace a product id with another one .
*
2021-11-24 22:56:32 +01:00
* @ param DoliDB $dbs Database handler
2021-11-24 18:16:48 +01:00
* @ param int $origin_id Old product id
* @ param int $dest_id New product id
* @ return bool
*/
2021-11-24 22:56:32 +01:00
public static function replaceProduct ( DoliDB $dbs , $origin_id , $dest_id )
2021-11-24 18:16:48 +01:00
{
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'actioncomm SET fk_element = ' . (( int ) $dest_id ) . ' WHERE elementtype="product" AND fk_element = ' . (( int ) $origin_id );
2021-11-24 22:56:32 +01:00
// using $dbs, not $this->db because function is static
if ( ! $dbs -> query ( $sql )) {
//$this->errors = $dbs->lasterror();
2021-11-24 18:16:48 +01:00
return false ;
}
return true ;
}
2020-09-08 21:27:28 +02:00
/**
* Is the action delayed ?
*
* @ return bool
*/
public function hasDelay ()
{
global $conf ;
$now = dol_now ();
return $this -> datep && ( $this -> datep < ( $now - $conf -> agenda -> warning_delay ));
}
2020-09-14 20:53:42 +02:00
/**
* Load event reminder of events
*
2020-09-14 21:06:40 +02:00
* @ param string $type Type of reminder 'browser' or 'email'
* @ param int $fk_user Id of user
2020-09-24 12:31:28 +02:00
* @ param bool $onlypast true = get only past reminder , false = get all reminders linked to this
2024-04-02 01:48:30 +02:00
* @ return int <- 1 , max > < if OK , else count of number of reminders
2020-09-14 20:53:42 +02:00
*/
2020-09-24 12:31:28 +02:00
public function loadReminders ( $type = '' , $fk_user = 0 , $onlypast = true )
2020-09-14 20:53:42 +02:00
{
global $conf , $langs , $user ;
$error = 0 ;
$this -> reminders = array ();
//Select all action comm reminders for event
2023-12-18 17:42:17 +01:00
$sql = " SELECT rowid as id, typeremind, dateremind, status, offsetvalue, offsetunit, fk_user, fk_email_template, lasterror " ;
2020-09-14 20:53:42 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm_reminder " ;
2021-08-23 19:33:24 +02:00
$sql .= " WHERE fk_actioncomm = " . (( int ) $this -> id );
2020-09-24 12:31:28 +02:00
if ( $onlypast ) {
$sql .= " AND dateremind <= ' " . $this -> db -> idate ( dol_now ()) . " ' " ;
}
2020-09-14 20:53:42 +02:00
if ( $type ) {
2023-12-21 14:27:05 +01:00
$sql .= " AND typeremind = ' " . $this -> db -> escape ( $type ) . " ' " ;
2020-09-14 20:53:42 +02:00
}
2020-09-14 21:06:40 +02:00
if ( $fk_user > 0 ) {
$sql .= " AND fk_user = " . (( int ) $fk_user );
}
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'AGENDA_REMINDER_EMAIL' )) {
2023-12-21 14:27:05 +01:00
$sql .= " AND typeremind <> 'email' " ;
2021-02-23 18:59:19 +01:00
}
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'AGENDA_REMINDER_BROWSER' )) {
2023-12-21 14:27:05 +01:00
$sql .= " AND typeremind <> 'browser' " ;
2021-02-23 18:59:19 +01:00
}
2020-09-14 20:53:42 +02:00
$sql .= $this -> db -> order ( " dateremind " , " ASC " );
$resql = $this -> db -> query ( $sql );
if ( $resql ) {
while ( $obj = $this -> db -> fetch_object ( $resql )) {
$tmpactioncommreminder = new ActionCommReminder ( $this -> db );
$tmpactioncommreminder -> id = $obj -> id ;
$tmpactioncommreminder -> typeremind = $obj -> typeremind ;
$tmpactioncommreminder -> dateremind = $obj -> dateremind ;
$tmpactioncommreminder -> offsetvalue = $obj -> offsetvalue ;
$tmpactioncommreminder -> offsetunit = $obj -> offsetunit ;
$tmpactioncommreminder -> status = $obj -> status ;
2020-09-14 21:06:40 +02:00
$tmpactioncommreminder -> fk_user = $obj -> fk_user ;
2023-12-18 17:42:17 +01:00
$tmpactioncommreminder -> fk_email_template = $obj -> fk_email_template ;
$tmpactioncommreminder -> lasterror = $obj -> lasterror ;
2020-09-14 20:53:42 +02:00
$this -> reminders [ $obj -> id ] = $tmpactioncommreminder ;
}
} else {
$this -> error = $this -> db -> lasterror ();
$error ++ ;
}
return count ( $this -> reminders );
}
2020-09-08 21:27:28 +02:00
/**
* Send reminders by emails
* CAN BE A CRON TASK
*
2024-04-02 01:48:30 +02:00
* @ return int <- 1 , 1 >| string 0 if OK , <> 0 if KO ( this function is used also by cron so only 0 is OK )
2020-09-08 21:27:28 +02:00
*/
public function sendEmailsReminder ()
{
global $conf , $langs , $user ;
$error = 0 ;
$this -> output = '' ;
2019-11-14 12:09:15 +01:00
$this -> error = '' ;
2020-09-02 21:39:22 +02:00
$nbMailSend = 0 ;
$errorsMsg = array ();
2017-08-21 13:11:29 +02:00
2022-09-25 15:28:36 +02:00
if ( ! isModEnabled ( 'agenda' )) { // Should not happen. If module disabled, cron job should not be visible.
2018-11-03 12:37:52 +01:00
$langs -> load ( " agenda " );
$this -> output = $langs -> trans ( 'ModuleNotEnabled' , $langs -> transnoentitiesnoconv ( " Agenda " ));
return 0 ;
}
2023-11-27 11:39:32 +01:00
if ( ! getDolGlobalString ( 'AGENDA_REMINDER_EMAIL' )) {
2020-09-08 21:27:28 +02:00
$langs -> load ( " agenda " );
$this -> output = $langs -> trans ( 'EventRemindersByEmailNotEnabled' , $langs -> transnoentitiesnoconv ( " Agenda " ));
return 0 ;
}
2018-11-19 14:25:34 +01:00
2020-09-08 21:27:28 +02:00
$now = dol_now ();
2020-11-22 20:36:05 +01:00
$actionCommReminder = new ActionCommReminder ( $this -> db );
2017-10-31 23:10:29 +01:00
2023-11-21 12:17:30 +01:00
dol_syslog ( __METHOD__ . " start " , LOG_INFO );
2017-08-03 11:42:22 +02:00
2020-09-08 21:27:28 +02:00
$this -> db -> begin ();
2020-09-01 10:01:59 +02:00
2021-04-19 10:35:19 +02:00
//Select all action comm reminders
2020-09-08 21:27:28 +02:00
$sql = " SELECT rowid as id FROM " . MAIN_DB_PREFIX . " actioncomm_reminder " ;
2023-12-21 14:27:05 +01:00
$sql .= " WHERE typeremind = 'email' " ;
2023-12-21 14:35:40 +01:00
$sql .= " AND status = 0 " ; // 0=No yet sent, -1=Error. TODO Include reminder in error once we can count number of error, so we can try 5 times and not more on errors.
2021-04-19 10:35:19 +02:00
$sql .= " AND dateremind <= ' " . $this -> db -> idate ( $now ) . " ' " ;
$sql .= " AND entity IN ( " . getEntity ( 'actioncomm' ) . " ) " ;
2020-09-01 15:33:02 +02:00
$sql .= $this -> db -> order ( " dateremind " , " ASC " );
2020-09-08 21:27:28 +02:00
$resql = $this -> db -> query ( $sql );
2020-08-27 12:30:59 +02:00
2020-09-08 21:27:28 +02:00
if ( $resql ) {
2021-04-19 12:48:08 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' ;
2020-09-08 21:27:28 +02:00
$formmail = new FormMail ( $this -> db );
2024-04-02 01:48:30 +02:00
$to = null ; // Ensure 'to' is defined for static analysis
2020-09-01 15:33:02 +02:00
2020-09-14 04:30:04 +02:00
while ( $obj = $this -> db -> fetch_object ( $resql )) {
2020-09-08 21:27:28 +02:00
$res = $actionCommReminder -> fetch ( $obj -> id );
if ( $res < 0 ) {
$error ++ ;
$errorsMsg [] = " Failed to load invoice ActionComm Reminder " ;
}
2020-11-22 20:36:05 +01:00
if ( ! $error ) {
2020-09-08 21:27:28 +02:00
//Select email template
$arraymessage = $formmail -> getEMailTemplate ( $this -> db , 'actioncomm_send' , $user , $langs , ( ! empty ( $actionCommReminder -> fk_email_template )) ? $actionCommReminder -> fk_email_template : - 1 , 1 );
// Load event
$res = $this -> fetch ( $actionCommReminder -> fk_actioncomm );
2024-10-30 21:33:30 +01:00
if ( $res > 0 ) {
2024-11-20 22:49:59 +01:00
$res2 = $this -> fetch_thirdparty ();
if ( $res2 >= 0 ) {
// PREPARE EMAIL
$errormesg = '' ;
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray ( $langs , 0 , null , $this );
complete_substitutions_array ( $substitutionarray , $langs , $this );
// Content
$sendContent = make_substitutions ( $langs -> trans ( $arraymessage -> content ), $substitutionarray );
//Topic
$sendTopic = ( ! empty ( $arraymessage -> topic )) ? $arraymessage -> topic : html_entity_decode ( $langs -> transnoentities ( 'EventReminder' ));
// Recipient
$recipient = new User ( $this -> db );
$res = $recipient -> fetch ( $actionCommReminder -> fk_user );
if ( $res > 0 ) {
if ( ! empty ( $recipient -> email )) {
$to = $recipient -> email ;
} else {
$errormesg = " Failed to send remind to user id= " . $actionCommReminder -> fk_user . " . No email defined for user. " ;
$error ++ ;
}
2020-11-21 17:42:07 +01:00
} else {
2024-11-20 22:49:59 +01:00
$errormesg = " Failed to load recipient with user id= " . $actionCommReminder -> fk_user ;
2020-11-21 17:42:07 +01:00
$error ++ ;
}
2020-09-08 21:27:28 +02:00
2024-11-20 22:49:59 +01:00
// Sender
$from = getDolGlobalString ( 'MAIN_MAIL_EMAIL_FROM' );
if ( empty ( $from )) {
$errormesg = " Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM " ;
2020-11-21 17:42:07 +01:00
$error ++ ;
}
2024-11-20 22:49:59 +01:00
if ( ! $error ) {
// Errors Recipient
$errors_to = getDolGlobalString ( 'MAIN_MAIL_ERRORS_TO' );
2020-11-21 17:42:07 +01:00
2024-11-20 22:49:59 +01:00
// Mail Creation
$cMailFile = new CMailFile ( $sendTopic , $to , $from , $sendContent , array (), array (), array (), '' , " " , 0 , 1 , $errors_to , '' , '' , '' , '' , '' );
// Sending Mail
if ( $cMailFile -> sendfile ()) {
$nbMailSend ++ ;
} else {
$errormesg = 'Failed to send email to: ' . $to . ' ' . $cMailFile -> error . implode ( ',' , $cMailFile -> errors );
$error ++ ;
}
2020-09-08 21:27:28 +02:00
}
2020-11-21 17:42:07 +01:00
2024-11-20 22:49:59 +01:00
if ( ! $error ) {
$actionCommReminder -> status = $actionCommReminder :: STATUS_DONE ;
$res = $actionCommReminder -> update ( $user );
if ( $res < 0 ) {
$errorsMsg [] = " Failed to update status to done of ActionComm Reminder " ;
$error ++ ;
break ; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first.
}
2020-11-21 17:42:07 +01:00
} else {
2024-11-20 22:49:59 +01:00
$actionCommReminder -> status = $actionCommReminder :: STATUS_ERROR ;
$actionCommReminder -> lasterror = dol_trunc ( $errormesg , 128 , 'right' , 'UTF-8' , 1 );
$res = $actionCommReminder -> update ( $user );
if ( $res < 0 ) {
$errorsMsg [] = " Failed to update status to error of ActionComm Reminder " ;
$error ++ ;
break ; // This is to avoid to have this error on all the selected email. If we fails here for one record, it may fails for others. We must solve first.
} else {
$errorsMsg [] = $errormesg ;
}
2020-11-21 17:42:07 +01:00
}
2024-11-20 22:49:59 +01:00
} else {
$errorsMsg [] = 'Failed to fetch record thirdparty on actioncomm with ID = ' . $actionCommReminder -> fk_actioncomm ;
$error ++ ;
2020-09-08 21:27:28 +02:00
}
} else {
2020-11-21 17:42:07 +01:00
$errorsMsg [] = 'Failed to fetch record actioncomm with ID = ' . $actionCommReminder -> fk_actioncomm ;
2020-09-08 21:27:28 +02:00
$error ++ ;
}
}
}
} else {
$error ++ ;
}
2020-11-22 20:36:05 +01:00
if ( ! $error ) {
2020-09-08 21:27:28 +02:00
// Delete also very old past events (we do not keep more than 1 month record in past)
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " actioncomm_reminder " ;
2020-09-01 15:33:02 +02:00
$sql .= " WHERE dateremind < ' " . $this -> db -> idate ( $now - ( 3600 * 24 * 32 )) . " ' " ;
2021-06-09 15:36:47 +02:00
$sql .= " AND status = " . (( int ) $actionCommReminder :: STATUS_DONE );
2020-09-08 21:27:28 +02:00
$resql = $this -> db -> query ( $sql );
if ( ! $resql ) {
$errorsMsg [] = 'Failed to delete old reminders' ;
//$error++; // If this fails, we must not rollback other SQL requests already done. Never mind.
}
}
if ( ! $error ) {
$this -> output = 'Nb of emails sent : ' . $nbMailSend ;
$this -> db -> commit ();
2023-11-21 12:17:30 +01:00
dol_syslog ( __METHOD__ . " end - " . $this -> output , LOG_INFO );
2020-09-08 21:27:28 +02:00
return 0 ;
2020-11-22 20:36:05 +01:00
} else {
2020-12-01 02:41:19 +01:00
$this -> db -> commit (); // We commit also on error, to have the error message recorded.
2024-03-11 14:01:28 +01:00
$this -> error = 'Nb of emails sent : ' . $nbMailSend . ', ' . ( ! empty ( $errorsMsg ) ? implode ( ', ' , $errorsMsg ) : $error );
2023-11-21 12:17:30 +01:00
dol_syslog ( __METHOD__ . " end - " . $this -> error , LOG_INFO );
2020-09-08 21:27:28 +02:00
return $error ;
}
}
2020-05-19 08:29:23 +02:00
2020-05-19 08:07:21 +02:00
/**
2024-01-14 12:26:37 +01:00
* Update the percent value of a event with the given id
2020-05-19 08:07:21 +02:00
*
2024-04-02 01:48:30 +02:00
* @ param int $id The id of the event
* @ param int < 0 , 100 > $percent The new percent value for the event
* @ param int $usermodid The user who modified the percent
* @ return int <- 1 , 1 > 1 when update of the event was successful , otherwise - 1
2020-05-19 08:07:21 +02:00
*/
2022-06-12 13:33:42 +02:00
public function updatePercent ( $id , $percent , $usermodid = 0 )
2020-05-19 08:07:21 +02:00
{
$this -> db -> begin ();
$sql = " UPDATE " . MAIN_DB_PREFIX . " actioncomm " ;
2020-05-23 14:26:28 +02:00
$sql .= " SET percent = " . ( int ) $percent ;
2023-12-04 12:01:45 +01:00
if ( $usermodid > 0 ) {
$sql .= " , fk_user_mod = " . $usermodid ;
}
2021-04-24 20:18:11 +02:00
$sql .= " WHERE id = " . (( int ) $id );
2020-05-19 08:07:21 +02:00
2021-02-23 18:59:19 +01:00
if ( $this -> db -> query ( $sql )) {
2020-05-19 08:07:21 +02:00
$this -> db -> commit ();
return 1 ;
2020-05-23 21:07:47 +02:00
} else {
2020-05-19 08:07:21 +02:00
$this -> db -> rollback ();
$this -> error = $this -> db -> lasterror ();
return - 1 ;
}
}
2006-10-24 01:07:46 +02:00
}