2
0
forked from Wavyzz/dolibarr

Use the new banner for first tab of products.

This commit is contained in:
Laurent Destailleur
2015-11-06 18:57:35 +01:00
parent 11f0cad2ab
commit d0e6db7f89
4 changed files with 106 additions and 80 deletions

View File

@@ -5157,7 +5157,7 @@ class Form
* To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria.
*
* @param object $object Object to show
* @param string $paramid Name of parameter to use to name the id into the URL link
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
* @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
@@ -5192,7 +5192,7 @@ class Form
$ret.='<div class="inline-block floatleft valignmiddle refid'.(($shownav && ($previous_ref || $next_ref))?' refidpadding':'').'">';
// For thirdparty and contact, the ref is he id, so we show something else
// For thirdparty and contact, the ref is the id, so we show something else
if ($object->element == 'societe')
{
$ret.=dol_htmlentities($object->name);
@@ -5360,7 +5360,7 @@ class Form
else
{
$nophoto='/public/theme/common/nophoto.png';
if (in_array($modulepart,array('userphoto','contact'))) // For module thar are "physical" users
if (in_array($modulepart,array('userphoto','contact'))) // For module that are "physical" users
{
$nophoto='/public/theme/common/user_anonymous.png';
if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png';

View File

@@ -854,7 +854,7 @@ function dol_get_fiche_end($notab=0)
* Show tab footer of a card
*
* @param object $object Object to show
* @param string $paramid Name of parameter to use to name the id into the URL link
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
* @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
@@ -870,28 +870,67 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{
global $conf, $form, $user, $langs;
//$showlogo=$object->logo;
$showlogo=1;
$maxvisiblephotos=1;
$showimage=1;
$showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0);
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$modulepart='societe';
$modulepart='unknown';
if ($object->element == 'societe') $modulepart='societe';
if ($object->element == 'contact') $modulepart='contact';
if ($object->element == 'member') $modulepart='memberphoto';
if ($object->element == 'user') $modulepart='userphoto';
if ($object->element == 'product') $modulepart='product';
print '<div class="arearef heightref valignmiddle" width="100%">';
if ($showlogo) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref').'</div>';
if ($object->element == 'product')
{
$width=80; $cssclass='photoref';
$showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
if ($conf->browser->phone) $maxvisiblephotos=1;
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],1,-$maxvisiblephotos,0,0,0,$width,0).'</div>';
else
{
$nophoto='/public/theme/common/nophoto.png';
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').($height?' height="'.$height.'"':'').' src="'.DOL_URL_ROOT.$nophoto.'"></div>';
}
}
else
{
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showphoto($modulepart,$object,0,0,0,'photoref','',1,0,$maxvisiblephotos).'</div>';
}
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlright.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
}
elseif ($object->element == 'product')
{
//$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Sell").') ';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlright.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else {
$morehtmlright.=$object->getLibStatut(2,0);
}
$morehtmlright.=' &nbsp; ';
//$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Buy").') ';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlright.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else {
$morehtmlright.=$object->getLibStatut(2,1);
}
}
else {
$morehtmlright.=$object->getLibStatut(2);
}
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>';
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; // For product
if ($object->element != 'product')
{
$morehtmlref.='<div class="refidno">';
$morehtmlref.=$object->getBannerAddress('refaddress',$object);
$morehtmlref.='</div>';
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member')))
}
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product')))
{
$morehtmlref.='<div style="clear: both;"></div><div class="refidno">';
$morehtmlref.=$langs->trans("TechnicalID").': '.$object->id;

View File

@@ -1239,16 +1239,9 @@ else
print $object->showOptionals($extrafields,'edit');
}
// Note
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
$doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create();
print "</td></tr>";
if($conf->categorie->enabled) {
// Categories
// Tags-Categories
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
@@ -1260,6 +1253,14 @@ else
print "</td></tr>";
}
// Note
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
$doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80);
$doleditor->Create();
print "</td></tr>";
print '</table>';
print '<br>';
@@ -1298,58 +1299,29 @@ else
// Fiche en mode visu
else
{
$showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
$head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'card', $titre, 0, $picto);
$showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
$showbarcode=empty($conf->barcode->enabled)?0:1;
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0;
dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
// En mode visu
print '<table class="border" width="100%"><tr>';
// Ref
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">';
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->label.'</td>';
$nblignes=7;
if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) $nblignes++;
if ($showbarcode) $nblignes+=2;
if ($object->type!= Product::TYPE_SERVICE) $nblignes++;
if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2;
if ($object->isservice()) $nblignes++;
else $nblignes+=4;
// Photo
if ($showphoto || $showbarcode)
{
print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">';
print '<div class="photolist">';
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
if ($conf->browser->phone) $maxvisiblephotos=1;
if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,$maxvisiblephotos,0,0,0,80);
if ($showphoto && $showbarcode) print '<br><br>';
if ($showbarcode) print $form->showbarcode($object);
print '</div>';
print '</td>';
}
print '</tr>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Type
if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled))
{
// TODO change for compatibility with edit in place
$typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
print '<tr><td>'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">';
print '<tr><td class="titlefield">'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).'</td><td colspan="2">';
print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat);
print '</td></tr>';
}
@@ -1412,6 +1384,7 @@ else
print '</td></tr>';
// Status (to sell)
/*
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
@@ -1428,6 +1401,7 @@ else
print $object->getLibStatut(2,1);
}
print '</td></tr>';
*/
// Batch number management (to batch)
if (! empty($conf->productbatch->enabled)) {
@@ -1448,10 +1422,17 @@ else
print dol_print_url($object->url);
print '</td></tr>';
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Nature
if($object->type!= Product::TYPE_SERVICE)
{
print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="2">';
print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td colspan="2">';
print $object->getLibFinished();
print '</td></tr>';
}
@@ -1459,7 +1440,7 @@ else
if ($object->isservice())
{
// Duration
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.'&nbsp;';
if ($object->duration_value > 1)
{
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
@@ -1475,7 +1456,7 @@ else
else
{
// Weight
print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="2">';
print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">';
if ($object->weight != '')
{
print $object->weight." ".measuring_units_string($object->weight_units,"weight");
@@ -1549,11 +1530,6 @@ else
print $object->showOptionals($extrafields);
}
// Note
print '<!-- show Note --> '."\n";
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>'."\n";
print '<!-- End show Note --> '."\n";
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
@@ -1561,7 +1537,16 @@ else
print "</td></tr>";
}
// Note
print '<!-- show Note --> '."\n";
print '<tr><td class="tdtop">'.$langs->trans("Note").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'</td></tr>'."\n";
print '<!-- End show Note --> '."\n";
print "</table>\n";
print '</div>';
print '</div></div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
}

View File

@@ -3485,9 +3485,10 @@ class Product extends CommonObject
* @param int $showaction 1=Show icon with action links (resize, delete)
* @param int $maxHeight Max height of image when size=1
* @param int $maxWidth Max width of image when size=1
* @param int $nolink Do not add a href link to view enlarged imaged into a new tab
* @return string Html code to show photo. Number of photos shown is saved in this->nbphoto
*/
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160)
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160,$nolink=0)
{
global $conf,$user,$langs;
@@ -3552,7 +3553,7 @@ class Product extends CommonObject
else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
$return.= "\n";
$return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
if (empty($nolink)) $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
// Show image (width height=$maxHeight)
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
@@ -3568,7 +3569,8 @@ class Product extends CommonObject
$return.= '<img class="photo photowithmargin" border="0" '.($conf->dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
}
$return.= '</a>'."\n";
if (empty($nolink)) $return.= '</a>';
$return.="\n";
if ($showfilename) $return.= '<br>'.$viewfilename;
if ($showaction)