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$ + */ +?> + + + + + + + + + + + + + + +tpl['photos']) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
trans("Ref"); ?>tpl['showrefnav']; ?>
trans("Label") ?>libelle; ?> +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']; ?>
+ + + \ No newline at end of file diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 50fad237af9..decfd635213 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -127,6 +127,8 @@ class Product extends CommonObject //! Product ID already linked to a reference supplier var $product_id_already_linked; + + var $nbphoto; /** * \brief Constructeur de la classe @@ -140,6 +142,7 @@ class Product extends CommonObject $this->db = $DB; $this->id = $id ; $this->status = 0; + $this->nbphoto = 0; $this->stock_reel = 0; $this->seuil_stock_alerte = 0; $this->canvas = ''; @@ -2502,6 +2505,7 @@ class Product extends CommonObject $dirthumb = $dir.'thumbs/'; $pdirthumb = $pdir.'thumbs/'; + $return=''; $nbphoto=0; $dir_osencoded=dol_osencode($dir); @@ -2531,69 +2535,69 @@ class Product extends CommonObject // Get filesize of original file $imgarray=dol_getImageSize($dir.$photo); - if ($nbbyrow && $nbphoto == 1) print ''; + if ($nbbyrow && $nbphoto == 1) $return.= '
'; - if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print ''; - if ($nbbyrow) print ''; + if ($nbbyrow) $return.= ''; - if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print ''; + if ($nbbyrow) $return.= ''; + if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= ''; } if ($size == 0) { // Format origine - print ''; + $return.= ''; - if ($showfilename) print '
'.$viewfilename; + if ($showfilename) $return.= '
'.$viewfilename; if ($showaction) { 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().''; } } } @@ -2608,17 +2612,19 @@ class Product extends CommonObject // Ferme tableau while ($nbphoto % $nbbyrow) { - print ''; + $return.= ''; $nbphoto++; } - if ($nbphoto) print '
'; + 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 ''; + $return.= ''; + $return.= ''; } else { - print ''; - print ''; + $return.= ''; + $return.= ''; } - print ''; + $return.= ''; - if ($showfilename) 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 ($nbphoto) $return.= ''; } closedir($handle); } - - return $nbphoto; + + $this->nbphoto = $nbphoto; + + return $return; } /** diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 6ac7eea3e56..15de4c73602 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -857,17 +857,15 @@ if ($_GET["id"] || $_GET["ref"]) } // Gestion des produits specifiques - if ($product->canvas <> '' && file_exists('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') ) + if (!empty($product->canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php') ) { $classname = 'Product'.ucfirst($product->canvas); - include_once('canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); + include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/product.'.$product->canvas.'.class.php'); $product = new $classname($db); $result = $product->fetchCanvas($_GET["id"],'',$_GET["action"]); - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/'; - - $product->assign_smarty_values($smarty,$_GET["action"]); + $template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/'; } @@ -890,159 +888,10 @@ if ($_GET["id"] || $_GET["ref"]) } print($mesg); - } - if ($_GET["action"] <> 'edit' && $product->canvas <> '') - { - /* - * Smarty en mode visu - */ - $smarty->assign('fiche_cursor_prev',$previous_ref); - $smarty->assign('fiche_cursor_next',$next_ref); - // Photo - //$nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); - - $smarty->display($product->canvas.'-view.tpl'); - - print "\n\n"; - } - - if ($_GET["action"] <> 'edit' && $product->canvas == '') - { - // En mode visu - print ''; - - // Ref - print ''; - - print ''; - - // Label - print ''; - - $nblignes=4; - if ($product->is_photo_available($conf->produit->dir_output)) - { - // Photo - print ''; - } - - print ''; - - // Accountancy buy code - print ''; - - // Accountancy sell code - print ''; - - // Statut - print ''; - - // Description - print ''; - - // Nature - if($product->type!=1) - { - print ''; - } - - if ($product->isservice()) - { - // Duration - print ''; - } - else - { - // Weight - print '\n"; - // Length - print '\n"; - // Surface - print '\n"; - // Volume - print '\n"; - } - - // Hidden - if ((! $product->isservice() && $user->rights->produit->hidden) - || ($product->isservice() && $user->rights->service->hidden)) - { - print '\n"; - } - else - { - print ''; - } - - // Note - print ''; - - print "
'.$langs->trans("Ref").''; - print $html->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->libelle.''; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0,0,0,80); - 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).'
\n"; - print "\n\n"; + $product->assign_values('view'); + + include($template_dir.'view.tpl.php'); } } diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 46fab2e7a86..a6527f19af2 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -177,9 +177,9 @@ if ($_GET["id"] || $_GET["ref"]) $maxWidth = 160; $maxHeight = 120; - $nbphoto=$product->show_photos($dir,1,1000,$nbbyrow,1,1); + print $product->show_photos($dir,1,1000,$nbbyrow,1,1); - if ($nbphoto < 1) + if ($product->nbphoto < 1) { print '
'; print ''; print ''; }
'; 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 '