2011-02-20 16:51:14 +01:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2017-11-11 00:28:00 +01:00
|
|
|
* Copyright (C) 2004-2017 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-11-13 22:22:51 +01:00
|
|
|
* Copyright (C) 2015-2020 Frederic France <frederic.france@netlogic.fr>
|
2011-02-20 16:51:14 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2011-02-20 16:51:14 +01:00
|
|
|
* (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/>.
|
2011-02-20 16:51:14 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2011-10-24 14:11:49 +02:00
|
|
|
* \file htdocs/core/boxes/box_members.php
|
2013-01-14 13:06:08 +01:00
|
|
|
* \ingroup adherent
|
|
|
|
|
* \brief Module to show box of members
|
2011-02-20 16:51:14 +01:00
|
|
|
*/
|
|
|
|
|
|
2012-08-23 02:04:35 +02:00
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
|
2011-02-20 16:51:14 +01:00
|
|
|
|
|
|
|
|
|
2012-01-26 13:49:15 +01:00
|
|
|
/**
|
|
|
|
|
* Class to manage the box to show last members
|
|
|
|
|
*/
|
2012-02-20 09:42:57 +01:00
|
|
|
class box_members extends ModeleBoxes
|
|
|
|
|
{
|
2020-10-31 14:32:18 +01:00
|
|
|
public $boxcode = "lastmembers";
|
|
|
|
|
public $boximg = "object_user";
|
|
|
|
|
public $boxlabel = "BoxLastMembers";
|
|
|
|
|
public $depends = array("adherent");
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2018-08-22 10:51:55 +02:00
|
|
|
/**
|
2020-10-31 14:32:18 +01:00
|
|
|
* @var DoliDB Database handler.
|
|
|
|
|
*/
|
|
|
|
|
public $db;
|
2019-02-09 15:24:21 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
public $param;
|
|
|
|
|
public $enabled = 1;
|
2013-04-23 16:18:26 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
public $info_box_head = array();
|
|
|
|
|
public $info_box_contents = array();
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2013-01-14 13:06:08 +01:00
|
|
|
|
2011-02-20 16:51:14 +01:00
|
|
|
/**
|
2013-04-23 16:18:26 +02:00
|
|
|
* Constructor
|
2013-04-04 13:58:33 +02:00
|
|
|
*
|
2013-04-23 16:18:26 +02:00
|
|
|
* @param DoliDB $db Database handler
|
2020-10-31 14:32:18 +01:00
|
|
|
* @param string $param More parameters
|
2011-02-20 16:51:14 +01:00
|
|
|
*/
|
2019-02-28 20:48:07 +01:00
|
|
|
public function __construct($db, $param = '')
|
2011-02-20 16:51:14 +01:00
|
|
|
{
|
2013-01-15 17:06:53 +01:00
|
|
|
global $conf, $user;
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2013-01-15 17:06:53 +01:00
|
|
|
$this->db = $db;
|
2013-04-23 16:18:26 +02:00
|
|
|
|
2013-01-14 13:06:08 +01:00
|
|
|
// disable module for such cases
|
2020-04-10 10:59:32 +02:00
|
|
|
$listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
2021-01-02 21:50:58 +01:00
|
|
|
if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
|
|
|
|
|
$this->enabled = 0; // disabled for external users
|
|
|
|
|
}
|
2017-06-12 14:09:00 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$this->hidden = !($user->rights->adherent->lire);
|
2011-02-20 16:51:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-11-23 18:28:14 +01:00
|
|
|
* Load data into info_box_contents array to show array later.
|
|
|
|
|
*
|
|
|
|
|
* @param int $max Maximum number of records to load
|
2020-10-31 14:32:18 +01:00
|
|
|
* @return void
|
2011-02-20 16:51:14 +01:00
|
|
|
*/
|
2019-02-28 20:48:07 +01:00
|
|
|
public function loadBox($max = 5)
|
2011-02-20 16:51:14 +01:00
|
|
|
{
|
2019-09-23 18:39:21 +02:00
|
|
|
global $user, $langs, $conf;
|
2011-02-20 16:51:14 +01:00
|
|
|
$langs->load("boxes");
|
|
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$this->max = $max;
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
|
|
|
|
$memberstatic = new Adherent($this->db);
|
2011-05-21 17:18:04 +02:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max));
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2020-10-27 08:17:12 +01:00
|
|
|
if ($user->rights->adherent->lire) {
|
2021-01-02 22:12:19 +01:00
|
|
|
$sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
|
2020-04-10 10:59:32 +02:00
|
|
|
$sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,";
|
2020-10-27 08:17:12 +01:00
|
|
|
$sql .= ' a.photo, a.email, a.gender, a.morphy,';
|
2021-01-02 21:50:58 +01:00
|
|
|
$sql .= " t.subscription, t.libelle as label";
|
2020-04-10 10:59:32 +02:00
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t";
|
|
|
|
|
$sql .= " WHERE a.entity IN (".getEntity('member').")";
|
|
|
|
|
$sql .= " AND a.fk_adherent_type = t.rowid";
|
|
|
|
|
$sql .= " ORDER BY a.tms DESC";
|
|
|
|
|
$sql .= $this->db->plimit($max, 0);
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2019-09-23 18:39:21 +02:00
|
|
|
$result = $this->db->query($sql);
|
2020-10-27 08:17:12 +01:00
|
|
|
if ($result) {
|
2019-09-23 18:39:21 +02:00
|
|
|
$num = $this->db->num_rows($result);
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2015-01-31 17:47:58 +01:00
|
|
|
$line = 0;
|
2020-10-27 08:17:12 +01:00
|
|
|
while ($line < $num) {
|
2019-09-23 18:39:21 +02:00
|
|
|
$objp = $this->db->fetch_object($result);
|
2020-04-10 10:59:32 +02:00
|
|
|
$datec = $this->db->jdate($objp->datec);
|
|
|
|
|
$datem = $this->db->jdate($objp->tms);
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$memberstatic->lastname = $objp->lastname;
|
|
|
|
|
$memberstatic->firstname = $objp->firstname;
|
2015-07-16 21:17:31 +02:00
|
|
|
$memberstatic->id = $objp->rowid;
|
2021-01-02 22:12:19 +01:00
|
|
|
$memberstatic->ref = $objp->ref;
|
2020-10-31 14:32:18 +01:00
|
|
|
$memberstatic->photo = $objp->photo;
|
|
|
|
|
$memberstatic->gender = $objp->gender;
|
|
|
|
|
$memberstatic->email = $objp->email;
|
|
|
|
|
$memberstatic->morphy = $objp->morphy;
|
|
|
|
|
$memberstatic->company = $objp->company;
|
2020-11-13 22:22:51 +01:00
|
|
|
$memberstatic->statut = $objp->status;
|
2021-02-27 19:16:14 +01:00
|
|
|
$memberstatic->date_creation = $datec;
|
|
|
|
|
$memberstatic->date_modification = $datem;
|
2021-01-02 21:50:58 +01:00
|
|
|
$memberstatic->need_subscription = $objp->subscription;
|
|
|
|
|
$memberstatic->datefin = $this->db->jdate($objp->date_end_subscription);
|
2012-01-28 17:22:02 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
if (!empty($objp->fk_soc)) {
|
2012-09-30 21:26:58 +02:00
|
|
|
$memberstatic->socid = $objp->fk_soc;
|
|
|
|
|
$memberstatic->fetch_thirdparty();
|
2020-04-10 10:59:32 +02:00
|
|
|
$memberstatic->name = $memberstatic->thirdparty->name;
|
2012-09-30 21:26:58 +02:00
|
|
|
} else {
|
2020-04-10 10:59:32 +02:00
|
|
|
$memberstatic->name = $objp->company;
|
2012-09-24 12:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$this->info_box_contents[$line][] = array(
|
|
|
|
|
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
|
|
|
|
|
'text' => $memberstatic->getNomUrl(-1),
|
|
|
|
|
'asis' => 1,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->info_box_contents[$line][] = array(
|
|
|
|
|
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
|
|
|
|
|
'text' => $memberstatic->company,
|
|
|
|
|
'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->info_box_contents[$line][] = array(
|
2021-05-25 00:29:32 +02:00
|
|
|
'td' => 'class="center nowraponall"',
|
|
|
|
|
'text' => dol_print_date($datem, "day", 'tzuserrel'),
|
2020-10-31 14:32:18 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->info_box_contents[$line][] = array(
|
|
|
|
|
'td' => 'class="right" width="18"',
|
|
|
|
|
'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$line++;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 21:50:58 +01:00
|
|
|
if ($num == 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$this->info_box_contents[$line][0] = array(
|
|
|
|
|
'td' => 'class="center"',
|
|
|
|
|
'text'=>$langs->trans("NoRecordedCustomers"),
|
|
|
|
|
);
|
2021-01-02 21:50:58 +01:00
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
|
|
|
|
|
$this->db->free($result);
|
|
|
|
|
} else {
|
|
|
|
|
$this->info_box_contents[0][0] = array(
|
|
|
|
|
'td' => '',
|
|
|
|
|
'maxlength'=>500,
|
|
|
|
|
'text' => ($this->db->error().' sql='.$sql),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->info_box_contents[0][0] = array(
|
|
|
|
|
'td' => 'class="nohover opacitymedium left"',
|
|
|
|
|
'text' => $langs->trans("ReadPermissionNotAllowed")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-20 16:51:14 +01:00
|
|
|
|
2011-11-23 18:28:14 +01:00
|
|
|
/**
|
|
|
|
|
* Method to show box
|
|
|
|
|
*
|
|
|
|
|
* @param array $head Array with properties of box title
|
|
|
|
|
* @param array $contents Array with properties of box lines
|
2016-06-27 13:57:10 +02:00
|
|
|
* @param int $nooutput No print, only return string
|
2017-06-12 14:09:00 +02:00
|
|
|
* @return string
|
2011-11-23 18:28:14 +01:00
|
|
|
*/
|
2020-10-31 14:32:18 +01:00
|
|
|
public function showBox($head = null, $contents = null, $nooutput = 0)
|
|
|
|
|
{
|
2017-06-12 14:09:00 +02:00
|
|
|
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
|
2011-02-20 16:51:14 +01:00
|
|
|
}
|
|
|
|
|
}
|