Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
5f290e0de1
@ -8285,22 +8285,31 @@ abstract class CommonObject
|
|||||||
* Initialise object with example values
|
* Initialise object with example values
|
||||||
* Id must be 0 if object instance is a specimen
|
* Id must be 0 if object instance is a specimen
|
||||||
*
|
*
|
||||||
* @return void
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function initAsSpecimenCommon()
|
public function initAsSpecimenCommon()
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$this->id = 0;
|
$this->id = 0;
|
||||||
if (array_key_exists('label', $this->fields)) $this->label = 'This is label';
|
$this->specimen = 1;
|
||||||
if (array_key_exists('note_public', $this->fields)) $this->note_public = 'Public note';
|
$fields = array(
|
||||||
if (array_key_exists('note_private', $this->fields)) $this->note_private = 'Private note';
|
'label' => 'This is label',
|
||||||
if (array_key_exists('date_creation', $this->fields)) $this->date_creation = (dol_now() - 3600 * 24);
|
'ref' => 'ABCD1234',
|
||||||
if (array_key_exists('date_modification', $this->fields)) $this->date_modification = (dol_now() - 3600 * 24);
|
'description' => 'This is a description',
|
||||||
if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat = $user->id;
|
'qty' => 123.12,
|
||||||
if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif = $user->id;
|
'note_public' => 'Public note',
|
||||||
if (array_key_exists('date', $this->fields)) $this->date = dol_now();
|
'note_private' => 'Private note',
|
||||||
// ...
|
'date_creation' => (dol_now() - 3600 * 48),
|
||||||
|
'date_modification' => (dol_now() - 3600 * 24),
|
||||||
|
'fk_user_creat' => $user->id,
|
||||||
|
'fk_user_modif' => $user->id,
|
||||||
|
'date' => dol_now(),
|
||||||
|
);
|
||||||
|
foreach ($fields as $key => $value) {
|
||||||
|
if (array_key_exists($key, $this->fields)) $this->{$key} = $value;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -138,56 +138,39 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
|||||||
*/
|
*/
|
||||||
public function getExample($langs, $objsoc = 0, $type = -1)
|
public function getExample($langs, $objsoc = 0, $type = -1)
|
||||||
{
|
{
|
||||||
if ($type == 0 || $type == -1)
|
$errmsg = array(
|
||||||
{
|
"ErrorBadMask",
|
||||||
|
"ErrorCantUseRazIfNoYearInMask",
|
||||||
|
"ErrorCantUseRazInStartedYearIfNoYearMonthInMask",
|
||||||
|
);
|
||||||
|
if ($type != 1) {
|
||||||
$examplecust = $this->getNextValue($objsoc, 0);
|
$examplecust = $this->getNextValue($objsoc, 0);
|
||||||
if (!$examplecust)
|
if (!$examplecust) {
|
||||||
{
|
|
||||||
$examplecust = $langs->trans('NotConfigured');
|
$examplecust = $langs->trans('NotConfigured');
|
||||||
}
|
}
|
||||||
if ($examplecust == "ErrorBadMask")
|
if (in_array($examplecust, $errmsg)) {
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$examplecust = $langs->trans($examplecust);
|
|
||||||
}
|
|
||||||
if ($examplecust == "ErrorCantUseRazIfNoYearInMask")
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$examplecust = $langs->trans($examplecust);
|
|
||||||
}
|
|
||||||
if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$examplecust = $langs->trans($examplecust);
|
$examplecust = $langs->trans($examplecust);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($type == 1 || $type == -1)
|
if ($type != 0) {
|
||||||
{
|
|
||||||
$examplesup = $this->getNextValue($objsoc, 1);
|
$examplesup = $this->getNextValue($objsoc, 1);
|
||||||
if (!$examplesup)
|
if (!$examplesup) {
|
||||||
{
|
|
||||||
$examplesup = $langs->trans('NotConfigured');
|
$examplesup = $langs->trans('NotConfigured');
|
||||||
}
|
}
|
||||||
if ($examplesup == "ErrorBadMask")
|
if (in_array($examplesup, $errmsg)) {
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$examplesup = $langs->trans($examplesup);
|
|
||||||
}
|
|
||||||
if ($examplesup == "ErrorCantUseRazIfNoYearInMask")
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$examplesup = $langs->trans($examplesup);
|
|
||||||
}
|
|
||||||
if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$examplesup = $langs->trans($examplesup);
|
$examplesup = $langs->trans($examplesup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 0) return $examplecust;
|
if ($type == 0) {
|
||||||
if ($type == 1) return $examplesup;
|
return $examplecust;
|
||||||
return $examplecust.'<br>'.$examplesup;
|
} elseif ($type == 1) {
|
||||||
|
return $examplesup;
|
||||||
|
} else {
|
||||||
|
return $examplecust.'<br>'.$examplesup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -140,11 +140,17 @@ abstract class ModeleThirdPartyCode
|
|||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
if ($this->version == 'development') {
|
||||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
return $langs->trans("VersionDevelopment");
|
||||||
if ($this->version == 'dolibarr') return DOL_VERSION;
|
} elseif ($this->version == 'experimental') {
|
||||||
if ($this->version) return $this->version;
|
return $langs->trans("VersionExperimental");
|
||||||
return $langs->trans("NotAvailable");
|
} elseif ($this->version == 'dolibarr') {
|
||||||
|
return DOL_VERSION;
|
||||||
|
} elseif ($this->version) {
|
||||||
|
return $this->version;
|
||||||
|
} else {
|
||||||
|
return $langs->trans("NotAvailable");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
@ -153,7 +159,7 @@ abstract class ModeleThirdPartyCode
|
|||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param integer $maxfilenamelength Max length of value to show
|
* @param integer $maxfilenamelength Max length of value to show
|
||||||
* @return array List of numbers
|
* @return array|int List of numbers
|
||||||
*/
|
*/
|
||||||
public static function liste_modeles($db, $maxfilenamelength = 0)
|
public static function liste_modeles($db, $maxfilenamelength = 0)
|
||||||
{
|
{
|
||||||
@ -193,31 +199,32 @@ abstract class ModeleThirdPartyCode
|
|||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
$s = '';
|
$s = '';
|
||||||
if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
|
if ($type == -1) {
|
||||||
if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
$s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
|
||||||
if ($type == 0) $s .= $langs->trans("CustomerCodeDesc").'<br>';
|
} elseif ($type == -1) {
|
||||||
if ($type == 1) $s .= $langs->trans("SupplierCodeDesc").'<br>';
|
$s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||||
if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
} elseif ($type == 0) {
|
||||||
|
$s .= $langs->trans("CustomerCodeDesc").'<br>';
|
||||||
|
} elseif ($type == 1) {
|
||||||
|
$s .= $langs->trans("SupplierCodeDesc").'<br>';
|
||||||
|
} elseif ($type != -1) {
|
||||||
|
$s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
|
||||||
|
}
|
||||||
$s .= '<br>';
|
$s .= '<br>';
|
||||||
$s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
$s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||||
if ($type == 0)
|
if ($type == 0) {
|
||||||
{
|
|
||||||
$s .= $langs->trans("RequiredIfCustomer").': ';
|
$s .= $langs->trans("RequiredIfCustomer").': ';
|
||||||
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
|
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
|
||||||
$s .= yn(!$this->code_null, 1, 2);
|
$s .= yn(!$this->code_null, 1, 2);
|
||||||
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
|
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
|
||||||
$s .= '<br>';
|
$s .= '<br>';
|
||||||
}
|
} elseif ($type == 1) {
|
||||||
if ($type == 1)
|
|
||||||
{
|
|
||||||
$s .= $langs->trans("RequiredIfSupplier").': ';
|
$s .= $langs->trans("RequiredIfSupplier").': ';
|
||||||
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
|
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
|
||||||
$s .= yn(!$this->code_null, 1, 2);
|
$s .= yn(!$this->code_null, 1, 2);
|
||||||
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
|
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
|
||||||
$s .= '<br>';
|
$s .= '<br>';
|
||||||
}
|
} elseif ($type == -1) {
|
||||||
if ($type == -1)
|
|
||||||
{
|
|
||||||
$s .= $langs->trans("Required").': ';
|
$s .= $langs->trans("Required").': ';
|
||||||
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
|
if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
|
||||||
$s .= yn(!$this->code_null, 1, 2);
|
$s .= yn(!$this->code_null, 1, 2);
|
||||||
@ -230,14 +237,12 @@ abstract class ModeleThirdPartyCode
|
|||||||
$s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
|
$s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
|
||||||
$s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
|
$s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
|
||||||
$s .= '<br>';
|
$s .= '<br>';
|
||||||
if ($type == 0 || $type == -1)
|
if ($type == 0 || $type == -1) {
|
||||||
{
|
|
||||||
$nextval = $this->getNextValue($soc, 0);
|
$nextval = $this->getNextValue($soc, 0);
|
||||||
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
||||||
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
|
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
|
||||||
}
|
}
|
||||||
if ($type == 1 || $type == -1)
|
if ($type == 1 || $type == -1) {
|
||||||
{
|
|
||||||
$nextval = $this->getNextValue($soc, 1);
|
$nextval = $this->getNextValue($soc, 1);
|
||||||
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
||||||
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
|
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Supplier").')' : '').': <b>'.$nextval.'</b>';
|
||||||
@ -317,11 +322,17 @@ abstract class ModeleAccountancyCode
|
|||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
if ($this->version == 'development') {
|
||||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
return $langs->trans("VersionDevelopment");
|
||||||
if ($this->version == 'dolibarr') return DOL_VERSION;
|
} elseif ($this->version == 'experimental') {
|
||||||
if ($this->version) return $this->version;
|
return $langs->trans("VersionExperimental");
|
||||||
return $langs->trans("NotAvailable");
|
} elseif ($this->version == 'dolibarr') {
|
||||||
|
return DOL_VERSION;
|
||||||
|
} elseif ($this->version) {
|
||||||
|
return $this->version;
|
||||||
|
} else {
|
||||||
|
return $langs->trans("NotAvailable");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,20 +350,20 @@ abstract class ModeleAccountancyCode
|
|||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
|
|
||||||
$s = '';
|
$s = '';
|
||||||
if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
|
if ($type == -1) {
|
||||||
if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
$s .= $langs->trans("Name").': <b>'.$this->name.'</b><br>';
|
||||||
|
$s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
|
||||||
|
}
|
||||||
//$s.='<br>';
|
//$s.='<br>';
|
||||||
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
|
||||||
$s .= '<br>';
|
$s .= '<br>';
|
||||||
if ($type == 0 || $type == -1)
|
if ($type == 0 || $type == -1) {
|
||||||
{
|
|
||||||
$result = $this->get_code($db, $soc, 'customer');
|
$result = $this->get_code($db, $soc, 'customer');
|
||||||
$nextval = $this->code;
|
$nextval = $this->code;
|
||||||
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
||||||
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
|
$s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Customer").')' : '').': <b>'.$nextval.'</b><br>';
|
||||||
}
|
}
|
||||||
if ($type == 1 || $type == -1)
|
if ($type == 1 || $type == -1) {
|
||||||
{
|
|
||||||
$result = $this->get_code($db, $soc, 'supplier');
|
$result = $this->get_code($db, $soc, 'supplier');
|
||||||
$nextval = $this->code;
|
$nextval = $this->code;
|
||||||
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
if (empty($nextval)) $nextval = $langs->trans("Undefined");
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
|
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||||
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -635,10 +635,6 @@ class Fichinter extends CommonObject
|
|||||||
$this->statut = 1;
|
$this->statut = 1;
|
||||||
$this->brouillon = 0;
|
$this->brouillon = 0;
|
||||||
$this->date_validation = $now;
|
$this->date_validation = $now;
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error)
|
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@ -970,14 +966,13 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
$main = MAIN_DB_PREFIX.'fichinterdet';
|
||||||
$main = MAIN_DB_PREFIX.'fichinterdet';
|
$ef = $main."_extrafields";
|
||||||
$ef = $main."_extrafields";
|
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = ".$this->id.")";
|
||||||
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = ".$this->id.")";
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) $error++;
|
if (!$resql) $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
|
|||||||
@ -1600,201 +1600,229 @@ class Holiday extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function fetchUsers($stringlist = true, $type = true, $filters = '')
|
public function fetchUsers($stringlist = true, $type = true, $filters = '')
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
|
||||||
|
|
||||||
if ($stringlist)
|
if ($stringlist) {
|
||||||
|
$this->fetchUsersById($type, $filters);
|
||||||
|
} else {
|
||||||
|
$this->fetchUsersByDetail($type, $filters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of Users or list of vacation balance by User Id
|
||||||
|
*
|
||||||
|
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
|
||||||
|
* @param string $filters Filters
|
||||||
|
* @return array|string|int Return an array
|
||||||
|
*/
|
||||||
|
public function fetchUsersById($type = true, $filters = '')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::fetchUsersById", LOG_DEBUG);
|
||||||
|
|
||||||
|
if ($type)
|
||||||
{
|
{
|
||||||
if ($type)
|
// If user of Dolibarr
|
||||||
|
$sql = "SELECT";
|
||||||
|
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||||
|
$sql .= " DISTINCT";
|
||||||
|
}
|
||||||
|
$sql .= " u.rowid";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
|
|
||||||
|
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||||
{
|
{
|
||||||
// If user of Dolibarr
|
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||||
$sql = "SELECT";
|
$sql .= " WHERE ((ug.fk_user = u.rowid";
|
||||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
||||||
$sql .= " DISTINCT";
|
$sql .= " OR u.entity = 0)"; // Show always superadmin
|
||||||
}
|
|
||||||
$sql .= " u.rowid";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
|
||||||
|
|
||||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
|
||||||
{
|
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
|
||||||
$sql .= " WHERE ((ug.fk_user = u.rowid";
|
|
||||||
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
|
||||||
$sql .= " OR u.entity = 0)"; // Show always superadmin
|
|
||||||
} else {
|
|
||||||
$sql .= " WHERE u.entity IN (".getEntity('user').")";
|
|
||||||
}
|
|
||||||
$sql .= " AND u.statut > 0";
|
|
||||||
if ($filters) $sql .= $filters;
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
|
|
||||||
// Si pas d'erreur SQL
|
|
||||||
if ($resql) {
|
|
||||||
$i = 0;
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
$stringlist = '';
|
|
||||||
|
|
||||||
// Boucles du listage des utilisateurs
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
|
|
||||||
if ($i == 0) {
|
|
||||||
$stringlist .= $obj->rowid;
|
|
||||||
} else {
|
|
||||||
$stringlist .= ', '.$obj->rowid;
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
// Retoune le tableau des utilisateurs
|
|
||||||
return $stringlist;
|
|
||||||
} else {
|
|
||||||
// Erreur SQL
|
|
||||||
$this->error = "Error ".$this->db->lasterror();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// We want only list of vacation balance for user ids
|
$sql .= " WHERE u.entity IN (".getEntity('user').")";
|
||||||
$sql = "SELECT DISTINCT cpu.fk_user";
|
}
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
$sql .= " AND u.statut > 0";
|
||||||
$sql .= " WHERE cpu.fk_user = u.rowid";
|
if ($filters) $sql .= $filters;
|
||||||
if ($filters) $sql .= $filters;
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
// Si pas d'erreur SQL
|
// Si pas d'erreur SQL
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$stringlist = '';
|
$stringlist = '';
|
||||||
|
|
||||||
// Boucles du listage des utilisateurs
|
// Boucles du listage des utilisateurs
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
$stringlist .= $obj->fk_user;
|
$stringlist .= $obj->rowid;
|
||||||
} else {
|
} else {
|
||||||
$stringlist .= ', '.$obj->fk_user;
|
$stringlist .= ', '.$obj->rowid;
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
// Retoune le tableau des utilisateurs
|
|
||||||
return $stringlist;
|
$i++;
|
||||||
} else {
|
|
||||||
// Erreur SQL
|
|
||||||
$this->error = "Error ".$this->db->lasterror();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
// Retoune le tableau des utilisateurs
|
||||||
|
return $stringlist;
|
||||||
|
} else {
|
||||||
|
// Erreur SQL
|
||||||
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Si faux donc return array
|
// We want only list of vacation balance for user ids
|
||||||
// List for Dolibarr users
|
$sql = "SELECT DISTINCT cpu.fk_user";
|
||||||
if ($type)
|
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||||
{
|
$sql .= " WHERE cpu.fk_user = u.rowid";
|
||||||
// If user of Dolibarr
|
if ($filters) $sql .= $filters;
|
||||||
$sql = "SELECT";
|
|
||||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
|
||||||
$sql .= " DISTINCT";
|
|
||||||
}
|
|
||||||
$sql .= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
|
||||||
|
|
||||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
// Si pas d'erreur SQL
|
||||||
|
if ($resql) {
|
||||||
|
$i = 0;
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
$stringlist = '';
|
||||||
|
|
||||||
|
// Boucles du listage des utilisateurs
|
||||||
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
$obj = $this->db->fetch_object($resql);
|
||||||
$sql .= " WHERE ((ug.fk_user = u.rowid";
|
|
||||||
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
|
||||||
$sql .= " OR u.entity = 0)"; // Show always superadmin
|
|
||||||
} else {
|
|
||||||
$sql .= " WHERE u.entity IN (".getEntity('user').")";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql .= " AND u.statut > 0";
|
if ($i == 0) {
|
||||||
if ($filters) $sql .= $filters;
|
$stringlist .= $obj->fk_user;
|
||||||
|
} else {
|
||||||
$resql = $this->db->query($sql);
|
$stringlist .= ', '.$obj->fk_user;
|
||||||
|
|
||||||
// Si pas d'erreur SQL
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$i = 0;
|
|
||||||
$tab_result = $this->holiday;
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
|
|
||||||
// Boucles du listage des utilisateurs
|
|
||||||
while ($i < $num) {
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
|
|
||||||
$tab_result[$i]['rowid'] = $obj->rowid; // rowid of user
|
|
||||||
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
|
||||||
$tab_result[$i]['lastname'] = $obj->lastname;
|
|
||||||
$tab_result[$i]['firstname'] = $obj->firstname;
|
|
||||||
$tab_result[$i]['gender'] = $obj->gender;
|
|
||||||
$tab_result[$i]['status'] = $obj->statut;
|
|
||||||
$tab_result[$i]['employee'] = $obj->employee;
|
|
||||||
$tab_result[$i]['photo'] = $obj->photo;
|
|
||||||
$tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager
|
|
||||||
//$tab_result[$i]['type'] = $obj->type;
|
|
||||||
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
// Retoune le tableau des utilisateurs
|
|
||||||
return $tab_result;
|
$i++;
|
||||||
} else {
|
|
||||||
// Erreur SQL
|
|
||||||
$this->errors[] = "Error ".$this->db->lasterror();
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
// Retoune le tableau des utilisateurs
|
||||||
|
return $stringlist;
|
||||||
} else {
|
} else {
|
||||||
// List of vacation balance users
|
// Erreur SQL
|
||||||
$sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
return -1;
|
||||||
$sql .= " WHERE cpu.fk_user = u.rowid";
|
}
|
||||||
if ($filters) $sql .= $filters;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
/**
|
||||||
|
* Get list of Users or list of vacation balance by detail
|
||||||
|
*
|
||||||
|
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
|
||||||
|
* @param string $filters Filters
|
||||||
|
* @return array|string|int Return an array
|
||||||
|
*/
|
||||||
|
public function fetchUsersByDetail($type = true, $filters = '')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
// Si pas d'erreur SQL
|
dol_syslog(get_class($this)."::fetchUsersByDetail", LOG_DEBUG);
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$i = 0;
|
|
||||||
$tab_result = $this->holiday;
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
|
|
||||||
// Boucles du listage des utilisateurs
|
// List for Dolibarr users
|
||||||
while ($i < $num)
|
if ($type)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
// If user of Dolibarr
|
||||||
|
$sql = "SELECT";
|
||||||
|
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||||
|
$sql .= " DISTINCT";
|
||||||
|
}
|
||||||
|
$sql .= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
|
|
||||||
$tab_result[$i]['rowid'] = $obj->rowid; // rowid of user
|
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||||
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
{
|
||||||
$tab_result[$i]['lastname'] = $obj->lastname;
|
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||||
$tab_result[$i]['firstname'] = $obj->firstname;
|
$sql .= " WHERE ((ug.fk_user = u.rowid";
|
||||||
$tab_result[$i]['gender'] = $obj->gender;
|
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
||||||
$tab_result[$i]['status'] = $obj->statut;
|
$sql .= " OR u.entity = 0)"; // Show always superadmin
|
||||||
$tab_result[$i]['employee'] = $obj->employee;
|
} else {
|
||||||
$tab_result[$i]['photo'] = $obj->photo;
|
$sql .= " WHERE u.entity IN (".getEntity('user').")";
|
||||||
$tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager
|
}
|
||||||
|
|
||||||
$tab_result[$i]['type'] = $obj->fk_type;
|
$sql .= " AND u.statut > 0";
|
||||||
$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
if ($filters) $sql .= $filters;
|
||||||
|
|
||||||
$i++;
|
$resql = $this->db->query($sql);
|
||||||
}
|
|
||||||
// Retoune le tableau des utilisateurs
|
// Si pas d'erreur SQL
|
||||||
return $tab_result;
|
if ($resql)
|
||||||
} else {
|
{
|
||||||
// Erreur SQL
|
$i = 0;
|
||||||
$this->error = "Error ".$this->db->lasterror();
|
$tab_result = $this->holiday;
|
||||||
return -1;
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
// Boucles du listage des utilisateurs
|
||||||
|
while ($i < $num) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
$tab_result[$i]['rowid'] = $obj->rowid; // rowid of user
|
||||||
|
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
||||||
|
$tab_result[$i]['lastname'] = $obj->lastname;
|
||||||
|
$tab_result[$i]['firstname'] = $obj->firstname;
|
||||||
|
$tab_result[$i]['gender'] = $obj->gender;
|
||||||
|
$tab_result[$i]['status'] = $obj->statut;
|
||||||
|
$tab_result[$i]['employee'] = $obj->employee;
|
||||||
|
$tab_result[$i]['photo'] = $obj->photo;
|
||||||
|
$tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager
|
||||||
|
//$tab_result[$i]['type'] = $obj->type;
|
||||||
|
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||||
|
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
|
// Retoune le tableau des utilisateurs
|
||||||
|
return $tab_result;
|
||||||
|
} else {
|
||||||
|
// Erreur SQL
|
||||||
|
$this->errors[] = "Error ".$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// List of vacation balance users
|
||||||
|
$sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||||
|
$sql .= " WHERE cpu.fk_user = u.rowid";
|
||||||
|
if ($filters) $sql .= $filters;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
// Si pas d'erreur SQL
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$tab_result = $this->holiday;
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
// Boucles du listage des utilisateurs
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
$tab_result[$i]['rowid'] = $obj->rowid; // rowid of user
|
||||||
|
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
||||||
|
$tab_result[$i]['lastname'] = $obj->lastname;
|
||||||
|
$tab_result[$i]['firstname'] = $obj->firstname;
|
||||||
|
$tab_result[$i]['gender'] = $obj->gender;
|
||||||
|
$tab_result[$i]['status'] = $obj->statut;
|
||||||
|
$tab_result[$i]['employee'] = $obj->employee;
|
||||||
|
$tab_result[$i]['photo'] = $obj->photo;
|
||||||
|
$tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager
|
||||||
|
|
||||||
|
$tab_result[$i]['type'] = $obj->fk_type;
|
||||||
|
$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
// Retoune le tableau des utilisateurs
|
||||||
|
return $tab_result;
|
||||||
|
} else {
|
||||||
|
// Erreur SQL
|
||||||
|
$this->error = "Error ".$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1805,7 +1833,7 @@ class Holiday extends CommonObject
|
|||||||
* Return list of people with permission to validate leave requests.
|
* Return list of people with permission to validate leave requests.
|
||||||
* Search for permission "approve leave requests"
|
* Search for permission "approve leave requests"
|
||||||
*
|
*
|
||||||
* @return array Array of user ids
|
* @return array|int Array of user ids
|
||||||
*/
|
*/
|
||||||
public function fetch_users_approver_holiday()
|
public function fetch_users_approver_holiday()
|
||||||
{
|
{
|
||||||
@ -1936,7 +1964,8 @@ class Holiday extends CommonObject
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql)
|
if (!$resql)
|
||||||
{
|
{
|
||||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
$error++;
|
||||||
|
$this->errors[] = "Error ".$this->db->lasterror();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
@ -2007,7 +2036,7 @@ class Holiday extends CommonObject
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On liste les résultats et on les ajoutent dans le tableau
|
// On liste les résultats et on les ajoute dans le tableau
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
|
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||||
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
|
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -1408,18 +1408,17 @@ class User extends CommonObject
|
|||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
$rd = array();
|
||||||
|
$num = 0;
|
||||||
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def";
|
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def";
|
||||||
$sql .= " WHERE bydefault = 1";
|
$sql .= " WHERE bydefault = 1";
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$rd = array();
|
while ($i < $num) {
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($resql);
|
$row = $this->db->fetch_row($resql);
|
||||||
$rd[$i] = $row[0];
|
$rd[$i] = $row[0];
|
||||||
$i++;
|
$i++;
|
||||||
@ -1427,8 +1426,7 @@ class User extends CommonObject
|
|||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]";
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user