2004-10-19 22:43:23 +02:00
< ? php
2003-09-19 13:27:17 +02:00
/* Copyright ( C ) 2002 - 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2014-09-18 08:58:47 +02:00
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2020-09-03 12:43:38 +02:00
* Copyright ( C ) 2011 - 2020 Juanjo Menent < jmenent @ 2 byte . es >
2015-04-18 20:50:03 +02:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2020-09-30 15:17:44 +02:00
* Copyright ( C ) 2015 - 2020 Charlene Benke < charlie @ patas - monkey . com >
2019-03-21 15:08:09 +01:00
* Copyright ( C ) 2018 Nicolas ZABOURI < info @ inovea - conseil . com >
2024-07-01 19:06:24 +02:00
* Copyright ( C ) 2018 - 2024 Frédéric France < frederic . france @ free . fr >
* Copyright ( C ) 2023 - 2024 William Mead < william . mead @ manchenumerique . fr >
2025-02-03 11:24:16 +01:00
* Copyright ( C ) 2024 - 2025 MDW < mdeweerd @ users . noreply . github . com >
2013-08-22 16:49:23 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2013-08-22 16:49:23 +02:00
*/
2003-09-19 13:27:17 +02:00
2011-08-27 17:14:31 +02:00
/**
* \file htdocs / fichinter / class / fichinter . class . php
2023-03-12 13:55:33 +01:00
* \ingroup fichinter
2024-01-13 19:48:41 +01:00
* \brief File for class to manage interventions
2013-08-22 16:49:23 +02:00
*/
2019-12-18 15:20:36 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php' ;
2024-08-29 17:39:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinterligne.class.php' ;
2024-09-10 16:22:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/commonsignedobject.class.php' ;
2005-01-09 19:30:34 +01:00
2008-06-21 01:01:02 +02:00
/**
2014-09-18 08:58:47 +02:00
* Class to manage interventions
2024-09-13 17:45:05 +02:00
* @ property int $signed_status
* @ static array < int > $SIGNED_STATUSES
2008-06-21 01:01:02 +02:00
*/
2006-06-18 16:35:35 +02:00
class Fichinter extends CommonObject
2003-09-19 13:27:17 +02:00
{
2024-09-10 16:22:25 +02:00
use CommonSignedObject ;
2020-03-12 12:45:44 +01:00
public $fields = array (
2024-03-11 22:55:05 +01:00
'rowid' => array ( 'type' => 'integer' , 'label' => 'TechnicalID' , 'enabled' => 1 , 'visible' => - 1 , 'notnull' => 1 , 'position' => 10 ),
'fk_soc' => array ( 'type' => 'integer:Societe:societe/class/societe.class.php' , 'label' => 'ThirdParty' , 'enabled' => 'isModEnabled("societe")' , 'visible' => - 1 , 'notnull' => 1 , 'position' => 15 ),
'fk_projet' => array ( 'type' => 'integer:Project:projet/class/project.class.php:1:(fk_statut:=:1)' , 'label' => 'Fk projet' , 'enabled' => 'isModEnabled("project")' , 'visible' => - 1 , 'position' => 20 ),
'fk_contrat' => array ( 'type' => 'integer' , 'label' => 'Fk contrat' , 'enabled' => '$conf->contrat->enabled' , 'visible' => - 1 , 'position' => 25 ),
'ref' => array ( 'type' => 'varchar(30)' , 'label' => 'Ref' , 'enabled' => 1 , 'visible' => - 1 , 'notnull' => 1 , 'showoncombobox' => 1 , 'position' => 30 ),
2025-01-12 18:00:01 +01:00
'ref_ext' => array ( 'type' => 'varchar(255)' , 'label' => 'RefExt' , 'enabled' => 1 , 'visible' => 0 , 'position' => 35 ),
2024-03-11 22:55:05 +01:00
'ref_client' => array ( 'type' => 'varchar(255)' , 'label' => 'RefCustomer' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 36 ),
'entity' => array ( 'type' => 'integer' , 'label' => 'Entity' , 'default' => '1' , 'enabled' => 1 , 'visible' => - 2 , 'notnull' => 1 , 'position' => 40 , 'index' => 1 ),
'tms' => array ( 'type' => 'timestamp' , 'label' => 'DateModification' , 'enabled' => 1 , 'visible' => - 1 , 'notnull' => 1 , 'position' => 45 ),
'datec' => array ( 'type' => 'datetime' , 'label' => 'DateCreation' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 50 ),
'date_valid' => array ( 'type' => 'datetime' , 'label' => 'DateValidation' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 55 ),
'datei' => array ( 'type' => 'date' , 'label' => 'Datei' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 60 ),
'fk_user_author' => array ( 'type' => 'integer:User:user/class/user.class.php' , 'label' => 'Fk user author' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 65 ),
'fk_user_modif' => array ( 'type' => 'integer:User:user/class/user.class.php' , 'label' => 'UserModif' , 'enabled' => 1 , 'visible' => - 2 , 'notnull' => - 1 , 'position' => 70 ),
'fk_user_valid' => array ( 'type' => 'integer:User:user/class/user.class.php' , 'label' => 'UserValidation' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 75 ),
'dateo' => array ( 'type' => 'date' , 'label' => 'Dateo' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 85 ),
'datee' => array ( 'type' => 'date' , 'label' => 'Datee' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 90 ),
'datet' => array ( 'type' => 'date' , 'label' => 'Datet' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 95 ),
2024-10-24 01:32:10 +02:00
'duree' => array ( 'type' => 'integer' , 'label' => 'Duree' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 100 ),
2024-08-27 07:01:03 +02:00
'signed_status' => array ( 'type' => 'smallint(6)' , 'label' => 'SignedStatus' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 101 , 'arrayofkeyval' => array ( 0 => 'NoSignature' , 1 => 'SignedSender' , 2 => 'SignedReceiver' , 3 => 'SignedReceiverOnline' , 9 => 'SignedAll' )),
2024-03-11 22:55:05 +01:00
'description' => array ( 'type' => 'html' , 'label' => 'Description' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 105 , 'showoncombobox' => 2 ),
'note_private' => array ( 'type' => 'html' , 'label' => 'NotePrivate' , 'enabled' => 1 , 'visible' => 0 , 'position' => 110 ),
'note_public' => array ( 'type' => 'html' , 'label' => 'NotePublic' , 'enabled' => 1 , 'visible' => 0 , 'position' => 115 ),
'model_pdf' => array ( 'type' => 'varchar(255)' , 'label' => 'Model pdf' , 'enabled' => 1 , 'visible' => 0 , 'position' => 120 ),
'last_main_doc' => array ( 'type' => 'varchar(255)' , 'label' => 'Last main doc' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 125 ),
'import_key' => array ( 'type' => 'varchar(14)' , 'label' => 'ImportId' , 'enabled' => 1 , 'visible' => - 2 , 'position' => 130 ),
'extraparams' => array ( 'type' => 'varchar(255)' , 'label' => 'Extraparams' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 135 ),
'fk_statut' => array ( 'type' => 'integer' , 'label' => 'Fk statut' , 'enabled' => 1 , 'visible' => - 1 , 'position' => 500 ),
2020-03-04 10:05:20 +01:00
);
2022-09-02 08:53:13 +02:00
2018-08-23 18:35:45 +02:00
/**
* @ var string ID to identify managed object
*/
2019-12-18 15:20:36 +01:00
public $element = 'fichinter' ;
2018-09-02 23:25:10 +02:00
2018-08-22 18:48:53 +02:00
/**
* @ var string Name of table without prefix where object is stored
*/
2019-12-18 15:20:36 +01:00
public $table_element = 'fichinter' ;
2018-09-02 23:25:10 +02:00
2018-09-02 11:08:41 +02:00
/**
2024-01-22 17:50:52 +01:00
* @ var string Name of subtable line
2018-09-02 11:08:41 +02:00
*/
2019-12-18 15:20:36 +01:00
public $table_element_line = 'fichinterdet' ;
2018-09-02 11:08:41 +02:00
2018-09-05 12:21:13 +02:00
/**
* @ var string String with name of icon for myobject . Must be the part after the 'object_' into object_myobject . png
*/
2017-10-07 13:09:31 +02:00
public $picto = 'intervention' ;
2017-07-25 21:22:22 +02:00
2014-12-25 21:47:39 +01:00
/**
* { @ inheritdoc }
*/
protected $table_ref_field = 'ref' ;
2020-11-19 20:50:58 +01:00
/**
* @ var int Thirdparty Id
*/
public $socid ;
2006-06-23 21:40:28 +02:00
2024-08-29 17:39:17 +02:00
/**
* @ var User User that created intervention
*/
2018-09-01 15:27:55 +02:00
public $author ;
2019-03-21 20:15:19 +01:00
2019-03-21 15:08:09 +01:00
/**
2024-07-01 19:06:24 +02:00
* @ var null | int | '' Date creation record ( datec )
2020-10-31 14:32:18 +01:00
*/
public $datec ;
2019-03-21 20:15:19 +01:00
2024-07-01 19:06:24 +02:00
/**
* @ var null | int | '' Date record ( datev )
*/
2018-09-01 15:27:55 +02:00
public $datev ;
2024-07-01 19:06:24 +02:00
/**
* @ var null | int | '' Date record ( dateo )
*/
2018-09-01 15:27:55 +02:00
public $dateo ;
2024-07-01 19:06:24 +02:00
/**
* @ var null | int | '' Date record ( datee )
*/
2018-09-01 15:27:55 +02:00
public $datee ;
2024-07-01 19:06:24 +02:00
/**
* @ var null | int | '' Date t record ( datet )
*/
2018-09-01 15:27:55 +02:00
public $datet ;
2019-03-21 20:15:19 +01:00
2019-03-21 15:08:09 +01:00
/**
2020-10-31 14:32:18 +01:00
* Date modification record ( tms )
*
2024-10-24 01:32:10 +02:00
* @ var int
2020-10-31 14:32:18 +01:00
*/
public $datem ;
2019-03-21 20:15:19 +01:00
2020-11-19 20:50:58 +01:00
/**
* @ var int duration
*/
2018-09-01 15:27:55 +02:00
public $duration ;
2020-11-19 20:50:58 +01:00
/**
* @ var int status
*/
2019-12-18 15:20:36 +01:00
public $statut = 0 ; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
2018-08-31 19:26:08 +02:00
/**
* @ var string description
*/
public $description ;
2006-06-23 21:40:28 +02:00
2018-10-10 12:16:20 +02:00
/**
2020-11-19 20:50:58 +01:00
* @ var int Contract ID
2020-10-31 14:32:18 +01:00
*/
2018-09-01 15:27:55 +02:00
public $fk_contrat = 0 ;
2018-10-10 12:16:20 +02:00
/**
2020-11-19 20:50:58 +01:00
* @ var int Project ID
2020-10-31 14:32:18 +01:00
*/
2018-09-01 15:27:55 +02:00
public $fk_project = 0 ;
2018-10-10 12:16:20 +02:00
2022-05-17 12:53:50 +02:00
/**
* Customer Ref
* @ var string
*/
public $ref_client ;
2020-11-19 20:50:58 +01:00
/**
2024-09-12 21:16:42 +02:00
* @ var array < string , string > ( Encoded as JSON in database )
2020-11-19 20:50:58 +01:00
*/
2019-12-18 15:20:36 +01:00
public $extraparams = array ();
2008-06-21 01:01:02 +02:00
2020-11-19 20:50:58 +01:00
/**
2023-02-08 22:23:40 +01:00
* @ var FichinterLigne [] lines
2020-11-19 20:50:58 +01:00
*/
2018-09-01 15:27:55 +02:00
public $lines = array ();
2008-06-21 01:01:02 +02:00
2017-07-25 21:22:22 +02:00
/**
* Draft status
*/
const STATUS_DRAFT = 0 ;
2018-09-02 11:08:41 +02:00
2017-07-25 21:22:22 +02:00
/**
* Validated status
*/
const STATUS_VALIDATED = 1 ;
2018-09-02 11:08:41 +02:00
2017-07-25 21:22:22 +02:00
/**
* Billed
*/
const STATUS_BILLED = 2 ;
2018-09-02 11:08:41 +02:00
2017-07-25 21:22:22 +02:00
/**
* Closed
*/
const STATUS_CLOSED = 3 ;
2023-11-18 12:12:40 +01:00
/**
2025-01-05 13:53:16 +01:00
* Date of delivery of receipt
* @ var null | int | '' Date the intervention receipt has been delivered
* @ deprecated Use $delivery_date_receipt
2023-11-18 12:12:40 +01:00
*/
2023-11-18 17:55:47 +01:00
public $date_delivery ;
2023-11-18 12:12:40 +01:00
2025-01-05 13:53:16 +01:00
/**
* Date of delivery of receipt
* @ var null | int | '' Date the intervention receipt has been delivered
*/
public $delivery_date_receipt ;
2023-11-18 12:12:40 +01:00
/**
* Author Id
* @ var int
*/
2023-11-18 17:55:47 +01:00
public $user_author_id ;
2023-11-18 12:12:40 +01:00
2020-11-28 14:47:39 +01:00
2008-06-21 01:01:02 +02:00
/**
2011-09-11 20:35:38 +02:00
* Constructor
2011-09-10 19:52:21 +02:00
*
2012-02-24 17:25:53 +01:00
* @ param DoliDB $db Database handler
2017-10-07 13:09:31 +02:00
*/
2020-10-31 14:32:18 +01:00
public function __construct ( $db )
{
2012-07-30 17:17:33 +02:00
$this -> db = $db ;
2020-10-31 14:32:18 +01:00
}
2008-06-21 01:01:02 +02:00
2016-04-23 13:16:19 +02:00
/**
* Load indicators into this -> nb for board
*
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2016-04-23 13:16:19 +02:00
*/
2024-01-18 18:55:53 +01:00
public function loadStateBoard ()
2016-04-23 13:16:19 +02:00
{
global $user ;
2019-12-18 15:20:36 +01:00
$this -> nb = array ();
2016-04-23 13:16:19 +02:00
$clause = " WHERE " ;
$sql = " SELECT count(fi.rowid) as nb " ;
2019-12-18 15:20:36 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " fichinter as fi " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON fi.fk_soc = s.rowid " ;
2024-01-09 13:08:22 +01:00
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2019-12-18 15:20:36 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON s.rowid = sc.fk_soc " ;
2021-08-23 17:41:11 +02:00
$sql .= " WHERE sc.fk_user = " . (( int ) $user -> id );
2016-04-23 13:16:19 +02:00
$clause = " AND " ;
}
2019-12-18 15:20:36 +01:00
$sql .= " " . $clause . " fi.entity IN ( " . getEntity ( 'intervention' ) . " ) " ;
2016-04-23 13:16:19 +02:00
2019-12-18 15:20:36 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( $resql ) {
while ( $obj = $this -> db -> fetch_object ( $resql )) {
2020-04-12 16:36:25 +02:00
$this -> nb [ " interventions " ] = $obj -> nb ;
2016-04-23 13:16:19 +02:00
}
$this -> db -> free ( $resql );
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2016-04-23 13:16:19 +02:00
dol_print_error ( $this -> db );
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2016-04-23 13:16:19 +02:00
return - 1 ;
}
}
2008-06-21 01:01:02 +02:00
2011-07-08 11:18:54 +02:00
/**
2011-10-27 16:38:49 +02:00
* Create an intervention into data base
*
2024-01-13 19:48:41 +01:00
* @ param User $user Object user that make creation
2017-10-07 13:09:31 +02:00
* @ param int $notrigger Disable all triggers
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2020-10-31 14:32:18 +01:00
public function create ( $user , $notrigger = 0 )
2007-09-22 03:47:43 +02:00
{
2018-01-27 19:31:48 +01:00
global $conf , $langs ;
2009-07-07 18:19:37 +02:00
2020-10-31 14:32:18 +01:00
$error = 0 ;
2019-12-12 20:25:36 +01:00
2011-10-27 16:04:50 +02:00
dol_syslog ( get_class ( $this ) . " ::create ref= " . $this -> ref );
2007-09-22 03:47:43 +02:00
2010-05-04 20:12:43 +02:00
// Check parameters
2021-02-25 23:00:32 +01:00
if ( ! empty ( $this -> ref )) { // We check that ref is not already used
2019-12-18 15:20:36 +01:00
$result = self :: isExistingObject ( $this -> element , 0 , $this -> ref ); // Check ref is not yet used
2021-02-25 23:00:32 +01:00
if ( $result > 0 ) {
2019-12-18 15:20:36 +01:00
$this -> error = 'ErrorRefAlreadyExists' ;
2019-01-27 11:55:16 +01:00
dol_syslog ( get_class ( $this ) . " ::create " . $this -> error , LOG_WARNING );
2014-05-13 10:12:45 +02:00
$this -> db -> rollback ();
return - 1 ;
}
2013-05-19 18:28:27 +02:00
}
2021-02-25 23:00:32 +01:00
if ( ! is_numeric ( $this -> duration )) {
$this -> duration = 0 ;
}
2022-05-17 12:53:50 +02:00
if ( isset ( $this -> ref_client )) {
$this -> ref_client = trim ( $this -> ref_client );
}
2014-05-13 10:12:45 +02:00
2021-02-25 23:00:32 +01:00
if ( $this -> socid <= 0 ) {
2022-03-18 10:13:19 +01:00
$this -> error = 'ErrorFicheinterCompanyDoesNotExist' ;
2019-01-27 11:55:16 +01:00
dol_syslog ( get_class ( $this ) . " ::create " . $this -> error , LOG_ERR );
2007-09-22 03:47:43 +02:00
return - 1 ;
}
2024-11-21 19:11:32 +01:00
$this -> entity = setEntity ( $this );
2014-05-13 10:12:45 +02:00
2007-09-22 03:47:43 +02:00
$soc = new Societe ( $this -> db );
2019-12-18 15:20:36 +01:00
$result = $soc -> fetch ( $this -> socid );
2008-06-21 01:01:02 +02:00
2019-12-18 15:20:36 +01:00
$now = dol_now ();
2010-05-04 20:12:43 +02:00
$this -> db -> begin ();
2009-05-02 16:26:54 +02:00
$sql = " INSERT INTO " . MAIN_DB_PREFIX . " fichinter ( " ;
2019-12-18 15:20:36 +01:00
$sql .= " fk_soc " ;
$sql .= " , datec " ;
$sql .= " , ref " ;
2022-05-17 12:53:50 +02:00
$sql .= " , ref_client " ;
2019-12-18 15:20:36 +01:00
$sql .= " , entity " ;
$sql .= " , fk_user_author " ;
$sql .= " , fk_user_modif " ;
$sql .= " , description " ;
$sql .= " , model_pdf " ;
$sql .= " , fk_projet " ;
$sql .= " , fk_contrat " ;
$sql .= " , fk_statut " ;
2024-08-27 07:01:03 +02:00
$sql .= " , signed_status " ;
2019-12-18 15:20:36 +01:00
$sql .= " , note_private " ;
$sql .= " , note_public " ;
$sql .= " ) " ;
$sql .= " VALUES ( " ;
$sql .= $this -> socid ;
$sql .= " , ' " . $this -> db -> idate ( $now ) . " ' " ;
$sql .= " , ' " . $this -> db -> escape ( $this -> ref ) . " ' " ;
2022-05-18 22:24:30 +02:00
$sql .= " , " . ( $this -> ref_client ? " ' " . $this -> db -> escape ( $this -> ref_client ) . " ' " : " null " );
2024-11-21 19:11:32 +01:00
$sql .= " , " . (( int ) $this -> entity );
2021-09-03 21:25:17 +02:00
$sql .= " , " . (( int ) $user -> id );
$sql .= " , " . (( int ) $user -> id );
2019-12-18 15:20:36 +01:00
$sql .= " , " . ( $this -> description ? " ' " . $this -> db -> escape ( $this -> description ) . " ' " : " null " );
2020-09-10 01:49:09 +02:00
$sql .= " , ' " . $this -> db -> escape ( $this -> model_pdf ) . " ' " ;
2021-09-03 21:25:17 +02:00
$sql .= " , " . ( $this -> fk_project ? (( int ) $this -> fk_project ) : 0 );
$sql .= " , " . ( $this -> fk_contrat ? (( int ) $this -> fk_contrat ) : 0 );
$sql .= " , " . (( int ) $this -> statut );
2024-08-27 07:01:03 +02:00
$sql .= " , " . ( $this -> signed_status );
2019-12-18 15:20:36 +01:00
$sql .= " , " . ( $this -> note_private ? " ' " . $this -> db -> escape ( $this -> note_private ) . " ' " : " null " );
$sql .= " , " . ( $this -> note_public ? " ' " . $this -> db -> escape ( $this -> note_public ) . " ' " : " null " );
$sql .= " ) " ;
2007-09-22 03:47:43 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( get_class ( $this ) . " ::create " , LOG_DEBUG );
2019-12-18 15:20:36 +01:00
$result = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( $result ) {
2019-12-18 15:20:36 +01:00
$this -> id = $this -> db -> last_insert_id ( MAIN_DB_PREFIX . " fichinter " );
2013-05-19 11:18:45 +02:00
2021-02-25 23:00:32 +01:00
if ( $this -> id ) {
2019-12-18 15:20:36 +01:00
$this -> ref = '(PROV' . $this -> id . ')' ;
2021-03-14 12:20:23 +01:00
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " fichinter SET ref=' " . $this -> db -> escape ( $this -> ref ) . " ' WHERE rowid= " . (( int ) $this -> id );
2013-05-20 21:21:03 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( get_class ( $this ) . " ::create " , LOG_DEBUG );
2019-12-18 15:20:36 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( ! $resql ) {
$error ++ ;
}
2013-03-10 13:58:32 +01:00
}
2014-08-28 14:48:16 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2019-12-18 15:20:36 +01:00
$result = $this -> insertExtraFields ();
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
2017-10-07 13:09:31 +02:00
$error ++ ;
}
}
2014-08-28 14:48:16 +02:00
2013-05-18 12:17:43 +02:00
// Add linked object
2021-02-25 23:00:32 +01:00
if ( ! $error && $this -> origin && $this -> origin_id ) {
2013-05-18 12:17:43 +02:00
$ret = $this -> add_object_linked ();
2021-02-25 23:00:32 +01:00
if ( ! $ret ) {
dol_print_error ( $this -> db );
}
2013-05-18 12:17:43 +02:00
}
2012-12-05 18:48:02 +01:00
2021-02-25 23:00:32 +01:00
if ( ! $error && ! $notrigger ) {
2017-10-07 13:09:31 +02:00
// Call trigger
2019-12-18 15:20:36 +01:00
$result = $this -> call_trigger ( 'FICHINTER_CREATE' , $user );
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2017-10-07 13:09:31 +02:00
// End call triggers
}
2012-07-29 12:54:19 +02:00
2020-11-19 20:50:58 +01:00
if ( ! $error ) {
2012-12-30 17:13:43 +01:00
$this -> db -> commit ();
return $this -> id ;
2020-05-21 15:05:19 +02:00
} else {
2012-12-30 17:13:43 +01:00
$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
$this -> error = implode ( ',' , $this -> errors );
2019-01-27 11:55:16 +01:00
dol_syslog ( get_class ( $this ) . " ::create " . $this -> error , LOG_ERR );
2012-12-30 17:13:43 +01:00
return - 1 ;
}
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2007-09-22 03:47:43 +02:00
$this -> db -> rollback ();
return - 1 ;
}
}
2005-02-10 23:55:42 +01:00
2011-07-08 11:18:54 +02:00
/**
2011-10-27 16:38:49 +02:00
* Update an intervention
*
2024-01-13 19:48:41 +01:00
* @ param User $user Object user that make creation
2017-10-07 13:09:31 +02:00
* @ param int $notrigger Disable all triggers
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2020-10-31 14:32:18 +01:00
public function update ( $user , $notrigger = 0 )
2008-06-21 01:01:02 +02:00
{
2020-10-31 14:32:18 +01:00
global $conf ;
2019-12-12 20:25:36 +01:00
2021-02-25 23:00:32 +01:00
if ( ! is_numeric ( $this -> duration )) {
$this -> duration = 0 ;
}
2024-09-13 17:40:03 +02:00
if ( ! dol_strlen (( string ) $this -> fk_project )) {
2021-02-25 23:00:32 +01:00
$this -> fk_project = 0 ;
}
2022-05-17 12:53:50 +02:00
if ( isset ( $this -> ref_client )) {
$this -> ref_client = trim ( $this -> ref_client );
}
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
$error = 0 ;
2018-08-12 16:29:26 +02:00
2011-10-27 16:04:50 +02:00
$this -> db -> begin ();
2011-11-04 00:27:30 +01:00
2008-06-21 01:01:02 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " fichinter SET " ;
2019-12-18 15:20:36 +01:00
$sql .= " description = ' " . $this -> db -> escape ( $this -> description ) . " ' " ;
2021-06-09 15:36:47 +02:00
$sql .= " , duree = " . (( int ) $this -> duration );
2022-05-17 12:53:50 +02:00
$sql .= " , ref_client = " . ( $this -> ref_client ? " ' " . $this -> db -> escape ( $this -> ref_client ) . " ' " : " null " );
2021-06-09 15:36:47 +02:00
$sql .= " , fk_projet = " . (( int ) $this -> fk_project );
2019-12-18 15:20:36 +01:00
$sql .= " , note_private = " . ( $this -> note_private ? " ' " . $this -> db -> escape ( $this -> note_private ) . " ' " : " null " );
$sql .= " , note_public = " . ( $this -> note_public ? " ' " . $this -> db -> escape ( $this -> note_public ) . " ' " : " null " );
2021-08-23 19:33:24 +02:00
$sql .= " , fk_user_modif = " . (( int ) $user -> id );
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2005-09-07 23:47:16 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( get_class ( $this ) . " ::update " , LOG_DEBUG );
2021-02-25 23:00:32 +01:00
if ( $this -> db -> query ( $sql )) {
if ( ! $error ) {
2019-12-18 15:20:36 +01:00
$result = $this -> insertExtraFields ();
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
2018-08-12 16:29:26 +02:00
$error ++ ;
}
}
2013-05-20 21:21:03 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error && ! $notrigger ) {
2017-10-07 13:09:31 +02:00
// Call trigger
2019-12-18 15:20:36 +01:00
$result = $this -> call_trigger ( 'FICHINTER_MODIFY' , $user );
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
2023-12-04 12:12:12 +01:00
$error ++ ;
$this -> db -> rollback ();
return - 1 ;
2021-02-25 23:00:32 +01:00
}
2017-10-07 13:09:31 +02:00
// End call triggers
2013-05-18 12:53:11 +02:00
}
2013-06-16 21:31:21 +02:00
2011-10-27 16:04:50 +02:00
$this -> db -> commit ();
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2011-10-27 16:04:50 +02:00
$this -> db -> rollback ();
2006-04-29 03:28:16 +02:00
return - 1 ;
2008-06-21 01:01:02 +02:00
}
}
/**
2011-07-08 11:18:54 +02:00
* Fetch a intervention
2011-10-27 16:38:49 +02:00
*
2012-01-08 00:52:07 +01:00
* @ param int $rowid Id of intervention
* @ param string $ref Ref of intervention
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2020-10-31 14:32:18 +01:00
public function fetch ( $rowid , $ref = '' )
2008-06-21 01:01:02 +02:00
{
2024-08-27 07:01:03 +02:00
$sql = " SELECT f.rowid, f.ref, f.ref_client, f.description, f.fk_soc, f.fk_statut as status, f.signed_status, " ;
2019-12-18 15:20:36 +01:00
$sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author, " ;
$sql .= " f.date_valid as datev, " ;
$sql .= " f.tms as datem, " ;
2022-10-20 16:41:27 +02:00
$sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.last_main_doc, f.extraparams, fk_contrat, f.entity as entity " ;
2019-12-18 15:20:36 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " fichinter as f " ;
2018-03-22 16:18:11 +01:00
if ( $ref ) {
2019-12-18 15:20:36 +01:00
$sql .= " WHERE f.entity IN ( " . getEntity ( 'intervention' ) . " ) " ;
2022-01-03 18:15:19 +01:00
$sql .= " AND f.ref = ' " . $this -> db -> escape ( $ref ) . " ' " ;
2021-02-25 23:00:32 +01:00
} else {
2022-01-03 18:15:19 +01:00
$sql .= " WHERE f.rowid = " . (( int ) $rowid );
2021-02-25 23:00:32 +01:00
}
2005-09-07 23:47:16 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( get_class ( $this ) . " ::fetch " , LOG_DEBUG );
2019-12-18 15:20:36 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( $resql ) {
if ( $this -> db -> num_rows ( $resql )) {
2008-06-21 01:01:02 +02:00
$obj = $this -> db -> fetch_object ( $resql );
2009-07-07 18:19:37 +02:00
$this -> id = $obj -> rowid ;
2008-06-21 01:01:02 +02:00
$this -> ref = $obj -> ref ;
2022-05-17 12:53:50 +02:00
$this -> ref_client = $obj -> ref_client ;
2008-06-21 01:01:02 +02:00
$this -> description = $obj -> description ;
$this -> socid = $obj -> fk_soc ;
2023-08-06 00:16:25 +02:00
$this -> status = $obj -> status ;
$this -> statut = $obj -> status ; // deprecated
2024-09-12 21:16:42 +02:00
$this -> signed_status = $obj -> signed_status ;
2015-06-11 23:18:29 +02:00
$this -> duration = $obj -> duree ;
2010-01-13 19:51:19 +01:00
$this -> datec = $this -> db -> jdate ( $obj -> datec );
2018-05-10 16:08:45 +02:00
$this -> dateo = $this -> db -> jdate ( $obj -> dateo );
$this -> datee = $this -> db -> jdate ( $obj -> datee );
2015-12-15 11:52:11 +01:00
$this -> datet = $this -> db -> jdate ( $obj -> datet );
2010-01-13 19:51:19 +01:00
$this -> datev = $this -> db -> jdate ( $obj -> datev );
$this -> datem = $this -> db -> jdate ( $obj -> datem );
2019-02-27 15:32:18 +01:00
$this -> fk_project = $obj -> fk_project ;
2008-06-21 01:01:02 +02:00
$this -> note_public = $obj -> note_public ;
$this -> note_private = $obj -> note_private ;
2020-08-18 14:48:38 +02:00
$this -> model_pdf = $obj -> model_pdf ;
2019-02-25 20:35:59 +01:00
$this -> fk_contrat = $obj -> fk_contrat ;
2022-04-14 12:08:06 +02:00
$this -> entity = $obj -> entity ;
2012-03-18 01:25:08 +01:00
2023-10-24 11:37:29 +02:00
$this -> user_creation_id = $obj -> fk_user_author ;
2017-07-25 21:22:22 +02:00
2024-09-13 02:52:27 +02:00
$this -> extraparams = is_null ( $obj -> extraparams ) ? [] : ( array ) json_decode ( $obj -> extraparams , true );
2008-06-21 01:01:02 +02:00
2022-10-20 16:41:27 +02:00
$this -> last_main_doc = $obj -> last_main_doc ;
2022-10-20 18:54:45 +02:00
2019-02-10 12:59:09 +01:00
// Retrieve extrafields
2018-02-20 19:38:18 +01:00
$this -> fetch_optionals ();
2013-05-18 12:53:11 +02:00
2011-07-01 18:24:44 +02:00
/*
* Lines
2018-02-20 19:38:18 +01:00
*/
2019-12-18 15:20:36 +01:00
$result = $this -> fetch_lines ();
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
2011-07-01 18:24:44 +02:00
return - 3 ;
}
2008-06-21 01:01:02 +02:00
$this -> db -> free ( $resql );
return 1 ;
}
2023-01-06 19:24:57 +01:00
return 0 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> lasterror ();
2008-06-21 01:01:02 +02:00
return - 1 ;
}
}
/**
2011-07-08 11:18:54 +02:00
* Set status to draft
2011-12-19 17:29:09 +01:00
*
* @ param User $user User that set draft
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2020-10-31 14:32:18 +01:00
public function setDraft ( $user )
2008-06-21 01:01:02 +02:00
{
2019-12-18 15:20:36 +01:00
$error = 0 ;
2019-03-21 17:37:56 +01:00
// Protection
2021-02-25 23:00:32 +01:00
if ( $this -> statut <= self :: STATUS_DRAFT ) {
2020-10-31 14:32:18 +01:00
return 0 ;
2019-03-21 17:37:56 +01:00
}
2009-03-12 23:49:05 +01:00
2019-03-21 17:37:56 +01:00
dol_syslog ( get_class ( $this ) . " ::setDraft " , LOG_DEBUG );
2009-03-12 23:49:05 +01:00
2024-01-10 17:03:09 +01:00
$this -> oldcopy = dol_clone ( $this , 2 );
2022-08-22 15:06:09 +02:00
2019-03-21 17:37:56 +01:00
$this -> db -> begin ();
$sql = " UPDATE " . MAIN_DB_PREFIX . " fichinter " ;
2019-12-18 15:20:36 +01:00
$sql .= " SET fk_statut = " . self :: STATUS_DRAFT ;
2021-08-23 19:33:24 +02:00
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2019-03-21 17:37:56 +01:00
2019-12-18 15:20:36 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( $resql ) {
2020-10-31 14:32:18 +01:00
if ( ! $error ) {
// Call trigger
$result = $this -> call_trigger ( 'FICHINTER_UNVALIDATE' , $user );
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2020-10-31 14:32:18 +01:00
}
2019-03-21 17:37:56 +01:00
if ( ! $error ) {
2020-10-31 14:32:18 +01:00
$this -> statut = self :: STATUS_DRAFT ;
$this -> db -> commit ();
return 1 ;
2019-03-21 17:37:56 +01:00
} else {
2020-10-31 14:32:18 +01:00
$this -> db -> rollback ();
return - 1 ;
2008-07-12 14:45:29 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-03-21 17:37:56 +01:00
$this -> db -> rollback ();
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> lasterror ();
2019-03-21 17:37:56 +01:00
return - 1 ;
}
2008-11-02 23:11:34 +01:00
}
2009-03-12 23:49:05 +01:00
2008-11-02 23:11:34 +01:00
/**
2011-07-08 11:18:54 +02:00
* Validate a intervention
2011-12-19 17:29:09 +01:00
*
* @ param User $user User that validate
2017-10-07 13:09:31 +02:00
* @ param int $notrigger 1 = Does not execute triggers , 0 = execute triggers
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-11-02 23:11:34 +01:00
*/
2020-10-31 14:32:18 +01:00
public function setValid ( $user , $notrigger = 0 )
2008-11-02 23:11:34 +01:00
{
2014-08-20 19:03:58 +02:00
global $conf ;
2013-12-01 21:03:12 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2012-01-04 23:56:10 +01:00
2019-12-18 15:20:36 +01:00
$error = 0 ;
2012-01-04 23:56:10 +01:00
2023-08-06 00:16:25 +02:00
if ( $this -> status != self :: STATUS_VALIDATED ) {
2008-11-02 23:11:34 +01:00
$this -> db -> begin ();
2012-07-29 12:54:19 +02:00
2019-12-18 15:20:36 +01:00
$now = dol_now ();
2013-05-20 21:21:03 +02:00
2013-03-10 13:58:32 +01:00
// Define new ref
2021-02-25 23:00:32 +01:00
if ( ! $error && ( preg_match ( '/^[\(]?PROV/i' , $this -> ref ) || empty ( $this -> ref ))) { // empty should not happened, but when it occurs, the test save life
2013-05-12 17:54:30 +02:00
$num = $this -> getNextNumRef ( $this -> thirdparty );
2020-05-21 15:05:19 +02:00
} else {
2013-03-10 13:58:32 +01:00
$num = $this -> ref ;
}
2020-03-03 11:49:17 +01:00
$this -> newref = dol_sanitizeFileName ( $num );
2009-03-12 23:49:05 +01:00
2008-11-02 23:11:34 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " fichinter " ;
2019-12-18 15:20:36 +01:00
$sql .= " SET fk_statut = 1 " ;
2021-08-23 19:33:24 +02:00
$sql .= " , ref = ' " . $this -> db -> escape ( $num ) . " ' " ;
2019-12-18 15:20:36 +01:00
$sql .= " , date_valid = ' " . $this -> db -> idate ( $now ) . " ' " ;
2022-07-03 12:54:58 +02:00
$sql .= " , fk_user_valid = " . ( $user -> id > 0 ? ( int ) $user -> id : " null " );
2021-08-23 19:33:24 +02:00
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2024-02-21 17:06:05 +01:00
$sql .= " AND entity = " . (( int ) $this -> entity );
2024-02-20 23:01:16 +01:00
2019-12-18 15:20:36 +01:00
$sql .= " AND fk_statut = 0 " ;
2009-03-12 23:49:05 +01:00
2014-06-12 11:31:53 +02:00
dol_syslog ( get_class ( $this ) . " ::setValid " , LOG_DEBUG );
2019-12-18 15:20:36 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( ! $resql ) {
2013-12-01 21:03:12 +01:00
dol_print_error ( $this -> db );
$error ++ ;
}
2021-02-25 23:00:32 +01:00
if ( ! $error && ! $notrigger ) {
2017-10-07 13:09:31 +02:00
// Call trigger
2019-12-18 15:20:36 +01:00
$result = $this -> call_trigger ( 'FICHINTER_VALIDATE' , $user );
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2017-10-07 13:09:31 +02:00
// End call triggers
2014-10-27 03:24:45 +01:00
}
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2014-10-27 03:24:45 +01:00
$this -> oldref = $this -> ref ;
2013-12-01 21:03:12 +01:00
// Rename directory if dir was a temporary ref
2021-02-25 23:00:32 +01:00
if ( preg_match ( '/^[\(]?PROV/i' , $this -> ref )) {
2019-07-28 22:26:55 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
// Now we rename also files into index
2019-12-18 15:20:36 +01:00
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " ecm_files set filename = CONCAT(' " . $this -> db -> escape ( $this -> newref ) . " ', SUBSTR(filename, " . ( strlen ( $this -> ref ) + 1 ) . " )), filepath = 'ficheinter/ " . $this -> db -> escape ( $this -> newref ) . " ' " ;
2024-02-21 17:06:05 +01:00
$sql .= " WHERE filename LIKE ' " . $this -> db -> escape ( $this -> ref ) . " %' AND filepath = 'ficheinter/ " . $this -> db -> escape ( $this -> ref ) . " ' and entity = " . (( int ) $this -> entity );
2019-07-28 22:26:55 +02:00
$resql = $this -> db -> query ( $sql );
2023-10-31 19:28:11 +01:00
if ( ! $resql ) {
2023-12-04 12:12:12 +01:00
$error ++ ;
$this -> error = $this -> db -> lasterror ();
2023-10-31 19:28:11 +01:00
}
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " ecm_files set filepath = 'ficheinter/ " . $this -> db -> escape ( $this -> newref ) . " ' " ;
$sql .= " WHERE filepath = 'ficheinter/ " . $this -> db -> escape ( $this -> ref ) . " ' and entity = " . $conf -> entity ;
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( ! $resql ) {
2023-12-04 12:12:12 +01:00
$error ++ ;
$this -> error = $this -> db -> lasterror ();
2021-02-25 23:00:32 +01:00
}
2019-07-28 22:26:55 +02:00
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
2013-12-01 21:03:12 +01:00
$oldref = dol_sanitizeFileName ( $this -> ref );
2014-10-27 03:24:45 +01:00
$newref = dol_sanitizeFileName ( $num );
2013-12-01 21:03:12 +01:00
$dirsource = $conf -> ficheinter -> dir_output . '/' . $oldref ;
2014-10-27 03:24:45 +01:00
$dirdest = $conf -> ficheinter -> dir_output . '/' . $newref ;
2021-02-25 23:00:32 +01:00
if ( ! $error && file_exists ( $dirsource )) {
2014-10-27 03:24:45 +01:00
dol_syslog ( get_class ( $this ) . " ::setValid rename dir " . $dirsource . " into " . $dirdest );
2013-12-01 21:03:12 +01:00
2021-02-25 23:00:32 +01:00
if ( @ rename ( $dirsource , $dirdest )) {
2017-10-07 13:09:31 +02:00
dol_syslog ( " Rename ok " );
// Rename docs starting with $oldref with $newref
2019-12-18 15:20:36 +01:00
$listoffiles = dol_dir_list ( $conf -> ficheinter -> dir_output . '/' . $newref , 'files' , 1 , '^' . preg_quote ( $oldref , '/' ));
2021-02-25 23:00:32 +01:00
foreach ( $listoffiles as $fileentry ) {
2019-12-18 15:20:36 +01:00
$dirsource = $fileentry [ 'name' ];
$dirdest = preg_replace ( '/^' . preg_quote ( $oldref , '/' ) . '/' , $newref , $dirsource );
$dirsource = $fileentry [ 'path' ] . '/' . $dirsource ;
$dirdest = $fileentry [ 'path' ] . '/' . $dirdest ;
2017-10-07 13:09:31 +02:00
@ rename ( $dirsource , $dirdest );
}
2013-12-01 21:03:12 +01:00
}
}
}
}
2024-08-13 20:29:40 +02:00
// Set new ref and define current status
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2013-12-01 21:03:12 +01:00
$this -> ref = $num ;
2023-08-06 00:16:25 +02:00
$this -> status = self :: STATUS_VALIDATED ;
$this -> statut = self :: STATUS_VALIDATED ; // deprecated
2019-12-18 15:20:36 +01:00
$this -> date_validation = $now ;
2013-12-01 21:03:12 +01:00
$this -> db -> commit ();
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2008-11-02 23:11:34 +01:00
$this -> db -> rollback ();
2019-01-27 11:55:16 +01:00
dol_syslog ( get_class ( $this ) . " ::setValid " . $this -> error , LOG_ERR );
2008-11-02 23:11:34 +01:00
return - 1 ;
}
2008-06-21 01:01:02 +02:00
}
2023-01-06 19:24:57 +01:00
return 0 ;
2008-06-21 01:01:02 +02:00
}
2011-07-02 18:48:31 +02:00
2023-10-05 12:11:39 +02:00
/**
* Close intervention
*
2024-01-13 19:48:41 +01:00
* @ param User $user Object user that close
2023-10-05 12:11:39 +02:00
* @ param int $notrigger 1 = Does not execute triggers , 0 = Execute triggers
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2023-10-05 12:11:39 +02:00
*/
public function setClose ( $user , $notrigger = 0 )
{
global $conf ;
$error = 0 ;
if ( $this -> statut == self :: STATUS_CLOSED ) {
return 0 ;
} else {
$this -> db -> begin ();
$now = dol_now ();
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this -> table_element ;
$sql .= ' SET fk_statut = ' . self :: STATUS_CLOSED . ',' ;
$sql .= " datet = ' " . $this -> db -> idate ( $now ) . " ', " ;
2023-10-06 15:37:02 +02:00
$sql .= " fk_user_modif = " . (( int ) $user -> id );
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2023-10-05 12:11:39 +02:00
$sql .= " AND fk_statut > " . self :: STATUS_DRAFT ;
$sql .= " AND entity = " . (( int ) $conf -> entity );
if ( $this -> db -> query ( $sql )) {
if ( ! $notrigger ) {
// Call trigger
$result = $this -> call_trigger ( 'FICHINTER_CLOSE' , $user );
if ( $result < 0 ) {
$error ++ ;
}
// End call triggers
}
if ( ! $error ) {
$this -> statut = self :: STATUS_CLOSED ;
$this -> db -> commit ();
return 1 ;
} else {
$this -> db -> rollback ();
return - 1 ;
}
} else {
$this -> error = $this -> db -> lasterror ();
$this -> db -> rollback ();
return - 1 ;
}
}
}
2017-05-09 22:24:24 +02:00
/**
* Returns amount based on user thm
*
2017-09-11 14:41:46 +02:00
* @ return float Amount
2017-05-09 22:24:24 +02:00
*/
2019-02-25 20:35:59 +01:00
public function getAmount ()
2017-09-11 14:41:46 +02:00
{
2017-05-09 22:24:24 +02:00
$amount = 0 ;
2017-07-25 21:22:22 +02:00
2023-10-24 11:37:29 +02:00
$this -> author = new User ( $this -> db );
$this -> author -> fetch ( $this -> user_creation_id );
2017-07-25 21:22:22 +02:00
2017-05-09 22:24:24 +02:00
$thm = $this -> author -> thm ;
2017-07-25 21:22:22 +02:00
2019-12-18 15:20:36 +01:00
foreach ( $this -> lines as $line ) {
2024-03-23 01:12:53 +01:00
$amount += ( $line -> duration / 60 / 60 * ( float ) $thm );
2017-05-09 22:24:24 +02:00
}
2017-07-25 21:22:22 +02:00
2024-01-22 17:50:52 +01:00
return ( float ) price2num ( $amount , 'MT' );
2017-05-09 22:24:24 +02:00
}
2017-09-11 14:50:00 +02:00
2017-09-12 13:26:25 +02:00
2017-09-09 20:00:09 +02:00
/**
* Create a document onto disk according to template module .
*
2024-10-03 19:40:34 +02:00
* @ param string $modele Force model to use ( '' to not force )
* @ param Translate $outputlangs Object langs to use for output
* @ param int < 0 , 1 > $hidedetails Hide details of lines
* @ param int < 0 , 1 > $hidedesc Hide description
* @ param int < 0 , 1 > $hideref Hide ref
* @ param ? array < string , mixed > $moreparams Array to provide more information
* @ return int 0 if KO , 1 if OK
2017-09-09 20:00:09 +02:00
*/
2019-01-27 15:20:16 +01:00
public function generateDocument ( $modele , $outputlangs , $hidedetails = 0 , $hidedesc = 0 , $hideref = 0 , $moreparams = null )
2017-09-09 20:00:09 +02:00
{
2020-12-13 13:34:21 +01:00
global $conf ;
2017-09-09 20:00:09 +02:00
2020-12-13 13:34:21 +01:00
$outputlangs -> load ( " interventions " );
2017-09-09 20:00:09 +02:00
2019-12-18 15:20:36 +01:00
if ( ! dol_strlen ( $modele )) {
2017-09-11 14:50:00 +02:00
$modele = 'soleil' ;
2017-09-09 20:00:09 +02:00
2020-12-13 13:34:21 +01:00
if ( ! empty ( $this -> model_pdf )) {
$modele = $this -> model_pdf ;
2023-11-27 11:41:05 +01:00
} elseif ( getDolGlobalString ( 'FICHEINTER_ADDON_PDF' )) {
2024-01-05 04:18:53 +01:00
$modele = getDolGlobalString ( 'FICHEINTER_ADDON_PDF' );
2017-09-09 20:00:09 +02:00
}
}
$modelpath = " core/modules/fichinter/doc/ " ;
2019-01-27 11:55:16 +01:00
return $this -> commonGenerateDocument ( $modelpath , $modele , $outputlangs , $hidedetails , $hidedesc , $hideref , $moreparams );
2017-09-09 20:00:09 +02:00
}
2017-07-25 21:22:22 +02:00
2008-06-21 01:01:02 +02:00
/**
2011-07-08 11:18:54 +02:00
* Returns the label status
2012-01-08 00:52:07 +01:00
*
2011-12-19 17:29:09 +01:00
* @ param int $mode 0 = long label , 1 = short label , 2 = Picto + short label , 3 = Picto , 4 = Picto + long label , 5 = Short label + Picto
* @ return string Label
2008-06-21 01:01:02 +02:00
*/
2019-02-25 20:35:59 +01:00
public function getLibStatut ( $mode = 0 )
2008-06-21 01:01:02 +02:00
{
2020-04-20 02:48:05 +02:00
return $this -> LibStatut (( isset ( $this -> statut ) ? $this -> statut : $this -> status ), $mode );
2008-06-21 01:01:02 +02:00
}
2020-10-31 14:32:18 +01:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2008-06-21 01:01:02 +02:00
/**
2019-10-24 16:10:00 +02:00
* Returns the label of a status
2011-12-19 17:29:09 +01:00
*
2019-10-24 16:10:00 +02:00
* @ param int $status Id status
2016-09-19 13:09:50 +02:00
* @ param int $mode 0 = long label , 1 = short label , 2 = Picto + short label , 3 = Picto , 4 = Picto + long label , 5 = Short label + Picto , 6 = Long label + Picto
2011-12-19 17:29:09 +01:00
* @ return string Label
2008-06-21 01:01:02 +02:00
*/
2019-10-24 16:10:00 +02:00
public function LibStatut ( $status , $mode = 0 )
2008-06-21 01:01:02 +02:00
{
2020-10-31 14:32:18 +01:00
// phpcs:enable
2024-08-27 07:01:03 +02:00
global $langs ;
2018-04-21 15:46:55 +02:00
// Init/load array of translation of status
2023-01-12 13:02:04 +01:00
if ( empty ( $this -> labelStatus ) || empty ( $this -> labelStatusShort )) {
2024-08-13 20:29:40 +02:00
$langs -> load ( " interventions " );
2024-08-27 07:01:03 +02:00
$langs -> load ( " propal " );
2018-04-21 15:46:55 +02:00
2023-01-12 13:02:04 +01:00
$this -> labelStatus [ self :: STATUS_DRAFT ] = $langs -> transnoentitiesnoconv ( 'Draft' );
$this -> labelStatus [ self :: STATUS_VALIDATED ] = $langs -> transnoentitiesnoconv ( 'Validated' );
$this -> labelStatus [ self :: STATUS_BILLED ] = $langs -> transnoentitiesnoconv ( 'StatusInterInvoiced' );
$this -> labelStatus [ self :: STATUS_CLOSED ] = $langs -> transnoentitiesnoconv ( 'Done' );
$this -> labelStatusShort [ self :: STATUS_DRAFT ] = $langs -> transnoentitiesnoconv ( 'Draft' );
$this -> labelStatusShort [ self :: STATUS_VALIDATED ] = $langs -> transnoentitiesnoconv ( 'Validated' );
$this -> labelStatusShort [ self :: STATUS_BILLED ] = $langs -> transnoentitiesnoconv ( 'StatusInterInvoiced' );
$this -> labelStatusShort [ self :: STATUS_CLOSED ] = $langs -> transnoentitiesnoconv ( 'Done' );
2018-04-21 15:46:55 +02:00
}
2010-01-04 22:45:59 +01:00
2023-01-12 13:02:04 +01:00
$statuscode = 'status' . $status ;
if ( $status == self :: STATUS_BILLED || $status == self :: STATUS_CLOSED ) {
$statuscode = 'status6' ;
}
2024-08-27 07:01:03 +02:00
$signed_label = ' (' . $this -> getLibSignedStatus () . ')' ;
$status_label = $this -> signed_status ? $this -> labelStatus [ $status ] . $signed_label : $this -> labelStatus [ $status ];
$status_label_short = $this -> signed_status ? $this -> labelStatusShort [ $status ] . $signed_label : $this -> labelStatusShort [ $status ];
return dolGetStatus ( $status_label , $status_label_short , '' , $statuscode , $mode );
}
2023-02-08 22:20:46 +01:00
/**
* getTooltipContentArray
2024-09-23 03:24:19 +02:00
* @ param array < string , mixed > $params params to construct tooltip data
2023-02-08 22:20:46 +01:00
* @ since v18
2024-09-23 03:24:19 +02:00
* @ return array { picto ? : string , ref ? : string , refsupplier ? : string , label ? : string , date ? : string , date_echeance ? : string , amountht ? : string , total_ht ? : string , totaltva ? : string , amountlt1 ? : string , amountlt2 ? : string , amountrevenustamp ? : string , totalttc ? : string } | array { optimize : string }
2023-02-08 22:20:46 +01:00
*/
public function getTooltipContentArray ( $params )
{
2024-09-18 15:55:20 +02:00
global $langs ;
2023-02-08 22:20:46 +01:00
2024-08-13 20:29:40 +02:00
$langs -> load ( 'interventions' );
2023-02-08 22:20:46 +01:00
$datas = [];
2024-11-11 18:26:57 +01:00
$datas [ 'picto' ] = img_picto ( '' , $this -> picto ) . ' <u class="paddingrightonly">' . $langs -> trans ( " ShowIntervention " ) . '</u>' ;
2023-02-08 22:20:46 +01:00
if ( isset ( $this -> status )) {
$datas [ 'picto' ] .= ' ' . $this -> getLibStatut ( 5 );
}
$datas [ 'ref' ] = '<br><b>' . $langs -> trans ( 'Ref' ) . ':</b> ' . $this -> ref ;
return $datas ;
}
2010-02-27 14:37:13 +01:00
/**
2024-08-07 01:20:43 +02:00
* Return clickable name ( with picto eventually )
2011-12-19 17:29:09 +01:00
*
2017-10-03 14:50:52 +02:00
* @ param int $withpicto 0 = _No picto , 1 = Includes the picto in the linkn , 2 = Picto only
* @ param string $option Options
2017-10-07 13:09:31 +02:00
* @ param int $notooltip 1 = Disable tooltip
* @ param int $save_lastsearch_value - 1 = Auto , 0 = No save of lastsearch_values when clicking , 1 = Save lastsearch_values whenclicking
2023-06-29 11:20:19 +02:00
* @ param string $morecss Add more css on link
2017-10-03 14:50:52 +02:00
* @ return string String with URL
2010-02-27 14:37:13 +01:00
*/
2023-06-29 11:20:19 +02:00
public function getNomUrl ( $withpicto = 0 , $option = '' , $notooltip = 0 , $save_lastsearch_value = - 1 , $morecss = '' )
2010-02-27 14:37:13 +01:00
{
2018-06-04 13:36:38 +02:00
global $conf , $langs , $hookmanager ;
2010-02-27 14:37:13 +01:00
2023-06-29 11:20:19 +02:00
if ( ! empty ( $conf -> dol_no_mouse_hover )) {
$notooltip = 1 ; // Force disable tooltips
}
2019-12-18 15:20:36 +01:00
$result = '' ;
2023-02-08 22:20:46 +01:00
$params = [
'id' => $this -> id ,
'objecttype' => $this -> element ,
2023-06-29 11:20:19 +02:00
'option' => $option ,
2023-02-08 22:20:46 +01:00
];
$classfortooltip = 'classfortooltip' ;
$dataparams = '' ;
if ( getDolGlobalInt ( 'MAIN_ENABLE_AJAX_TOOLTIP' )) {
$classfortooltip = 'classforajaxtooltip' ;
2023-04-03 19:51:40 +02:00
$dataparams = ' data-params="' . dol_escape_htmltag ( json_encode ( $params )) . '"' ;
$label = '' ;
} else {
$label = implode ( $this -> getTooltipContentArray ( $params ));
2020-02-24 05:23:34 +01:00
}
2010-02-27 14:37:13 +01:00
2017-10-07 13:09:31 +02:00
$url = DOL_URL_ROOT . '/fichinter/card.php?id=' . $this -> id ;
2010-02-27 14:37:13 +01:00
2021-02-25 23:00:32 +01:00
if ( $option !== 'nolink' ) {
2017-10-07 13:09:31 +02:00
// Add param to save lastsearch_values or not
2019-12-18 15:20:36 +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-25 23:00:32 +01:00
$add_save_lastsearch_values = 1 ;
}
if ( $add_save_lastsearch_values ) {
$url .= '&save_lastsearch_values=1' ;
}
}
2017-10-03 14:50:52 +02:00
2019-12-18 15:20:36 +01:00
$linkclose = '' ;
2021-02-25 23:00:32 +01:00
if ( empty ( $notooltip )) {
2023-11-27 11:41:05 +01:00
if ( getDolGlobalString ( 'MAIN_OPTIMIZEFORTEXTBROWSER' )) {
2019-12-18 15:20:36 +01:00
$label = $langs -> trans ( " ShowIntervention " );
2025-01-09 02:01:49 +01:00
$linkclose .= ' alt="' . dolPrintHTMLForAttribute ( $label ) . '"' ;
2017-10-03 14:50:52 +02:00
}
2025-01-09 02:01:49 +01:00
$linkclose .= ( $label ? ' title="' . dolPrintHTMLForAttribute ( $label ) . '"' : ' title="tocomplete"' );
2023-06-29 11:20:19 +02:00
$linkclose .= $dataparams . ' class="' . $classfortooltip . ( $morecss ? ' ' . $morecss : '' ) . '"' ;
} else {
$linkclose = ( $morecss ? ' class="' . $morecss . '"' : '' );
2017-10-03 14:50:52 +02:00
}
2010-02-27 14:37:13 +01:00
2023-06-29 11:20:19 +02:00
if ( $option == 'nolink' || empty ( $url )) {
$linkstart = '<span' ;
} else {
$linkstart = '<a href="' . $url . '"' ;
}
2019-12-18 15:20:36 +01:00
$linkstart .= $linkclose . '>' ;
2023-06-29 11:20:19 +02:00
if ( $option == 'nolink' || empty ( $url )) {
$linkend = '</span>' ;
} else {
$linkend = '</a>' ;
}
2010-02-27 14:37:13 +01:00
2017-11-02 15:03:09 +01:00
$result .= $linkstart ;
2021-02-25 23:00:32 +01:00
if ( $withpicto ) {
2023-06-29 11:20:19 +02:00
$result .= img_object (( $notooltip ? '' : $label ), ( $this -> picto ? $this -> picto : 'generic' ), ( $notooltip ? (( $withpicto != 2 ) ? 'class="paddingright"' : '' ) : 'class="' . (( $withpicto != 2 ) ? 'paddingright ' : '' ) . '"' ), 0 , 0 , $notooltip ? 0 : 1 );
2021-02-25 23:00:32 +01:00
}
2023-06-29 11:20:19 +02:00
2021-02-25 23:00:32 +01:00
if ( $withpicto != 2 ) {
$result .= $this -> ref ;
}
2023-06-29 11:20:19 +02:00
2017-11-02 15:03:09 +01:00
$result .= $linkend ;
2018-06-18 13:31:29 +02:00
global $action ;
2020-09-30 15:17:44 +02:00
$hookmanager -> initHooks ( array ( 'interventiondao' ));
2024-03-11 22:55:05 +01:00
$parameters = array ( 'id' => $this -> id , 'getnomurl' => & $result );
2019-12-18 15:20:36 +01:00
$reshook = $hookmanager -> executeHooks ( 'getNomUrl' , $parameters , $this , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-25 23:00:32 +01:00
if ( $reshook > 0 ) {
$result = $hookmanager -> resPrint ;
} else {
$result .= $hookmanager -> resPrint ;
}
2018-06-18 13:31:29 +02:00
2010-02-27 14:37:13 +01:00
return $result ;
}
2008-06-21 01:01:02 +02:00
/**
2011-07-08 11:18:54 +02:00
* Returns the next non used reference of intervention
* depending on the module numbering assets within FICHEINTER_ADDON
2011-12-19 17:29:09 +01:00
*
2014-12-20 15:42:03 +01:00
* @ param Societe $soc Thirdparty object
2011-12-19 17:29:09 +01:00
* @ return string Free reference for intervention
2008-06-21 01:01:02 +02:00
*/
2019-02-25 20:35:59 +01:00
public function getNextNumRef ( $soc )
2008-06-21 01:01:02 +02:00
{
2009-03-23 20:13:51 +01:00
global $conf , $db , $langs ;
2008-06-21 01:01:02 +02:00
$langs -> load ( " interventions " );
2023-11-27 11:41:05 +01:00
if ( getDolGlobalString ( 'FICHEINTER_ADDON' )) {
2015-01-17 18:58:05 +01:00
$mybool = false ;
2023-10-15 18:12:03 +02:00
$file = " mod_ " . getDolGlobalString ( 'FICHEINTER_ADDON' ) . " .php " ;
$classname = " mod_ " . getDolGlobalString ( 'FICHEINTER_ADDON' );
2015-01-17 18:58:05 +01:00
// Include file with class
$dirmodels = array_merge ( array ( '/' ), ( array ) $conf -> modules_parts [ 'models' ]);
foreach ( $dirmodels as $reldir ) {
$dir = dol_buildpath ( $reldir . " core/modules/fichinter/ " );
// Load file with numbering class (if found)
2024-03-21 13:21:33 +01:00
$mybool = (( bool ) @ include_once $dir . $file ) || $mybool ;
2009-03-23 20:13:51 +01:00
}
2009-04-29 20:02:50 +02:00
2024-08-07 03:05:02 +02:00
if ( ! $mybool ) {
2024-01-20 09:22:38 +01:00
dol_print_error ( null , " Failed to include file " . $file );
2015-01-17 18:58:05 +01:00
return '' ;
}
2008-06-21 01:01:02 +02:00
$obj = new $classname ();
2024-08-29 13:34:24 +02:00
'@phan-var-force ModeleNumRefFicheinter $obj' ;
2008-06-21 01:01:02 +02:00
$numref = " " ;
2018-10-27 21:19:19 +02:00
$numref = $obj -> getNextValue ( $soc , $this );
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
if ( $numref != " " ) {
2008-06-21 01:01:02 +02:00
return $numref ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
dol_print_error ( $db , " Fichinter::getNextNumRef " . $obj -> error );
2008-06-21 01:01:02 +02:00
return " " ;
}
2020-05-21 15:05:19 +02:00
} else {
2015-01-17 18:58:05 +01:00
$langs -> load ( " errors " );
2008-06-21 01:01:02 +02:00
print $langs -> trans ( " Error " ) . " " . $langs -> trans ( " Error_FICHEINTER_ADDON_NotDefined " );
return " " ;
}
}
2007-06-22 14:36:50 +02:00
/**
2013-11-05 14:24:37 +01:00
* Load information on object
2012-01-04 23:56:10 +01:00
*
2013-11-05 14:24:37 +01:00
* @ param int $id Id of object
2012-01-08 00:52:07 +01:00
* @ return void
2008-06-21 01:01:02 +02:00
*/
2019-02-25 20:35:59 +01:00
public function info ( $id )
2008-02-24 18:01:48 +01:00
{
2010-01-13 19:51:19 +01:00
$sql = " SELECT f.rowid, " ;
2019-12-18 15:20:36 +01:00
$sql .= " f.datec, " ;
$sql .= " f.tms as date_modification, " ;
$sql .= " f.date_valid as datev, " ;
$sql .= " f.fk_user_author, " ;
$sql .= " f.fk_user_modif as fk_user_modification, " ;
$sql .= " f.fk_user_valid " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " fichinter as f " ;
2021-03-14 11:48:39 +01:00
$sql .= " WHERE f.rowid = " . (( int ) $id );
2008-06-21 01:01:02 +02:00
2013-11-05 14:24:37 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( $resql ) {
if ( $this -> db -> num_rows ( $resql )) {
2013-11-05 14:24:37 +01:00
$obj = $this -> db -> fetch_object ( $resql );
2008-06-21 01:01:02 +02:00
$this -> id = $obj -> rowid ;
2010-01-13 19:51:19 +01:00
$this -> date_creation = $this -> db -> jdate ( $obj -> datec );
2014-10-20 11:16:51 +02:00
$this -> date_modification = $this -> db -> jdate ( $obj -> date_modification );
2010-01-13 19:51:19 +01:00
$this -> date_validation = $this -> db -> jdate ( $obj -> datev );
2008-06-21 01:01:02 +02:00
2023-10-24 11:37:29 +02:00
$this -> user_creation_id = $obj -> fk_user_author ;
$this -> user_validation_id = $obj -> fk_user_valid ;
$this -> user_modification_id = $obj -> fk_user_modification ;
2008-06-21 01:01:02 +02:00
}
2013-11-05 14:24:37 +01:00
$this -> db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $this -> db );
2008-06-21 01:01:02 +02:00
}
}
2008-04-22 01:02:50 +02:00
/**
2011-07-08 11:18:54 +02:00
* Delete intervetnion
2011-12-19 17:29:09 +01:00
*
2013-07-07 13:14:32 +02:00
* @ param User $user Object user who delete
* @ param int $notrigger Disable trigger
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2023-01-03 13:37:11 +01:00
public function delete ( User $user , $notrigger = 0 )
2007-08-28 09:44:17 +02:00
{
2019-12-18 15:20:36 +01:00
global $conf , $langs ;
2017-10-07 13:09:31 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2010-05-04 20:03:45 +02:00
2019-12-18 15:20:36 +01:00
$error = 0 ;
2008-06-21 01:01:02 +02:00
2008-04-22 01:02:50 +02:00
$this -> db -> begin ();
2011-07-02 18:48:31 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error && ! $notrigger ) {
2017-11-06 19:27:10 +01:00
// Call trigger
2019-12-18 15:20:36 +01:00
$result = $this -> call_trigger ( 'FICHINTER_DELETE' , $user );
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
2023-12-04 12:12:12 +01:00
$error ++ ;
$this -> db -> rollback ();
return - 1 ;
2021-02-25 23:00:32 +01:00
}
2017-11-06 19:27:10 +01:00
// End call triggers
}
2011-07-01 18:24:44 +02:00
// Delete linked object
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-11-06 19:27:10 +01:00
$res = $this -> deleteObjectLinked ();
2021-02-25 23:00:32 +01:00
if ( $res < 0 ) {
$error ++ ;
}
2017-11-06 19:27:10 +01:00
}
2011-07-02 18:48:31 +02:00
2011-07-01 18:24:44 +02:00
// Delete linked contacts
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-11-06 19:27:10 +01:00
$res = $this -> delete_linked_contact ();
2021-02-25 23:00:32 +01:00
if ( $res < 0 ) {
2019-12-18 15:20:36 +01:00
$this -> error = 'ErrorFailToDeleteLinkedContact' ;
2017-11-06 19:27:10 +01:00
$error ++ ;
}
2011-07-01 18:24:44 +02:00
}
2011-07-02 18:48:31 +02:00
2020-11-01 21:52:34 +01:00
if ( ! $error ) {
$main = MAIN_DB_PREFIX . 'fichinterdet' ;
$ef = $main . " _extrafields " ;
2024-10-24 01:26:53 +02:00
$sql = " DELETE FROM " . $this -> db -> sanitize ( $ef ) . " WHERE fk_object IN (SELECT rowid FROM " . $this -> db -> sanitize ( $main ) . " WHERE fk_fichinter = " . (( int ) $this -> id ) . " ) " ;
2020-04-23 18:52:45 +02:00
2020-11-01 21:52:34 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( ! $resql ) {
$error ++ ;
}
2020-04-23 18:55:36 +02:00
}
2020-04-23 18:52:45 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-11-06 19:27:10 +01:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " fichinterdet " ;
2021-08-23 19:33:24 +02:00
$sql .= " WHERE fk_fichinter = " . (( int ) $this -> id );
2017-11-06 19:27:10 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( ! $resql ) {
$error ++ ;
}
2010-04-30 07:44:19 +02:00
}
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-11-06 19:27:10 +01:00
// Remove extrafields
$res = $this -> deleteExtraFields ();
2021-02-25 23:00:32 +01:00
if ( $res < 0 ) {
$error ++ ;
}
2017-11-06 19:27:10 +01:00
}
2009-07-07 18:19:37 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-11-06 19:27:10 +01:00
// Delete object
2009-05-02 16:26:54 +02:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " fichinter " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2009-07-07 18:19:37 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( " Fichinter::delete " , LOG_DEBUG );
2017-11-06 19:27:10 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( ! $resql ) {
$error ++ ;
}
2017-11-06 19:27:10 +01:00
}
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2020-09-12 04:25:54 +02:00
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
2023-11-13 12:24:47 +01:00
$this -> deleteEcmFiles ( 0 ); // Deleting files physically is done later with the dol_delete_dir_recursive
$this -> deleteEcmFiles ( 1 ); // Deleting files physically is done later with the dol_delete_dir_recursive
2020-09-03 12:43:38 +02:00
2017-11-06 19:27:10 +01:00
// Remove directory with files
$fichinterref = dol_sanitizeFileName ( $this -> ref );
2021-02-25 23:00:32 +01:00
if ( $conf -> ficheinter -> dir_output ) {
2019-12-18 15:20:36 +01:00
$dir = $conf -> ficheinter -> dir_output . " / " . $fichinterref ;
$file = $conf -> ficheinter -> dir_output . " / " . $fichinterref . " / " . $fichinterref . " .pdf " ;
2021-02-25 23:00:32 +01:00
if ( file_exists ( $file )) {
2017-11-06 19:27:10 +01:00
dol_delete_preview ( $this );
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
if ( ! dol_delete_file ( $file , 0 , 0 , 0 , $this )) { // For triggers
2018-09-25 00:39:28 +02:00
$langs -> load ( " errors " );
2019-12-18 15:20:36 +01:00
$this -> error = $langs -> trans ( " ErrorFailToDeleteFile " , $file );
2017-11-06 19:27:10 +01:00
return 0 ;
2007-08-28 09:44:17 +02:00
}
}
2021-02-25 23:00:32 +01:00
if ( file_exists ( $dir )) {
if ( ! dol_delete_dir_recursive ( $dir )) {
2018-09-25 00:39:28 +02:00
$langs -> load ( " errors " );
2019-12-18 15:20:36 +01:00
$this -> error = $langs -> trans ( " ErrorFailToDeleteDir " , $dir );
2017-11-06 19:27:10 +01:00
return 0 ;
}
2013-05-19 18:28:27 +02:00
}
2007-08-28 09:44:17 +02:00
}
}
2017-11-06 19:27:10 +01:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-11-06 19:27:10 +01:00
$this -> db -> commit ();
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2008-04-22 01:02:50 +02:00
$this -> db -> rollback ();
2007-08-28 09:44:17 +02:00
return - 1 ;
}
}
2008-06-21 01:01:02 +02:00
2020-10-31 14:32:18 +01:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2008-06-21 01:01:02 +02:00
/**
2025-01-05 13:53:16 +01:00
* Defines a delivery date of the receipt of intervention
2011-12-19 17:29:09 +01:00
*
2025-01-05 13:53:16 +01:00
* @ param User $user Object user who define
* @ param integer $delivery_date_receipt Date of delivery of receipt
* @ return int Return integer < 0 if KO , > 0 if OK
2020-10-31 14:32:18 +01:00
*/
2025-01-05 13:53:16 +01:00
public function set_date_delivery ( $user , $delivery_date_receipt )
2020-10-31 14:32:18 +01:00
{
// phpcs:enable
2023-10-15 18:12:03 +02:00
if ( $user -> hasRight ( 'ficheinter' , 'creer' )) {
2025-01-05 13:53:16 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " fichinter " ;
$sql .= " SET datei = ' " . $this -> db -> idate ( $delivery_date_receipt ) . " ' " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2019-12-18 15:20:36 +01:00
$sql .= " AND fk_statut = 0 " ;
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
if ( $this -> db -> query ( $sql )) {
2025-01-05 13:53:16 +01:00
$this -> date_delivery = $delivery_date_receipt ;
$this -> delivery_date_receipt = $delivery_date_receipt ;
2008-06-21 01:01:02 +02:00
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2009-02-20 23:53:15 +01:00
dol_syslog ( " Fichinter::set_date_delivery Erreur SQL " );
2008-06-21 01:01:02 +02:00
return - 1 ;
}
}
2023-01-06 19:24:57 +01:00
return 0 ;
2008-06-21 01:01:02 +02:00
}
2020-10-31 14:32:18 +01:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2008-06-21 01:01:02 +02:00
/**
2011-07-08 11:18:54 +02:00
* Define the label of the intervention
2011-12-19 17:29:09 +01:00
*
* @ param User $user Object user who modify
* @ param string $description description
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2020-10-31 14:32:18 +01:00
public function set_description ( $user , $description )
2008-06-21 01:01:02 +02:00
{
2020-10-31 14:32:18 +01:00
// phpcs:enable
2023-10-15 18:12:03 +02:00
if ( $user -> hasRight ( 'ficheinter' , 'creer' )) {
2008-06-21 01:01:02 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " fichinter " ;
2019-12-18 15:20:36 +01:00
$sql .= " SET description = ' " . $this -> db -> escape ( $description ) . " ', " ;
2024-10-29 02:18:17 +01:00
$sql .= " fk_user_modif = " . (( int ) $user -> id );
2021-08-27 16:33:03 +02:00
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2008-06-21 01:01:02 +02:00
2021-02-25 23:00:32 +01:00
if ( $this -> db -> query ( $sql )) {
2008-06-21 01:01:02 +02:00
$this -> description = $description ;
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2009-02-20 23:53:15 +01:00
dol_syslog ( " Fichinter::set_description Erreur SQL " );
2008-06-21 01:01:02 +02:00
return - 1 ;
}
}
2023-01-06 19:24:57 +01:00
return 0 ;
2008-06-21 01:01:02 +02:00
}
2013-06-03 01:43:12 +02:00
2020-10-31 14:32:18 +01:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2013-06-03 01:43:12 +02:00
/**
2013-08-22 16:49:23 +02:00
* Link intervention to a contract
2013-06-03 01:43:12 +02:00
*
* @ param User $user Object user who modify
2013-07-07 13:14:32 +02:00
* @ param int $contractid Description
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2013-06-03 01:43:12 +02:00
*/
2020-10-31 14:32:18 +01:00
public function set_contrat ( $user , $contractid )
{
// phpcs:enable
2023-10-15 18:12:03 +02:00
if ( $user -> hasRight ( 'ficheinter' , 'creer' )) {
2013-06-03 01:43:12 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " fichinter " ;
2020-09-20 02:30:53 +02:00
$sql .= " SET fk_contrat = " . (( int ) $contractid );
2021-08-27 16:33:03 +02:00
$sql .= " WHERE rowid = " . (( int ) $this -> id );
2013-06-03 01:43:12 +02:00
2021-02-25 23:00:32 +01:00
if ( $this -> db -> query ( $sql )) {
2013-08-22 16:49:23 +02:00
$this -> fk_contrat = $contractid ;
2013-06-03 01:43:12 +02:00
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2013-06-03 01:43:12 +02:00
return - 1 ;
}
}
2023-01-06 19:24:57 +01:00
2013-08-22 16:49:23 +02:00
return - 2 ;
2013-06-03 01:43:12 +02:00
}
2017-07-25 21:22:22 +02:00
2016-07-01 18:12:37 +02:00
2017-10-07 13:09:31 +02:00
/**
* Load an object from its id and create a new one in database
*
2019-04-25 12:11:32 +02:00
* @ param User $user User making the clone
* @ param int $socid Id of thirdparty
2025-01-30 17:33:12 +01:00
* @ param bool $clone_contacts Clone contacts from origin
* @ param bool $clone_notes Clone notes from origin
2019-04-25 12:11:32 +02:00
* @ return int New id of clone
2017-10-07 13:09:31 +02:00
*/
2025-01-30 17:07:31 +01:00
public function createFromClone ( User $user , $socid = 0 , $clone_contacts = false , $clone_notes = false )
2017-10-07 13:09:31 +02:00
{
2025-01-30 17:07:31 +01:00
global $hookmanager , $langs ;
$langs -> load ( " errors " );
2016-07-01 18:12:37 +02:00
2019-12-18 15:20:36 +01:00
$error = 0 ;
2016-07-01 18:12:37 +02:00
2017-10-07 13:09:31 +02:00
$this -> db -> begin ();
2016-07-01 18:12:37 +02:00
// get extrafields so they will be clone
2021-02-25 23:00:32 +01:00
foreach ( $this -> lines as $line ) {
2020-03-27 16:02:58 +01:00
$line -> fetch_optionals ();
2021-02-25 23:00:32 +01:00
}
2016-07-01 18:12:37 +02:00
2017-10-07 13:09:31 +02:00
// Load source object
$objFrom = clone $this ;
2016-07-01 18:12:37 +02:00
2017-10-07 13:09:31 +02:00
// Change socid if needed
2021-02-25 23:00:32 +01:00
if ( ! empty ( $socid ) && $socid != $this -> socid ) {
2017-10-07 13:09:31 +02:00
$objsoc = new Societe ( $this -> db );
2016-07-01 18:12:37 +02:00
2021-02-25 23:00:32 +01:00
if ( $objsoc -> fetch ( $socid ) > 0 ) {
2019-12-18 15:20:36 +01:00
$this -> socid = $objsoc -> id ;
2022-08-31 22:14:20 +02:00
//$this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
//$this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
2024-01-22 17:50:52 +01:00
$this -> fk_project = 0 ;
$this -> fk_delivery_address = 0 ;
2017-10-07 13:09:31 +02:00
}
2016-07-01 18:12:37 +02:00
2017-10-07 13:09:31 +02:00
// TODO Change product price if multi-prices
}
2016-07-01 18:12:37 +02:00
2019-12-18 15:20:36 +01:00
$this -> id = 0 ;
2016-07-01 18:12:37 +02:00
$this -> ref = '' ;
2023-08-06 00:16:25 +02:00
$this -> status = self :: STATUS_DRAFT ;
$this -> statut = self :: STATUS_DRAFT ; // deprecated
2017-10-07 13:09:31 +02:00
// Clear fields
$this -> user_author_id = $user -> id ;
2023-10-17 11:10:25 +02:00
$this -> user_validation_id = 0 ;
2017-10-07 13:09:31 +02:00
$this -> date_creation = '' ;
$this -> date_validation = '' ;
2023-10-17 11:10:25 +02:00
2017-10-07 13:09:31 +02:00
$this -> ref_client = '' ;
2025-01-30 17:07:31 +01:00
if ( ! $clone_notes ) {
$this -> note_private = '' ;
$this -> note_public = '' ;
}
2017-10-07 13:09:31 +02:00
// Create clone
2019-01-19 12:46:38 +01:00
$this -> context [ 'createfromclone' ] = 'createfromclone' ;
2019-12-18 15:20:36 +01:00
$result = $this -> create ( $user );
2021-02-25 23:00:32 +01:00
if ( $result < 0 ) {
$error ++ ;
}
2017-10-07 13:09:31 +02:00
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-10-07 13:09:31 +02:00
// Add lines because it is not included into create function
2021-02-25 23:00:32 +01:00
foreach ( $this -> lines as $line ) {
2022-09-04 14:48:05 +02:00
$this -> addline ( $user , $this -> id , $line -> desc , $line -> datei , $line -> duration , $line -> array_options );
2017-10-07 13:09:31 +02:00
}
// Hook of thirdparty module
2021-02-25 23:00:32 +01:00
if ( is_object ( $hookmanager )) {
2024-03-11 22:55:05 +01:00
$parameters = array ( 'objFrom' => $objFrom );
2019-12-18 15:20:36 +01:00
$action = '' ;
$reshook = $hookmanager -> executeHooks ( 'createFrom' , $parameters , $this , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-25 23:00:32 +01:00
if ( $reshook < 0 ) {
2023-02-24 16:57:39 +01:00
$this -> setErrorsFromObject ( $hookmanager );
2021-02-25 23:00:32 +01:00
$error ++ ;
}
2017-10-07 13:09:31 +02:00
}
}
2025-01-30 17:07:31 +01:00
//Duplicate contact
if ( $clone_contacts ) {
foreach ( array ( 'internal' , 'external' ) as $source ) {
$tab = $objFrom -> liste_contact ( - 1 , $source );
if ( is_array ( $tab ) && count ( $tab ) > 0 ) {
foreach ( $tab as $contacttoadd ) {
$retAddContact = $this -> add_contact (
$contacttoadd [ 'id' ],
$contacttoadd [ 'code' ],
$contacttoadd [ 'source' ]
);
if ( $this -> error == 'DB_ERROR_RECORD_ALREADY_EXISTS' ) {
$this -> error .= $langs -> trans ( " ErrorThisContactIsAlreadyDefinedAsThisType " );
$error ++ ;
} elseif ( $retAddContact < 0 ) {
$error ++ ;
}
}
} elseif ( $tab < 0 ) {
$this -> error .= $objFrom -> error ;
$error ++ ;
}
}
}
2017-10-07 13:09:31 +02:00
unset ( $this -> context [ 'createfromclone' ]);
// End
2021-02-25 23:00:32 +01:00
if ( ! $error ) {
2017-10-07 13:09:31 +02:00
$this -> db -> commit ();
return $this -> id ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
$this -> db -> rollback ();
return - 1 ;
}
}
2017-07-25 21:22:22 +02:00
2008-06-21 01:01:02 +02:00
/**
2011-07-08 11:18:54 +02:00
* Adding a line of intervention into data base
2011-12-19 17:29:09 +01:00
*
2013-05-19 18:28:27 +02:00
* @ param user $user User that do the action
2011-12-19 17:29:09 +01:00
* @ param int $fichinterid Id of intervention
* @ param string $desc Line description
2024-10-03 19:40:34 +02:00
* @ param int $date_intervention Intervention date
2011-12-19 17:29:09 +01:00
* @ param int $duration Intervention duration
2024-10-03 19:40:34 +02:00
* @ param array < string , ? mixed > $array_options Array option
2011-12-19 17:29:09 +01:00
* @ return int > 0 if ok , < 0 if ko
2008-06-21 01:01:02 +02:00
*/
2023-12-16 11:09:26 +01:00
public function addline ( $user , $fichinterid , $desc , $date_intervention , $duration , $array_options = [])
2008-06-21 01:01:02 +02:00
{
2014-08-28 14:48:16 +02:00
dol_syslog ( get_class ( $this ) . " ::addline $fichinterid , $desc , $date_intervention , $duration " );
2009-03-12 23:49:05 +01:00
2023-08-06 00:16:25 +02:00
if ( $this -> status == self :: STATUS_DRAFT ) {
2008-06-21 01:01:02 +02:00
$this -> db -> begin ();
2009-03-12 23:49:05 +01:00
2008-06-21 01:01:02 +02:00
// Insertion ligne
2019-12-18 15:20:36 +01:00
$line = new FichinterLigne ( $this -> db );
2009-03-12 23:49:05 +01:00
2010-12-15 08:12:28 +01:00
$line -> fk_fichinter = $fichinterid ;
$line -> desc = $desc ;
2022-09-02 08:53:13 +02:00
$line -> date = $date_intervention ;
$line -> datei = $date_intervention ; // For backward compatibility
2010-12-15 08:12:28 +01:00
$line -> duration = $duration ;
2009-03-12 23:49:05 +01:00
2019-12-18 15:20:36 +01:00
if ( is_array ( $array_options ) && count ( $array_options ) > 0 ) {
$line -> array_options = $array_options ;
2014-08-26 17:08:03 +02:00
}
2019-12-18 15:20:36 +01:00
$result = $line -> insert ( $user );
2014-08-28 14:48:16 +02:00
2021-02-25 23:00:32 +01:00
if ( $result >= 0 ) {
2008-06-21 01:01:02 +02:00
$this -> db -> commit ();
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2008-06-21 01:01:02 +02:00
$this -> db -> rollback ();
return - 1 ;
}
}
2023-01-06 19:24:57 +01:00
return 0 ;
2008-06-21 01:01:02 +02:00
}
2007-08-28 09:44:17 +02:00
2007-08-29 09:55:34 +02:00
/**
2013-05-19 11:18:45 +02:00
* Initialise an instance with random values .
* Used to build previews or test instances .
* id must be 0 if object instance is a specimen .
*
2024-03-02 16:38:35 +01:00
* @ return int
2008-06-21 01:01:02 +02:00
*/
2019-02-25 20:35:59 +01:00
public function initAsSpecimen ()
2007-08-29 09:55:34 +02:00
{
2023-01-03 17:34:51 +01:00
global $langs ;
2007-08-29 09:55:34 +02:00
2019-12-18 15:20:36 +01:00
$now = dol_now ();
2007-08-29 09:55:34 +02:00
2024-01-13 19:48:41 +01:00
// Initialise parameters
2019-12-18 15:20:36 +01:00
$this -> id = 0 ;
2007-08-29 09:55:34 +02:00
$this -> ref = 'SPECIMEN' ;
2022-05-17 12:53:50 +02:00
$this -> ref_client = 'SPECIMEN CLIENT' ;
2019-12-18 15:20:36 +01:00
$this -> specimen = 1 ;
2010-09-01 16:13:51 +02:00
$this -> socid = 1 ;
2012-09-17 00:43:23 +02:00
$this -> datec = $now ;
2019-12-18 15:20:36 +01:00
$this -> note_private = 'Private note' ;
$this -> note_public = 'SPECIMEN' ;
2015-06-11 23:18:29 +02:00
$this -> duration = 0 ;
2015-02-03 13:43:37 +01:00
$nbp = 25 ;
2007-08-29 09:55:34 +02:00
$xnbp = 0 ;
2021-02-25 23:00:32 +01:00
while ( $xnbp < $nbp ) {
2019-12-18 15:20:36 +01:00
$line = new FichinterLigne ( $this -> db );
$line -> desc = $langs -> trans ( " Description " ) . " " . $xnbp ;
2022-09-02 08:53:13 +02:00
$line -> date = ( $now - 3600 * ( 1 + $xnbp ));
$line -> datei = ( $now - 3600 * ( 1 + $xnbp )); // For backward compatibility
2019-12-18 15:20:36 +01:00
$line -> duration = 600 ;
$line -> fk_fichinter = 0 ;
$this -> lines [ $xnbp ] = $line ;
2007-08-29 09:55:34 +02:00
$xnbp ++ ;
2011-09-12 20:43:01 +02:00
2019-12-18 15:20:36 +01:00
$this -> duration += $line -> duration ;
2011-09-12 21:34:59 +02:00
}
2024-03-02 16:38:35 +01:00
return 1 ;
2007-08-29 09:55:34 +02:00
}
2007-08-28 09:44:17 +02:00
2020-10-31 14:32:18 +01:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2008-06-21 01:01:02 +02:00
/**
2014-09-04 18:58:33 +02:00
* Load array lines -> lines
2011-12-19 17:29:09 +01:00
*
2023-12-01 19:51:32 +01:00
* @ return int Return integer < 0 if KO , > 0 if OK
2008-06-21 01:01:02 +02:00
*/
2020-10-31 14:32:18 +01:00
public function fetch_lines ()
{
// phpcs:enable
2018-02-08 12:41:31 +01:00
$this -> lines = array ();
2022-03-28 13:50:47 +02:00
$sql = " SELECT rowid, fk_fichinter, description, duree, date, rang " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " fichinterdet " ;
$sql .= " WHERE fk_fichinter = " . (( int ) $this -> id );
$sql .= " ORDER BY rang ASC, date ASC " ;
2007-08-28 09:44:17 +02:00
2014-06-12 11:31:53 +02:00
dol_syslog ( get_class ( $this ) . " ::fetch_lines " , LOG_DEBUG );
2022-03-28 13:50:47 +02:00
2019-12-18 15:20:36 +01:00
$resql = $this -> db -> query ( $sql );
2021-02-25 23:00:32 +01:00
if ( $resql ) {
2011-07-01 18:24:44 +02:00
$num = $this -> db -> num_rows ( $resql );
2008-06-21 01:01:02 +02:00
$i = 0 ;
2021-02-25 23:00:32 +01:00
while ( $i < $num ) {
2011-07-01 18:24:44 +02:00
$objp = $this -> db -> fetch_object ( $resql );
2008-06-21 01:01:02 +02:00
2010-12-15 08:12:28 +01:00
$line = new FichinterLigne ( $this -> db );
$line -> id = $objp -> rowid ;
2019-11-02 14:32:25 +01:00
$line -> fk_fichinter = $objp -> fk_fichinter ;
2011-07-01 18:24:44 +02:00
$line -> desc = $objp -> description ;
2016-07-01 19:15:30 +02:00
$line -> duration = $objp -> duree ;
2011-07-01 18:24:44 +02:00
//For invoicing we calculing hours
2019-12-18 15:20:36 +01:00
$line -> qty = round ( $objp -> duree / 3600 , 2 );
2011-07-01 18:24:44 +02:00
$line -> date = $this -> db -> jdate ( $objp -> date );
2022-09-02 08:53:13 +02:00
$line -> datei = $this -> db -> jdate ( $objp -> date ); // For backward compatibility
2011-07-01 18:24:44 +02:00
$line -> rang = $objp -> rang ;
2011-07-02 19:02:00 +02:00
$line -> product_type = 1 ;
2020-10-27 22:57:06 +01:00
$line -> fetch_optionals ();
2007-08-28 09:44:17 +02:00
2010-12-15 08:12:28 +01:00
$this -> lines [ $i ] = $line ;
2008-06-21 01:01:02 +02:00
$i ++ ;
}
2011-07-01 18:24:44 +02:00
$this -> db -> free ( $resql );
2010-10-27 16:47:32 +02:00
2008-06-21 01:01:02 +02:00
return 1 ;
2020-05-21 15:05:19 +02:00
} else {
2019-12-18 15:20:36 +01:00
$this -> error = $this -> db -> error ();
2008-06-21 01:01:02 +02:00
return - 1 ;
}
}
2015-04-18 18:11:01 +02:00
/**
* Function used to replace a thirdparty id with another one .
*
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 (
'fichinter'
);
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
}
2022-05-17 12:53:50 +02:00
/**
* Set customer reference number
*
* @ param User $user Object user that modify
* @ param string $ref_client Customer reference
* @ param int $notrigger 1 = Does not execute triggers , 0 = execute triggers
2023-12-06 15:46:39 +01:00
* @ return int Return integer < 0 if ko , > 0 if ok
2022-05-17 12:53:50 +02:00
*/
public function setRefClient ( $user , $ref_client , $notrigger = 0 )
{
// phpcs:enable
2023-10-15 18:12:03 +02:00
if ( $user -> hasRight ( 'ficheinter' , 'creer' )) {
2022-05-17 12:53:50 +02:00
$error = 0 ;
$this -> db -> begin ();
2024-04-22 18:57:21 +02:00
$this -> oldcopy = dol_clone ( $this , 2 );
2022-08-22 15:06:09 +02:00
2022-05-17 12:53:50 +02:00
$sql = " UPDATE " . MAIN_DB_PREFIX . $this -> table_element . " SET ref_client = " . ( empty ( $ref_client ) ? 'NULL' : " ' " . $this -> db -> escape ( $ref_client ) . " ' " );
$sql .= " WHERE rowid = " . (( int ) $this -> id );
dol_syslog ( __METHOD__ . ' $this->id=' . $this -> id . ', ref_client=' . $ref_client , LOG_DEBUG );
$resql = $this -> db -> query ( $sql );
if ( ! $resql ) {
$this -> errors [] = $this -> db -> error ();
$error ++ ;
}
if ( ! $error ) {
$this -> ref_client = $ref_client ;
}
if ( ! $notrigger && empty ( $error )) {
// Call trigger
$result = $this -> call_trigger ( 'FICHINTER_MODIFY' , $user );
if ( $result < 0 ) {
$error ++ ;
}
// End call triggers
}
if ( ! $error ) {
$this -> db -> commit ();
return 1 ;
} else {
foreach ( $this -> errors as $errmsg ) {
dol_syslog ( __METHOD__ . ' Error: ' . $errmsg , LOG_ERR );
$this -> error .= ( $this -> error ? ', ' . $errmsg : $errmsg );
}
$this -> db -> rollback ();
return - 1 * $error ;
}
} else {
return - 1 ;
}
}
2023-01-09 17:52:01 +01:00
/**
2024-08-07 01:20:43 +02:00
* Return clickable link of object ( with eventually picto )
2023-01-09 17:52:01 +01:00
*
2024-08-22 03:31:04 +02:00
* @ param string $option Where point the link ( 0 => main card , 1 , 2 => shipment , 'nolink' => No link )
2025-02-03 11:24:16 +01:00
* @ param ? array < string , mixed > $arraydata Array of data
2024-08-22 03:31:04 +02:00
* @ return string HTML Code for Kanban thumb .
2023-01-09 17:52:01 +01:00
*/
2023-01-18 22:27:52 +01:00
public function getKanbanView ( $option = '' , $arraydata = null )
2023-01-09 17:52:01 +01:00
{
global $langs ;
2023-03-07 22:04:40 +01:00
$selected = ( empty ( $arraydata [ 'selected' ]) ? 0 : $arraydata [ 'selected' ]);
2023-01-09 17:52:01 +01:00
$return = '<div class="box-flex-item box-flex-grow-zero">' ;
$return .= '<div class="info-box info-box-sm">' ;
$return .= '<span class="info-box-icon bg-infobox-action">' ;
$return .= img_picto ( '' , $this -> picto );
$return .= '</span>' ;
$return .= '<div class="info-box-content">' ;
2023-05-11 11:03:26 +02:00
$return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . ( method_exists ( $this , 'getNomUrl' ) ? $this -> getNomUrl () : $this -> ref ) . '</span>' ;
2023-10-17 15:43:56 +02:00
if ( $selected >= 0 ) {
$return .= '<input id="cb' . $this -> id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
2023-04-06 12:00:28 +02:00
if ( ! empty ( $arraydata [ 'thirdparty' ])) {
$tmpthirdparty = $arraydata [ 'thirdparty' ];
2024-10-03 19:40:34 +02:00
'@phan-var-force Societe $tmpthirdparty' ;
2023-04-06 12:00:28 +02:00
$return .= '<br><span class="info-box-label">' . $tmpthirdparty -> getNomUrl ( 1 ) . '</span>' ;
2023-01-09 17:52:01 +01:00
}
if ( property_exists ( $this , 'duration' )) {
$return .= '<br><span class="info-box-label ">' . $langs -> trans ( " Duration " ) . ' : ' . convertSecondToTime ( $this -> duration , 'allhourmin' ) . '</span>' ;
}
if ( method_exists ( $this , 'getLibStatut' )) {
2023-12-19 11:51:48 +01:00
$return .= '<br><div class="info-box-status">' . $this -> getLibStatut ( 3 ) . '</div>' ;
2023-01-09 17:52:01 +01:00
}
$return .= '</div>' ;
$return .= '</div>' ;
$return .= '</div>' ;
return $return ;
}
2008-06-21 01:01:02 +02:00
}