Skip to content

Commit

Permalink
fix dashboard sttaus
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Oct 3, 2023
1 parent 509fb5d commit a8227ad
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 337 deletions.
48 changes: 18 additions & 30 deletions class/immoowner.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ImmoOwner extends CommonObjectUltimateImmo
'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'visible' => -2, 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'foreignkey' => 'llx_user.rowid',),
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'visible' => -2, 'enabled' => 1, 'position' => 1000, 'notnull' => -1,),
'status' => array('type' => 'integer', 'label' => 'Status', 'visible' => 1, 'enabled' => 1, 'position' => 1000, 'notnull' => 1, 'index' => 1, 'default'=>1,
'arrayofkeyval' => array('0' => 'ImmoOwnerStatusDisabled', '1' => 'ImmoOwnerStatusActive', '-1' => 'Cancel')
'arrayofkeyval' => array(0 => 'Draft', 1 => 'Actif', 9 => 'Canceled')

),

Expand Down Expand Up @@ -661,39 +661,27 @@ function getLibStatut($mode = 0)
* @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
* @return string Label of status
*/
static function LibStatut($status, $mode = 0)
function LibStatut($status, $mode = 0)
{
global $langs;

if ($mode == 0) {
$prefix = '';
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 1) {
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
if ($mode == 2) {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled');
}
if ($mode == 3) {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
}
if ($mode == 4) {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled');
}
if ($mode == 5) {
if ($status == 1) return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4');
if ($status == 0) return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5');
}
if ($mode == 6) {
if ($status == 1) return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4');
if ($status == 0) return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5');
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Actif');
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Actif');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
}

$statusType = 'status'.$status;
if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
if ($status == self::STATUS_CANCELED) $statusType = 'status6';

return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
if ($user->rights->ultimateimmo->read) {
$globalboxes[] = array('name' => $langs->trans('MenuImmoOwner'), 'color' =>'#C19875',
'url' => dol_buildpath('/ultimateimmo/owner/immowner_list.php', 1),
'url_add' => dol_buildpath('/ultimateimmo/owner/immorenter_card.php?action=create', 1),
'url_add' => dol_buildpath('/ultimateimmo/owner/immoowner_card.php?action=create', 1),
'right' => $user->rights->ultimateimmo->read,
'lines' => array(
array('title' => $langs->trans('MenuImmoNotActiveOwner'), 'value' => getRenterNumber(1), 'url' => dol_buildpath('/ultimateimmo/renter/immorenter_list.php', 1)),
array('title' => $langs->trans('MenuImmoActiveOwner'), 'value' => getRenterNumber(0), 'url' => dol_buildpath('/ultimateimmo/renter/immorenter_list.php', 1)),
array('title' => $langs->trans('MenuImmoActiveOwner'), 'value' => getOwnerNumber(1), 'url' => dol_buildpath('/ultimateimmo/owner/immoowner_list.php?search_status=1', 1)),
array('title' => $langs->trans('MenuImmoNotActiveOwner'), 'value' => getOwnerNumber(9), 'url' => dol_buildpath('/ultimateimmo/owner/immoowner_list.php?search_status=9', 1)),
)
);
}
Expand Down
19 changes: 19 additions & 0 deletions lib/dashboard.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ function getPropertiesNumber($status)

return $res;
}
/**
* Get the number of devices
*
* @return int
*/
// get number property
function getOwnerNumber($status)
{
global $db;

$res = 0;
$sql = 'SELECT COUNT(rowid) AS total FROM '.MAIN_DB_PREFIX.'ultimateimmo_immoowner WHERE status = '.$status;
$resql = $db->query($sql);
if ($resql) {
$res = ($db->fetch_object($resql))->total;
}

return $res;
}

function getRentNumber($status)
{
Expand Down
Loading

0 comments on commit a8227ad

Please sign in to comment.