2006-08-01 23:54:39 +00:00
< ? php
2015-11-30 20:20:45 +00:00
/* Copyright ( C ) 2006 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-05-23 16:52:31 +00:00
* Copyright ( C ) 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2009 - 2010 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2015-10-19 13:13:19 +00:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2006-08-01 22:42:38 +00: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 14:36:08 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2006-08-01 22:42:38 +00: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
2011-07-31 23:24:38 +00:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2006-08-01 22:42:38 +00:00
* or see http :// www . gnu . org /
*/
/**
2011-10-24 10:59:44 +00:00
* \file htdocs / core / lib / product . lib . php
2008-09-04 17:56:55 +00:00
* \brief Ensemble de fonctions de base pour le module produit et service
2008-12-11 20:12:44 +00:00
* \ingroup product
2008-08-28 00:31:27 +00:00
*/
2008-12-11 20:12:44 +00:00
2012-02-04 09:48:47 +00:00
/**
* Prepare array with list of tabs
*
2015-03-16 23:21:17 +00:00
* @ param Product $object Object related to tabs
2014-08-30 03:30:37 +00:00
* @ return array Array of tabs to show
2012-02-04 09:48:47 +00:00
*/
2015-04-07 01:00:11 +00:00
function product_prepare_head ( $object )
2006-08-01 23:54:39 +00:00
{
2016-01-23 16:19:34 +00:00
global $db , $langs , $conf , $user ;
2010-03-13 22:27:37 +00:00
$langs -> load ( " products " );
2008-08-28 00:31:27 +00:00
$h = 0 ;
$head = array ();
2014-09-18 19:18:25 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/card.php?id= " . $object -> id ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 1 ] = $langs -> trans ( " Card " );
$head [ $h ][ 2 ] = 'card' ;
$h ++ ;
2016-01-06 23:05:28 +00:00
if ( ! empty ( $object -> status ))
2010-03-13 22:27:37 +00:00
{
2016-01-06 23:05:28 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/price.php?id= " . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " SellingPrices " );
$head [ $h ][ 2 ] = 'price' ;
$h ++ ;
2010-03-13 22:27:37 +00:00
}
2016-01-06 23:05:28 +00:00
if ( ! empty ( $object -> status_buy ) || ( ! empty ( $conf -> margin -> enabled ) && ! empty ( $object -> status ))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase
{
if (( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> lire )
|| ( ! empty ( $conf -> margin -> enabled ) && $user -> rights -> margin -> liretous )
)
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/fournisseurs.php?id= " . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " BuyingPrices " );
$head [ $h ][ 2 ] = 'suppliers' ;
$h ++ ;
}
}
2008-08-28 00:31:27 +00:00
// Multilangs
2012-09-15 08:01:35 +00:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2006-08-01 23:54:39 +00:00
{
2010-12-19 11:05:07 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/traduction.php?id= " . $object -> id ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 1 ] = $langs -> trans ( " Translation " );
$head [ $h ][ 2 ] = 'translation' ;
$h ++ ;
}
2008-09-04 17:56:55 +00:00
// Sub products
2012-09-15 08:01:35 +00:00
if ( ! empty ( $conf -> global -> PRODUIT_SOUSPRODUITS ))
2008-08-28 00:31:27 +00:00
{
2014-09-18 19:18:25 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/composition/card.php?id= " . $object -> id ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 1 ] = $langs -> trans ( 'AssociatedProducts' );
$head [ $h ][ 2 ] = 'subproduct' ;
$h ++ ;
}
2014-09-18 19:18:25 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/stats/card.php?id= " . $object -> id ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 1 ] = $langs -> trans ( 'Statistics' );
$head [ $h ][ 2 ] = 'stats' ;
$h ++ ;
2016-02-17 21:33:02 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/stats/facture.php?showmessage=1&id= " . $object -> id ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 1 ] = $langs -> trans ( 'Referers' );
$head [ $h ][ 2 ] = 'referers' ;
$h ++ ;
2015-11-07 13:37:47 +00:00
if ( $object -> isProduct () || ( $object -> isService () && ! empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES ))) // If physical product we can stock (or service with option)
2011-01-24 23:35:21 +00:00
{
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> stock -> enabled ) && $user -> rights -> stock -> lire )
2011-01-24 23:35:21 +00:00
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/stock/product.php?id= " . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Stock " );
$head [ $h ][ 2 ] = 'stock' ;
$h ++ ;
}
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
2012-12-01 14:45:05 +00:00
// $this->tabs = array('entity:-tabname); to remove a tab
2011-01-24 23:35:21 +00:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'product' );
2016-07-28 11:53:17 +00:00
// Notes
if ( empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB ))
{
$nbNote = 0 ;
if ( ! empty ( $object -> note_private )) $nbNote ++ ;
if ( ! empty ( $object -> note_public )) $nbNote ++ ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/product/note.php?id=' . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( 'Notes' );
if ( $nbNote > 0 ) $head [ $h ][ 1 ] .= ' <span class="badge">' . $nbNote . '</span>' ;
$head [ $h ][ 2 ] = 'note' ;
$h ++ ;
}
2015-02-06 20:26:41 +00:00
// Attachments
2013-07-15 23:28:24 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2016-01-23 16:19:34 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php' ;
2016-03-01 16:28:08 +00:00
if ( ! empty ( $conf -> product -> enabled ) && ( $object -> type == Product :: TYPE_PRODUCT )) $upload_dir = $conf -> product -> multidir_output [ $object -> entity ] . '/' . dol_sanitizeFileName ( $object -> ref );
if ( ! empty ( $conf -> service -> enabled ) && ( $object -> type == Product :: TYPE_SERVICE )) $upload_dir = $conf -> service -> multidir_output [ $object -> entity ] . '/' . dol_sanitizeFileName ( $object -> ref );
$nbFiles = count ( dol_dir_list ( $upload_dir , 'files' , 0 , '' , '(\.meta|_preview\.png)$' ));
if ( ! empty ( $conf -> global -> PRODUCT_USE_OLD_PATH_FOR_PHOTO )) {
if ( ! empty ( $conf -> product -> enabled ) && ( $object -> type == Product :: TYPE_PRODUCT )) $upload_dir = $conf -> produit -> multidir_output [ $object -> entity ] . '/' . get_exdir ( $object -> id , 2 , 0 , 0 , $object , 'product' ) . $object -> id . '/photos' ;
if ( ! empty ( $conf -> service -> enabled ) && ( $object -> type == Product :: TYPE_SERVICE )) $upload_dir = $conf -> service -> multidir_output [ $object -> entity ] . '/' . get_exdir ( $object -> id , 2 , 0 , 0 , $object , 'product' ) . $object -> id . '/photos' ;
$nbFiles += count ( dol_dir_list ( $upload_dir , 'files' , 0 , '' , '(\.meta|_preview\.png)$' ));
}
2016-01-23 16:19:34 +00:00
$nbLinks = Link :: count ( $db , $object -> element , $object -> id );
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/product/document.php?id=' . $object -> id ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 1 ] = $langs -> trans ( 'Documents' );
2016-01-23 16:23:00 +00:00
if (( $nbFiles + $nbLinks ) > 0 ) $head [ $h ][ 1 ] .= ' <span class="badge">' . ( $nbFiles + $nbLinks ) . '</span>' ;
2008-08-28 00:31:27 +00:00
$head [ $h ][ 2 ] = 'documents' ;
$h ++ ;
2012-09-25 12:42:58 +00:00
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'product' , 'remove' );
2015-11-19 13:45:05 +00:00
// Log
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/product/info.php?id=' . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Info " );
$head [ $h ][ 2 ] = 'info' ;
$h ++ ;
2008-08-28 00:31:27 +00:00
return $head ;
2006-08-01 23:54:39 +00:00
}
2016-09-12 15:27:44 +00:00
/**
* Prepare array with list of tabs
*
* @ param ProductLot $object Object related to tabs
* @ return array Array of tabs to show
*/
function productlot_prepare_head ( $object )
{
global $db , $langs , $conf , $user ;
$langs -> load ( " products " );
$langs -> load ( " productbatch " );
$h = 0 ;
$head = array ();
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/stock/productlot_card.php?id= " . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Card " );
$head [ $h ][ 2 ] = 'card' ;
$h ++ ;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'productlot' );
complete_head_from_modules ( $conf , $langs , $object , $head , $h , 'productlot' , 'remove' );
// Log
/*
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/product/info.php?id=' . $object -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( " Info " );
$head [ $h ][ 2 ] = 'info' ;
$h ++ ;
*/
return $head ;
}
2012-03-03 15:33:38 +00:00
/**
* Return array head with list of tabs to view object informations .
*
* @ return array head array with tabs
*/
2014-12-04 12:20:56 +00:00
function product_admin_prepare_head ()
2012-03-03 15:33:38 +00:00
{
2012-05-22 16:35:14 +00:00
global $langs , $conf , $user ;
2012-06-09 17:16:31 +00:00
2012-05-22 16:35:14 +00:00
$h = 0 ;
$head = array ();
2012-06-09 17:16:31 +00:00
2012-05-22 16:35:14 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . " /product/admin/product.php " ;
$head [ $h ][ 1 ] = $langs -> trans ( 'Parameters' );
$head [ $h ][ 2 ] = 'general' ;
$h ++ ;
2012-06-09 17:16:31 +00:00
2015-11-02 09:02:09 +00:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ) && ! empty ( $conf -> global -> PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL ))
{
2015-10-19 13:13:19 +00:00
$head [ $h ] = array (
0 => DOL_URL_ROOT . " /product/admin/price_rules.php " ,
1 => $langs -> trans ( 'MultipriceRules' ),
2 => 'generator'
);
$h ++ ;
}
2012-05-22 16:35:14 +00:00
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
2012-12-01 14:45:05 +00:00
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
2014-12-04 12:20:56 +00:00
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'product_admin' );
2012-06-09 17:16:31 +00:00
2012-05-22 16:35:14 +00:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/product/admin/product_extrafields.php' ;
$head [ $h ][ 1 ] = $langs -> trans ( " ExtraFields " );
$head [ $h ][ 2 ] = 'attributes' ;
$h ++ ;
2012-06-09 17:16:31 +00:00
2014-12-04 12:20:56 +00:00
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'product_admin' , 'remove' );
2012-06-09 17:16:31 +00:00
2012-05-22 16:35:14 +00:00
return $head ;
2012-03-03 15:33:38 +00:00
}
2016-09-12 15:27:44 +00:00
/**
* Return array head with list of tabs to view object informations .
*
* @ return array head array with tabs
*/
function product_lot_admin_prepare_head ()
{
global $langs , $conf , $user ;
$h = 0 ;
$head = array ();
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'product_lot_admin' );
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/product/admin/product_lot_extrafields.php' ;
$head [ $h ][ 1 ] = $langs -> trans ( " ExtraFields " );
$head [ $h ][ 2 ] = 'attributes' ;
$h ++ ;
complete_head_from_modules ( $conf , $langs , null , $head , $h , 'product_lot_admin' , 'remove' );
return $head ;
}
2012-03-03 15:33:38 +00:00
/**
2012-03-18 18:23:01 +00:00
* Show stats for company
2012-03-03 15:33:38 +00:00
*
2012-03-18 18:23:01 +00:00
* @ param Product $product Product object
* @ param int $socid Thirdparty id
2016-02-17 21:33:02 +00:00
* @ return integer NB of lines shown into array
2012-03-03 15:33:38 +00:00
*/
2006-09-13 18:56:30 +00:00
function show_stats_for_company ( $product , $socid )
2006-08-18 23:16:40 +00:00
{
2008-08-28 00:31:27 +00:00
global $conf , $langs , $user , $db ;
2016-02-17 21:33:02 +00:00
$nblines = 0 ;
2008-08-28 00:31:27 +00:00
print '<tr>' ;
print '<td align="left" width="25%" valign="top">' . $langs -> trans ( " Referers " ) . '</td>' ;
print '<td align="right" width="25%">' . $langs -> trans ( " NbOfThirdParties " ) . '</td>' ;
2016-02-17 21:33:02 +00:00
print '<td align="right" width="25%">' . $langs -> trans ( " NbOfObjectReferers " ) . '</td>' ;
2008-08-28 00:31:27 +00:00
print '<td align="right" width="25%">' . $langs -> trans ( " TotalQuantity " ) . '</td>' ;
print '</tr>' ;
// Propals
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> lire )
2008-08-28 00:31:27 +00:00
{
2016-02-17 21:33:02 +00:00
$nblines ++ ;
2008-08-28 00:31:27 +00:00
$ret = $product -> load_stats_propale ( $socid );
2009-02-20 22:53:15 +00:00
if ( $ret < 0 ) dol_print_error ( $db );
2008-08-28 00:31:27 +00:00
$langs -> load ( " propal " );
print '<tr><td>' ;
print '<a href="propal.php?id=' . $product -> id . '">' . img_object ( '' , 'propal' ) . ' ' . $langs -> trans ( " Proposals " ) . '</a>' ;
print '</td><td align="right">' ;
print $product -> stats_propale [ 'customers' ];
print '</td><td align="right">' ;
print $product -> stats_propale [ 'nb' ];
print '</td><td align="right">' ;
print $product -> stats_propale [ 'qty' ];
print '</td>' ;
print '</tr>' ;
}
// Commandes clients
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire )
2008-08-28 00:31:27 +00:00
{
2016-02-17 21:33:02 +00:00
$nblines ++ ;
2008-08-28 00:31:27 +00:00
$ret = $product -> load_stats_commande ( $socid );
2009-02-20 22:53:15 +00:00
if ( $ret < 0 ) dol_print_error ( $db );
2008-08-28 00:31:27 +00:00
$langs -> load ( " orders " );
print '<tr><td>' ;
print '<a href="commande.php?id=' . $product -> id . '">' . img_object ( '' , 'order' ) . ' ' . $langs -> trans ( " CustomersOrders " ) . '</a>' ;
print '</td><td align="right">' ;
print $product -> stats_commande [ 'customers' ];
print '</td><td align="right">' ;
print $product -> stats_commande [ 'nb' ];
print '</td><td align="right">' ;
print $product -> stats_commande [ 'qty' ];
print '</td>' ;
print '</tr>' ;
}
// Commandes fournisseurs
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> commande -> lire )
2008-08-28 00:31:27 +00:00
{
2016-02-17 21:33:02 +00:00
$nblines ++ ;
2008-08-28 00:31:27 +00:00
$ret = $product -> load_stats_commande_fournisseur ( $socid );
2009-02-20 22:53:15 +00:00
if ( $ret < 0 ) dol_print_error ( $db );
2008-08-28 00:31:27 +00:00
$langs -> load ( " orders " );
print '<tr><td>' ;
print '<a href="commande_fournisseur.php?id=' . $product -> id . '">' . img_object ( '' , 'order' ) . ' ' . $langs -> trans ( " SuppliersOrders " ) . '</a>' ;
print '</td><td align="right">' ;
print $product -> stats_commande_fournisseur [ 'suppliers' ];
print '</td><td align="right">' ;
print $product -> stats_commande_fournisseur [ 'nb' ];
print '</td><td align="right">' ;
print $product -> stats_commande_fournisseur [ 'qty' ];
print '</td>' ;
print '</tr>' ;
}
// Contrats
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire )
2008-08-28 00:31:27 +00:00
{
2016-02-17 21:33:02 +00:00
$nblines ++ ;
2008-08-28 00:31:27 +00:00
$ret = $product -> load_stats_contrat ( $socid );
2009-02-20 22:53:15 +00:00
if ( $ret < 0 ) dol_print_error ( $db );
2008-08-28 00:31:27 +00:00
$langs -> load ( " contracts " );
print '<tr><td>' ;
print '<a href="contrat.php?id=' . $product -> id . '">' . img_object ( '' , 'contract' ) . ' ' . $langs -> trans ( " Contracts " ) . '</a>' ;
print '</td><td align="right">' ;
print $product -> stats_contrat [ 'customers' ];
print '</td><td align="right">' ;
print $product -> stats_contrat [ 'nb' ];
print '</td><td align="right">' ;
print $product -> stats_contrat [ 'qty' ];
print '</td>' ;
print '</tr>' ;
}
// Factures clients
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2008-08-28 00:31:27 +00:00
{
2016-02-17 21:33:02 +00:00
$nblines ++ ;
2008-08-28 00:31:27 +00:00
$ret = $product -> load_stats_facture ( $socid );
2009-02-20 22:53:15 +00:00
if ( $ret < 0 ) dol_print_error ( $db );
2008-08-28 00:31:27 +00:00
$langs -> load ( " bills " );
print '<tr><td>' ;
2012-07-06 08:22:37 +00:00
print '<a href="facture.php?id=' . $product -> id . '">' . img_object ( '' , 'bill' ) . ' ' . $langs -> trans ( " CustomersInvoices " ) . '</a>' ;
2008-08-28 00:31:27 +00:00
print '</td><td align="right">' ;
print $product -> stats_facture [ 'customers' ];
print '</td><td align="right">' ;
print $product -> stats_facture [ 'nb' ];
print '</td><td align="right">' ;
print $product -> stats_facture [ 'qty' ];
print '</td>' ;
print '</tr>' ;
}
// Factures fournisseurs
2012-09-15 09:21:22 +00:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> facture -> lire )
2008-08-28 00:31:27 +00:00
{
2016-02-17 21:33:02 +00:00
$nblines ++ ;
2008-08-28 00:31:27 +00:00
$ret = $product -> load_stats_facture_fournisseur ( $socid );
2009-02-20 22:53:15 +00:00
if ( $ret < 0 ) dol_print_error ( $db );
2008-08-28 00:31:27 +00:00
$langs -> load ( " bills " );
print '<tr><td>' ;
print '<a href="facture_fournisseur.php?id=' . $product -> id . '">' . img_object ( '' , 'bill' ) . ' ' . $langs -> trans ( " SuppliersInvoices " ) . '</a>' ;
print '</td><td align="right">' ;
print $product -> stats_facture_fournisseur [ 'suppliers' ];
print '</td><td align="right">' ;
print $product -> stats_facture_fournisseur [ 'nb' ];
print '</td><td align="right">' ;
print $product -> stats_facture_fournisseur [ 'qty' ];
print '</td>' ;
print '</tr>' ;
}
2016-02-17 21:33:02 +00:00
return $nblines ++ ;
2006-08-18 23:16:40 +00:00
}
2008-11-16 01:09:04 +00:00
/**
2010-08-24 18:40:17 +00:00
* Return translation label of a unit key
2012-02-04 13:39:47 +00:00
*
* @ param int $unit Unit key ( - 3 , 0 , 3 , 98 , 99. .. )
* @ param string $measuring_style Style of unit : weight , volume , ...
* @ return string Unit string
2016-02-25 12:46:38 +00:00
* @ see formproduct -> load_measuring_units
2008-11-16 01:09:04 +00:00
*/
function measuring_units_string ( $unit , $measuring_style = '' )
{
global $langs ;
2014-11-15 14:19:37 +00:00
$measuring_units = array ();
2008-11-16 01:09:04 +00:00
if ( $measuring_style == 'weight' )
{
2016-02-25 12:46:38 +00:00
$measuring_units [ 3 ] = $langs -> transnoentitiesnoconv ( " WeightUnitton " );
$measuring_units [ 0 ] = $langs -> transnoentitiesnoconv ( " WeightUnitkg " );
$measuring_units [ - 3 ] = $langs -> transnoentitiesnoconv ( " WeightUnitg " );
$measuring_units [ - 6 ] = $langs -> transnoentitiesnoconv ( " WeightUnitmg " );
$measuring_units [ 99 ] = $langs -> transnoentitiesnoconv ( " WeightUnitpound " );
2008-11-16 01:09:04 +00:00
}
else if ( $measuring_style == 'size' )
{
2016-02-25 12:46:38 +00:00
$measuring_units [ 0 ] = $langs -> transnoentitiesnoconv ( " SizeUnitm " );
$measuring_units [ - 1 ] = $langs -> transnoentitiesnoconv ( " SizeUnitdm " );
$measuring_units [ - 2 ] = $langs -> transnoentitiesnoconv ( " SizeUnitcm " );
$measuring_units [ - 3 ] = $langs -> transnoentitiesnoconv ( " SizeUnitmm " );
$measuring_units [ 98 ] = $langs -> transnoentitiesnoconv ( " SizeUnitfoot " );
$measuring_units [ 99 ] = $langs -> transnoentitiesnoconv ( " SizeUnitinch " );
2008-11-16 01:09:04 +00:00
}
2010-03-12 23:40:39 +00:00
else if ( $measuring_style == 'surface' )
{
2016-02-25 12:46:38 +00:00
$measuring_units [ 0 ] = $langs -> transnoentitiesnoconv ( " SurfaceUnitm2 " );
$measuring_units [ - 2 ] = $langs -> transnoentitiesnoconv ( " SurfaceUnitdm2 " );
$measuring_units [ - 4 ] = $langs -> transnoentitiesnoconv ( " SurfaceUnitcm2 " );
$measuring_units [ - 6 ] = $langs -> transnoentitiesnoconv ( " SurfaceUnitmm2 " );
$measuring_units [ 98 ] = $langs -> transnoentitiesnoconv ( " SurfaceUnitfoot2 " );
$measuring_units [ 99 ] = $langs -> transnoentitiesnoconv ( " SurfaceUnitinch2 " );
2010-03-12 23:40:39 +00:00
}
else if ( $measuring_style == 'volume' )
{
2016-02-25 12:46:38 +00:00
$measuring_units [ 0 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitm3 " );
$measuring_units [ - 3 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitdm3 " );
$measuring_units [ - 6 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitcm3 " );
$measuring_units [ - 9 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitmm3 " );
$measuring_units [ 88 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitfoot3 " );
$measuring_units [ 89 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitinch3 " );
$measuring_units [ 97 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitounce " );
$measuring_units [ 98 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitlitre " );
$measuring_units [ 99 ] = $langs -> transnoentitiesnoconv ( " VolumeUnitgallon " );
2010-03-12 23:40:39 +00:00
}
2008-11-16 01:09:04 +00:00
return $measuring_units [ $unit ];
}