From f2dc99dc7f1aed8b2031fbb85c8c5c47b9622f7c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 1 May 2010 14:37:02 +0000 Subject: [PATCH] Works on product canvas and templates !! WARNING : not stable !! --- .../canvas/default/product.default.class.php | 60 ++---- .../product/canvas/default/tpl/create.tpl.php | 174 ++++++++++++++++++ .../canvas/service/product.service.class.php | 71 +++++++ htdocs/product/fiche.php | 4 +- 4 files changed, 267 insertions(+), 42 deletions(-) create mode 100644 htdocs/product/canvas/default/tpl/create.tpl.php diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index 34fe98c7cf5..9827b4eb018 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -64,9 +64,9 @@ class ProductDefault extends Product * \brief Lecture des donnees dans la base * \param id Product id */ - function fetchCanvas($id='', $action='') + function fetch($id='', $action='') { - $result = $this->fetch($id); + $result = parent::fetch($id); return $result; } @@ -106,54 +106,34 @@ class ProductDefault extends Product $this->tpl['description'] = nl2br($this->description); // Nature - if($this->type!=1) + $this->tpl['finishedLabel'] = $this->getLibFinished(); + + // Weight + if ($this->weight != '') { - $this->tpl['finishedLabel'] = $this->getLibFinished(); + $this->tpl['weight'] = $this->weight." ".measuring_units_string($this->weight_units,"weight"); } - if ($this->isservice()) + // Length + if ($this->length != '') { - // 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]); + $this->tpl['length'] = $this->length." ".measuring_units_string($this->length_units,"size"); } - else + + // Surface + if ($this->surface != '') { - // Weight - if ($this->weight != '') - { - $this->tpl['weight'] = $this->weight." ".measuring_units_string($this->weight_units,"weight"); - } + $this->tpl['surface'] = $this->surface." ".measuring_units_string($this->surface_units,"surface"); + } - // 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"); - } + // 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)) + if ($user->rights->produit->hidden) { $this->tpl['hidden'] = yn($this->hidden); } diff --git a/htdocs/product/canvas/default/tpl/create.tpl.php b/htdocs/product/canvas/default/tpl/create.tpl.php new file mode 100644 index 00000000000..95f96f603e1 --- /dev/null +++ b/htdocs/product/canvas/default/tpl/create.tpl.php @@ -0,0 +1,174 @@ + + * + * 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$ + */ +?> + + + +
" method="post"> + + + + + + else $title=$langs->trans("NewProduct"); + print_fiche_titre($title); + + + + + + + + + + + + + + + + + if ($_GET["type"] != 1 && $conf->stock->enabled) + { + + } + else + { + + } + + + + + + + + + + + + + + // Hidden + if (($_GET["type"] != 1 && $user->rights->produit->hidden) + || ($_GET["type"] == 1 && $user->rights->service->hidden)) + { + + } + else + { + print yn("No"); + } + + +
trans("Ref"); ?>"> + if ($_error == 1) + { + print $langs->trans("RefAlreadyExists"); + } +
trans("Label"); ?>">
trans("Status"); ?> + $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); + $html->select_array('statut',$statutarray,$_POST["statut"]); +
trans("StockLimit"); ?> +"> +
trans("Description"); ?> + + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$_POST["desc"],160,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + +
trans("Nature"); ?> + $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + $html->select_array('finished',$statutarray,$_POST["finished"]); +
trans("Weight"); ?> +"> + print $formproduct->select_measuring_units("weight_units","weight"); +
trans("Length"); ?> +"> + print $formproduct->select_measuring_units("size_units","size"); +
trans("Surface"); ?> +"> + print $formproduct->select_measuring_units("surface_units","surface"); +
trans("Volume"); ?> +"> + print $formproduct->select_measuring_units("volume_units","volume"); +
trans("Hidden"); ?> + print $html->selectyesno('hidden',$product->hidden); +
trans("NoteNotVisibleOnBill"); ?> + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note',$_POST["note"],180,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } +
+ +
+ + if ($conf->global->PRODUIT_MULTIPRICES) + { + // We do no show price array on create when multiprices enabled. + // We must set them on prices tab. + } + else + { + print ''; + + // PRIX + print ''; + print ''; + + // MIN PRICE + print ''; + print ''; + + // VAT + print ''; + + print '
'.$langs->trans("SellingPrice").''; + print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); + print '
'.$langs->trans("MinPrice").''; + print '
'.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); + print '
'; + + print '
'; + } + +
">
+ +
+ + \ No newline at end of file diff --git a/htdocs/product/canvas/service/product.service.class.php b/htdocs/product/canvas/service/product.service.class.php index 5df6861f0a0..8f411217e49 100644 --- a/htdocs/product/canvas/service/product.service.class.php +++ b/htdocs/product/canvas/service/product.service.class.php @@ -55,6 +55,77 @@ class ProductService extends Product return 'Services'; } + /** + * \brief Lecture des donnees dans la base + * \param id Product id + */ + function fetch($id='', $action='') + { + $result = parent::fetch($id); + + return $result; + } + + /** + * \brief Assigne les valeurs pour les templates + * \param object object + */ + function assign_values($action='') + { + global $conf,$html; + + // Ref + $this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref'); + // Label + $this->tpl['label'] = $this->libelle; + // Statut + $this->tpl['status'] = $this->getLibStatut(2); + + if ($action == 'view') + { + $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); + + // Description + $this->tpl['description'] = nl2br($this->description); + + // 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]); + + // Hidden + if ($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/fiche.php b/htdocs/product/fiche.php index bba7b2744fe..ed211a33305 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -620,7 +620,7 @@ $formproduct = new FormProduct($db); */ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if ($_GET["canvas"] <> '' && file_exists('canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) + if ($_GET["canvas"] <> '' && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) { if (! isset($product)) { @@ -855,7 +855,7 @@ if ($_GET["id"] || $_GET["ref"]) include_once(DOL_DOCUMENT_ROOT.'/product/canvas/'.$productstatic->canvas.'/product.'.$productstatic->canvas.'.class.php'); $product = new $classname($db); - $result = $product->fetchCanvas($productstatic->id,'',$_GET["action"]); + $result = $product->fetch($productstatic->id,'',$_GET["action"]); $template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/tpl/'; }