Qual: Reduce memory required by 2%

This commit is contained in:
Laurent Destailleur 2008-11-16 01:09:04 +00:00
parent 1c58b61eba
commit 584d23bfbc
18 changed files with 436 additions and 525 deletions

View File

@ -271,7 +271,7 @@ if ($resql)
print ' '; print ' ';
if ($user->rights->adherent->supprimer) if ($user->rights->adherent->supprimer)
{ {
print "<a href=\"fiche.php?rowid=$objp->rowid&action=resign&return=liste.php\">".img_disable($langs->trans("Resiliate"))."</a>"; print "<a href=\"fiche.php?rowid=$objp->rowid&action=resign&return=liste.php\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
} }
print "</td>"; print "</td>";

View File

@ -28,6 +28,7 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("companies"); $langs->load("companies");

View File

@ -1309,7 +1309,7 @@ if ($_GET['propalid'] > 0)
else else
{ {
$picto = '<a href="#" onClick="dialogWindow($(\'calc_markup'.$i.'\').innerHTML,\''.$langs->trans('ToCalculateMarkup').'\')">'; $picto = '<a href="#" onClick="dialogWindow($(\'calc_markup'.$i.'\').innerHTML,\''.$langs->trans('ToCalculateMarkup').'\')">';
$picto.= img_calc(); $picto.= img_picto($langs->trans("Calculate"),'calc.png');
$picto.= '</a>'; $picto.= '</a>';
print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i); print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i);
} }

View File

@ -27,6 +27,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
/* /*
@ -212,9 +213,7 @@ foreach($graphfiles as $graph){
</table>' ; </table>' ;
} }
/**************
* Fin de page
**************/
$db->close(); $db->close();
llxFooter(); llxFooter();
?> ?>

View File

@ -26,6 +26,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
if (!$user->rights->compta->resultat->lire) if (!$user->rights->compta->resultat->lire)
accessforbidden(); accessforbidden();
@ -216,9 +217,8 @@ if($_GET['id']!="")
} }
} }
/**************
* Fin de page
**************/
$db->close(); $db->close();
llxFooter(); llxFooter();
?> ?>

View File

@ -98,7 +98,7 @@ print '<br>';
print $langs->trans("ExportCardToFormat").': '; print $langs->trans("ExportCardToFormat").': ';
print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$_GET["id"].'">'; print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$_GET["id"].'">';
print img_vcard($langs->trans("VCard")).' '; print img_picto($langs->trans("VCard"),'vcard.png').' ';
print $langs->trans("VCard"); print $langs->trans("VCard");
print '</a>'; print '</a>';

View File

@ -348,7 +348,7 @@ if ($result)
// Link export vcard // Link export vcard
print '<td align="right">'; print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$obj->cidp.'">'; print '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$obj->cidp.'">';
print img_vcard($langs->trans("VCard")).' '; print img_picto($langs->trans("VCard"),'vcard.png').' ';
print '</a></td>'; print '</a></td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -30,6 +30,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formproduct.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formproduct.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/sendings.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/sendings.lib.php");
if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php"); if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php");
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");

View File

@ -2613,10 +2613,18 @@ class Form
print '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; print '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
print '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; print '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
print '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n"; print '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
if($form_name =="") if ($form_name =="")
print '<A HREF="javascript:showCalendar(document.forms[3].'.$prefix.')">'.img_cal().'</a>'; {
print '<A HREF="javascript:showCalendar(document.forms[3].'.$prefix.')">';
print '<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
print '</a>';
}
else else
print '<A HREF="javascript:showCalendar(document.forms[\''.$form_name.'\'].'.$prefix.')">'.img_cal().'</a>'; {
print '<A HREF="javascript:showCalendar(document.forms[\''.$form_name.'\'].'.$prefix.')">';
print '<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
print '</a>';
}
} }
} }

View File

