From 01b46068e658f242f8e6ce3b146af62ab7a9122e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 2 May 2010 14:29:16 +0000 Subject: [PATCH] Works on product canvas and templates !! WARNING : not stable !! --- .../canvas/default/product.default.class.php | 11 + .../product/canvas/default/tpl/edit.tpl.php | 113 +++++ htdocs/product/canvas/default/tpl/list.tpl | 104 ----- .../canvas/service/product.service.class.php | 131 +++++- .../product/canvas/service/tpl/create.tpl.php | 102 +++++ .../product/canvas/service/tpl/edit.tpl.php | 86 ++++ .../product/canvas/service/tpl/list.tpl.php | 102 +++++ htdocs/product/canvas/service/tpl/liste.tpl | 102 ----- .../product/canvas/service/tpl/view.tpl.php | 81 ++++ htdocs/product/fiche.php | 407 +----------------- 10 files changed, 618 insertions(+), 621 deletions(-) create mode 100644 htdocs/product/canvas/default/tpl/edit.tpl.php delete mode 100644 htdocs/product/canvas/default/tpl/list.tpl create mode 100644 htdocs/product/canvas/service/tpl/create.tpl.php create mode 100644 htdocs/product/canvas/service/tpl/edit.tpl.php create mode 100644 htdocs/product/canvas/service/tpl/list.tpl.php delete mode 100644 htdocs/product/canvas/service/tpl/liste.tpl create mode 100644 htdocs/product/canvas/service/tpl/view.tpl.php diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index 9fc10c127e6..1755195db32 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -81,6 +81,12 @@ class ProductDefault extends Product global $html; global $formproduct; + // canvas + $this->tpl['canvas'] = $this->canvas; + + // id + $this->tpl['id'] = $this->id; + // Ref $this->tpl['ref'] = $this->ref; @@ -123,6 +129,11 @@ class ProductDefault extends Product $this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); } + if ($action == 'edit') + { + $this->tpl['title'] = load_fiche_titre($langs->trans('Modify').' '.$langs->trans('Product').' : '.$this->ref, ""); + } + if ($action == 'create' || $action == 'edit') { // Status diff --git a/htdocs/product/canvas/default/tpl/edit.tpl.php b/htdocs/product/canvas/default/tpl/edit.tpl.php new file mode 100644 index 00000000000..1634a5fadb8 --- /dev/null +++ b/htdocs/product/canvas/default/tpl/edit.tpl.php @@ -0,0 +1,113 @@ + + * + * 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['title']; ?> + + +

