NEW Show also size in bytes in tooltip if visible unit is not bytes

This commit is contained in:
Laurent Destailleur
2018-04-15 17:58:13 +02:00
parent 8fbde88872
commit e2838aa074
5 changed files with 22 additions and 10 deletions

View File

@@ -990,6 +990,7 @@ class FormFile
global $user, $conf, $langs, $hookmanager; global $user, $conf, $langs, $hookmanager;
global $sortfield, $sortorder, $maxheightmini; global $sortfield, $sortorder, $maxheightmini;
global $dolibarr_main_url_root; global $dolibarr_main_url_root;
global $form;
// Define relative path used to store the file // Define relative path used to store the file
if (empty($relativepath)) if (empty($relativepath))
@@ -1034,6 +1035,8 @@ class FormFile
} }
else else
{ {
if (! is_object($form)) $form=new Form($this->db);
if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id; if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id;
$relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath); $relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath);
if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend); if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend);
@@ -1161,7 +1164,15 @@ class FormFile
print "</td>\n"; print "</td>\n";
// Size // Size
print '<td align="right" width="80px">'.dol_print_size($file['size'],1,1).'</td>'; $sizetoshow = dol_print_size($file['size'],1,1);
$sizetoshowbytes = dol_print_size($file['size'],0,1);
print '<td align="right" width="80px">';
if ($sizetoshow == $sizetoshowbytes) print $sizetoshow;
else {
print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
}
print '</td>';
// Date // Date
print '<td align="center" width="130px">'.dol_print_date($file['date'],"dayhour","tzuser").'</td>'; print '<td align="center" width="130px">'.dol_print_date($file['date'],"dayhour","tzuser").'</td>';

View File

@@ -2040,7 +2040,7 @@ function dol_now($mode='gmt')
* *
* @param int $size Size to print * @param int $size Size to print
* @param int $shortvalue Tell if we want long value to use another unit (Ex: 1.5Kb instead of 1500b) * @param int $shortvalue Tell if we want long value to use another unit (Ex: 1.5Kb instead of 1500b)
* @param int $shortunit Use short value of size unit * @param int $shortunit Use short label of size unit (for example 'b' instead of 'bytes')
* @return string Link * @return string Link
*/ */
function dol_print_size($size,$shortvalue=0,$shortunit=0) function dol_print_size($size,$shortvalue=0,$shortunit=0)

View File

@@ -75,9 +75,7 @@ class modVariants extends DolibarrModules
$this->dirs = array(); $this->dirs = array();
// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
$this->config_page_url = array( $this->config_page_url = array('admin.php@variants');
'admin.php@variants'
);
// Dependencies // Dependencies
$this->hidden = false; // A condition to hide module $this->hidden = false; // A condition to hide module

View File

@@ -295,7 +295,7 @@ if ($resql)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_products', 0, '', '', $limit);
$topicmail="Information"; $topicmail="Information";
$modelmail="productlot"; $modelmail="productlot";

View File

@@ -18,7 +18,7 @@
require '../main.inc.php'; require '../main.inc.php';
require DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; require DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
$id = GETPOST('id'); $id = GETPOST('id','int');
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
$object = new ProductAttribute($db); $object = new ProductAttribute($db);
@@ -57,9 +57,12 @@ $variants = $object->fetchAll();
llxHeader('', $title); llxHeader('', $title);
$buttonadd='<a href="create.php" class="butAction">'.$langs->trans('Create').'</a>'; $newcardbutton='';
if ($user->rights->produit->creer)
print load_fiche_titre($title, $buttonadd); {
$newcardbutton='<a href="create.php" class="butActionNew">'.$langs->trans('Create').'</a>';
}
print load_fiche_titre($title, $newcardbutton, 'title_products');
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1; $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
?> ?>