@ -14,22 +14,22 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
/** /**
\file htdocs/includes/triggers/interface_modCommande_fraisport.class.php \file htdocs/includes/triggers/interface_modCommande_fraisport.class.php
\ingroup core \ingroup core
\brief Fichier trigger pour ajout frais port \brief Fichier trigger pour ajout frais port
\version $Id$
*/ */
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
/** /**
\class InterfaceFraisport \class InterfaceFraisport
\brief Classe des fonctions triggers des actions personalisées du workflow \brief Classe des fonctions triggers des actions personalisées du workflow
*/ */
class InterfaceFraisport class InterfaceFraisport
{ {
var $db; var $db;

View File

@ -18,22 +18,22 @@
*/ */
/** /**
\file htdocs/lib/files.lib.php * \file htdocs/lib/files.lib.php
\brief Library for file managing functions * \brief Library for file managing functions
\version $Id$ * \version $Id$
*/ */
/** /**
\brief Scan a directory and return a list of files/directories * \brief Scan a directory and return a list of files/directories
\param $path Starting path from which to search * \param $path Starting path from which to search
\param $types Can be "directories", "files", or "all" * \param $types Can be "directories", "files", or "all"
\param $recursive Determines whether subdirectories are searched * \param $recursive Determines whether subdirectories are searched
\param $filter Regex for filter * \param $filter Regex for filter
\param $exludefilter Regex for exclude filter (example: '\.meta$') * \param $exludefilter Regex for exclude filter (example: '\.meta$')
\param $sortcriteria Sort criteria ("name","date","size") * \param $sortcriteria Sort criteria ("name","date","size")
\param $sortorder Sort order (SORT_ASC, SORT_DESC) * \param $sortorder Sort order (SORT_ASC, SORT_DESC)
\param $mode 0=Return array with only keys needed, 1=Force all keys to be loaded * \param $mode 0=Return array with only keys needed, 1=Force all keys to be loaded
\return array Array of array('name'=>xxx,'date'=>yyy,'size'=>zzz) * \return array Array of array('name'=>xxx,'date'=>yyy,'size'=>zzz)
*/ */
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0) function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
{ {
@ -181,4 +181,32 @@ function dol_mimetype($file)
if (eregi('\.(zip|rar|gz|tgz|z|cab|bz2)$',$file)) $mime='archive'; if (eregi('\.(zip|rar|gz|tgz|z|cab|bz2)$',$file)) $mime='archive';
return $mime; return $mime;
} }
/**
* \brief Test if a folder is empty
* \return true is empty or non-existing, false if it contains files
*/
function dol_dir_is_emtpy($folder)
{
if (is_dir($folder))
{
$handle = opendir($folder);
while( (gettype( $name = readdir($handle)) != "boolean")){
$name_array[] = $name;
}
foreach($name_array as $temp)
$folder_content .= $temp;
if($folder_content == "...")
return true;
else
return false;
closedir($handle);
}
else
return true; // Le repertoire n'existe pas
}
?> ?>

View File

@ -26,7 +26,8 @@
/** /**
* \file htdocs/lib/functions.lib.php * \file htdocs/lib/functions.lib.php
* \brief Ensemble de fonctions de base de dolibarr sous forme d'include * \brief A set of functions for Dolibarr
* This file contains all frequently used functions.
* \version $Id$ * \version $Id$
*/ */
@ -926,12 +927,12 @@ function img_object($alt, $object)
} }
/** /**
\brief Affiche picto (fonction g<EFBFBD>n<EFBFBD>rique) * \brief Affiche picto (fonction generique)
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\param picto Nom de l'image a afficher (Si pas d'extension, on met '.png') * \param picto Nom de l'image a afficher (Si pas d'extension, on met '.png')
\param options Attribut supplementaire a la balise img * \param options Attribut supplementaire a la balise img
\param pictoisfullpath If 1, image path is a full path * \param pictoisfullpath If 1, image path is a full path
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_picto($alt, $picto, $options='', $pictoisfullpath=0) function img_picto($alt, $picto, $options='', $pictoisfullpath=0)
{ {
@ -1002,9 +1003,9 @@ function img_refresh($alt = "default")
} }
/** /**
\brief Affiche logo dossier * \brief Affiche logo dossier
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_folder($alt = "default") function img_folder($alt = "default")
{ {
@ -1014,9 +1015,9 @@ function img_folder($alt = "default")
} }
/** /**
\brief Affiche logo nouveau fichier * \brief Affiche logo nouveau fichier
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_file_new($alt = "default") function img_file_new($alt = "default")
{ {
@ -1039,21 +1040,9 @@ function img_pdf($alt = "default",$size=3)
} }
/** /**
\brief Affiche logo vcard * \brief Affiche logo +
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\return string Retourne tag img * \return string Retourne tag img
*/
function img_vcard($alt = "default")
{
global $conf,$langs;
if ($alt=="default") $alt=$langs->trans("VCard");
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/vcard.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
}
/**
\brief Affiche logo +
\param alt Texte sur le alt de l'image
\return string Retourne tag img
*/ */
function img_edit_add($alt = "default") function img_edit_add($alt = "default")
{ {
@ -1062,9 +1051,9 @@ function img_edit_add($alt = "default")
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/edit_add.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/edit_add.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
} }
/** /**
\brief Affiche logo - * \brief Affiche logo -
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_edit_remove($alt = "default") function img_edit_remove($alt = "default")
{ {
@ -1074,10 +1063,10 @@ function img_edit_remove($alt = "default")
} }
/** /**
\brief Affiche logo editer/modifier fiche * \brief Affiche logo editer/modifier fiche
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\param float Si il faut y mettre le style "float: right" * \param float Si il faut y mettre le style "float: right"
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_edit($alt = "default", $float=0, $other='') function img_edit($alt = "default", $float=0, $other='')
{ {
@ -1091,10 +1080,10 @@ function img_edit($alt = "default", $float=0, $other='')
} }
/** /**
\brief Affiche logo voir fiche * \brief Affiche logo voir fiche
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\param float Si il faut y mettre le style "float: right" * \param float Si il faut y mettre le style "float: right"
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_view($alt = "default", $float=0, $other='') function img_view($alt = "default", $float=0, $other='')
{ {
@ -1119,22 +1108,10 @@ function img_delete($alt = "default")
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
} }
/**
\brief Affiche logo d<EFBFBD>sactiver
\param alt Texte sur le alt de l'image
\return string Retourne tag img
*/
function img_disable($alt = "default")
{
global $conf,$langs;
if ($alt=="default") $alt=$langs->trans("Disable");
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/disable.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
}
/** /**
\brief Affiche logo help avec curseur "?" * \brief Affiche logo help avec curseur "?"
\return string Retourne tag img * \return string Retourne tag img
*/ */
function img_help($usehelpcursor=1,$usealttitle=1) function img_help($usehelpcursor=1,$usealttitle=1)
{ {
@ -1148,19 +1125,9 @@ function img_help($usehelpcursor=1,$usealttitle=1)
} }
/** /**
\brief Affiche picto calendrier "?" * \brief Affiche logo info
\return string Retourne tag img * \param alt Texte sur le alt de l'image
*/ * \return string Retourne tag img
function img_cal()
{
global $conf,$langs;
return '<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
}
/**
\brief Affiche logo info
\param alt Texte sur le alt de l'image
\return string Retourne tag img
*/ */
function img_info($alt = "default") function img_info($alt = "default")
{ {
@ -1170,22 +1137,10 @@ function img_info($alt = "default")
} }
/** /**
\brief Affiche logo calculatrice * \brief Affiche logo warning
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\return string Retourne tag img * \param float Si il faut afficher le style "float: right"
*/ * \return string Retourne tag img
function img_calc($alt = "default")
{
global $conf,$langs;
if ($alt=="default") $alt=$langs->trans("Calculate");
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calc.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
}
/**
\brief Affiche logo warning
\param alt Texte sur le alt de l'image
\param float Si il faut afficher le style "float: right"
\return string Retourne tag img
*/ */
function img_warning($alt = "default",$float=0) function img_warning($alt = "default",$float=0)
{ {
@ -1199,7 +1154,7 @@ function img_warning($alt = "default",$float=0)
} }
/** /**
\brief Affiche logo warning \brief Affiche logo error
\param alt Texte sur le alt de l'image \param alt Texte sur le alt de l'image
\return string Retourne tag img \return string Retourne tag img
*/ */
@ -1211,22 +1166,10 @@ function img_error($alt = "default")
} }
/** /**
\brief Affiche logo alerte * \brief Affiche logo telephone
\param alt Texte sur le alt de l'image * \param alt Texte sur le alt de l'image
\return string Retourne tag img * \param option Choose of logo
*/ * \return string Retourne tag img
function img_alerte($alt = "default")
{
global $conf,$langs;
if ($alt=="default") $alt=$langs->trans("Alert");
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/alerte.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
}
/**
\brief Affiche logo t<EFBFBD>l<EFBFBD>phone
\param alt Texte sur le alt de l'image
\param option Choose of logo
\return string Retourne tag img
*/ */
function img_phone($alt = "default",$option=0) function img_phone($alt = "default",$option=0)
{ {
@ -1381,40 +1324,10 @@ function img_mime($file,$alt='')
/** /**
\brief Return if a filename is file name of a supported image format * \brief Affiche info admin
\param file Filename * \param text Text info
\return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported * \param infoonimgalt Info is shown on alt of star picto
*/ * \return string String with info text
function image_format_supported($file)
{
// Case filename is not a format image
if (! eregi('(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$',$file,$reg)) return -1;
// Case filename is a format image but not supported by this PHP
$imgfonction='';
if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif';
if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng';
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
if ($imgfonction)
{
if (! function_exists($imgfonction))
{
// Fonctions de conversion non presente dans ce PHP
return 0;
}
}
// Filename is a format image and supported by this PHP
return 1;
}
/**
\brief Affiche info admin
\param text Text info
\param infoonimgalt Info is shown on alt of star picto
\return string String with info text
*/ */
function info_admin($texte,$infoonimgalt=0) function info_admin($texte,$infoonimgalt=0)
{ {
@ -2246,18 +2159,18 @@ function get_product_vat_for_country($idprod, $countrycode)
/** /**
\brief Fonction qui renvoie la tva d'une ligne (en fonction du vendeur, acheteur et taux du produit) * \brief Fonction qui renvoie la tva d'une ligne (en fonction du vendeur, acheteur et taux du produit)
\remarks Si vendeur non assujeti a TVA, TVA par d<EFBFBD>faut=0. Fin de r<EFBFBD>gle. * \remarks Si vendeur non assujeti a TVA, TVA par d<EFBFBD>faut=0. Fin de r<EFBFBD>gle.
Si le (pays vendeur = pays acheteur) alors TVA par d<EFBFBD>faut=TVA du produit vendu. Fin de r<EFBFBD>gle. * Si le (pays vendeur = pays acheteur) alors TVA par d<EFBFBD>faut=TVA du produit vendu. Fin de r<EFBFBD>gle.
Si (vendeur et acheteur dans Communaut<EFBFBD> europ<EFBFBD>enne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par d<EFBFBD>faut=0 (La TVA doit <EFBFBD>tre pay<EFBFBD> par acheteur au centre d'impots de son pays et non au vendeur). Fin de r<EFBFBD>gle. * Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par d<EFBFBD>faut=0 (La TVA doit <EFBFBD>tre pay<EFBFBD> par acheteur au centre d'impots de son pays et non au vendeur). Fin de r<EFBFBD>gle.
Si (vendeur et acheteur dans Communaut<EFBFBD> europ<EFBFBD>enne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par d<EFBFBD>faut=TVA du produit vendu. Fin de r<EFBFBD>gle * Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par d<EFBFBD>faut=TVA du produit vendu. Fin de r<EFBFBD>gle
Si (vendeur et acheteur dans Communaut<EFBFBD> europ<EFBFBD>enne) et (acheteur = entreprise avec num TVA) intra alors TVA par d<EFBFBD>faut=0. Fin de r<EFBFBD>gle * Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise avec num TVA) intra alors TVA par d<EFBFBD>faut=0. Fin de r<EFBFBD>gle
Sinon TVA propos<EFBFBD>e par d<EFBFBD>faut=0. Fin de r<EFBFBD>gle. * Sinon TVA proposee par defaut=0. Fin de regle.
\param societe_vendeuse Objet soci<EFBFBD>t<EFBFBD> vendeuse * \param societe_vendeuse Objet societe vendeuse
\param societe_acheteuse Objet soci<EFBFBD>t<EFBFBD> acheteuse * \param societe_acheteuse Objet societe acheteuse
\param taux_produit Taux par defaut du produit vendu (old way to get product vat rate) * \param taux_produit Taux par defaut du produit vendu (old way to get product vat rate)
\param idprod Id product (new way to get product vat rate) * \param idprod Id product (new way to get product vat rate)
\return float Taux de tva a appliquer, -1 si ne peut etre d<EFBFBD>termin<EFBFBD> * \return float Taux de tva a appliquer, -1 si ne peut etre d<EFBFBD>termin<EFBFBD>
*/ */
function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $idprod=0) function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $idprod=0)
{ {
@ -2349,43 +2262,10 @@ function yn($yesno, $case=1, $color=0)
/** /**
\brief Fonction pour qui retourne le rowid d'un departement par son code * \brief Return a path to class a directory according to an id
\param db handler d'acc<EFBFBD>s base * \remarks Examples: 1->"0/0/1/", 15->"0/1/5/"
\param code Code r<EFBFBD>gion * \param $num Id to develop
\param pays_id Id du pays * \param $level Level of development (1, 2 or 3 level)
*/
function departement_rowid($db,$code, $pays_id)
{
$sql = "SELECT c.rowid FROM ".MAIN_DB_PREFIX."c_departements as c,".MAIN_DB_PREFIX."c_regions as r";
$sql .= " WHERE c.code_departement=". $code;
$sql .= " AND c.fk_region = r.code_region";
$sql .= " AND r.fk_pays =".$pays_id;
if ($db->query($sql))
{
$num = $db->num_rows();
if ($num)
{
$obj = $db->fetch_object();
return $obj->rowid;
}
else
{
return 0;
}
$db->free();
}
else
{
return 0;
}
}
/**
\brief Renvoi un chemin de classement r<EFBFBD>pertoire en fonction d'un i
\remarks Examples: 1->"0/0/1/", 15->"0/1/5/"
\param $num Id a d<EFBFBD>composer
\param $level Niveau de decoupage (1, 2 ou 3 niveaux)
*/ */
function get_exdir($num,$level=3) function get_exdir($num,$level=3)
{ {
@ -2456,177 +2336,21 @@ function create_exdir($dir)
} }
/** /**
\brief Retourne le numero de la semaine par rapport a une date * \brief Retourne le picto champ obligatoire
\param time Date au format 'timestamp' * \return string Chaine avec picto obligatoire
\return int Numero de semaine
*/
function numero_semaine($time)
{
$stime = strftime('%Y-%m-%d',$time);
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?',$stime,$reg))
{
// Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
$annee = $reg[1];
$mois = $reg[2];
$jour = $reg[3];
}
/*
* Norme ISO-8601:
* - La semaine 1 de toute ann<EFBFBD>e est celle qui contient le 4 janvier ou que la semaine 1 de toute ann<EFBFBD>e est celle qui contient le 1er jeudi de janvier.
* - La majorit<EFBFBD> des ann<EFBFBD>es ont 52 semaines mais les ann<EFBFBD>es qui commence un jeudi et les ann<EFBFBD>es bissextiles commen<EFBFBD>ant un mercredi en poss<EFBFBD>de 53.
* - Le 1er jour de la semaine est le Lundi
*/
// D<>finition du Jeudi de la semaine
if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60;
else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60;
else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
else // Jeudi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee);
// D<>finition du premier Jeudi de l'ann<6E>e
if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60;
}
else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60;
}
else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60;
}
else // Jeudi
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine));
}
// D<>finition du num<75>ro de semaine: nb de jours entre "premier Jeudi de l'ann<6E>e" et "Jeudi de la semaine";
$numeroSemaine = (
(
date("z",mktime(12,0,0,date("m",$jeudiSemaine),date("d",$jeudiSemaine),date("Y",$jeudiSemaine)))
-
date("z",mktime(12,0,0,date("m",$premierJeudiAnnee),date("d",$premierJeudiAnnee),date("Y",$premierJeudiAnnee)))
) / 7
) + 1;
// Cas particulier de la semaine 53
if ($numeroSemaine==53)
{
// Les ann<6E>es qui commence un Jeudi et les ann<6E>es bissextiles commen<65>ant un Mercredi en poss<73>de 53
if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365))
{
$numeroSemaine = 53;
}
else
{
$numeroSemaine = 1;
}
}
//echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."<BR>";
return sprintf("%02d",$numeroSemaine);
}
/**
\brief Retourne le picto champ obligatoire
\return string Chaine avec picto obligatoire
*/ */
function picto_required() function picto_required()
{ {
return '<b>*</b>'; return '<b>*</b>';
} }
/**
\brief Convertit une masse d'une unite vers une autre unite
\param weight float Masse a convertir
\param from_unit int Unite originale en puissance de 10
\param to_unit int Nouvelle unite en puissance de 10
\return float Masse convertie
*/
function weight_convert($weight,&$from_unit,$to_unit)
{
/* Pour convertire 320 gr en Kg appeler
* $f = -3
* weigh_convert(320, $f, 0) retournera 0.32
*
*/
while ($from_unit <> $to_unit)
{
if ($from_unit > $to_unit)
{
$weight = $weight * 10;
$from_unit = $from_unit - 1;
$weight = weight_convert($weight,$from_unit, $to_unit);
}
if ($from_unit < $to_unit)
{
$weight = $weight / 10;
$from_unit = $from_unit + 1;
$weight = weight_convert($weight,$from_unit, $to_unit);
}
}
return $weight;
}
/** /**
\brief Renvoi le texte d'une unite * \brief Clean an url
\param int Unit * \param url Url
\param measuring_style Le style de mesure : weight, volume,... * \param http 1: keep http, 0: remove also http
\return string Unite * \return string CleanUrl
\todo gerer les autres unit<EFBFBD>s de mesure comme la livre, le gallon, le litre, ...
*/
function measuring_units_string($unit,$measuring_style='')
{
/* Note Rodo aux dev :)
* Ne pas ins<EFBFBD>rer dans la base de donn<EFBFBD>es ces valeurs
* cela surchagerait inutilement d'une requete suppl<EFBFBD>mentaire
* pour quelque chose qui est somme toute peu variable
*/
global $langs;
if ($measuring_style == 'weight')
{
$measuring_units[3] = $langs->trans("WeightUnitton");
$measuring_units[0] = $langs->trans("WeightUnitkg");
$measuring_units[-3] = $langs->trans("WeightUnitg");
$measuring_units[-6] = $langs->trans("WeightUnitmg");
}
else if ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->trans("VolumeUnitm3");
$measuring_units[-3] = $langs->trans("VolumeUnitdm3");
$measuring_units[-6] = $langs->trans("VolumeUnitcm3");
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
}
else if ($measuring_style == 'size')
{
$measuring_units[0] = $langs->trans("SizeUnitm");
$measuring_units[-1] = $langs->trans("SizeUnitdm");
$measuring_units[-2] = $langs->trans("SizeUnitcm");
$measuring_units[-3] = $langs->trans("SizeUnitmm");
}
return $measuring_units[$unit];
}
/**
\brief Clean an url
\param url Url
\param http 1: keep http, 0: remove also http
\return string CleanUrl
*/ */
function clean_url($url,$http=1) function clean_url($url,$http=1)
{ {
@ -2686,36 +2410,6 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1)
return $CleanString; return $CleanString;
} }
/**
\brief Convert a binaray data to string that represent hexadecimal value
\param bin Value to convert
\param pad Add 0
\param upper Convert to tupper
\return string x
*/
function binhex($bin, $pad=false, $upper=false){
$last = strlen($bin)-1;
for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2,$i); }
$x = dechex($x);
if($pad){ while(strlen($x) < intval(strlen($bin))/4){ $x = "0$x"; } }
if($upper){ $x = strtoupper($x); }
return $x;
}
/**
\brief Convertir de l'h<EFBFBD>xad<EFBFBD>cimal en binaire
\param string hexa
\return string bin
*/
function hexbin($hexa){
$bin='';
for($i=0;$i<strlen($hexa);$i++)
{
$bin.=str_pad(decbin(hexdec($hexa{$i})),4,'0',STR_PAD_LEFT);
}
return $bin;
}
/** /**
* \brief Replace CRLF in string with a HTML BR tag. * \brief Replace CRLF in string with a HTML BR tag.
@ -2837,9 +2531,9 @@ function dol_nboflines($s,$maxchar=0)
/** /**
* \brief Fonction retournant le nombre de lignes dans un texte formate * \brief Fonction retournant le nombre de lignes dans un texte formate
* \param texte Texte * \param texte Texte
* \param maxlinesize Largeur de ligne en caracteres(ou 0 si pas de limite - defaut) * \param maxlinesize Largeur de ligne en caracteres(ou 0 si pas de limite - defaut)
* \return nblines Nombre de lignes * \return nblines Nombre de lignes
*/ */
function num_lines($texte,$maxlinesize=0) function num_lines($texte,$maxlinesize=0)
{ {
@ -2911,7 +2605,7 @@ function dol_textishtml($msg,$option=0)
} }
} }
/* /**
* \brief Effectue les substitutions des mots cl<EFBFBD>s par les donn<EFBFBD>es en fonction du tableau * \brief Effectue les substitutions des mots cl<EFBFBD>s par les donn<EFBFBD>es en fonction du tableau
* \param chaine Chaine dans laquelle faire les substitutions * \param chaine Chaine dans laquelle faire les substitutions
* \param substitutionarray Tableau cl<EFBFBD> substitution => valeur a mettre * \param substitutionarray Tableau cl<EFBFBD> substitution => valeur a mettre
@ -2956,28 +2650,11 @@ function print_date_range($date_start,$date_end,$format = '',$outputlangs='')
} }
/*
*
*/
function make_alpha_from_numbers($number)
{
$numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if($number<strlen($numeric))
{
return $numeric[$number];
}
else
{
$dev_by = floor($number/strlen($numeric));
return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*strlen($numeric)));
}
}
/** /**
\brief Retourne un tableau des mois ou le mois s<EFBFBD>lectionn<EFBFBD> * \brief Retourne un tableau des mois ou le mois selectionne
\param selected Mois <EFBFBD> s<EFBFBD>lectionner ou -1 * \param selected Mois a selectionner ou -1
\return string or array Month string or array if selected < 0 * \return string or array Month string or array if selected < 0
*/ */
function monthArrayOrSelected($selected=0) function monthArrayOrSelected($selected=0)
{ {
@ -3017,9 +2694,9 @@ function monthArrayOrSelected($selected=0)
} }
/** /**
\brief Returns formated reduction * \brief Returns formated reduction
\param reduction Reduction percentage * \param reduction Reduction percentage
\return string Formated reduction * \return string Formated reduction
*/ */
function dolibarr_print_reduction($reduction=0) function dolibarr_print_reduction($reduction=0)
{ {
@ -3027,7 +2704,6 @@ function dolibarr_print_reduction($reduction=0)
$langs->load("main"); $langs->load("main");
$string = ''; $string = '';
if ($reduction == 100) if ($reduction == 100)
{ {
$string = $langs->trans("Offered"); $string = $langs->trans("Offered");
@ -3042,9 +2718,9 @@ function dolibarr_print_reduction($reduction=0)
/** /**
\brief Returns formated reduction * \brief Returns formated reduction
\param reduction Reduction percentage * \param reduction Reduction percentage
\return int Return number of error messages shown * \return int Return number of error messages shown
*/ */
function dol_htmloutput_errors($mesgstring='',$mesgarray='') function dol_htmloutput_errors($mesgstring='',$mesgarray='')
{ {
@ -3112,62 +2788,6 @@ function dol_sort_array($array, $index, $order='asc', $natsort, $case_sensitive)
return $array; return $array;
} }
/**
* \brief Test if a folder is empty
* \return true is empty or non-existing, false if it contains files
*/
function is_emtpy_folder($folder){
if(is_dir($folder) ){
$handle = opendir($folder);
while( (gettype( $name = readdir($handle)) != "boolean")){
$name_array[] = $name;
}
foreach($name_array as $temp)
$folder_content .= $temp;
if($folder_content == "...")
return true;
else
return false;
closedir($handle);
}
else
return true; // Le r<>pertoire n'existe pas
}
/**
* \brief Return an html table from an array
*/
function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions=''){
$text='' ;
if($tableMarkup) $text = '<table '.$tableoptions.'>' ;
foreach($data as $key => $item){
if(is_array($item)){
$text.=array2tr($item,$troptions,$tdoptions) ;
} else {
$text.= '<tr '.$troptions.'>' ;
$text.= '<td '.$tdoptions.'>'.$key.'</td>' ;
$text.= '<td '.$tdoptions.'>'.$item.'</td>' ;
$text.= '</tr>' ;
}
}
if($tableMarkup) $text.= '</table>' ;
return $text ;
}
/**
* \brief Return lines of an html table from an array
*/
function array2tr($data,$troptions='',$tdoptions=''){
$text = '<tr '.$troptions.'>' ;
foreach($data as $key => $item){
$text.= '<td '.$tdoptions.'>'.$item.'</td>' ;
}
$text.= '</tr>' ;
return $text ;
}
/** /**
* \brief Check if a string is in UTF8 * \brief Check if a string is in UTF8
@ -3194,25 +2814,4 @@ function utf8_check($Str)
} }
/**
* \brief Search for prospect state selection in $_GET, $_POST, and $_REQUEST
* \return prospect state selection (array of prospect_state_id => 'true'/'false')
* \author Matelli (www.matelli.fr)
* \remarks See http://matelli.fr/showcases/patchs-dolibarr/add-icons-for-prospect-status.html for details
*/
function get_prospect_state_selection()
{
$sts = array(-1,0,1,2,3);
if (isSet($_POST["nouvel_etat"]))
return $_POST["nouvel_etat"];
else if (isSet($_GET["nouvel_etat"]))
return $_GET["nouvel_etat"];
else if (isSet($_REQUEST["nouvel_etat"]))
return $_REQUEST["nouvel_etat"];
else
return false;
}
?> ?>

View File

@ -20,12 +20,45 @@
/** /**
* \file htdocs/lib/functions2.lib.php * \file htdocs/lib/functions2.lib.php
* \brief Ensemble de fonctions de base de dolibarr sous forme d'include. * \brief A set of functions for Dolibarr
* This file contains rare functions. * This file contains all rare functions.
* \version $Id$ * \version $Id$
*/ */
/**
* \brief Return lines of an html table from an array
* \remarks Used by array2table function only
*/
function array2tr($data,$troptions='',$tdoptions=''){
$text = '<tr '.$troptions.'>' ;
foreach($data as $key => $item){
$text.= '<td '.$tdoptions.'>'.$item.'</td>' ;
}
$text.= '</tr>' ;
return $text ;
}
/**
* \brief Return an html table from an array
*/
function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions=''){
$text='' ;
if($tableMarkup) $text = '<table '.$tableoptions.'>' ;
foreach($data as $key => $item){
if(is_array($item)){
$text.=array2tr($item,$troptions,$tdoptions) ;
} else {
$text.= '<tr '.$troptions.'>' ;
$text.= '<td '.$tdoptions.'>'.$key.'</td>' ;
$text.= '<td '.$tdoptions.'>'.$item.'</td>' ;
$text.= '</tr>' ;
}
}
if($tableMarkup) $text.= '</table>' ;
return $text ;
}
/** /**
* Return next value for a mask * Return next value for a mask
@ -224,4 +257,185 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='',$date=
dolibarr_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); dolibarr_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG);
return $numFinal; return $numFinal;
} }
/**
* \brief Convert a binary data to string that represent hexadecimal value
* \param bin Value to convert
* \param pad Add 0
* \param upper Convert to tupper
* \return string x
*/
function binhex($bin, $pad=false, $upper=false)
{
$last = strlen($bin)-1;
for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2,$i); }
$x = dechex($x);
if($pad){ while(strlen($x) < intval(strlen($bin))/4){ $x = "0$x"; } }
if($upper){ $x = strtoupper($x); }
return $x;
}
/**
* \brief Convertir de l'hexadecimal en binaire
* \param string hexa
* \return string bin
*/
function hexbin($hexa)
{
$bin='';
for($i=0;$i<strlen($hexa);$i++)
{
$bin.=str_pad(decbin(hexdec($hexa{$i})),4,'0',STR_PAD_LEFT);
}
return $bin;
}
/**
* \brief Return if a filename is file name of a supported image format
* \param file Filename
* \return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported
*/
function image_format_supported($file)
{
// Case filename is not a format image
if (! eregi('(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$',$file,$reg)) return -1;
// Case filename is a format image but not supported by this PHP
$imgfonction='';
if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif';
if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng';
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
if ($imgfonction)
{
if (! function_exists($imgfonction))
{
// Fonctions de conversion non presente dans ce PHP
return 0;
}
}
// Filename is a format image and supported by this PHP
return 1;
}
/**
* \brief Retourne le numero de la semaine par rapport a une date
* \param time Date au format 'timestamp'
* \return int Numero de semaine
*/
function numero_semaine($time)
{
$stime = strftime('%Y-%m-%d',$time);
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?',$stime,$reg))
{
// Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
$annee = $reg[1];
$mois = $reg[2];
$jour = $reg[3];
}
/*
* Norme ISO-8601:
* - La semaine 1 de toute ann<EFBFBD>e est celle qui contient le 4 janvier ou que la semaine 1 de toute ann<EFBFBD>e est celle qui contient le 1er jeudi de janvier.
* - La majorit<EFBFBD> des ann<EFBFBD>es ont 52 semaines mais les ann<EFBFBD>es qui commence un jeudi et les ann<EFBFBD>es bissextiles commen<EFBFBD>ant un mercredi en poss<EFBFBD>de 53.
* - Le 1er jour de la semaine est le Lundi
*/
// D<>finition du Jeudi de la semaine
if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60;
else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60;
else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
else // Jeudi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee);
// D<>finition du premier Jeudi de l'ann<6E>e
if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60;
}
else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60;
}
else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60;
}
else // Jeudi
{
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine));
}
// D<>finition du num<75>ro de semaine: nb de jours entre "premier Jeudi de l'ann<6E>e" et "Jeudi de la semaine";
$numeroSemaine = (
(
date("z",mktime(12,0,0,date("m",$jeudiSemaine),date("d",$jeudiSemaine),date("Y",$jeudiSemaine)))
-
date("z",mktime(12,0,0,date("m",$premierJeudiAnnee),date("d",$premierJeudiAnnee),date("Y",$premierJeudiAnnee)))
) / 7
) + 1;
// Cas particulier de la semaine 53
if ($numeroSemaine==53)
{
// Les ann<6E>es qui commence un Jeudi et les ann<6E>es bissextiles commen<65>ant un Mercredi en poss<73>de 53
if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365))
{
$numeroSemaine = 53;
}
else
{
$numeroSemaine = 1;
}
}
//echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."<BR>";
return sprintf("%02d",$numeroSemaine);
}
/**
* \brief Convertit une masse d'une unite vers une autre unite
* \param weight float Masse a convertir
* \param from_unit int Unite originale en puissance de 10
* \param to_unit int Nouvelle unite en puissance de 10
* \return float Masse convertie
*/
function weight_convert($weight,&$from_unit,$to_unit)
{
/* Pour convertire 320 gr en Kg appeler
* $f = -3
* weigh_convert(320, $f, 0) retournera 0.32
*
*/
while ($from_unit <> $to_unit)
{
if ($from_unit > $to_unit)
{
$weight = $weight * 10;
$from_unit = $from_unit - 1;
$weight = weight_convert($weight,$from_unit, $to_unit);
}
if ($from_unit < $to_unit)
{
$weight = $weight / 10;
$from_unit = $from_unit + 1;
$weight = weight_convert($weight,$from_unit, $to_unit);
}
}
return $weight;
}

