mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Merge pull request #13035 from Dolibarr/scrutinizer-patch-2
Scrutinizer Auto-Fixes
This commit is contained in:
@@ -68,9 +68,9 @@ class AssetType extends CommonObject
|
||||
public $note;
|
||||
|
||||
/** @var array Array of asset */
|
||||
public $asset=array();
|
||||
public $asset = array();
|
||||
|
||||
public $fields=array(
|
||||
public $fields = array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
|
||||
@@ -104,9 +104,9 @@ class AssetType extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
$this->label=trim($this->label);
|
||||
$this->label = trim($this->label);
|
||||
$this->accountancy_code_asset = trim($this->accountancy_code_asset);
|
||||
$this->accountancy_code_depreciation_asset = trim($this->accountancy_code_depreciation_asset);
|
||||
$this->accountancy_code_depreciation_expense = trim($this->accountancy_code_depreciation_expense);
|
||||
@@ -114,20 +114,20 @@ class AssetType extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_type (";
|
||||
$sql.= "label";
|
||||
$sql.= ", accountancy_code_asset";
|
||||
$sql.= ", accountancy_code_depreciation_asset";
|
||||
$sql.= ", accountancy_code_depreciation_expense";
|
||||
$sql.= ", note";
|
||||
$sql.= ", entity";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->escape($this->label)."'";
|
||||
$sql.= ", '".$this->db->escape($this->accountancy_code_asset)."'";
|
||||
$sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'";
|
||||
$sql.= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'";
|
||||
$sql.= ", '".$this->db->escape($this->note)."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ")";
|
||||
$sql .= "label";
|
||||
$sql .= ", accountancy_code_asset";
|
||||
$sql .= ", accountancy_code_depreciation_asset";
|
||||
$sql .= ", accountancy_code_depreciation_expense";
|
||||
$sql .= ", note";
|
||||
$sql .= ", entity";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->escape($this->label)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_asset)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_asset)."'";
|
||||
$sql .= ", '".$this->db->escape($this->accountancy_code_depreciation_expense)."'";
|
||||
$sql .= ", '".$this->db->escape($this->note)."'";
|
||||
$sql .= ", ".$conf->entity;
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog("Asset_type::create", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@@ -142,15 +142,15 @@ class AssetType extends CommonObject
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (! $notrigger)
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ASSET_TYPE_CREATE', $user);
|
||||
$result = $this->call_trigger('ASSET_TYPE_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
@@ -164,7 +164,7 @@ class AssetType extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@@ -181,45 +181,45 @@ class AssetType extends CommonObject
|
||||
{
|
||||
global $conf, $hookmanager;
|
||||
|
||||
$error=0;
|
||||
$error = 0;
|
||||
|
||||
$this->label=trim($this->label);
|
||||
$this->label = trim($this->label);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."asset_type ";
|
||||
$sql.= "SET ";
|
||||
$sql.= "label = '".$this->db->escape($this->label) ."',";
|
||||
$sql.= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',";
|
||||
$sql.= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',";
|
||||
$sql.= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',";
|
||||
$sql.= "note = '".$this->db->escape($this->note) ."'";
|
||||
$sql.= " WHERE rowid =".$this->id;
|
||||
$sql .= "SET ";
|
||||
$sql .= "label = '".$this->db->escape($this->label)."',";
|
||||
$sql .= "accountancy_code_asset = '".$this->db->escape($this->accountancy_code_asset)."',";
|
||||
$sql .= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',";
|
||||
$sql .= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',";
|
||||
$sql .= "note = '".$this->db->escape($this->note)."'";
|
||||
$sql .= " WHERE rowid =".$this->id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$action='update';
|
||||
$action = 'update';
|
||||
|
||||
// Actions on extra fields
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ASSET_TYPE_MODIFY', $user);
|
||||
$result = $this->call_trigger('ASSET_TYPE_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
@@ -233,7 +233,7 @@ class AssetType extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@@ -251,13 +251,13 @@ class AssetType extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_type";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ASSET_TYPE_DELETE', $user);
|
||||
$result = $this->call_trigger('ASSET_TYPE_DELETE', $user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -2; }
|
||||
// End call triggers
|
||||
|
||||
@@ -267,7 +267,7 @@ class AssetType extends CommonObject
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class AssetType extends CommonObject
|
||||
|
||||
dol_syslog("Asset_type::fetch", LOG_DEBUG);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
@@ -306,7 +306,7 @@ class AssetType extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -320,15 +320,15 @@ class AssetType extends CommonObject
|
||||
public function liste_array()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf,$langs;
|
||||
global $conf, $langs;
|
||||
|
||||
$assettypes = array();
|
||||
|
||||
$sql = "SELECT rowid, label as label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."asset_type";
|
||||
$sql.= " WHERE entity IN (".getEntity('asset_type').")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset_type";
|
||||
$sql .= " WHERE entity IN (".getEntity('asset_type').")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$nump = $this->db->num_rows($resql);
|
||||
@@ -365,13 +365,13 @@ class AssetType extends CommonObject
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
$ret=array();
|
||||
$ret = array();
|
||||
|
||||
$sql = "SELECT a.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."asset as a";
|
||||
$sql.= " WHERE a.entity IN (".getEntity('asset').")";
|
||||
$sql.= " AND a.fk_asset_type = ".$this->id;
|
||||
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')';
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."asset as a";
|
||||
$sql .= " WHERE a.entity IN (".getEntity('asset').")";
|
||||
$sql .= " AND a.fk_asset_type = ".$this->id;
|
||||
if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
|
||||
|
||||
dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -379,31 +379,31 @@ class AssetType extends CommonObject
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if (! array_key_exists($obj->rowid, $ret))
|
||||
if (!array_key_exists($obj->rowid, $ret))
|
||||
{
|
||||
if ($mode < 2)
|
||||
{
|
||||
$assetstatic=new Asset($this->db);
|
||||
$assetstatic = new Asset($this->db);
|
||||
if ($mode == 1) {
|
||||
$assetstatic->fetch($obj->rowid, '', '', '', false, false);
|
||||
} else {
|
||||
$assetstatic->fetch($obj->rowid);
|
||||
}
|
||||
$ret[$obj->rowid]=$assetstatic;
|
||||
$ret[$obj->rowid] = $assetstatic;
|
||||
}
|
||||
else $ret[$obj->rowid]=$obj->rowid;
|
||||
else $ret[$obj->rowid] = $obj->rowid;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
$this->asset=$ret;
|
||||
$this->asset = $ret;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -420,15 +420,15 @@ class AssetType extends CommonObject
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result='';
|
||||
$label=$langs->trans("ShowTypeCard", $this->label);
|
||||
$result = '';
|
||||
$label = $langs->trans("ShowTypeCard", $this->label);
|
||||
|
||||
$linkstart = '<a href="'.DOL_URL_ROOT.'/asset/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend='</a>';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
|
||||
if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->label, $maxlen):$this->label);
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
@@ -448,13 +448,13 @@ class AssetType extends CommonObject
|
||||
// Initialize parameters
|
||||
$this->id = 0;
|
||||
$this->ref = 'ATSPEC';
|
||||
$this->specimen=1;
|
||||
$this->specimen = 1;
|
||||
|
||||
$this->label='ASSET TYPE SPECIMEN';
|
||||
$this->note='This is a note';
|
||||
$this->label = 'ASSET TYPE SPECIMEN';
|
||||
$this->note = 'This is a note';
|
||||
|
||||
// Assets of this asset type is just me
|
||||
$this->asset=array(
|
||||
$this->asset = array(
|
||||
$user->id => $user
|
||||
);
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ print '</tr>'."\n";
|
||||
// Fields title label
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
foreach($object->fields as $key => $val)
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
@@ -427,8 +427,8 @@ foreach($object->fields as $key => $val)
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
|
||||
@@ -436,7 +436,7 @@ print '</tr>'."\n";
|
||||
|
||||
|
||||
// Detect if we need a fetch on each output line
|
||||
$needToFetchEachLine=0;
|
||||
$needToFetchEachLine = 0;
|
||||
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
|
||||
@@ -448,19 +448,19 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
|
||||
|
||||
// Loop on record
|
||||
// --------------------------------------------------------------------
|
||||
$i=0;
|
||||
$totalarray=array();
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < ($limit ? min($num, $limit) : $num))
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
if (empty($obj)) break; // Should not happen
|
||||
|
||||
// Store properties in $object
|
||||
$object->setVarsFromFetchObj($obj);
|
||||
|
||||
// Show here line of result
|
||||
print '<tr class="oddeven">';
|
||||
foreach($object->fields as $key => $val)
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$cssforfield = (empty($val['css']) ? '' : $val['css']);
|
||||
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
||||
|
||||
@@ -38,15 +38,15 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
|
||||
global $conf;
|
||||
|
||||
$num = str_replace(array(',', ' '), '', trim($num));
|
||||
if (! $num) {
|
||||
if (!$num) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($centimes && strlen($num) == 1) {
|
||||
$num = $num*10;
|
||||
$num = $num * 10;
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_MODULE_NUMBERWORDS)) {
|
||||
if (!empty($conf->global->MAIN_MODULE_NUMBERWORDS)) {
|
||||
if ($currency) {
|
||||
$type = 1;
|
||||
} else {
|
||||
@@ -106,24 +106,24 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
|
||||
$num_length = strlen($num);
|
||||
$levels = (int) (($num_length + 2) / 3);
|
||||
$max_length = $levels * 3;
|
||||
$num = substr('00' . $num, -$max_length);
|
||||
$num = substr('00'.$num, -$max_length);
|
||||
$num_levels = str_split($num, 3);
|
||||
$nboflevels = count($num_levels);
|
||||
for ($i = 0; $i < $nboflevels; $i++) {
|
||||
$levels--;
|
||||
$hundreds = (int) ($num_levels[$i] / 100);
|
||||
$hundreds = ($hundreds ? ' ' . $list1[$hundreds] . ' '.$langs->transnoentities('hundred') . ( $hundreds == 1 ? '' : 's' ) . ' ': '');
|
||||
$hundreds = ($hundreds ? ' '.$list1[$hundreds].' '.$langs->transnoentities('hundred').($hundreds == 1 ? '' : 's').' ' : '');
|
||||
$tens = (int) ($num_levels[$i] % 100);
|
||||
$singles = '';
|
||||
if ( $tens < 20 ) {
|
||||
$tens = ($tens ? ' ' . $list1[$tens] . ' ' : '' );
|
||||
if ($tens < 20) {
|
||||
$tens = ($tens ? ' '.$list1[$tens].' ' : '');
|
||||
} else {
|
||||
$tens = (int) ($tens / 10);
|
||||
$tens = ' ' . $list2[$tens] . ' ';
|
||||
$tens = ' '.$list2[$tens].' ';
|
||||
$singles = (int) ($num_levels[$i] % 10);
|
||||
$singles = ' ' . $list1[$singles] . ' ';
|
||||
$singles = ' '.$list1[$singles].' ';
|
||||
}
|
||||
$words[] = $hundreds . $tens . $singles . ( ( $levels && ( int ) ( $num_levels[$i] ) ) ? ' ' . $list3[$levels] . ' ' : '' );
|
||||
$words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ? ' '.$list3[$levels].' ' : '');
|
||||
} //end for loop
|
||||
$commas = count($words);
|
||||
if ($commas > 1) {
|
||||
@@ -133,15 +133,15 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
|
||||
// Delete multi whitespaces
|
||||
$concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords));
|
||||
|
||||
if(!empty($currency)) {
|
||||
if (!empty($currency)) {
|
||||
$concatWords .= ' '.$currency;
|
||||
}
|
||||
|
||||
// If we need to write cents call again this function for cents
|
||||
if(!empty($TNum[1])) {
|
||||
if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
|
||||
if (!empty($TNum[1])) {
|
||||
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
|
||||
$concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
|
||||
if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
|
||||
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
|
||||
}
|
||||
return $concatWords;
|
||||
}
|
||||
@@ -165,35 +165,35 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
return -1;
|
||||
// Get 2 decimals to cents, another functions round or truncate
|
||||
$strnumber = number_format($numero, 10);
|
||||
$len=strlen($strnumber);
|
||||
for ($i=0; $i<$len; $i++)
|
||||
$len = strlen($strnumber);
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
if ($strnumber[$i]=='.') {
|
||||
$parte_decimal = $strnumber[$i+1].$strnumber[$i+2];
|
||||
if ($strnumber[$i] == '.') {
|
||||
$parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and
|
||||
in case exist why ask $lang like a parameter?*/
|
||||
if (((is_object($langs) && $langs->default == 'es_MX') || (! is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency')
|
||||
if (((is_object($langs) && $langs->default == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency')
|
||||
{
|
||||
if ($numero>=1 && $numero<2) {
|
||||
if ($numero >= 1 && $numero < 2) {
|
||||
return ("UN PESO ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
elseif ($numero>=0 && $numero<1){
|
||||
elseif ($numero >= 0 && $numero < 1) {
|
||||
return ("CERO PESOS ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
elseif ($numero>=1000000 && $numero<1000001){
|
||||
elseif ($numero >= 1000000 && $numero < 1000001) {
|
||||
return ("UN MILLÓN DE PESOS ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
elseif ($numero>=1000000000000 && $numero<1000000000001){
|
||||
elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
|
||||
return ("UN BILLÓN DE PESOS ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
else {
|
||||
$entexto ="";
|
||||
$entexto = "";
|
||||
$number = $numero;
|
||||
if ($number >= 1000000000){
|
||||
if ($number >= 1000000000) {
|
||||
$CdMMillon = (int) ($numero / 100000000000);
|
||||
$numero = $numero - $CdMMillon * 100000000000;
|
||||
$DdMMillon = (int) ($numero / 10000000000);
|
||||
@@ -203,7 +203,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
$entexto .= hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
|
||||
$entexto .= " MIL ";
|
||||
}
|
||||
if ($number >= 1000000){
|
||||
if ($number >= 1000000) {
|
||||
$CdMILLON = (int) ($numero / 100000000);
|
||||
$numero = $numero - $CdMILLON * 100000000;
|
||||
$DdMILLON = (int) ($numero / 10000000);
|
||||
@@ -211,7 +211,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
$udMILLON = (int) ($numero / 1000000);
|
||||
$numero = $numero - $udMILLON * 1000000;
|
||||
$entexto .= hundreds2text($CdMILLON, $DdMILLON, $udMILLON);
|
||||
if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1)
|
||||
if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1)
|
||||
$entexto .= " MILLÓN ";
|
||||
else
|
||||
$entexto .= " MILLONES ";
|
||||
@@ -232,7 +232,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
$d = (int) ($numero / 10);
|
||||
$u = (int) $numero - $d * 10;
|
||||
$entexto .= hundreds2text($c, $d, $u);
|
||||
if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000)
|
||||
if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000)
|
||||
$entexto .= " DE";
|
||||
$entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
|
||||
}
|
||||
@@ -250,40 +250,40 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
*/
|
||||
function hundreds2text($hundreds, $tens, $units)
|
||||
{
|
||||
if ($hundreds==1 && $tens==0 && $units==0){
|
||||
if ($hundreds == 1 && $tens == 0 && $units == 0) {
|
||||
return "CIEN";
|
||||
}
|
||||
$centenas = array("CIENTO","DOSCIENTOS","TRESCIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTOS","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS");
|
||||
$decenas = array("","","TREINTA ","CUARENTA ","CINCUENTA ","SESENTA ","SETENTA ","OCHENTA ","NOVENTA ");
|
||||
$veintis = array("VEINTE","VEINTIUN","VEINTIDÓS","VEINTITRÉS","VEINTICUATRO","VEINTICINCO","VEINTISÉIS","VEINTISIETE","VEINTIOCHO","VEINTINUEVE");
|
||||
$diecis = array("DIEZ","ONCE","DOCE","TRECE","CATORCE","QUINCE","DIECISÉIS","DIECISIETE","DIECIOCHO","DIECINUEVE");
|
||||
$unidades = array("UN","DOS","TRES","CUATRO","CINCO","SEIS","SIETE","OCHO","NUEVE");
|
||||
$centenas = array("CIENTO", "DOSCIENTOS", "TRESCIENTOS", "CUATROCIENTOS", "QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", "NOVECIENTOS");
|
||||
$decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ");
|
||||
$veintis = array("VEINTE", "VEINTIUN", "VEINTIDÓS", "VEINTITRÉS", "VEINTICUATRO", "VEINTICINCO", "VEINTISÉIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE");
|
||||
$diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECISÉIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE");
|
||||
$unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
|
||||
$entexto = "";
|
||||
if ($hundreds!=0){
|
||||
$entexto .= $centenas[$hundreds-1];
|
||||
if ($hundreds != 0) {
|
||||
$entexto .= $centenas[$hundreds - 1];
|
||||
}
|
||||
if ($tens>2){
|
||||
if ($hundreds!=0) $entexto .= " ";
|
||||
$entexto .= $decenas[$tens-1];
|
||||
if ($units!=0){
|
||||
if ($tens > 2) {
|
||||
if ($hundreds != 0) $entexto .= " ";
|
||||
$entexto .= $decenas[$tens - 1];
|
||||
if ($units != 0) {
|
||||
$entexto .= " Y ";
|
||||
$entexto .= $unidades[$units-1];
|
||||
$entexto .= $unidades[$units - 1];
|
||||
}
|
||||
return $entexto;
|
||||
}
|
||||
elseif ($tens==2){
|
||||
if ($hundreds!=0) $entexto .= " ";
|
||||
elseif ($tens == 2) {
|
||||
if ($hundreds != 0) $entexto .= " ";
|
||||
$entexto .= " ".$veintis[$units];
|
||||
return $entexto;
|
||||
}
|
||||
elseif ($tens==1){
|
||||
if ($hundreds!=0) $entexto .= " ";
|
||||
elseif ($tens == 1) {
|
||||
if ($hundreds != 0) $entexto .= " ";
|
||||
$entexto .= $diecis[$units];
|
||||
return $entexto;
|
||||
}
|
||||
if ($units!=0) {
|
||||
if ($hundreds!=0 || $tens!=0) $entexto .= " ";
|
||||
$entexto .= $unidades[$units-1];
|
||||
if ($units != 0) {
|
||||
if ($hundreds != 0 || $tens != 0) $entexto .= " ";
|
||||
$entexto .= $unidades[$units - 1];
|
||||
}
|
||||
return $entexto;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user