Use dolGetStatus
This commit is contained in:
parent
1c1334effe
commit
6855f588b5
@ -1255,45 +1255,34 @@ class Contact extends CommonObject
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $statut Id statut
|
||||
* @param int $status Id statut
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Libelle
|
||||
*/
|
||||
public function LibStatut($statut, $mode)
|
||||
public function LibStatut($status, $mode)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if ($mode == 0)
|
||||
if (empty($this->status) || empty($this->statusshort))
|
||||
{
|
||||
if ($statut==0 || $statut==5) return $langs->trans('Disabled');
|
||||
elseif ($statut==1 || $statut==4) return $langs->trans('Enabled');
|
||||
}
|
||||
elseif ($mode == 1)
|
||||
{
|
||||
if ($statut==0 || $statut==5) return $langs->trans('Disabled');
|
||||
elseif ($statut==1 || $statut==4) return $langs->trans('Enabled');
|
||||
}
|
||||
elseif ($mode == 2)
|
||||
{
|
||||
if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
|
||||
elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
|
||||
}
|
||||
elseif ($mode == 3)
|
||||
{
|
||||
if ($statut==0 || $statut==5) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
|
||||
elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
|
||||
}
|
||||
elseif ($mode == 4)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
|
||||
elseif ($statut==1 || $statut==4) return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
|
||||
}
|
||||
elseif ($mode == 5)
|
||||
{
|
||||
if ($statut==0 || $statut==5) return '<span class="hideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
|
||||
elseif ($statut==1 || $statut==4) return '<span class="hideonsmartphone">'.$langs->trans('Enabled').' </span>'.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
|
||||
$this->labelstatus[0] = 'ActivityCeased';
|
||||
$this->labelstatusshort[0] = 'ActivityCeased';
|
||||
$this->labelstatus[5] = 'ActivityCeased';
|
||||
$this->labelstatusshort[5] = 'ActivityCeased';
|
||||
$this->labelstatus[1] = 'InActivity';
|
||||
$this->labelstatusshort[1] = 'InActivity';
|
||||
$this->labelstatus[4] = 'InActivity';
|
||||
$this->labelstatusshort[4] = 'InActivity';
|
||||
}
|
||||
|
||||
$statusType = 'status4';
|
||||
if ($status==0 || $status==5) $statusType = 'status5';
|
||||
|
||||
$label = $langs->trans($this->labelstatus[$status]);
|
||||
$labelshort = $langs->trans($this->labelstatusshort[$status]);
|
||||
|
||||
return dolGetStatus($label, $labelshort, '', $statusType, $mode);
|
||||
}
|
||||
|
||||
|
||||
@ -1301,14 +1290,14 @@ class Contact extends CommonObject
|
||||
/**
|
||||
* Return translated label of Public or Private
|
||||
*
|
||||
* @param int $statut Type (0 = public, 1 = private)
|
||||
* @param int $status Type (0 = public, 1 = private)
|
||||
* @return string Label translated
|
||||
*/
|
||||
public function LibPubPriv($statut)
|
||||
public function LibPubPriv($status)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
if ($statut=='1') return $langs->trans('ContactPrivate');
|
||||
if ($status=='1') return $langs->trans('ContactPrivate');
|
||||
else return $langs->trans('ContactPublic');
|
||||
}
|
||||
|
||||
@ -1361,18 +1350,18 @@ class Contact extends CommonObject
|
||||
/**
|
||||
* Change status of a user
|
||||
*
|
||||
* @param int $statut Status to set
|
||||
* @param int $status Status to set
|
||||
* @return int <0 if KO, 0 if nothing is done, >0 if OK
|
||||
*/
|
||||
public function setstatus($statut)
|
||||
public function setstatus($status)
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Check parameters
|
||||
if ($this->statut == $statut) return 0;
|
||||
else $this->statut = $statut;
|
||||
if ($this->statut == $status) return 0;
|
||||
else $this->statut = $status;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
@ -972,7 +972,7 @@ while ($i < min($num, $limit))
|
||||
// Status
|
||||
if (! empty($arrayfields['p.statut']['checked']))
|
||||
{
|
||||
print '<td class="center">'.$contactstatic->getLibStatut(3).'</td>';
|
||||
print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['p.import_key']['checked']))
|
||||
|
||||
@ -662,12 +662,15 @@ class MyObject extends CommonObject
|
||||
$this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||
$this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
|
||||
$this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
|
||||
$this->labelstatusshort[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||
$this->labelstatusshort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
|
||||
$this->labelstatusshort[self::STATUS_CANCELED] = $langs->trans('Disabled');
|
||||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
|
||||
|
||||
return dolGetStatus($this->labelstatus[$status], $this->labelstatus[$status], '', $statusType, $mode);
|
||||
return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -646,45 +646,19 @@ class Entrepot extends CommonObject
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function LibStatut($statut, $mode = 0)
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
$statusType = 'status5';
|
||||
if ($status > 0) $statusType = 'status4';
|
||||
|
||||
$langs->load('stocks');
|
||||
$label = $langs->trans($this->statuts[$status]);
|
||||
$labelshort = $langs->trans($this->statuts[$status]);
|
||||
|
||||
$picto = 'statut5';
|
||||
$label = $langs->trans($this->statuts[$statut]);
|
||||
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
return $label;
|
||||
}
|
||||
elseif ($mode == 1)
|
||||
{
|
||||
return $label;
|
||||
}
|
||||
elseif ($mode == 2)
|
||||
{
|
||||
if ($statut > 0) $picto = 'statut4';
|
||||
return img_picto($label, $picto).' '.$label;
|
||||
}
|
||||
elseif ($mode == 3)
|
||||
{
|
||||
if ($statut > 0) $picto = 'statut4';
|
||||
return img_picto($label, $picto).' '.$label;
|
||||
}
|
||||
elseif ($mode == 4)
|
||||
{
|
||||
if ($statut > 0) $picto = 'statut4';
|
||||
return img_picto($label, $picto).' '.$label;
|
||||
}
|
||||
elseif ($mode == 5)
|
||||
{
|
||||
if ($statut > 0) $picto = 'statut4';
|
||||
return $label.' '.img_picto($label, $picto);
|
||||
}
|
||||
return dolGetStatus($label, $labelshort, '', $statusType, $mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
@ -2268,52 +2268,29 @@ class Societe extends CommonObject
|
||||
/**
|
||||
* Return the label of a given status
|
||||
*
|
||||
* @param int $statut Status id
|
||||
* @param int $status Status id
|
||||
* @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 Status label
|
||||
*/
|
||||
public function LibStatut($statut, $mode = 0)
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
$langs->load('companies');
|
||||
|
||||
if ($mode == 0)
|
||||
$statusType = 'status4';
|
||||
if ($status == 0) $statusType = 'status5';
|
||||
|
||||
if (empty($this->labelstatus) || empty($this->labelstatusshort))
|
||||
{
|
||||
if ($statut==0) return $langs->trans("ActivityCeased");
|
||||
elseif ($statut==1) return $langs->trans("InActivity");
|
||||
$this->labelstatus[0] = $langs->trans("ActivityCeased");
|
||||
$this->labelstatus[1] = $langs->trans("InActivity");
|
||||
$this->labelstatusshort[0] = $langs->trans("ActivityCeased");
|
||||
$this->labelstatusshort[1] = $langs->trans("InActivity");
|
||||
}
|
||||
elseif ($mode == 1)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("ActivityCeased");
|
||||
elseif ($statut==1) return $langs->trans("InActivity");
|
||||
}
|
||||
elseif ($mode == 2)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased");
|
||||
elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity");
|
||||
}
|
||||
elseif ($mode == 3)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"');
|
||||
elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"');
|
||||
}
|
||||
elseif ($mode == 4)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased");
|
||||
elseif ($statut==1) return img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity");
|
||||
}
|
||||
elseif ($mode == 5)
|
||||
{
|
||||
if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"');
|
||||
elseif ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"');
|
||||
}
|
||||
elseif ($mode == 6)
|
||||
{
|
||||
if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"), 'statut5', 'class="pictostatus"');
|
||||
elseif ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"), 'statut4', 'class="pictostatus"');
|
||||
}
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelstatus[$status], $this->labelstatusshort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
@ -3734,12 +3711,12 @@ class Societe extends CommonObject
|
||||
/**
|
||||
* Return label of a given status
|
||||
*
|
||||
* @param int|string $statut Id or code for prospection status
|
||||
* @param int|string $status Id or code for prospection status
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||
* @param string $label Label to use for status for added status
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
public function LibProspCommStatut($statut, $mode = 0, $label = '')
|
||||
public function LibProspCommStatut($status, $mode = 0, $label = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
@ -3747,38 +3724,38 @@ class Societe extends CommonObject
|
||||
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1");
|
||||
elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
|
||||
elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
|
||||
elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
|
||||
elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
|
||||
if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1");
|
||||
elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
|
||||
elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
|
||||
elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
|
||||
elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
|
||||
else
|
||||
{
|
||||
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
|
||||
return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label);
|
||||
}
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1);
|
||||
elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0);
|
||||
elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1);
|
||||
elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2);
|
||||
elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3);
|
||||
if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1);
|
||||
elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0);
|
||||
elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1);
|
||||
elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2);
|
||||
elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3);
|
||||
else
|
||||
{
|
||||
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0);
|
||||
return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0);
|
||||
}
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1");
|
||||
elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
|
||||
elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
|
||||
elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
|
||||
elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
|
||||
if ($status == '-1' || $status == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1).' '.$langs->trans("StatusProspect-1");
|
||||
elseif ($status == '0' || $status == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0");
|
||||
elseif ($status == '1' || $status == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1");
|
||||
elseif ($status == '2' || $status == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2");
|
||||
elseif ($status == '3' || $status == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3");
|
||||
else
|
||||
{
|
||||
return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label);
|
||||
return img_action(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label, 0).' '.(($langs->trans("StatusProspect".$status) != "StatusProspect".$status) ? $langs->trans("StatusProspect".$status) : $label);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3975,19 +3952,19 @@ class Societe extends CommonObject
|
||||
/**
|
||||
* Return the label of the customer/prospect status
|
||||
*
|
||||
* @param int $statut Id statut
|
||||
* @param int $status Id statut
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
public function LibCustProspStatut($statut)
|
||||
public function LibCustProspStatut($status)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
$langs->load('companies');
|
||||
|
||||
if ($statut==0) return $langs->trans("NorProspectNorCustomer");
|
||||
elseif ($statut==1) return $langs->trans("Customer");
|
||||
elseif ($statut==2) return $langs->trans("Prospect");
|
||||
elseif ($statut==3) return $langs->trans("ProspectCustomer");
|
||||
if ($status==0) return $langs->trans("NorProspectNorCustomer");
|
||||
elseif ($status==1) return $langs->trans("Customer");
|
||||
elseif ($status==2) return $langs->trans("Prospect");
|
||||
elseif ($status==3) return $langs->trans("ProspectCustomer");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1279,7 +1279,7 @@ while ($i < min($num, $limit))
|
||||
// Status
|
||||
if (! empty($arrayfields['s.status']['checked']))
|
||||
{
|
||||
print '<td class="center nowrap">'.$companystatic->getLibStatut(3).'</td>';
|
||||
print '<td class="center nowrap">'.$companystatic->getLibStatut(5).'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['s.import_key']['checked']))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user