View File

@ -39,6 +39,8 @@
*/ */
function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50) function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50)
{ {
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
global $conf,$langs; global $conf,$langs;
dolibarr_syslog("functions.inc::vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality); dolibarr_syslog("functions.inc::vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality);

View File

@ -257,4 +257,46 @@ function show_stats_for_company($product,$socid)
} }
/**
* \brief Renvoi le texte d'une unite
* \param int Unit
* \param measuring_style Le style de mesure : weight, volume,...
* \return string Unite
* \TODO gerer les autres unites de mesure comme la livre, le gallon, le litre, ...
*/
function measuring_units_string($unit,$measuring_style='')
{
/* Note Rodo aux dev :)
* Ne pas ins<EFBFBD>rer dans la base de donn<EFBFBD>es ces valeurs
* cela surchagerait inutilement d'une requete suppl<EFBFBD>mentaire
* pour quelque chose qui est somme toute peu variable
*/
global $langs;
if ($measuring_style == 'weight')
{
$measuring_units[3] = $langs->trans("WeightUnitton");
$measuring_units[0] = $langs->trans("WeightUnitkg");
$measuring_units[-3] = $langs->trans("WeightUnitg");
$measuring_units[-6] = $langs->trans("WeightUnitmg");
}
else if ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->trans("VolumeUnitm3");
$measuring_units[-3] = $langs->trans("VolumeUnitdm3");
$measuring_units[-6] = $langs->trans("VolumeUnitcm3");
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
}
else if ($measuring_style == 'size')
{
$measuring_units[0] = $langs->trans("SizeUnitm");
$measuring_units[-1] = $langs->trans("SizeUnitdm");
$measuring_units[-2] = $langs->trans("SizeUnitcm");
$measuring_units[-3] = $langs->trans("SizeUnitmm");
}
return $measuring_units[$unit];
}
?> ?>

