From ea44e14b605725457bf6cf5f6293c9acf47184e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Apr 2017 11:01:12 +0200 Subject: [PATCH] Start debug the variant module --- htdocs/compta/index.php | 12 +- htdocs/core/class/html.formfile.class.php | 2 + htdocs/langs/en_US/products.lang | 3 + htdocs/product/card.php | 1 + htdocs/product/class/product.class.php | 5 + htdocs/product/index.php | 16 +-- htdocs/variants/combinations.php | 162 ++++++++++++++-------- htdocs/variants/generator.php | 46 +++--- 8 files changed, 143 insertions(+), 104 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index ea8d47b264e..736d5696c3e 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -233,7 +233,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- if ( $resql ) { - $var = false; $num = $db->num_rows($resql); print ''; @@ -248,7 +247,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; $tot_ttc+=$obj->total_ttc; $i++; - $var=!$var; } print ''; @@ -278,7 +276,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- } else { - print ''; + print ''; } print "
'; + print '
'; $facturesupplierstatic->ref=$obj->ref; $facturesupplierstatic->id=$obj->rowid; $facturesupplierstatic->total_ht=$obj->total_ht; @@ -269,7 +268,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print '
'.$langs->trans("Total").'
'.$langs->trans("NoInvoice").'
'.$langs->trans("NoInvoice").'

"; $db->free($resql); @@ -768,6 +766,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $num = $db->num_rows($resql); $i = 0; + print '
'; print ''; print ''; print ''; @@ -848,7 +847,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } - print '
'.$langs->trans("BillsCustomersUnpaid",$num).' '.$num.''.$langs->trans("DateDue").'
'.$langs->trans("NoInvoice").'

'; + print '

'; $db->free($resql); } else @@ -890,6 +889,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $var=false; $num = $db->num_rows($resql); + print '
'; print ''; print ''; print ''; @@ -948,7 +948,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- if (! empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) $colspan++; print ''; } - print '
'.$langs->trans("BillsSuppliersUnpaid",$num).' '.$num.''.$langs->trans("DateDue").'
'.$langs->trans("NoInvoice").'

'; + print '

'; } else { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1e2dc1c4938..647d0cf6a76 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -593,6 +593,7 @@ class FormFile $out.= ''; $out.= load_fiche_titre($titletoshow, '', ''); + $out.= '
'; $out.= ''; $out.= ''; @@ -802,6 +803,7 @@ class FormFile { // Affiche pied du tableau $out.= "
\n"; + $out.= "
\n"; if ($genallowed) { if (empty($noform)) $out.= ''."\n"; diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 046521e398e..ef4c13c89cc 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -287,6 +287,9 @@ HideProductCombinations=Hide products variant in the products selector ProductCombination=Variant NewProductCombination=New variant EditProductCombination=Editing variant +NewProductCombinations=New variants +EditProductCombinations=Editing variants +SelectCombination=Select combination ProductCombinationGenerator=Variants generator Features=Features PriceImpact=Price impact diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ac260fc99fb..0c6109ba64a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2015,6 +2015,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action = /* * Documents generes */ + if ($action != 'edit' && $action != 'delete') { print '
'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 23be6de5111..5f5b6f6eae9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3559,6 +3559,11 @@ class Product extends CommonObject if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); } + if ($mode == 6) + { + if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); + if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4', 'class="pictostatus"'); + } return $langs->trans('Unknown'); } diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 355e0d2757f..73447e456e6 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -130,26 +130,26 @@ print ''; print ''; if (! empty($conf->product->enabled)) { - $statProducts = ""; + $statProducts = ''; $statProducts.= ''; $statProducts.= ""; - $statProducts.= ""; + $statProducts.= ''; $statProducts.= ''; $statProducts.= ""; - $statProducts.= ""; + $statProducts.= ''; $statProducts.= ''; $statProducts.= ""; } if (! empty($conf->service->enabled)) { - $statServices = ""; + $statServices = ''; $statServices.= ''; $statServices.= ""; - $statServices.= ""; + $statServices.= ''; $statServices.= ''; $statServices.= ""; - $statServices.= ""; + $statServices.= ''; $statServices.= ''; $statServices.= ""; @@ -325,10 +325,10 @@ if ($result) print ''; } print '"; print '"; print "\n"; $i++; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index dabace75ac0..cfbec4a8016 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -36,6 +36,7 @@ $price_impact = (float) GETPOST('price_impact'); $price_impact_percent = (bool) GETPOST('price_impact_percent'); $form = new Form($db); $action = GETPOST('action'); +$cancel = GETPOST('cancel'); // Security check $fieldvalue = (! empty($id) ? $id : $ref); @@ -57,6 +58,10 @@ if ($id > 0 || $ref) * Actions */ +if ($cancel) { + $action=''; +} + if (! $object->isProduct()) { header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2)); exit(); @@ -107,7 +112,7 @@ if ($_POST) { $db->begin(); if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) { - if (ProductCombination::createProductCombination($product, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact)) { + if (ProductCombination::createProductCombination($object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact)) { $db->commit(); setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); @@ -175,7 +180,7 @@ if ($_POST) { setEventMessage($langs->trans('RecordSaved')); } - } else { + } elseif ($valueid > 0) { if ($prodcomb->fetch($valueid) < 0) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); @@ -256,6 +261,9 @@ if ($action === 'confirm_deletecombination') { * View */ +$form = new Form($db); + + if (! empty($id) || ! empty($ref)) { llxHeader("", "", $langs->trans("CardProduct".$object->type)); @@ -342,6 +350,7 @@ if (! empty($id) || ! empty($ref)) { var select = jQuery("select#features"); select.empty(); + jQuery("form#combinationform input[type=hidden]").detach(); jQuery.each(variants_selected.index, function (key, val) { @@ -359,11 +368,12 @@ if (! empty($id) || ! empty($ref)) { jQuery(document).ready(function() { jQuery("select#attribute").change(function () { - console.log("Change of field attribute"); + console.log("Change of field variant attribute"); var select = jQuery("select#value"); if (!jQuery(this).val().length || jQuery(this).val() == '-1') { select.empty(); + select.append(''); return; } @@ -373,22 +383,27 @@ if (! empty($id) || ! empty($ref)) { id: jQuery(this).val() }, function(data) { if (data.error) { - jQuery("select#value").empty(); + select.empty(); + select.append(''); return alert(data.error); } select.empty(); - /* console.log(data.length); */ + select.append(''); jQuery(data).each(function (key, val) { keyforoption = val.id valforoption = val.value - jQuery("select#value").append(''); + select.append(''); }); }); }); + /* Click on button Add combination + @FIXME Not compatible with all browsers. + */ jQuery("#addfeature").click(function () { + console.log("Click on add"); var selectedattr = jQuery("select[name=attribute] option:selected"); var selectedvalu = jQuery("select[name=value] option:selected"); @@ -438,54 +453,69 @@ if (! empty($id) || ! empty($ref)) { '; + print ''; + print ''; + print dol_fiche_head(); ?>
'.$langs->trans("Statistics").'
'.$langs->trans("ProductsNotOnSell").''.round($prodser[0][0]).'
'.$langs->trans("ProductsOnSell").''.round($prodser[0][1]).'
'.$langs->trans("ProductsOnSellAndOnBuy").''.round($prodser[0][2]).'
'.$langs->trans("ServicesNotOnSell").''.round($prodser[1][0]).'
'.$langs->trans("ServicesOnSell").''.round($prodser[1][1]).'
'.$langs->trans("ServicesOnSellAndOnBuy").''.round($prodser[1][2]).'
'; - print $product_static->LibStatut($objp->tosell,5,0); + print $product_static->LibStatut($objp->tosell,3,0); print "'; - print $product_static->LibStatut($objp->tobuy,5,1); + print $product_static->LibStatut($objp->tobuy,3,1); print "
+ - + - - - - + +
+
+ trans("SelectCombination"); ?> +
+
+ + + + + + +
+ +
+ - - +
+
+
- -

