forked from Wavyzz/dolibarr
fetch greatest tms (#35122)
* fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms * fetch greatest tms
This commit is contained in:
@@ -1040,12 +1040,13 @@ class Contact extends CommonObject
|
||||
$sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,";
|
||||
$sql .= " c.fk_prospectlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,";
|
||||
$sql .= " c.import_key,";
|
||||
$sql .= " c.datec as date_creation, c.tms as date_modification, c.fk_user_creat, c.fk_user_modif,";
|
||||
$sql .= " c.datec as date_creation, GREATEST(c.tms, cef.tms) as date_modification, c.fk_user_creat, c.fk_user_modif,";
|
||||
$sql .= " co.label as country, co.code as country_code,";
|
||||
$sql .= " d.nom as state, d.code_departement as state_code,";
|
||||
$sql .= " u.rowid as user_id, u.login as user_login,";
|
||||
$sql .= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as cef ON cef.fk_object=c.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
|
||||
@@ -1435,8 +1436,9 @@ class Contact extends CommonObject
|
||||
public function info($id)
|
||||
{
|
||||
$sql = "SELECT c.rowid, c.datec as datec, c.fk_user_creat,";
|
||||
$sql .= " c.tms as tms, c.fk_user_modif";
|
||||
$sql .= " GREATEST(c.tms, cef.tms) as tms, c.fk_user_modif";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as cef ON cef.fk_object=c.rowid";
|
||||
$sql .= " WHERE c.rowid = ".((int) $id);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2025 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
|
||||
@@ -30,8 +31,13 @@ global $user;
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
'@phan-var-force Translate $langs';
|
||||
/**
|
||||
* @var CommonObject $object
|
||||
* @var Translate $langs
|
||||
*/
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
'@phan-var-force CommonObject[] $linkedObjectBlock';
|
||||
/** @var CommonObject[] $linkedObjectBlock */
|
||||
$langs->load("eventorganization");
|
||||
|
||||
$total = 0;
|
||||
|
||||
@@ -1030,21 +1030,28 @@ class MyObject extends CommonObject
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = "SELECT rowid,";
|
||||
$sql .= " date_creation as datec, tms as datem";
|
||||
$sql = "SELECT t.rowid, t.date_creation as datec";
|
||||
if (!empty($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
|
||||
$sql .= ", GREATEST(t.tms, te.tms) as datem";
|
||||
} else {
|
||||
$sql .= ", t.tms as datem";
|
||||
}
|
||||
if (!empty($this->fields['date_validation'])) {
|
||||
$sql .= ", date_validation as datev";
|
||||
$sql .= ", t.date_validation as datev";
|
||||
}
|
||||
if (!empty($this->fields['fk_user_creat'])) {
|
||||
$sql .= ", fk_user_creat";
|
||||
$sql .= ", t.fk_user_creat";
|
||||
}
|
||||
if (!empty($this->fields['fk_user_modif'])) {
|
||||
$sql .= ", fk_user_modif";
|
||||
$sql .= ", t.fk_user_modif";
|
||||
}
|
||||
if (!empty($this->fields['fk_user_valid'])) {
|
||||
$sql .= ", fk_user_valid";
|
||||
$sql .= ", t.fk_user_valid";
|
||||
}
|
||||
$sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
|
||||
if (!empty($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix().$this->table_element."_extrafields as te ON te.fk_object = t.rowid";
|
||||
}
|
||||
$sql .= " WHERE t.rowid = ".((int) $id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
@@ -1063,10 +1070,10 @@ class MyObject extends CommonObject
|
||||
if (!empty($this->fields['fk_user_valid'])) {
|
||||
$this->user_validation_id = $obj->fk_user_valid;
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
|
||||
if (!empty($obj->datev)) {
|
||||
$this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
|
||||
$this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1189,12 +1196,10 @@ class MyObject extends CommonObject
|
||||
$langs->load("mymodule@mymodule");
|
||||
|
||||
if (!dol_strlen($modele)) {
|
||||
$modele = 'standard_myobject';
|
||||
|
||||
if (!empty($this->model_pdf)) {
|
||||
$modele = $this->model_pdf;
|
||||
} elseif (getDolGlobalString('MYOBJECT_ADDON_PDF')) {
|
||||
$modele = getDolGlobalString('MYOBJECT_ADDON_PDF');
|
||||
} else {
|
||||
$modele = getDolGlobalString('MYOBJECT_ADDON_PDF', 'standard_myobject');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ global $noMoreLinkedObjectBlockAfter;
|
||||
|
||||
$langs = $GLOBALS['langs'];
|
||||
'@phan-var-force Translate $langs';
|
||||
/**
|
||||
* @var DoliDB $db
|
||||
* @var Translate $langs
|
||||
* @var string $action
|
||||
*/
|
||||
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
|
||||
'@phan-var-force array<CommonObject> $linkedObjectBlock';
|
||||
$object = $GLOBALS['object'];
|
||||
|
||||
@@ -2976,7 +2976,7 @@ class Product extends CommonObject
|
||||
} else {
|
||||
$sql .= " p.pmp,";
|
||||
}
|
||||
$sql .= " p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.sell_or_eat_by_mandatory, p.batch_mask, p.fk_unit,";
|
||||
$sql .= " p.datec, GREATEST(p.tms, pef.tms) AS tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.sell_or_eat_by_mandatory, p.batch_mask, p.fk_unit,";
|
||||
$sql .= " p.fk_price_expression, p.price_autogen, p.stockable_product, p.model_pdf,";
|
||||
$sql .= " p.price_label,";
|
||||
if ($separatedStock) {
|
||||
@@ -2985,6 +2985,7 @@ class Product extends CommonObject
|
||||
$sql .= " p.stock";
|
||||
}
|
||||
$sql .= " FROM ".$this->db->prefix()."product as p";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix()."product_extrafields as pef ON pef.fk_object=p.rowid";
|
||||
if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') || $separatedEntityPMP) {
|
||||
$sql .= " LEFT JOIN " . $this->db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
@@ -7154,9 +7155,10 @@ class Product extends CommonObject
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,";
|
||||
$sql = "SELECT p.rowid, p.ref, p.datec as date_creation, GREATEST(p.tms, pef.tms) as date_modification,";
|
||||
$sql .= " p.fk_user_author, p.fk_user_modif";
|
||||
$sql .= " FROM ".$this->db->prefix().$this->table_element." as p";
|
||||
$sql .= " LEFT JOIN ".$this->db->prefix().$this->table_element."_extrafields as pef ON pef.fk_object=p.rowid";
|
||||
$sql .= " WHERE p.rowid = ".((int) $id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
@@ -7170,7 +7172,7 @@ class Product extends CommonObject
|
||||
$this->user_creation_id = $obj->fk_user_author;
|
||||
$this->user_modification_id = $obj->fk_user_modif;
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||
$this->date_modification = $this->db->jdate($obj->date_modification);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2014-2025 Charlene BENKE <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2019 Pierre Ardoin <mapiolca@me.com>
|
||||
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
@@ -321,8 +321,9 @@ $lastmodified = "";
|
||||
if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("produit", "lire") || $user->hasRight("service", "lire"))) {
|
||||
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
|
||||
$sql .= " p.entity,";
|
||||
$sql .= " p.tms as datem";
|
||||
$sql .= " GREATEST(p.tms, pef.tms) as datem";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as pef ON pef.fk_object=p.rowid";
|
||||
$sql .= " WHERE p.entity IN (".getEntity($product_static->element, 1).")";
|
||||
/*if ($type != '') {
|
||||
$sql .= " AND p.fk_product_type = ".((int) $type);
|
||||
@@ -338,7 +339,7 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("pr
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $product_static); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= $db->order("p.tms", "DESC");
|
||||
$sql .= $db->order("datem", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
//print $sql;
|
||||
|
||||
@@ -1920,7 +1920,7 @@ class Societe extends CommonObject
|
||||
$sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.address, s.datec as date_creation, s.prefix_comm';
|
||||
$sql .= ', s.status, s.fk_warehouse';
|
||||
$sql .= ', s.price_level';
|
||||
$sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif';
|
||||
$sql .= ', GREATEST(s.tms, sef.tms) as date_modification, s.fk_user_creat, s.fk_user_modif';
|
||||
$sql .= ', s.phone, s.phone_mobile, s.fax, s.email';
|
||||
$sql .= ', s.socialnetworks';
|
||||
$sql .= ', s.url, s.zip, s.town, s.note_private, s.note_public, s.client, s.fournisseur';
|
||||
@@ -1965,6 +1965,7 @@ class Societe extends CommonObject
|
||||
$sql .= ', sr.remise_client, sr2.remise_supplier';
|
||||
}
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as sef ON sef.fk_object=s.rowid';
|
||||
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = ".((int) $conf->entity);
|
||||
}
|
||||
@@ -4395,9 +4396,10 @@ class Societe extends CommonObject
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = "SELECT s.rowid, s.nom as name, s.datec, tms as datem,";
|
||||
$sql = "SELECT s.rowid, s.nom as name, s.datec, GREATEST(s.tms, sef.tms) as datem,";
|
||||
$sql .= " fk_user_creat, fk_user_modif";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as sef ON sef.fk_object=s.rowid";
|
||||
$sql .= " WHERE s.rowid = ".((int) $id);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 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
|
||||
@@ -298,8 +298,9 @@ if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
||||
}
|
||||
$sql .= ", s.logo";
|
||||
$sql .= ", s.entity";
|
||||
$sql .= ", s.canvas, s.tms as date_modification, s.status as status";
|
||||
$sql .= ", s.canvas, GREATEST(s.tms, sef.tms) as date_modification, s.status as status";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as sef ON sef.fk_object=s.rowid";
|
||||
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
@@ -323,7 +324,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= $db->order("s.tms", "DESC");
|
||||
$sql .= $db->order("date_modification", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
//print $sql;
|
||||
@@ -419,10 +420,12 @@ if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
||||
$sql .= ", s.logo";
|
||||
$sql .= ", s.entity";
|
||||
$sql .= ", s.canvas";
|
||||
$sql .= ", s.tms as date_modification, s.status as status";
|
||||
$sql .= ", s.status as status";
|
||||
$sql .= ", GREATEST(sp.tms, spef.tms) as date_modification, sp.statut as cstatus";
|
||||
$sql .= ", sp.rowid as cid, sp.canvas as ccanvas, sp.email as cemail, sp.firstname, sp.lastname";
|
||||
$sql .= ", sp.address as caddress, sp.phone as cphone";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as sp";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople_extrafields as spef ON spef.fk_object=sp.rowid";
|
||||
if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
|
||||
}
|
||||
@@ -447,7 +450,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
}
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= $db->order("s.tms", "DESC");
|
||||
$sql .= $db->order("date_modification", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
//print $sql;
|
||||
@@ -497,6 +500,7 @@ if ($result) {
|
||||
$thirdparty_static->code_compta_client = $objp->code_compta;
|
||||
|
||||
$contact_static->id = $objp->cid;
|
||||
$contact_static->status = $objp->cstatus;
|
||||
$contact_static->firstname = $objp->firstname;
|
||||
$contact_static->lastname = $objp->lastname;
|
||||
$contact_static->email = $objp->cemail;
|
||||
|
||||
Reference in New Issue
Block a user