View File

@ -19,12 +19,29 @@
*/ */
/** /**
\file htdocs/lib/excel.lib.php * \file htdocs/lib/viewfiles.lib.php
\brief Ensemble de fonctions de base de dolibarr sous forme d'include * \brief Set of function to view file content
\version $Id$ * \version $Id$
*/ */
/**
*
*/
function make_alpha_from_numbers($number)
{
$numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if($number<strlen($numeric))
{
return $numeric[$number];
}
else
{
$dev_by = floor($number/strlen($numeric));
return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*strlen($numeric)));
}
}
/** /**
* \brief Affiche le contenu d'un fichier CSV sous forme de tableau * \brief Affiche le contenu d'un fichier CSV sous forme de tableau
* \param file_to_include Fichier CSV a afficher * \param file_to_include Fichier CSV a afficher

View File

@ -315,7 +315,7 @@ if ($_GET["action"] == 'create')
// Stock // Stock
if ($stock < $quantite_a_livrer) if ($stock < $quantite_a_livrer)
{ {
print '<td align="center">'.$stock.' '.img_alerte().'</td>'; print '<td align="center">'.$stock.' '.img_warning().'</td>';
} }
else else
{ {
@ -324,7 +324,7 @@ if ($_GET["action"] == 'create')
} }
else else
{ {
// Quantit<EFBFBD> <20> livrer // Quantite a livrer
print '<td align="center">'; print '<td align="center">';
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">'; print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">'; print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';

View File

@ -386,7 +386,7 @@ if ($_GET["id"] || $_GET["ref"])
if ($user->rights->produit->creer) if ($user->rights->produit->creer)
{ {
print '<a href="fournisseurs.php?id='.$product->id.'&amp;socid='.$objp->socid.'&amp;action=add_price&amp;rowid='.$objp->rowid.'">'.img_edit()."</a>"; print '<a href="fournisseurs.php?id='.$product->id.'&amp;socid='.$objp->socid.'&amp;action=add_price&amp;rowid='.$objp->rowid.'">'.img_edit()."</a>";
print '<a href="fournisseurs.php?id='.$product->id.'&amp;socid='.$objp->socid.'&amp;action=remove_pf&amp;rowid='.$objp->rowid.'">'.img_disable($langs->trans("Remove")).'</a>'; print '<a href="fournisseurs.php?id='.$product->id.'&amp;socid='.$objp->socid.'&amp;action=remove_pf&amp;rowid='.$objp->rowid.'">'.img_picto($langs->trans("Remove"),'disable.png').'</a>';
} }
print '</td>'; print '</td>';