- -
+ >
@@ -494,8 +524,10 @@ if (! empty($id) || ! empty($ref)) { ?>
- -
+ +   + +
@@ -509,7 +541,6 @@ if (! empty($id) || ! empty($ref)) { if ($action === 'delete') { if ($prodcomb->fetch($valueid) > 0) { - $form = new Form($db); $prodstatic->fetch($prodcomb->fk_product_child); print $form->formconfirm( @@ -524,8 +555,6 @@ if (! empty($id) || ! empty($ref)) { } } elseif ($action === 'copy') { - $form = new Form($db); - print $form->formconfirm( 'combinations.php?id='.$id, $langs->trans('CloneCombinationsProduct'), @@ -570,50 +599,64 @@ if (! empty($id) || ! empty($ref)) { }); - - - - - " class="button"> -
-
'; + print '
'; if ($productCombinations) { print ''.$langs->trans('Copy').''; } + print ''.$langs->trans('NewProductCombination').''; - print ''.$langs->trans('ProductCombinationGenerator').''; + + if (empty($conf->dol_optimize_smallscreen) && $conf->use_javascript_ajax) // Bugged page. Too much useless javascript. + { + print ''.$langs->trans('ProductCombinationGenerator').''; + } + print '
'; + print '
'; + print ''; + $aaa=''; + if (count($productCombinations)) + { + $aaa = ''; + $aaa .= ''; + $aaa .= ''; + $aaa .= ''; + } + $title = $langs->trans("ProductCombinations"); + + print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $aaa, 0); + + print '
'; ?> - - + + + + + + + - - - - - - - fetch($currcomb->fk_product_child); ?> - > - + - - + + - +
+ trans('Product') ?>trans('Combination') ?>trans('PriceImpact') ?>trans('WeightImpact') ?>trans('OnSell') ?>trans('OnBuy') ?> trans('Product') ?>trans('Combination') ?>trans('PriceImpact') ?>trans('WeightImpact') ?>trans('OnSell') ?>trans('OnBuy') ?>
getNomUrl(1) ?> variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?>variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight') ?>variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?>variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight') ?> getLibStatut(2, 0) ?> getLibStatut(2, 1) ?> - - + + +
- - - - '; + print ''; } } llxFooter(); + +$db->close(); diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index b709f240551..7b0358fd176 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -130,6 +130,8 @@ if ($_POST) { } } + + /* * View */ @@ -140,37 +142,21 @@ if (! empty($id) || ! empty($ref)) { llxHeader("", "", $langs->trans("CardProduct".$object->type)); - if ($result) { - $head = product_prepare_head($object); - $titre = $langs->trans("CardProduct".$object->type); - $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); - + if ($result > 0) + { + $showbarcode=empty($conf->barcode->enabled)?0:1; + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; + + $head=product_prepare_head($object); + $titre=$langs->trans("CardProduct".$object->type); + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'combinations', $titre, 0, $picto); - - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', '', 0); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2, 0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2, 1); - print '
'; - + + $linkback = ''.$langs->trans("BackToList").''; + $object->next_prev_filter=" fk_product_type = ".$object->type; + + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); + dol_fiche_end(); }