+ + +
" method="post"> + + + + + + + + + + + + + + + + + + + + + + +stock->enabled) { ?> + + + + + + + + + + + + + + + + + + + + + +
trans("Ref"); ?> +
trans("Label"); ?>
trans("Status"); ?>tpl['status']; ?>
trans("StockLimit"); ?> + +
trans("Description"); ?> +tpl['textarea_description']) { +$product->tpl['doleditor_description']->Create(); +}else{ +echo $product->tpl['textarea_description']; +}?> +
trans("Nature"); ?> +tpl['finished']; ?> +
trans("Weight"); ?> + +tpl['weight_units']; ?> +
trans("Length"); ?> + +tpl['length_units']; ?> +
trans("Surface"); ?> + +tpl['surface_units']; ?> +
trans("Volume"); ?> + +tpl['volume_units']; ?> +
trans("Hidden"); ?>tpl['hidden']; ?>
trans("NoteNotVisibleOnBill"); ?> +tpl['textarea_note']) { +$product->tpl['doleditor_note']->Create(); +}else{ +echo $product->tpl['textarea_note']; +}?> +
+ +
+ +
">     +">
+ +
+ + \ No newline at end of file diff --git a/htdocs/product/canvas/default/tpl/list.tpl b/htdocs/product/canvas/default/tpl/list.tpl deleted file mode 100644 index 4181ca9fa49..00000000000 --- a/htdocs/product/canvas/default/tpl/list.tpl +++ /dev/null @@ -1,104 +0,0 @@ -{* Copyright (C) 2009-2010 Regis Houssin - * - * 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$ - *} - - - - - - - - -
- {$title_picto} - -
{$title_text}
-
- -
- - - - - - - {section name=field loop=$fieldlist} - {strip} - - {if $fieldlist[field].enabled} - {if $fieldlist[field].sort} - - {else} - - {/if} - {/if} - - {/strip} - {/section} - - - - - - {section name=searchfield loop=$fieldlist} - {strip} - - {if $fieldlist[searchfield].enabled} - {if $fieldlist[searchfield].search} - - {elseif $smarty.section.search.last} - - {else} - - {/if} - {/if} - - {/strip} - {/section} - - - - -{foreach name=prodline item=line from=$datas} -{strip} - - {foreach name=valueline key=key item=value from=$line} - {foreach name=fieldline item=field from=$fieldlist} - {if $field.alias == $key} - - {/if} - {/foreach} - {/foreach} - -{/strip} -{/foreach} - -
{$fieldlist[field].title} - - A-Z - - - Z-A - - {$fieldlist[field].title}
- - -  
{$value}
-
- - \ 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 8f411217e49..60535cd807a 100644 --- a/htdocs/product/canvas/service/product.service.class.php +++ b/htdocs/product/canvas/service/product.service.class.php @@ -32,6 +32,8 @@ class ProductService 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 @@ -45,7 +47,7 @@ class ProductService extends Product $this->module = "service"; $this->canvas = "service"; $this->name = "service"; - $this->description = "Canvas des services"; + $this->definition = "Canvas des services"; $this->next_prev_filter = "canvas='service'"; } @@ -72,17 +74,122 @@ class ProductService extends Product */ function assign_values($action='') { - global $conf,$html; + global $conf,$langs; + global $html; + global $formproduct; + + // canvas + $this->tpl['canvas'] = $this->canvas; + + // id + $this->tpl['id'] = $this->id; // Ref - $this->tpl['showrefnav'] = $html->showrefnav($this,'ref','',1,'ref'); + $this->tpl['ref'] = $this->ref; + // Label $this->tpl['label'] = $this->libelle; + + // Description + $this->tpl['description'] = nl2br($this->description); + // Statut $this->tpl['status'] = $this->getLibStatut(2); + // Note + $this->tpl['note'] = nl2br($this->note); + + // Duration + $this->tpl['duration_value'] = $this->duration_value; + + // Hidden + if ($this->user->rights->service->hidden) + { + $this->tpl['hidden'] = yn($this->hidden); + } + else + { + $this->tpl['hidden'] = yn("No"); + } + + // Stock alert + $this->tpl['seuil_stock_alerte'] = $this->seuil_stock_alerte; + + if ($action == 'create') + { + // Title + $this->tpl['title'] = load_fiche_titre($langs->trans("NewService")); + + // Price + $this->tpl['price'] = $this->price; + $this->tpl['price_min'] = $this->price_min; + $this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type"); + + // VAT + $this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); + } + + if ($action == 'edit') + { + $this->tpl['title'] = load_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$this->ref, ""); + } + + if ($action == 'create' || $action == 'edit') + { + // Status + $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); + $this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status); + + // Hidden + if ($this->user->rights->service->hidden) + { + $this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden); + } + + // Duration unit + // TODO creer fonction + $duration_unit = 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); + $duration_unit.= '  '; + $duration_unit.= 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); + $duration_unit.= '  '; + $duration_unit.= 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); + $duration_unit.= '  '; + $duration_unit.= 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); + $duration_unit.= '  '; + $duration_unit.= 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); + $this->tpl['duration_unit'] = $duration_unit; + + // TODO creer fonction + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + + $doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false); + $this->tpl['doleditor_description'] = $doleditor; + + $doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false); + $this->tpl['doleditor_note'] = $doleditor; + } + else + { + $textarea = ''; + $this->tpl['textarea_description'] = $textarea; + + $textarea = ''; + $this->tpl['textarea_note'] = $textarea; + } + } + if ($action == 'view') { + // Ref + $this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref'); + + // Photo $this->tpl['nblignes'] = 4; if ($this->is_photo_available($conf->produit->dir_output)) { @@ -97,9 +204,6 @@ class ProductService extends Product $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) { @@ -109,20 +213,7 @@ class ProductService extends Product { $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); + $this->tpl['duration_unit'] = $langs->trans($dur[$this->duration_unit]); } } diff --git a/htdocs/product/canvas/service/tpl/create.tpl.php b/htdocs/product/canvas/service/tpl/create.tpl.php new file mode 100644 index 00000000000..3311228f162 --- /dev/null +++ b/htdocs/product/canvas/service/tpl/create.tpl.php @@ -0,0 +1,102 @@ + + * + * 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['title']; ?> + +
" method="post"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
trans("Ref"); ?> +trans("RefAlreadyExists"); ?> +
trans("Label"); ?>
trans("Status"); ?>tpl['status']; ?>
trans("Description"); ?> +tpl['textarea_description']) { +$product->tpl['doleditor_description']->Create(); +}else{ +echo $product->tpl['textarea_description']; +}?> +
trans("Duration"); ?>   +tpl['duration_unit']; ?> +
trans("Hidden"); ?>tpl['hidden']; ?>
trans("NoteNotVisibleOnBill"); ?> +tpl['textarea_note']) { +$product->tpl['doleditor_note']->Create(); +}else{ +echo $product->tpl['textarea_note']; +}?> +
+ +
+ +global->PRODUIT_MULTIPRICES) { ?> + + + + + + + + + + + +
trans("SellingPrice"); ?> +tpl['price_base_type']; ?> +
trans("MinPrice"); ?> +
trans("VATRate"); ?> +tpl['tva_tx']; ?> +
+ +
+ + +
">
+ +
+ + \ No newline at end of file diff --git a/htdocs/product/canvas/service/tpl/edit.tpl.php b/htdocs/product/canvas/service/tpl/edit.tpl.php new file mode 100644 index 00000000000..f1aa027e172 --- /dev/null +++ b/htdocs/product/canvas/service/tpl/edit.tpl.php @@ -0,0 +1,86 @@ + + * + * 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['title']; ?> + + +

+ + +
" method="post"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
trans("Ref"); ?> +
trans("Label"); ?>
trans("Status"); ?>tpl['status']; ?>
trans("Description"); ?> +tpl['textarea_description']) { +$product->tpl['doleditor_description']->Create(); +}else{ +echo $product->tpl['textarea_description']; +}?> +
trans("Duration"); ?>   +tpl['duration_unit']; ?> +
trans("Hidden"); ?>tpl['hidden']; ?>
trans("NoteNotVisibleOnBill"); ?> +tpl['textarea_note']) { +$product->tpl['doleditor_note']->Create(); +}else{ +echo $product->tpl['textarea_note']; +}?> +
+ +
+ +
">     +">
+ +
+ + \ No newline at end of file diff --git a/htdocs/product/canvas/service/tpl/list.tpl.php b/htdocs/product/canvas/service/tpl/list.tpl.php new file mode 100644 index 00000000000..4c07d85159d --- /dev/null +++ b/htdocs/product/canvas/service/tpl/list.tpl.php @@ -0,0 +1,102 @@ + + * + * 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$ + */ +?> + + + + + + + + +
+ + +
+
+ +
?canvas=default" method="post" name="formulaire"> + + + + + + + + + + + + + + + + + + + + + + $searchfield) { + if ($searchfield['enabled']) { + if ($searchfield['search']) { ?> + + + + + + + + + + + + > + $value) { + foreach($fieldlist as $field) { + if ($field['alias'] == $key) { ?> + + + + + +
+ ?sortfield=&sortorder=asc&begin=&envente=&canvas=default&fourn_id=&snom=&sref="> + A-Z + + ?sortfield=&sortorder=desc&begin=&envente=&canvas=default&fourn_id=&snom=&sref="> + Z-A + +
+ + +  
+
+ + \ No newline at end of file diff --git a/htdocs/product/canvas/service/tpl/liste.tpl b/htdocs/product/canvas/service/tpl/liste.tpl deleted file mode 100644 index 773e909ee4b..00000000000 --- a/htdocs/product/canvas/service/tpl/liste.tpl +++ /dev/null @@ -1,102 +0,0 @@ -{* Copyright (C) 2009-2010 Regis Houssin - * - * 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$ - *} - - - - - - - - -
- {$title_picto} - -
{$title_text}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -{section name=mysec loop=$datas} -{strip} - - - - - - - - - -{/strip} -{/section} - -
Référence - - A-Z - - - Z-A - - Libellé - - A-Z - - - Z-A - - Code barre - - A-Z - - - Z-A - - Date de modificationDuréePrix de venteEtat
    - - -
{$datas[mysec].ref}{$datas[mysec].label}{$datas[mysec].barcode}{$datas[mysec].datem}{$datas[mysec].duration}{$datas[mysec].sellingprice}{$datas[mysec].status}
-
- - \ No newline at end of file diff --git a/htdocs/product/canvas/service/tpl/view.tpl.php b/htdocs/product/canvas/service/tpl/view.tpl.php new file mode 100644 index 00000000000..c42550507d6 --- /dev/null +++ b/htdocs/product/canvas/service/tpl/view.tpl.php @@ -0,0 +1,81 @@ + + * + * 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['ref']; ?>
trans("Label") ?>tpl['label']; ?> +tpl['photos']; ?> +
tpl['accountancyBuyCodeKey']; ?>tpl['accountancyBuyCodeVal']; ?>
tpl['accountancySellCodeKey']; ?>tpl['accountancySellCodeVal']; ?>
trans("Status"); ?>tpl['status']; ?>
trans("Description"); ?>tpl['description']; ?>
trans("Duration"); ?>tpl['duration_value']; ?>  +tpl['duration_unit']; ?>  +
trans("Hidden"); ?>tpl['hidden']; ?>
trans("Note"); ?>tpl['note']; ?>
+ + + \ No newline at end of file diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 88b9176764a..52b2b5ea76b 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -51,6 +51,12 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid'; $socid=$user->societe_id?$user->societe_id:0; $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); +if (empty($_GET["canvas"])) +{ + $_GET["canvas"] = 'default'; + if ($_GET["type"] == 1) $_GET["canvas"] = 'service'; +} + $mesg = ''; @@ -156,7 +162,7 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights $product->note = dol_htmlcleanlastbr($_POST["note"]); $product->duration_value = $_POST["duration_value"]; $product->duration_unit = $_POST["duration_unit"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; $product->canvas = $_POST["canvas"]; $product->weight = $_POST["weight"]; $product->weight_units = $_POST["weight_units"]; @@ -658,189 +664,12 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ if (!empty($_GET["canvas"]) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/product.'.$_GET["canvas"].'.class.php')) { - // On assigne les valeurs meme en creation car elles sont definies si - // on revient en erreur $template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/tpl/'; - $tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,''); - //$smarty->assign('tva_taux_value', $tvaarray['value']); - //$smarty->assign('tva_taux_libelle', $tvaarray['label']); $product->assign_values('create'); include($template_dir.'create.tpl.php'); } - else - { - print '
'; - print ''; - print ''; - print ''."\n"; - - if ($_GET["type"]==1) $title=$langs->trans("NewService"); - else $title=$langs->trans("NewProduct"); - print_fiche_titre($title); - - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status - print ''; - - // Stock min level - if ($_GET["type"] != 1 && $conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } - - // Description (used in invoice, propal...) - print '"; - - // Nature - if ($_GET["type"] != 1) - { - print ''; - } - - //Duration - if ($_GET["type"] == 1) - { - print ''; - } - - if ($_GET["type"] != 1) // Le poids et le volume ne concerne que les produits et pas les services - { - // Weight - print ''; - // Length - print ''; - // Surface - print ''; - // Volume - print ''; - } - - // Hidden - if (($_GET["type"] != 1 && $user->rights->produit->hidden) - || ($_GET["type"] == 1 && $user->rights->service->hidden)) - { - print ''; - } - else - { - print ''; - } - - // Note (invisible sur facture, propales...) - print '"; - print '
'.$langs->trans("Ref").''; - if ($_error == 1) - { - print $langs->trans("RefAlreadyExists"); - } - print '
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $html->select_array('statut',$statutarray,$_POST["statut"]); - print '
'.$langs->trans("StockLimit").''; - print ''; - print '
'.$langs->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 ''; - } - - print "
'.$langs->trans("Nature").''; - $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - $html->select_array('finished',$statutarray,$_POST["finished"]); - print '
'.$langs->trans("Duration").'  '; - print ''.$langs->trans("Hour").' '; - print ''.$langs->trans("Day").' '; - print ''.$langs->trans("Week").' '; - print ''.$langs->trans("Month").' '; - print ''.$langs->trans("Year").' '; - print '
'.$langs->trans("Weight").''; - print ''; - print $formproduct->select_measuring_units("weight_units","weight"); - print '
'.$langs->trans("Length").''; - print ''; - print $formproduct->select_measuring_units("size_units","size"); - print '
'.$langs->trans("Surface").''; - print ''; - print $formproduct->select_measuring_units("surface_units","surface"); - print '
'.$langs->trans("Volume").''; - print ''; - print $formproduct->select_measuring_units("volume_units","volume"); - print '
'.$langs->trans("Hidden").''; - print $html->selectyesno('hidden',$product->hidden); - print '
'.$langs->trans("Hidden").''; - print yn("No"); - print '
'.$langs->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 ''; - } - print "
'; - - 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 '
'; - } - - print '
'; - - print '
'; - } } /** @@ -876,6 +705,7 @@ if ($_GET["id"] || $_GET["ref"]) $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'card', $titre, 0, $picto); print "\n\n"; + // Confirmation de la suppression de la facture if ($_GET["action"] == 'delete') { @@ -896,170 +726,13 @@ if ($_GET["id"] || $_GET["ref"]) */ if ($_GET["action"] == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if ($product->isservice()) { - print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$product->ref, ""); - } else { - print_fiche_titre($langs->trans('Modify').' '.$langs->trans('Product').' : '.$product->ref, ""); - } - if ($mesg) { print '
'.$mesg.'

'; } - - if ( $product->canvas == '') - { - print "\n"; - print "
\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Status - print ''; - - // Description (used in invoice, propal...) - print '"; - print "\n"; - - // Nature - if($product->type!=1) - { - print ''; - } - - if ($product->isproduct() && $conf->stock->enabled) - { - print "".''; - } - else - { - print ''; - } - - if ($product->isservice()) - { - // Duration - print ''; - } - else - { - // Weight - print ''; - // Length - print ''; - // Surface - print ''; - // Volume - print ''; - } - - // Hidden - if ((! $product->isservice() && $user->rights->produit->hidden) - || ($product->isservice() && $user->rights->service->hidden)) - { - print ''; - } - else - { - print ''; - } - - // Note - print '"; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print ''; - print '
'.$langs->trans("Description").''; - print "\n"; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print '"; - } - print "
'.$langs->trans("Nature").''; - $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - $html->select_array('finished',$statutarray,$product->finished); - print '
'.$langs->trans("StockLimit").''; - print ''; - print '
'.$langs->trans("Duration").''; - print '  '; - print 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); - print '  '; - print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); - print '  '; - print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); - print '  '; - print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); - print '  '; - print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); - - print '
'.$langs->trans("Weight").''; - print ' '; - print $formproduct->select_measuring_units("weight_units", "weight", $product->weight_units); - print '
'.$langs->trans("Length").''; - print ' '; - print $formproduct->select_measuring_units("size_units", "size", $product->length_units); - print '
'.$langs->trans("Surface").''; - print ' '; - print $formproduct->select_measuring_units("surface_units", "surface", $product->surface_units); - print '
'.$langs->trans("Volume").''; - print ' '; - print $formproduct->select_measuring_units("volume_units", "volume", $product->volume_units); - print '
'.$langs->trans("Hidden").''; - print $html->selectyesno('hidden',$product->hidden); - print '
'.$langs->trans("Hidden").''; - print yn("No"); - print '
'.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print '"; - } - print "
'; - - print '
'; - - print '
    '; - print '
'; - - print '
'; - print "\n"; - } - else - { - $tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'',''); - $smarty->assign('tva_taux_value', $tvaarray['value']); - $smarty->assign('tva_taux_libelle', $tvaarray['label']); - $smarty->display($product->canvas.'-edit.tpl'); - } + + $product->assign_values('edit'); + + include($template_dir.'edit.tpl.php'); } } else if (!$_GET["action"] == 'create') @@ -1519,60 +1192,4 @@ $db->close(); llxFooter('$Date$ - $Revision$'); - -/** - * \brief Load tva_taux_value and tva_taux_libelle array - * \remarks Ne sert que pour smarty - * \ TODO deplacer dans une classe - */ -function load_tva($db,$name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='') -{ - global $langs,$conf,$mysoc; - - $retarray=array(); - - if (is_object($societe_vendeuse->pays_code)) - { - $code_pays=$societe_vendeuse->pays_code; - } - else - { - $code_pays=$mysoc->pays_code; // Pour compatibilite ascendente - } - - // Recherche liste des codes TVA du pays vendeur - $sql = "SELECT t.taux,t.recuperableonly"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'"; - $sql .= " AND t.active = 1"; - $sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC"; - - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - for ($i = 0; $i < $num; $i++) - { - $obj = $db->fetch_object($resql); - $txtva[ $i ] = $obj->taux; - $libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':''); - } - } - - // Definition du taux a pre-selectionner - if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit); - // Si taux par defaut n'a pu etre trouve, on prend dernier. - // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant - if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1]; - - $nbdetaux = sizeof($txtva); - - for ($i = 0 ; $i < $nbdetaux ; $i++) - { - $retarray['value'][$i] = $txtva[$i]; - $retarray['label'][$i] = $libtva[$i]; - } - - return $retarray; -} ?>