diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index 59842107d3a..cc1b96d5d55 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -32,6 +32,8 @@ class ProductDefault extends Product //! Numero d'erreur Plage 1280-1535 var $errno = 0; + var $tpl = array(); + /** * \brief Constructeur de la classe * \param DB Handler acces base de donnees @@ -70,6 +72,100 @@ class ProductDefault extends Product return $result; } + /** + * \brief Assigne les valeurs pour les templates + * \param object object + */ + function assign_values($action='') + { + global $conf,$html; + + if ($action == 'view') + { + $this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref'); + + $this->tpl['nblignes'] = 4; + if ($this->is_photo_available($conf->produit->dir_output)) + { + $this->tpl['photos'] = $this->show_photos($conf->produit->dir_output,1,1,0,0,0,80); + } + + // Accountancy buy code + $this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer); + $this->tpl['accountancyBuyCodeVal'] = $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer); + + // Accountancy sell code + $this->tpl['accountancySellCodeKey'] = $html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); + $this->tpl['accountancySellCodeVal'] = $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,'id',$this->id,$user->rights->produit->creer); + + // Statut + $this->tpl['status'] = $this->getLibStatut(2); + + // Description + $this->tpl['description'] = nl2br($this->description); + + // Nature + if($this->type!=1) + { + $this->tpl['finishedLabel'] = $this->getLibFinished(); + } + + if ($this->isservice()) + { + // Duration + if ($this->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")); + } + else if ($this->duration_value > 0) + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + $this->tpl['duration'] = $langs->trans($dur[$this->duration_unit]); + } + else + { + // Weight + if ($this->weight != '') + { + $this->tpl['weight'] = $this->weight." ".measuring_units_string($this->weight_units,"weight"); + } + + // Length + if ($this->length != '') + { + $this->tpl['length'] = $this->length." ".measuring_units_string($this->length_units,"size"); + } + + // Surface + if ($this->surface != '') + { + $this->tpl['surface'] = $this->surface." ".measuring_units_string($this->surface_units,"surface"); + } + + // Volume + if ($this->volume != '') + { + $this->tpl['volume'] = $this->volume." ".measuring_units_string($this->volume_units,"volume"); + } + } + + // Hidden + if ((! $this->isservice() && $user->rights->produit->hidden) + || ($this->isservice() && $user->rights->service->hidden)) + { + $this->tpl['hidden'] = yn($this->hidden); + } + else + { + $this->tpl['hidden'] = yn("No"); + } + + // Note + $this->tpl['note'] = nl2br($this->note); + } + } + /** * \brief Fetch datas list */ diff --git a/htdocs/product/canvas/default/tpl/view.tpl.php b/htdocs/product/canvas/default/tpl/view.tpl.php new file mode 100644 index 00000000000..4f384a890ce --- /dev/null +++ b/htdocs/product/canvas/default/tpl/view.tpl.php @@ -0,0 +1,101 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + +
| trans("Ref"); ?> | +tpl['showrefnav']; ?> | +|
| trans("Label") ?> | +libelle; ?> | + +tpl['photos']) { ?> ++tpl['photos']; ?> + | + + +
| tpl['accountancyBuyCodeKey']; ?> | +tpl['accountancyBuyCodeVal']; ?> | +|
| tpl['accountancySellCodeKey']; ?> | +tpl['accountancySellCodeVal']; ?> | +|
| trans("Status"); ?> | +tpl['status']; ?> | +|
| trans("Description"); ?> | +tpl['description']; ?> | +|
| trans("Nature"); ?> | +tpl['finishedLabel']; ?> | +|
| trans("Weight"); ?> | +tpl['weight']; ?> | +|
| trans("Length"); ?> | +tpl['length']; ?> | +|
| trans("Surface"); ?> | +tpl['surface']; ?> | +|
| trans("Volume"); ?> | +tpl['volume']; ?> | +|
| trans("Hidden"); ?> | +tpl['hidden']; ?> | +|
| trans("Note"); ?> | +tpl['note']; ?> | +|
| '; + if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) $return.= ' |
| ';
- print "\n";
- print '';
+ $return.= "\n";
+ $return.= '';
// Show image (width height=$maxheight)
// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
$alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo;
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
if ($photo_vignette && $imgarray['height'] > $maxheight) {
- print '';
- print ' '.$viewfilename; + if ($showfilename) $return.= ' '.$viewfilename; if ($showaction) { - print ' '; + $return.= ' '; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) { - print ''.img_refresh($langs->trans('GenerateThumb')).' '; + $return.= ''.img_refresh($langs->trans('GenerateThumb')).' '; } if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize - print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).' '; + $return.= ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).' '; // Link to delete - print ''; - print img_delete().''; + $return.= ''; + $return.= img_delete().''; } } - print "\n"; + $return.= "\n"; - if ($nbbyrow) print ' | ';
- if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print ''; + $return.= ' | '; $nbphoto++; } - if ($nbphoto) print ' |
| '.$langs->trans("Ref").' | '; - print $html->showrefnav($product,'ref','',1,'ref'); - print ' | '; - - print '|
| '.$langs->trans("Label").' | '.$product->libelle.' | '; - - $nblignes=4; - if ($product->is_photo_available($conf->produit->dir_output)) - { - // Photo - print ''; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0,0,0,80); - print ' | '; - } - - print '
| '.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer).' | '; - print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$product->accountancy_code_sell,'id',$product->id,$user->rights->produit->creer); - print ' | |
| '.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer).' | '; - print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$product->accountancy_code_buy,'id',$product->id,$user->rights->produit->creer); - print ' | |
| '.$langs->trans("Status").' | '; - print $product->getLibStatut(2); - print ' | |
| '.$langs->trans("Description").' | '.nl2br($product->description).' | |
| '.$langs->trans("Nature").' | '; - print $product->getLibFinished(); - print ' | |
| '.$langs->trans("Duration").' | '.$product->duration_value.' '; - if ($product->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")); - } - else if ($product->duration_value > 0) - { - $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); - } - print $langs->trans($dur[$product->duration_unit])." "; - - print ' | |
| '.$langs->trans("Weight").' | '; - if ($product->weight != '') - { - print $product->weight." ".measuring_units_string($product->weight_units,"weight"); - } - else - { - print ' '; - } - print " | |
| '.$langs->trans("Length").' | '; - if ($product->length != '') - { - print $product->length." ".measuring_units_string($product->length_units,"size"); - } - else - { - print ' '; - } - print " | |
| '.$langs->trans("Surface").' | '; - if ($product->surface != '') - { - print $product->surface." ".measuring_units_string($product->surface_units,"surface"); - } - else - { - print ' '; - } - print " | |
| '.$langs->trans("Volume").' | '; - if ($product->volume != '') - { - print $product->volume." ".measuring_units_string($product->volume_units,"volume"); - } - else - { - print ' '; - } - print " | |
| '.$langs->trans("Hidden").' | '; - print yn($product->hidden); - print " | |
| '.$langs->trans("Hidden").' | '; - print yn("No"); - print ' | |
| '.$langs->trans("Note").' | '.nl2br($product->note).' | |
| '; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index eac073d9280..695139f0059 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -141,7 +141,7 @@ if ($product->is_photo_available($conf->produit->dir_output)) { // Photo print ' | '; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0,0,0,80); + print $product->show_photos($conf->produit->dir_output,1,1,0,0,0,80); print ' | '; }