2
0
forked from Wavyzz/dolibarr

Corrige comptage dans suppression recursive

This commit is contained in:
Laurent Destailleur
2006-11-11 15:52:17 +00:00
parent bf95f8142a
commit ac6f085ced
3 changed files with 99 additions and 99 deletions

View File

@@ -47,7 +47,9 @@ $form = new Form($db);
print_fiche_titre($langs->trans("SystemToolsArea"),'','setup'); print_fiche_titre($langs->trans("SystemToolsArea"),'','setup');
print "<br>"; //print "<br>";
print info_admin($langs->trans("SystemAreaForAdminOnly")).'<br>';
if ($message) print $message.'<br>'; if ($message) print $message.'<br>';

View File

@@ -68,7 +68,7 @@ if ($_POST["action"]=='purge')
foreach($filesarray as $key => $value) foreach($filesarray as $key => $value)
{ {
//print "x ".$filesarray[$key]['fullname']."<br>\n"; //print "x ".$filesarray[$key]['fullname']."<br>\n";
$count=dol_delete_dir_recursive($filesarray[$key]['fullname']); $count+=dol_delete_dir_recursive($filesarray[$key]['fullname']);
} }
} }

View File

@@ -70,7 +70,7 @@ function versioncompare($versionarray1,$versionarray2)
if ($operande1 < $operande2) { $ret = -1; break; } if ($operande1 < $operande2) { $ret = -1; break; }
if ($operande1 > $operande2) { $ret = 1; break; } if ($operande1 > $operande2) { $ret = 1; break; }
$i++; $i++;
} }
return $ret; return $ret;
} }
@@ -143,8 +143,8 @@ function unaccent($str)
*/ */
function sanitize_string($str) function sanitize_string($str)
{ {
$forbidden_chars_to_underscore=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); $forbidden_chars_to_underscore=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
//$forbidden_chars_to_remove=array("(",")"); //$forbidden_chars_to_remove=array("(",")");
$forbidden_chars_to_remove=array(); $forbidden_chars_to_remove=array();
return str_replace($forbidden_chars_to_underscore,"_",str_replace($forbidden_chars_to_remove,"",$str)); return str_replace($forbidden_chars_to_underscore,"_",str_replace($forbidden_chars_to_remove,"",$str));
} }
@@ -166,14 +166,14 @@ function sanitize_string($str)
function dolibarr_syslog($message, $level=LOG_INFO) function dolibarr_syslog($message, $level=LOG_INFO)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
if ($conf->syslog->enabled) if ($conf->syslog->enabled)
{ {
// Change this to LOg_DEBUG to see all messages on *nix // Change this to LOg_DEBUG to see all messages on *nix
$level_maximum = LOG_INFO; $level_maximum = LOG_INFO;
if ($level > $level_maximum) return; if ($level > $level_maximum) return;
// Ajout user a la log // Ajout user a la log
$login='???'; $login='???';
if (is_object($user) && $user->id) $login=$user->login; if (is_object($user) && $user->id) $login=$user->login;
@@ -197,7 +197,7 @@ function dolibarr_syslog($message, $level=LOG_INFO)
else else
{ {
//define_syslog_variables(); d<>j<EFBFBD> d<>finit dans master.inc.php //define_syslog_variables(); d<>j<EFBFBD> d<>finit dans master.inc.php
if (defined("MAIN_SYSLOG_FACILITY") && MAIN_SYSLOG_FACILITY) if (defined("MAIN_SYSLOG_FACILITY") && MAIN_SYSLOG_FACILITY)
{ {
$facility = MAIN_SYSLOG_FACILITY; $facility = MAIN_SYSLOG_FACILITY;
@@ -211,9 +211,9 @@ function dolibarr_syslog($message, $level=LOG_INFO)
{ {
$facility = LOG_USER; $facility = LOG_USER;
} }
openlog("dolibarr", LOG_PID | LOG_PERROR, $facility); openlog("dolibarr", LOG_PID | LOG_PERROR, $facility);
if (! $level) if (! $level)
{ {
syslog(LOG_ERR, $message); syslog(LOG_ERR, $message);
@@ -222,7 +222,7 @@ function dolibarr_syslog($message, $level=LOG_INFO)
{ {
syslog($level, $message); syslog($level, $message);
} }
closelog(); closelog();
} }
} }
@@ -245,7 +245,7 @@ function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
{ {
$limittitle=30; $limittitle=30;
print '<a class="tabTitle">'; print '<a class="tabTitle">';
print print
((!defined('MAIN_USE_SHORT_TITLE')) || (defined('MAIN_USE_SHORT_TITLE') && MAIN_USE_SHORT_TITLE)) ((!defined('MAIN_USE_SHORT_TITLE')) || (defined('MAIN_USE_SHORT_TITLE') && MAIN_USE_SHORT_TITLE))
? dolibarr_trunc($title,$limittitle) ? dolibarr_trunc($title,$limittitle)
: $title; : $title;
@@ -275,7 +275,7 @@ function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
} }
print "</div>\n"; print "</div>\n";
if (! $notab) print '<div class="tabBar">'."\n\n"; if (! $notab) print '<div class="tabBar">'."\n\n";
} }
@@ -289,11 +289,11 @@ function dolibarr_fiche_head($links, $active='0', $title='', $notab=0)
function dolibarr_get_const($db, $name) function dolibarr_get_const($db, $name)
{ {
$value=''; $value='';
$sql ="SELECT value"; $sql ="SELECT value";
$sql.=" FROM llx_const"; $sql.=" FROM llx_const";
$sql.=" WHERE name = '$name';"; $sql.=" WHERE name = '$name';";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$obj=$db->fetch_object($resql); $obj=$db->fetch_object($resql);
@@ -317,22 +317,22 @@ function dolibarr_get_const($db, $name)
function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='') function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='')
{ {
global $conf; global $conf;
$db->begin(); $db->begin();
if (! $name) if (! $name)
{ {
dolibarr_print_error("Error: Call to function dolibarr_set_const with wrong parameters"); dolibarr_print_error("Error: Call to function dolibarr_set_const with wrong parameters");
exit; exit;
} }
//dolibarr_syslog("dolibarr_set_const name=$name, value=$value"); //dolibarr_syslog("dolibarr_set_const name=$name, value=$value");
$sql = "DELETE FROM llx_const WHERE name = '$name';"; $sql = "DELETE FROM llx_const WHERE name = '$name';";
$resql=$db->query($sql); $resql=$db->query($sql);
$sql = "INSERT INTO llx_const(name,value,type,visible,note)"; $sql = "INSERT INTO llx_const(name,value,type,visible,note)";
$sql.= " VALUES ('$name','".addslashes($value)."','$type',$visible,'".addslashes($note)."');"; $sql.= " VALUES ('$name','".addslashes($value)."','$type',$visible,'".addslashes($note)."');";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@@ -382,7 +382,7 @@ function dolibarr_del_const($db, $name)
function dolibarr_set_user_page_param($db, &$user, $url='', $tab) function dolibarr_set_user_page_param($db, &$user, $url='', $tab)
{ {
$db->begin(); $db->begin();
// On efface param<61>tres anciens // On efface param<61>tres anciens
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE fk_user = ".$user->id; $sql.= " WHERE fk_user = ".$user->id;
@@ -428,7 +428,7 @@ function dolibarr_set_user_page_param($db, &$user, $url='', $tab)
function dolibarr_print_ca($ca) function dolibarr_print_ca($ca)
{ {
global $langs,$conf; global $langs,$conf;
if ($ca > 1000) if ($ca > 1000)
{ {
$cat = round(($ca / 1000),2); $cat = round(($ca / 1000),2);
@@ -479,7 +479,7 @@ function dolibarr_time_plus_duree($time,$duration_value,$duration_unit)
function dolibarr_print_date($time,$format='') function dolibarr_print_date($time,$format='')
{ {
global $conf; global $conf;
// Si format non d<>fini, on prend $conf->format_date_text_short // Si format non d<>fini, on prend $conf->format_date_text_short
if (! $format) $format=$conf->format_date_text_short; if (! $format) $format=$conf->format_date_text_short;
@@ -527,22 +527,22 @@ function dolibarr_print_object_info($object)
{ {
global $langs; global $langs;
$langs->load("other"); $langs->load("other");
if (isset($object->user_creation) && $object->user_creation->fullname) if (isset($object->user_creation) && $object->user_creation->fullname)
print $langs->trans("CreatedBy")." : " . $object->user_creation->fullname . '<br>'; print $langs->trans("CreatedBy")." : " . $object->user_creation->fullname . '<br>';
if (isset($object->date_creation)) if (isset($object->date_creation))
print $langs->trans("DateCreation")." : " . dolibarr_print_date($object->date_creation,"%A %d %B %Y %H:%M:%S") . '<br>'; print $langs->trans("DateCreation")." : " . dolibarr_print_date($object->date_creation,"%A %d %B %Y %H:%M:%S") . '<br>';
if (isset($object->user_modification) && $object->user_modification->fullname) if (isset($object->user_modification) && $object->user_modification->fullname)
print $langs->trans("ModifiedBy")." : " . $object->user_modification->fullname . '<br>'; print $langs->trans("ModifiedBy")." : " . $object->user_modification->fullname . '<br>';
if (isset($object->date_modification)) if (isset($object->date_modification))
print $langs->trans("DateLastModification")." : " . dolibarr_print_date($object->date_modification,"%A %d %B %Y %H:%M:%S") . '<br>'; print $langs->trans("DateLastModification")." : " . dolibarr_print_date($object->date_modification,"%A %d %B %Y %H:%M:%S") . '<br>';
if (isset($object->user_validation) && $object->user_validation->fullname) if (isset($object->user_validation) && $object->user_validation->fullname)
print $langs->trans("ValidatedBy")." : " . $object->user_validation->fullname . '<br>'; print $langs->trans("ValidatedBy")." : " . $object->user_validation->fullname . '<br>';
if (isset($object->date_validation)) if (isset($object->date_validation))
print $langs->trans("DateValidation")." : " . dolibarr_print_date($object->date_validation,"%A %d %B %Y %H:%M:%S") . '<br>'; print $langs->trans("DateValidation")." : " . dolibarr_print_date($object->date_validation,"%A %d %B %Y %H:%M:%S") . '<br>';
@@ -694,7 +694,7 @@ function img_statut($num,$alt = "default")
if ($num == 1) $alt=$langs->trans("Late"); if ($num == 1) $alt=$langs->trans("Late");
if ($num == 4) $alt=$langs->trans("Running"); if ($num == 4) $alt=$langs->trans("Running");
if ($num == 5) $alt=$langs->trans("Closed"); if ($num == 5) $alt=$langs->trans("Closed");
} }
return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/statut'.$num.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; return '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/statut'.$num.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
} }
@@ -860,7 +860,7 @@ function img_warning($alt = "default",$float=0)
$img='<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/warning.png" border="0" alt="'.$alt.'" title="'.$alt.'"'; $img='<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/warning.png" border="0" alt="'.$alt.'" title="'.$alt.'"';
if ($float) $img.=' style="float: right"'; if ($float) $img.=' style="float: right"';
$img.='>'; $img.='>';
return $img; return $img;
} }
@@ -1052,22 +1052,22 @@ function dol_loginfunction($notused,$pearstatus)
global $langs,$conf; global $langs,$conf;
$langs->load("main"); $langs->load("main");
$langs->load("other"); $langs->load("other");
$conf->css = "theme/".$conf->theme."/".$conf->theme.".css"; $conf->css = "theme/".$conf->theme."/".$conf->theme.".css";
// Si feuille de style en php existe // Si feuille de style en php existe
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php"; if (file_exists(DOL_DOCUMENT_ROOT.'/'.$conf->css.".php")) $conf->css.=".php";
// Ce DTD est KO car inhibe document.body.scrollTop // Ce DTD est KO car inhibe document.body.scrollTop
//print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; //print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
// Ce DTD est OK // Ce DTD est OK
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
print "\n<html><head><title>Dolibarr Authentification</title>\n"; print "\n<html><head><title>Dolibarr Authentification</title>\n";
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/'.$conf->css.'">'."\n"; print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/'.$conf->css.'">'."\n";
print '<style type="text/css">'."\n"; print '<style type="text/css">'."\n";
print '<!--'."\n"; print '<!--'."\n";
print '#login {'; print '#login {';
@@ -1096,17 +1096,17 @@ function dol_loginfunction($notused,$pearstatus)
print "}\n"; print "}\n";
print '</script>'."\n"; print '</script>'."\n";
print '</head>'."\n"; print '</head>'."\n";
print '<body class="body" onload="donnefocus();">'; print '<body class="body" onload="donnefocus();">';
print '<form id="login" name="login" method="post" action="'; print '<form id="login" name="login" method="post" action="';
print $_SERVER['PHP_SELF']; print $_SERVER['PHP_SELF'];
print $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:''; print $_SERVER["QUERY_STRING"]?'?'.$_SERVER["QUERY_STRING"]:'';
print '">'; print '">';
print '<table cellpadding="0" cellspacing="0" border="0" align="center" width="350">'; print '<table cellpadding="0" cellspacing="0" border="0" align="center" width="350">';
if (file_exists(DOL_DOCUMENT_ROOT.'/logo.png')) if (file_exists(DOL_DOCUMENT_ROOT.'/logo.png'))
{ {
print '<tr><td colspan="3" style="text-align:center;">'; print '<tr><td colspan="3" style="text-align:center;">';
@@ -1116,7 +1116,7 @@ function dol_loginfunction($notused,$pearstatus)
{ {
print '<tr class="vmenu"><td align="center">Dolibarr '.DOL_VERSION.'</td></tr>'; print '<tr class="vmenu"><td align="center">Dolibarr '.DOL_VERSION.'</td></tr>';
} }
print'</table> print'</table>
<br> <br>
@@ -1134,7 +1134,7 @@ function dol_loginfunction($notused,$pearstatus)
{ {
print '<td rowspan="2"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png"></td>'; print '<td rowspan="2"><img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/login_logo.png"></td>';
} }
else else
{ {
print '<td rowspan="2"><img src="'.DOL_URL_ROOT.'/theme/login_logo.png"></td>'; print '<td rowspan="2"><img src="'.DOL_URL_ROOT.'/theme/login_logo.png"></td>';
} }
@@ -1185,7 +1185,7 @@ function accessforbidden($message='')
{ {
global $user, $langs; global $user, $langs;
$langs->load("other"); $langs->load("other");
llxHeader(); llxHeader();
print '<div class="error">'; print '<div class="error">';
if (! $message) print $langs->trans("ErrorForbidden"); if (! $message) print $langs->trans("ErrorForbidden");
@@ -1223,7 +1223,7 @@ function dolibarr_print_error($db='',$msg='')
{ {
global $langs; global $langs;
$syslog = ''; $syslog = '';
// Si erreur intervenue avant chargement langue // Si erreur intervenue avant chargement langue
if (! $langs) if (! $langs)
{ {
@@ -1231,12 +1231,12 @@ function dolibarr_print_error($db='',$msg='')
$langs = new Translate(DOL_DOCUMENT_ROOT ."/langs", "en_US"); $langs = new Translate(DOL_DOCUMENT_ROOT ."/langs", "en_US");
} }
$langs->load("main"); $langs->load("main");
if ($_SERVER['DOCUMENT_ROOT']) // Mode web if ($_SERVER['DOCUMENT_ROOT']) // Mode web
{ {
print $langs->trans("DolibarrHasDetectedError").".<br>\n"; print $langs->trans("DolibarrHasDetectedError").".<br>\n";
print $langs->trans("InformationToHelpDiagnose").":<br><br>\n"; print $langs->trans("InformationToHelpDiagnose").":<br><br>\n";
print "<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";; print "<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";;
print "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";; print "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";;
print "<b>".$langs->trans("RequestedUrl").":</b> ".$_SERVER["REQUEST_URI"]."<br>\n";; print "<b>".$langs->trans("RequestedUrl").":</b> ".$_SERVER["REQUEST_URI"]."<br>\n";;
@@ -1247,11 +1247,11 @@ function dolibarr_print_error($db='',$msg='')
} }
else // Mode CLI else // Mode CLI
{ {
print $langs->trans("ErrorInternalErrorDetected")."\n"; print $langs->trans("ErrorInternalErrorDetected")."\n";
$syslog.="pid=".getmypid(); $syslog.="pid=".getmypid();
} }
if (is_object($db)) if (is_object($db))
{ {
if ($_SERVER['DOCUMENT_ROOT']) // Mode web if ($_SERVER['DOCUMENT_ROOT']) // Mode web
@@ -1268,12 +1268,12 @@ function dolibarr_print_error($db='',$msg='')
print $langs->trans("RequestLastAccessInError").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."\n"; print $langs->trans("RequestLastAccessInError").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."\n";
print $langs->trans("ReturnCodeLastAccess").":\n".$db->errno()."\n"; print $langs->trans("ReturnCodeLastAccess").":\n".$db->errno()."\n";
print $langs->trans("InformationLastAccess").":\n".$db->error()."\n"; print $langs->trans("InformationLastAccess").":\n".$db->error()."\n";
} }
$syslog.=", sql=".$db->lastquery(); $syslog.=", sql=".$db->lastquery();
$syslog.=", db_error=".$db->error(); $syslog.=", db_error=".$db->error();
} }
if ($msg) { if ($msg) {
if ($_SERVER['DOCUMENT_ROOT']) // Mode web if ($_SERVER['DOCUMENT_ROOT']) // Mode web
{ {
@@ -1285,7 +1285,7 @@ function dolibarr_print_error($db='',$msg='')
} }
$syslog.=", msg=".$msg; $syslog.=", msg=".$msg;
} }
dolibarr_syslog("Error $syslog"); dolibarr_syslog("Error $syslog");
} }
@@ -1299,7 +1299,7 @@ function dolibarr_print_error($db='',$msg='')
function doliMoveFileUpload($src_file, $dest_file) function doliMoveFileUpload($src_file, $dest_file)
{ {
$file_name = $dest_file; $file_name = $dest_file;
// On renomme les fichiers avec extentio executable car si on a mis le rep // On renomme les fichiers avec extentio executable car si on a mis le rep
// documents dans un rep de la racine web (pas bien), cela permet d'executer // documents dans un rep de la racine web (pas bien), cela permet d'executer
// du code a la demande. // du code a la demande.
@@ -1307,7 +1307,7 @@ function doliMoveFileUpload($src_file, $dest_file)
{ {
$file_name.= '.txt'; $file_name.= '.txt';
} }
return move_uploaded_file($src_file, $file_name); return move_uploaded_file($src_file, $file_name);
} }
@@ -1387,7 +1387,7 @@ function transcoS2L($zonein,$devise)
$i++; $i++;
} // fin initialise la table (fin) } // fin initialise la table (fin)
// echo "Pour une valeur en entr<74>e = $zonein<br>"; //pour ceux qui ne croient que ce qu'ils voient ! // echo "Pour une valeur en entr<74>e = $zonein<br>"; //pour ceux qui ne croient que ce qu'ils voient !
// quelques petits controles s'imposent !! // quelques petits controles s'imposent !!
$valid = "[a-zA-Z\&\<EFBFBD>\"\'\(\-\<EFBFBD>\_\<EFBFBD>\<EFBFBD>\)\=\;\:\!\*\$\^\<\>]"; $valid = "[a-zA-Z\&\<EFBFBD>\"\'\(\-\<EFBFBD>\_\<EFBFBD>\<EFBFBD>\)\=\;\:\!\*\$\^\<\>]";
if (ereg($valid,$zonein)) if (ereg($valid,$zonein))
{ {
@@ -1622,14 +1622,12 @@ function dol_delete_dir($dir)
} }
/** /**
\brief Effacement d'un r<>pertoire et son arborescence \brief Effacement d'un r<>pertoire $dir et de son arborescence
\param file R<>pertoire a effacer \param file R<>pertoire a effacer
\return int Nombre de fichier+rep<65>rtoires supprim<69>s \return int Nombre de fichier+rep<65>rtoires supprim<69>s
*/ */
function dol_delete_dir_recursive($dir) function dol_delete_dir_recursive($dir,$count=0)
{ {
$count=0;
if ($handle = opendir("$dir")) if ($handle = opendir("$dir"))
{ {
while (false !== ($item = readdir($handle))) while (false !== ($item = readdir($handle)))
@@ -1638,13 +1636,13 @@ function dol_delete_dir_recursive($dir)
{ {
if (is_dir("$dir/$item")) if (is_dir("$dir/$item"))
{ {
dol_delete_dir_recursive("$dir/$item"); $count=dol_delete_dir_recursive("$dir/$item",$count);
} }
else else
{ {
unlink("$dir/$item"); unlink("$dir/$item");
$count++; $count++;
//echo " removing $dir/$item<br>\n"; //echo " removing $dir/$item<br>\n";
} }
} }
} }
@@ -1653,7 +1651,7 @@ function dol_delete_dir_recursive($dir)
$count++; $count++;
//echo "removing $dir<br>\n"; //echo "removing $dir<br>\n";
} }
//echo "return=".$count; //echo "return=".$count;
return $count; return $count;
} }
@@ -1744,13 +1742,13 @@ function print_fleche_navigation($page,$file,$options='',$nextpage)
function price($amount, $html=0, $outlangs='') function price($amount, $html=0, $outlangs='')
{ {
global $langs; global $langs;
// Separateurs par defaut // Separateurs par defaut
$dec='.'; $thousand=' '; $dec='.'; $thousand=' ';
// Si $outlangs non force, on prend langue utilisateur // Si $outlangs non force, on prend langue utilisateur
if (! is_object($outlangs)) $outlangs=$langs; if (! is_object($outlangs)) $outlangs=$langs;
if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal"); if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand"); if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
//print "x".$langs->trans("SeparatorThousand")."x"; //print "x".$langs->trans("SeparatorThousand")."x";
@@ -1797,20 +1795,20 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit)
dolibarr_syslog("get_default_tva vendeur_assujeti=$societe_vendeuse->tva_assuj pays_vendeur=$societe_vendeuse->pays_id, pays_acheteur=$societe_acheteuse->pays_id, taux_produit=$taux_produit"); dolibarr_syslog("get_default_tva vendeur_assujeti=$societe_vendeuse->tva_assuj pays_vendeur=$societe_vendeuse->pays_id, pays_acheteur=$societe_acheteuse->pays_id, taux_produit=$taux_produit");
if (!is_object($societe_vendeuse)) return 0; if (!is_object($societe_vendeuse)) return 0;
// Si vendeur non assujeti <20> TVA (tva_assuj vaut 0/1 ou franchise/reel) // Si vendeur non assujeti <20> TVA (tva_assuj vaut 0/1 ou franchise/reel)
if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0; if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0;
if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') return 0; if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') return 0;
// Si le (pays vendeur = pays acheteur) alors la TVA par d<>faut=TVA du produit vendu. Fin de r<>gle. // Si le (pays vendeur = pays acheteur) alors la TVA par d<>faut=TVA du produit vendu. Fin de r<>gle.
if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && $societe_acheteuse->tva_assuj == 1) if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && $societe_acheteuse->tva_assuj == 1)
{ {
return $taux_produit; return $taux_produit;
} }
// Si vendeur et acheteur dans Communaut<75> europ<6F>enne et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par d<>faut=0 (La TVA doit <20>tre pay<61> par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de r<>gle. // Si vendeur et acheteur dans Communaut<75> europ<6F>enne et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par d<>faut=0 (La TVA doit <20>tre pay<61> par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de r<>gle.
// Non g<>r<EFBFBD> // Non g<>r<EFBFBD>
// Si vendeur et acheteur dans Communaut<75> europ<6F>enne et bien vendu autre que transport neuf alors la TVA par d<>faut=TVA du produit vendu. Fin de r<>gle. // Si vendeur et acheteur dans Communaut<75> europ<6F>enne et bien vendu autre que transport neuf alors la TVA par d<>faut=TVA du produit vendu. Fin de r<>gle.
if (is_object($societe_acheteuse) && ($societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC()) && $societe_acheteuse->tva_assuj == 1) if (is_object($societe_acheteuse) && ($societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC()) && $societe_acheteuse->tva_assuj == 1)
{ {
@@ -1831,7 +1829,7 @@ function yn($yesno, $case=1) {
global $langs; global $langs;
if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0 if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0
return $case?$langs->trans("Yes"):$langs->trans("yes"); return $case?$langs->trans("Yes"):$langs->trans("yes");
if ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') if ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false')
return $case?$langs->trans("No"):$langs->trans("no"); return $case?$langs->trans("No"):$langs->trans("no");
return "unknown"; return "unknown";
} }
@@ -1951,7 +1949,7 @@ function create_exdir($dir)
dolibarr_syslog("functions.inc.php::create_exdir: dir=$dir"); dolibarr_syslog("functions.inc.php::create_exdir: dir=$dir");
if (@is_dir($dir)) return 0; if (@is_dir($dir)) return 0;
$nberr=0; $nberr=0;
$nbcreated=0; $nbcreated=0;
@@ -2009,20 +2007,20 @@ function create_exdir($dir)
function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="", $sortorder=SORT_ASC) function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="", $sortorder=SORT_ASC)
{ {
dolibarr_syslog("functions.inc.php::dolibarr_dir_list $path"); dolibarr_syslog("functions.inc.php::dolibarr_dir_list $path");
if (! is_dir($path)) return array(); if (! is_dir($path)) return array();
if ($dir = opendir($path)) if ($dir = opendir($path))
{ {
$file_list = array(); $file_list = array();
while (false !== ($file = readdir($dir))) while (false !== ($file = readdir($dir)))
{ {
$qualified=1; $qualified=1;
// Check if file is qualified // Check if file is qualified
if (eregi('^\.',$file)) $qualified=0; if (eregi('^\.',$file)) $qualified=0;
if ($excludefilter && eregi($excludefilter,$file)) $qualified=0; if ($excludefilter && eregi($excludefilter,$file)) $qualified=0;
// print "path=$path file=$file<br>\n"; // print "path=$path file=$file<br>\n";
if ($qualified) if ($qualified)
@@ -2033,7 +2031,7 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu
// Add entry into file_list array // Add entry into file_list array
if ($sortcriteria == 'date') $filedate=filemtime($path."/".$file); if ($sortcriteria == 'date') $filedate=filemtime($path."/".$file);
if ($sortcriteria == 'size') $filesize=filesize($path."/".$file); if ($sortcriteria == 'size') $filesize=filesize($path."/".$file);
if (! $filter || eregi($filter,$path.'/'.$file)) if (! $filter || eregi($filter,$path.'/'.$file))
{ {
$file_list[] = array( $file_list[] = array(
@@ -2043,7 +2041,7 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu
"size" => $filesize "size" => $filesize
); );
} }
// if we're in a directory and we want recursive behavior, call this function again // if we're in a directory and we want recursive behavior, call this function again
if ($recursive) if ($recursive)
{ {
@@ -2068,7 +2066,7 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu
} }
} }
closedir($dir); closedir($dir);
// Obtain a list of columns // Obtain a list of columns
$myarray=array(); $myarray=array();
foreach ($file_list as $key => $row) foreach ($file_list as $key => $row)
@@ -2076,10 +2074,10 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu
$myarray[$key] = $row[$sortcriteria]; $myarray[$key] = $row[$sortcriteria];
//$myarray2[$key] = $row['size']; //$myarray2[$key] = $row['size'];
} }
// Sort the data // Sort the data
array_multisort($myarray, $sortorder, $file_list); array_multisort($myarray, $sortorder, $file_list);
return $file_list; return $file_list;
} }
else else
@@ -2096,7 +2094,7 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu
function numero_semaine($time) function numero_semaine($time)
{ {
$stime = strftime( '%Y-%m-%d',$time); $stime = strftime( '%Y-%m-%d',$time);
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$stime,$reg)) if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$stime,$reg))
{ {
// Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
@@ -2104,14 +2102,14 @@ function numero_semaine($time)
$mois = $reg[2]; $mois = $reg[2];
$jour = $reg[3]; $jour = $reg[3];
} }
/* /*
* Norme ISO-8601: * Norme ISO-8601:
* - La semaine 1 de toute ann<6E>e est celle qui contient le 4 janvier ou que la semaine 1 de toute ann<6E>e est celle qui contient le 1er jeudi de janvier. * - La semaine 1 de toute ann<6E>e est celle qui contient le 4 janvier ou que la semaine 1 de toute ann<6E>e est celle qui contient le 1er jeudi de janvier.
* - La majorit<69> des ann<6E>es ont 52 semaines mais les ann<6E>es qui commence un jeudi et les ann<6E>es bissextiles commen<65>ant un mercredi en poss<73>de 53. * - La majorit<69> des ann<6E>es ont 52 semaines mais les ann<6E>es qui commence un jeudi et les ann<6E>es bissextiles commen<65>ant un mercredi en poss<73>de 53.
* - Le 1er jour de la semaine est le Lundi * - Le 1er jour de la semaine est le Lundi
*/ */
// D<>finition du Jeudi de la semaine // D<>finition du Jeudi de la semaine
if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60; $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60;
@@ -2121,7 +2119,7 @@ function numero_semaine($time)
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60; $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
else // Jeudi else // Jeudi
$jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee); $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee);
// D<>finition du premier Jeudi de l'ann<6E>e // D<>finition du premier Jeudi de l'ann<6E>e
if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche
{ {
@@ -2139,16 +2137,16 @@ function numero_semaine($time)
{ {
$premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine)); $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"; // 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 = ( $numeroSemaine = (
( (
date("z",mktime(12,0,0,date("m",$jeudiSemaine),date("d",$jeudiSemaine),date("Y",$jeudiSemaine))) 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))) date("z",mktime(12,0,0,date("m",$premierJeudiAnnee),date("d",$premierJeudiAnnee),date("Y",$premierJeudiAnnee)))
) / 7 ) / 7
) + 1; ) + 1;
// Cas particulier de la semaine 53 // Cas particulier de la semaine 53
if ($numeroSemaine==53) if ($numeroSemaine==53)
{ {
@@ -2162,9 +2160,9 @@ function numero_semaine($time)
$numeroSemaine = 1; $numeroSemaine = 1;
} }
} }
//echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."<BR>"; //echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."<BR>";
return sprintf("%02d",$numeroSemaine); return sprintf("%02d",$numeroSemaine);
} }