fix phan emailcollector (#30196)

* fix phan emailcollector

* fix phpstan

* add phpdoc

* add phpdoc

* add phpdoc

* add phpdoc

* add phpdoc

* add phpdoc

* add phpdoc
This commit is contained in:
Frédéric FRANCE 2024-06-29 18:57:43 +02:00 committed by GitHub
parent d03655b1fa
commit f1302291de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 126 additions and 59 deletions

View file

@ -150,7 +150,7 @@ class Propal extends CommonObject
public $datec;
/**
* @var integer|string $date_creation;
* @var integer|'' $date_creation;
*/
public $date_creation;
@ -161,12 +161,12 @@ class Propal extends CommonObject
public $datev;
/**
* @var integer|string $date_validation;
* @var integer|'' $date_validation;
*/
public $date_validation;
/**
* @var integer|string $date_signature;
* @var integer|'' $date_signature;
*/
public $date_signature;
@ -176,7 +176,7 @@ class Propal extends CommonObject
public $user_signature;
/**
* @var integer|string date of the quote;
* @var integer|'' date of the quote;
*/
public $date;
@ -187,13 +187,19 @@ class Propal extends CommonObject
public $datep;
/**
* @var integer|string $delivery_date;
* @var integer|'' $delivery_date;
*/
public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
/**
* @var integer|'' end of validity
*/
public $fin_validite;
/**
* @var int ID of user author
*/
public $user_author_id;
/**
@ -201,6 +207,7 @@ class Propal extends CommonObject
* @see $total_ht
*/
public $price;
/**
* @deprecated
* @see $total_tva
@ -254,14 +261,26 @@ class Propal extends CommonObject
public $duree_validite;
public $demand_reason_id; // id
public $demand_reason_code; // code
public $demand_reason; // label
/**
* @var int ID demand reason
*/
public $demand_reason_id;
/**
* @var string ID demand reason code
*/
public $demand_reason_code;
/**
* @var string ID demand reason label
*/
public $demand_reason;
/**
* @var int ID of warehouse
*/
public $warehouse_id;
public $extraparams = array();
/**
* @var PropaleLigne[]
*/
@ -1001,7 +1020,7 @@ class Propal extends CommonObject
{
global $user;
if ($this->statut == self::STATUS_DRAFT) {
if ($this->status == self::STATUS_DRAFT) {
$this->db->begin();
$line = new PropaleLigne($this->db);
@ -1162,7 +1181,7 @@ class Propal extends CommonObject
$sql .= ", ".($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL');
$sql .= ", '".$this->db->escape($this->ref_client)."'";
$sql .= ", '".$this->db->escape($this->ref_ext)."'";
$sql .= ", ".(empty($delivery_date) ? "NULL" : "'".$this->db->idate($delivery_date)."'");
$sql .= ", ".(!isDolTms($delivery_date) ? "NULL" : "'".$this->db->idate($delivery_date)."'");
$sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL');
$sql .= ", ".($this->warehouse_id > 0 ? $this->warehouse_id : 'NULL');
$sql .= ", ".$this->availability_id;
@ -1409,6 +1428,7 @@ class Propal extends CommonObject
// reset ref_client
$object->ref_client = '';
$object->ref_customer = '';
// TODO Change product price if multi-prices
} else {
@ -1484,6 +1504,7 @@ class Propal extends CommonObject
$object->fin_validite = $object->date + ($object->duree_validite * 24 * 3600);
if (!getDolGlobalString('MAIN_KEEP_REF_CUSTOMER_ON_CLONING')) {
$object->ref_client = '';
$object->ref_customer = '';
}
if (getDolGlobalInt('MAIN_DONT_KEEP_NOTE_ON_CLONING') == 1) {
$object->note_private = '';
@ -1764,7 +1785,7 @@ class Propal extends CommonObject
$sql .= " localtax2=".(isset($this->total_localtax2) ? $this->total_localtax2 : "null").",";
$sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").",";
$sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").",";
$sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").",";
$sql .= " fk_statut=".(isset($this->status) ? $this->status : "null").",";
$sql .= " fk_user_author=".(isset($this->user_author_id) ? $this->user_author_id : "null").",";
$sql .= " fk_user_valid=".(isset($this->user_validation_id) ? $this->user_validation_id : "null").",";
$sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").",";
@ -1967,7 +1988,7 @@ class Propal extends CommonObject
$error = 0;
// Protection
if ($this->statut == self::STATUS_VALIDATED) {
if ($this->status == self::STATUS_VALIDATED) {
dol_syslog(get_class($this)."::valid action abandoned: already validated", LOG_WARNING);
return 0;
}
@ -2283,7 +2304,7 @@ class Propal extends CommonObject
public function set_availability($user, $id, $notrigger = 0)
{
// phpcs:enable
if ($user->hasRight('propal', 'creer') && $this->statut >= self::STATUS_DRAFT) {
if ($user->hasRight('propal', 'creer') && $this->status >= self::STATUS_DRAFT) {
$error = 0;
$this->db->begin();
@ -2326,7 +2347,7 @@ class Propal extends CommonObject
return -1 * $error;
}
} else {
$error_str = 'Propal status do not meet requirement '.$this->statut;
$error_str = 'Propal status do not meet requirement '.$this->status;
dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error = $error_str;
$this->errors[] = $this->error;
@ -2346,7 +2367,7 @@ class Propal extends CommonObject
public function set_demand_reason($user, $id, $notrigger = 0)
{
// phpcs:enable
if ($user->hasRight('propal', 'creer') && $this->statut >= self::STATUS_DRAFT) {
if ($user->hasRight('propal', 'creer') && $this->status >= self::STATUS_DRAFT) {
$error = 0;
$this->db->begin();
@ -2391,7 +2412,7 @@ class Propal extends CommonObject
return -1 * $error;
}
} else {
$error_str = 'Propal status do not meet requirement '.$this->statut;
$error_str = 'Propal status do not meet requirement '.$this->status;
dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error = $error_str;
$this->errors[] = $this->error;
@ -2615,8 +2636,8 @@ class Propal extends CommonObject
$this->db->commit();
return 1;
} else {
$this->statut = $this->oldcopy->statut;
$this->status = $this->oldcopy->statut;
$this->statut = $this->oldcopy->status;
$this->status = $this->oldcopy->status;
$this->date_signature = $this->oldcopy->date_signature;
$this->note_private = $this->oldcopy->note_private;
@ -2689,6 +2710,7 @@ class Propal extends CommonObject
$this->oldcopy = clone $this;
$this->statut = self::STATUS_BILLED;
$this->status = self::STATUS_BILLED;
$this->date_cloture = $now;
$this->note_private = $newprivatenote;
}
@ -2745,6 +2767,7 @@ class Propal extends CommonObject
if (!$error) {
$this->statut = self::STATUS_CANCELED;
$this->status = self::STATUS_CANCELED;
$this->db->commit();
return 1;
} else {
@ -2776,7 +2799,7 @@ class Propal extends CommonObject
$error = 0;
// Protection
if ($this->statut <= self::STATUS_DRAFT) {
if ($this->status <= self::STATUS_DRAFT) {
return 0;
}
@ -3125,7 +3148,7 @@ class Propal extends CommonObject
{
global $user;
if ($this->statut >= self::STATUS_DRAFT) {
if ($this->status >= self::STATUS_DRAFT) {
$error = 0;
$this->db->begin();
@ -3167,7 +3190,7 @@ class Propal extends CommonObject
return -1 * $error;
}
} else {
$error_str = 'Propal status do not meet requirement '.$this->statut;
$error_str = 'Propal status do not meet requirement '.$this->status;
dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error = $error_str;
$this->errors[] = $this->error;
@ -3231,7 +3254,7 @@ class Propal extends CommonObject
return -1 * $error;
}
} else {
$error_str = 'Propal status do not meet requirement '.$this->statut;
$error_str = 'Propal status do not meet requirement '.$this->status;
dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error = $error_str;
$this->errors[] = $this->error;
@ -3293,7 +3316,7 @@ class Propal extends CommonObject
*/
public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->statut, $mode);
return $this->LibStatut($this->status, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View file

@ -3076,7 +3076,7 @@ class EmailCollector extends CommonObject
$percent_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'percent');
$projecttocreate->title = $subject;
$projecttocreate->date_start = $date; // date of email
$projecttocreate->date_start = $dateemail; // date of email
$projecttocreate->date_end = 0;
$projecttocreate->opp_status = $id_opp_status;
$projecttocreate->opp_percent = $percent_opp_status;
@ -3222,7 +3222,7 @@ class EmailCollector extends CommonObject
$tickettocreate->note_private = $descriptionfull;
$tickettocreate->entity = $conf->entity;
$tickettocreate->email_msgid = $msgid;
$tickettocreate->email_date = $date;
$tickettocreate->email_date = $dateemail;
//$tickettocreate->fk_contact = $contactstatic->id;
$savesocid = $tickettocreate->socid;
@ -3338,7 +3338,7 @@ class EmailCollector extends CommonObject
$candidaturetocreate->note_private = $descriptionfull;
$candidaturetocreate->entity = $conf->entity;
$candidaturetocreate->email_msgid = $msgid;
$candidaturetocreate->email_date = $date; // date of email
$candidaturetocreate->email_date = $dateemail; // date of email
$candidaturetocreate->status = $candidaturetocreate::STATUS_DRAFT;
//$candidaturetocreate->fk_contact = $contactstatic->id;

View file

@ -81,23 +81,51 @@ class Task extends CommonObjectLine
*/
public $description;
public $duration_effective; // total of time spent on this task
/**
* @var float|'' total of time spent on this task
*/
public $duration_effective;
/**
* @var float|'' planned workload
*/
public $planned_workload;
/**
* @var null|int|'' date creation
* @see isDolTms()
*/
public $date_c;
/**
* @var int|'' progress
*/
public $progress;
/**
* @var null|int|'' start date
* @see isDolTms()
* @deprecated Use date_start instead
*/
public $dateo;
/**
* @var null|int|'' start date
* @see isDolTms()
*/
public $date_start;
/**
* @var null|int|'' end date
* @see isDolTms()
* @deprecated Use date_end instead
*/
public $datee;
/**
* @var null|int|'' end date
* @see isDolTms()
*/
public $date_end;
/**
@ -111,6 +139,9 @@ class Task extends CommonObjectLine
*/
public $status;
/**
* @var int priority
*/
public $priority;
/**
@ -151,6 +182,10 @@ class Task extends CommonObjectLine
// Properties calculated from sum of llx_element_time linked to task
public $tobill;
/**
* @var int is task billed
*/
public $billed;
// Properties to store project information
@ -279,8 +314,8 @@ class Task extends CommonObjectLine
$sql .= ", '".$this->db->escape($this->note_private)."'";
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".((int) $user->id);
$sql .= ", ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql .= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql .= ", ".(isDolTms($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql .= ", ".(isDolTms($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? ((int) $this->planned_workload) : 'null');
$sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? ((int) $this->progress) : 'null');
$sql .= ", ".(($this->budget_amount != '' && $this->budget_amount >= 0) ? ((int) $this->budget_amount) : 'null');
@ -398,7 +433,7 @@ class Task extends CommonObjectLine
$this->planned_workload = $obj->planned_workload;
$this->date_c = $this->db->jdate($obj->datec);
$this->date_start = $this->db->jdate($obj->date_start);
$this->date_end = $this->db->jdate($obj->date_end);
$this->date_end = $this->db->jdate($obj->date_end);
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_valid = $obj->fk_user_valid;
$this->fk_statut = $obj->status;
@ -496,8 +531,8 @@ class Task extends CommonObjectLine
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
$sql .= " duration_effective=".(isset($this->duration_effective) ? $this->duration_effective : "null").",";
$sql .= " planned_workload=".((isset($this->planned_workload) && $this->planned_workload != '') ? $this->planned_workload : "null").",";
$sql .= " dateo=".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null').",";
$sql .= " datee=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null').",";
$sql .= " dateo=".(isDolTms($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : 'null').",";
$sql .= " datee=".(isDolTms($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : 'null').",";
$sql .= " progress=".(($this->progress != '' && $this->progress >= 0) ? $this->progress : 'null').",";
$sql .= " budget_amount=".(($this->budget_amount != '' && $this->budget_amount >= 0) ? $this->budget_amount : 'null').",";
$sql .= " rang=".((!empty($this->rang)) ? ((int) $this->rang) : "0").",";
@ -921,7 +956,7 @@ class Task extends CommonObjectLine
$this->label = 'Specimen task TK01';
$this->duration_effective = '';
$this->fk_user_creat = $user->id;
$this->progress = '25';
$this->progress = 25;
$this->status = 0;
$this->priority = 0;
$this->note_private = 'This is a specimen private note';

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
/* Copyright (C) 2014-2015 Florian HENRY <florian.henry@open-concept.pro>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -24,8 +25,16 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
*/
class TaskStats extends Stats
{
private $project;
private $project; // @phpstan-ignore-line
/**
* @var int ID of User
*/
public $userid;
/**
* @var int ID of Societe
*/
public $socid;
/**

View file

@ -1,12 +1,12 @@
<?php
/* Copyright (C) 2013-2018 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2013-2018 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -128,7 +128,7 @@ class Ticket extends CommonObject
public $status;
/**
* @var string State resolution
* @var null|integer State resolution
*/
public $resolution;
@ -233,7 +233,7 @@ class Ticket extends CommonObject
public $email_msgid;
/**
* @var string Email Date
* @var null|int|'' Email Date
*/
public $email_date;
@ -429,12 +429,12 @@ class Ticket extends CommonObject
}
}
if (isset($this->fk_statut)) {
$this->fk_statut = (int) $this->fk_statut;
if (isset($this->status)) {
$this->status = (int) $this->status;
}
if (isset($this->resolution)) {
$this->resolution = trim($this->resolution);
$this->resolution = (int) $this->resolution;
}
if (isset($this->progress)) {
@ -556,7 +556,7 @@ class Ticket extends CommonObject
$sql .= " ".(!isset($this->fk_user_create) ? ($user->id > 0 ? ((int) $user->id) : 'NULL') : ($this->fk_user_create > 0 ? ((int) $this->fk_user_create) : 'NULL')).",";
$sql .= " ".($this->fk_user_assign > 0 ? ((int) $this->fk_user_assign) : 'NULL').",";
$sql .= " ".(empty($this->email_msgid) ? 'NULL' : "'".$this->db->escape($this->email_msgid)."'").",";
$sql .= " ".(empty($this->email_date) ? 'NULL' : "'".$this->db->idate($this->email_date)."'").",";
$sql .= " ".(!isDolTms($this->email_date) ? 'NULL' : "'".$this->db->idate($this->email_date)."'").",";
$sql .= " ".(!isset($this->subject) ? 'NULL' : "'".$this->db->escape($this->subject)."'").",";
$sql .= " ".(!isset($this->message) ? 'NULL' : "'".$this->db->escape($this->message)."'").",";
$sql .= " ".(!isset($this->status) ? '0' : ((int) $this->status)).",";
@ -566,7 +566,7 @@ class Ticket extends CommonObject
$sql .= " ".(!isset($this->type_code) ? 'NULL' : "'".$this->db->escape($this->type_code)."'").",";
$sql .= " ".(empty($this->category_code) || $this->category_code == '-1' ? 'NULL' : "'".$this->db->escape($this->category_code)."'").",";
$sql .= " ".(!isset($this->severity_code) ? 'NULL' : "'".$this->db->escape($this->severity_code)."'").",";
$sql .= " ".(!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'".$this->db->idate($this->datec)."'").",";
$sql .= " ".(!isDolTms($this->datec) ? 'NULL' : "'".$this->db->idate($this->datec)."'").",";
$sql .= " ".(!isset($this->date_read) || dol_strlen($this->date_read) == 0 ? 'NULL' : "'".$this->db->idate($this->date_read)."'").",";
$sql .= " ".(!isset($this->date_close) || dol_strlen($this->date_close) == 0 ? 'NULL' : "'".$this->db->idate($this->date_close)."'");
$sql .= ", ".((int) $this->entity);
@ -1050,12 +1050,12 @@ class Ticket extends CommonObject
}
}
if (isset($this->fk_statut)) {
$this->fk_statut = (int) $this->fk_statut;
if (isset($this->status)) {
$this->status = (int) $this->status;
}
if (isset($this->resolution)) {
$this->resolution = trim($this->resolution);
$this->resolution = (int) $this->resolution;
}
if (isset($this->progress)) {
@ -1096,14 +1096,14 @@ class Ticket extends CommonObject
$sql .= " fk_user_assign=".(isset($this->fk_user_assign) ? (int) $this->fk_user_assign : "null").",";
$sql .= " subject=".(isset($this->subject) ? "'".$this->db->escape($this->subject)."'" : "null").",";
$sql .= " message=".(isset($this->message) ? "'".$this->db->escape($this->message)."'" : "null").",";
$sql .= " fk_statut=".(isset($this->fk_statut) ? (int) $this->fk_statut : "0").",";
$sql .= " fk_statut=".(isset($this->status) ? (int) $this->status : "0").",";
$sql .= " resolution=".(isset($this->resolution) ? (int) $this->resolution : "null").",";
$sql .= " progress=".(isset($this->progress) ? "'".$this->db->escape($this->progress)."'" : "null").",";
$sql .= " timing=".(isset($this->timing) ? "'".$this->db->escape($this->timing)."'" : "null").",";
$sql .= " type_code=".(isset($this->type_code) ? "'".$this->db->escape($this->type_code)."'" : "null").",";
$sql .= " category_code=".(isset($this->category_code) ? "'".$this->db->escape($this->category_code)."'" : "null").",";
$sql .= " severity_code=".(isset($this->severity_code) ? "'".$this->db->escape($this->severity_code)."'" : "null").",";
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " datec=".(isDolTms($this->datec) ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " date_read=".(dol_strlen($this->date_read) != 0 ? "'".$this->db->idate($this->date_read)."'" : 'null').",";
$sql .= " date_last_msg_sent=".(dol_strlen($this->date_last_msg_sent) != 0 ? "'".$this->db->idate($this->date_last_msg_sent)."'" : 'null').",";
$sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
@ -1316,9 +1316,9 @@ class Ticket extends CommonObject
$this->subject = 'Subject of ticket';
$this->message = 'Message of ticket';
$this->status = 0;
$this->resolution = '1';
$this->resolution = 1;
$this->progress = 10;
//$this->timing = '30';
// $this->timing = '30';
$this->type_code = 'TYPECODE';
$this->category_code = 'CATEGORYCODE';
$this->severity_code = 'SEVERITYCODE';