diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php index 4c24114a6f3..c17a6ac2636 100644 --- a/htdocs/product/composition/fiche.php +++ b/htdocs/product/composition/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -63,6 +63,10 @@ if ($id || $ref) } +/* + * Actions + */ + // Action association d'un sousproduit if ($action == 'add_prod' && $cancel <> $langs->trans("Cancel") && @@ -107,27 +111,6 @@ $cancel <> $langs->trans("Cancel") && } } -// action recherche des produits par mot-cle et/ou par categorie -if($action == 'search' ) -{ - $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.price, p.fk_product_type as type'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; - $sql.= " WHERE p.entity = ".$conf->entity; - if($key != "") - { - $sql.= " AND (p.ref like '%".$key."%'"; - $sql.= " OR p.label like '%".$key."%')"; - } - if ($conf->categorie->enabled && $catMere != -1 and $catMere) - { - $sql.= " AND cp.fk_categorie ='".$db->escape($catMere)."'"; - } - $sql.= " ORDER BY p.ref ASC"; - - $resql = $db->query($sql) ; -} - if ($cancel == $langs->trans("Cancel")) { $action = ''; @@ -140,6 +123,40 @@ if ($cancel == $langs->trans("Cancel")) * View */ +// action recherche des produits par mot-cle et/ou par categorie +if($action == 'search' ) +{ + $current_lang = $langs->getDefaultLang(); + + $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.price, p.fk_product_type as type'; + if ($conf->global->MAIN_MULTILANGS) $sql.= ', pl.label as labelm, pl.description as descriptionm'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; + if ($conf->global->MAIN_MULTILANGS) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; + $sql.= " WHERE p.entity = ".$conf->entity; + if($key != "") + { + if ($conf->global->MAIN_MULTILANGS) + { + $sql.= " AND (p.ref like '%".$key."%'"; + $sql.= " OR pl.label like '%".$key."%')"; + } + else + { + $sql.= " AND (p.ref like '%".$key."%'"; + $sql.= " OR p.label like '%".$key."%')"; + } + } + if ($conf->categorie->enabled && $catMere != -1 and $catMere) + { + $sql.= " AND cp.fk_categorie ='".$db->escape($catMere)."'"; + } + $sql.= " ORDER BY p.ref ASC"; + + $resql = $db->query($sql) ; +} +//print $sql; + $productstatic = new Product($db); $html = new Form($db); @@ -147,23 +164,19 @@ llxHeader("","",$langs->trans("CardProduct".$product->type)); $html = new Form($db); -if ($mesg) { - print '
'.$mesg.'

'; -} +dol_htmloutput_errors($mesg); + $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'subproduct', $titre, 0, $picto); -/* - * Fiche produit - */ + if ($id || $ref) { if ( $result ) { - if ($action <> 'edit' &&$action <> 'search' && $action <> 're-edit') { /* @@ -191,6 +204,9 @@ if ($id || $ref) $product->get_sousproduits_arbo (); print ''.$langs->trans("AssociatedProductsNumber").''.sizeof($product->get_arbo_each_prod()).''; + dol_fiche_end(); + + // List of subproducts $prods_arbo = $product->get_arbo_each_prod(); if(sizeof($prods_arbo) > 0) @@ -218,6 +234,7 @@ if ($id || $ref) print "\n"; + dol_fiche_end(); } } @@ -278,6 +295,8 @@ if ($id || $ref) print ''; + dol_fiche_end(); + print '
'; print '
'; @@ -307,8 +326,8 @@ if ($id || $ref) print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -361,7 +380,10 @@ if ($id || $ref) $productstatic->type=$objp->type; print ''; - print ''; + $labeltoshow=$objp->label; + if ($conf->global->MAIN_MULTILANGS && $objp->labelm) $labeltoshow=$objp->labelm; + + print ''; if($product->is_sousproduit($id, $objp->rowid)) { $addchecked = ' checked="true"'; @@ -375,7 +397,6 @@ if ($id || $ref) print ''; print ''; - print ''; print ''; } $i++; @@ -386,9 +407,9 @@ if ($id || $ref) { dol_print_error($db); } - print ''; print '
'.$langs->trans("Ref").''.$productstatic->getNomUrl(1,'',24).''.$objp->label.''.$labeltoshow.''; print '
'; - + print ''; + if($num > 0) { print '
trans("Update").'">'; @@ -402,7 +423,6 @@ if ($id || $ref) } } -print "\n"; /* ************************************************************************** */