diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index e6d3aac27d0..8118c4f9d4a 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -517,38 +517,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
llxHeader('', $title, $help_url);
-if (GETPOSTISSET("search_status")) {
- if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED
- $title = $langs->trans("MembersListQualified");
- }
- if ($search_status == Adherent::STATUS_DRAFT) {
- $title = $langs->trans("MembersListToValid");
- }
- if ($search_status == Adherent::STATUS_VALIDATED && $filter == '') {
- $title = $langs->trans("MenuMembersValidated");
- }
- if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'waitingsubscription') {
- $title = $langs->trans("MembersWithWaitingSubscription");
- }
- if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'withoutsubscription') {
- $title = $langs->trans("MembersWithSubscriptionToReceive");
- }
- if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'uptodate') {
- $title = $langs->trans("MembersListUpToDate");
- }
- if ($search_status == Adherent::STATUS_VALIDATED && $filter == 'outofdate') {
- $title = $langs->trans("MembersListNotUpToDate");
- }
- if ((string) $search_status == (string) Adherent::STATUS_RESILIATED) { // The cast to string is required to have test false when search_status is ''
- $title = $langs->trans("MembersListResiliated");
- }
- if ($search_status == Adherent::STATUS_EXCLUDED) {
- $title = $langs->trans("MembersListExcluded");
- }
-} elseif ($action == 'search') {
- $title = $langs->trans("MembersListQualified");
-}
-
if ($search_type > 0) {
$membertype = new AdherentType($db);
$result = $membertype->fetch($search_type);
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 590d1bafe17..39d5a43bc55 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -75,6 +75,7 @@ $offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
$remindertype = GETPOST('selectremindertype', 'aZ09');
$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
$complete = GETPOST('complete', 'alpha'); // 'na' must be allowed
+$private = GETPOST('private', 'alphanohtml');
if ($complete == 'na' || $complete == -2) {
$complete = -1;
}
@@ -695,7 +696,15 @@ if (empty($reshook) && $action == 'update') {
$datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
}
- $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
+ if ($object->elementtype == 'ticket') {
+ if ($private) {
+ $object->type_code = 'TICKET_MSG_PRIVATE';
+ } else {
+ $object->type_id = dol_getIdFromCode($db, 'AC_EMAIL', 'c_actioncomm');
+ }
+ } else {
+ $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
+ }
$object->label = GETPOST("label", "alphanohtml");
$object->datep = $datep;
$object->datef = $datef;
@@ -1694,7 +1703,7 @@ if ($id > 0) {
if ($backtopage) {
print ' ';
}
- if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
+ if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->code != "TICKET_MSG_PRIVATE") {
print ' ';
}
@@ -1706,7 +1715,7 @@ if ($id > 0) {
print '
'.$langs->trans("Ref").' '.$object->id.' ';
// Type of event
- if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
+ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype != "ticket") {
print ''.$langs->trans("Type").' ';
if ($object->type_code != 'AC_OTH_AUTO') {
print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"');
@@ -1719,6 +1728,9 @@ if ($id > 0) {
print ' ';
}
+ // Private
+ if ($object->elementtype == 'ticket') print ''.$langs->trans("PrivateEventMessage").' code == 'TICKET_MSG_PRIVATE') ? ' checked' : '').'> ';
+
// Title
print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Title").' ';
@@ -2184,13 +2196,16 @@ if ($id > 0) {
print '';
// Type
- if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
+ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype != 'ticket') {
print ''.$langs->trans("Type").' ';
print $object->getTypePicto();
print $langs->trans("Action".$object->type_code);
print ' ';
}
+ // Private
+ if ($object->elementtype == 'ticket') print ''.$langs->trans("PrivateEventMessage").' '.yn(($object->code == 'TICKET_MSG_PRIVATE') ? 1 : 0, 3).' ';
+
// Full day event
print ''.$langs->trans("EventOnFullDay").' '.yn($object->fulldayevent ? 1 : 0, 3).' ';
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index d0b64fdca77..82012400f68 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -950,7 +950,7 @@ abstract class CommonDocGenerator
}
}
- if (array_key_exists('option_'.$key, $object->array_options)) {
+ if (array_key_exists('options_'.$key, $object->array_options)) {
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
} else {
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => ''));
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 508129ba141..60270f440ba 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -6067,14 +6067,15 @@ abstract class CommonObject
//var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]);
}
}
+ }
- // If field is a computed field, value must become result of compute
- foreach ($tab as $key => $value) {
- if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
- //var_dump($conf->disable_compute);
- if (empty($conf->disable_compute)) {
- $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
- }
+ // If field is a computed field, value must become result of compute (regardless of whether a row exists
+ // in the element's extrafields table)
+ foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) {
+ if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
+ //var_dump($conf->disable_compute);
+ if (empty($conf->disable_compute)) {
+ $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
}
}
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 041f6902040..6aab933f29b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3173,6 +3173,8 @@ class Form
'type'=>$outtype,
'price_ht'=>price2num($outprice_ht),
'price_ttc'=>price2num($outprice_ttc),
+ 'price_ht_locale'=>price(price2num($outprice_ht)),
+ 'price_ttc_locale'=>price(price2num($outprice_ttc)),
'pricebasetype'=>$outpricebasetype,
'tva_tx'=>$outtva_tx,
'default_vat_code'=>$outdefault_vat_code,
@@ -3274,9 +3276,9 @@ class Form
$sql .= " pfp.supplier_reputation";
// if we use supplier description of the products
if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
- $sql .= " ,pfp.desc_fourn as description";
+ $sql .= ", pfp.desc_fourn as description";
} else {
- $sql .= " ,p.description";
+ $sql .= ", p.description";
}
// Units
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
@@ -3558,7 +3560,13 @@ class Form
$optstart .= ' disabled';
}
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
- $optstart .= ' data-product-id="'.$objp->rowid.'" data-price-id="'.$objp->idprodfournprice.'" data-qty="'.$objp->quantity.'" data-up="'.$objp->unitprice.'" data-discount="'.$outdiscount.'" data-tvatx="'.$objp->tva_tx.'"';
+ $opt .= ' data-product-id="'.dol_escape_htmltag($objp->rowid).'"';
+ $opt .= ' data-price-id="'.dol_escape_htmltag($objp->idprodfournprice).'"';
+ $opt .= ' data-qty="'.dol_escape_htmltag($objp->quantity).'"';
+ $opt .= ' data-up="'.dol_escape_htmltag($objp->unitprice).'"';
+ $opt .= ' data-up-locale="'.dol_escape_htmltag(price($objp->unitprice)).'"';
+ $opt .= ' data-discount="'.dol_escape_htmltag($outdiscount).'"';
+ $opt .= ' data-tvatx="'.dol_escape_htmltag($objp->tva_tx).'"';
}
$optstart .= ' data-description="'.dol_escape_htmltag($objp->description, 0, 1).'"';
@@ -3594,8 +3602,27 @@ class Form
// "key" value of json key array is used by jQuery automatically as selected value. Example: 'type' = product or service, 'price_ht' = unit price without tax
// "label" value of json key array is used by jQuery automatically as text for combo box
$out .= $optstart . ' data-html="'.dol_escape_htmltag($optlabel).'">' . $optlabel . "\n";;
- array_push($outarray, $outarrayentry);
-
+ array_push(
+ $outarray,
+ array('key'=>$outkey,
+ 'value'=>$outref,
+ 'label'=>$outval,
+ 'qty'=>$outqty,
+ 'price_qty_ht'=>price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty
+ 'price_unit_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price
+ 'price_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price (for compatibility)
+ 'price_qty_ht_locale'=>price($objp->fprice),
+ 'price_unit_ht_locale'=>price($objp->unitprice),
+ 'tva_tx'=>$objp->tva_tx,
+ 'default_vat_code'=>$objp->default_vat_code,
+ 'discount'=>$outdiscount,
+ 'type'=>$outtype,
+ 'duration_value'=>$outdurationvalue,
+ 'duration_unit'=>$outdurationunit,
+ 'disabled'=>(empty($objp->idprodfournprice) ? true : false),
+ 'description'=>$objp->description
+ )
+ );
// Exemple of var_dump $outarray
// array(1) {[0]=>array(6) {[key"]=>string(1) "2" ["value"]=>string(3) "ppp"
// ["label"]=>string(76) "ppp (f ff2) - ppp - 20,00 Euros/1unité (20,00 Euros/unité)"
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 850ccd34c1c..35e67f19e80 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -143,8 +143,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
textarea[key] = item[value];
});
}
+
console.log("Return value from GET to the rest of code");
- return { label: label, value: item.value, id: item.key, disabled: item.disabled,
+ return { label: label,
+ value: item.value,
+ id: item.key,
+ disabled: item.disabled,
update: update,
textarea: textarea,
pbq: item.pbq,
@@ -154,6 +158,8 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
pricebasetype: item.pricebasetype,
price_ht: item.price_ht,
price_ttc: item.price_ttc,
+ price_unit_ht: item.price_unit_ht,
+ price_unit_ht_locale: item.price_unit_ht_locale,
description : item.description,
ref_customer: item.ref_customer,
tva_tx: item.tva_tx }
@@ -173,6 +179,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
// For supplier price and customer when price by quantity is off
$("#'.$htmlnamejquery.'").attr("data-up", ui.item.price_ht);
+ $("#'.$htmlnamejquery.'").attr("data-up-locale", ui.item.price_unit_ht_locale);
$("#'.$htmlnamejquery.'").attr("data-base", ui.item.pricebasetype);
$("#'.$htmlnamejquery.'").attr("data-qty", ui.item.qty);
$("#'.$htmlnamejquery.'").attr("data-discount", ui.item.discount);
@@ -191,6 +198,8 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
';
}
$script .= '
+ // A new value has been selected, we trigger the handlers on #htmlnamejquery
+ console.log("Trigger changes on #'.$htmlnamejquery.'");
$("#'.$htmlnamejquery.'").val(ui.item.id).trigger("change"); // Select new value
// Complementary actions
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index d7eaa971a08..040267e0259 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -18,6 +18,7 @@
* Copyright (C) 2020 Open-Dsi
* Copyright (C) 2021 Gauthier VERDOL
* Copyright (C) 2022 Anthony Berton
+ * Copyright (C) 2022 Ferran Marcet
*
* 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
@@ -7676,6 +7677,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref : '');
$substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title : '');
}
+ if (is_object($object) && $object->element == 'project') {
+ $substitutionarray['__PROJECT_NAME__'] = $object->title;
+ }
if (is_object($object) && $object->element == 'shipping') {
$substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number;
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index bc48c28140e..4ec5fcc02c6 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -292,7 +292,9 @@ if ($nolinesbefore) {
$alsoproductwithnosupplierprice = 0;
} else {
$ajaxoptions = array(
- 'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
+ // Disabled: This is useless because setting discount and price_ht after a selection is already managed
+ // by ths page itself with a .change on the combolist '#idprodfournprice'
+ //'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
);
$alsoproductwithnosupplierprice = 1;
}
@@ -712,7 +714,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
/* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function()
{
- console.log("Call method change() after change on #idprod or #idprodfournprice (senderissupplier=). this.val = "+$(this).val());
+ console.log("objectline_create.tpl Call method change() after change on #idprod or #idprodfournprice (senderissupplier=). this.val = "+$(this).val());
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
jQuery('#trlinefordates').show();
@@ -725,7 +727,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
{
- console.log("We are in a price per qty context, we do not call ajax/product, init of fields is done few lines later");
+ console.log("objectline_create.tpl We are in a price per qty context, we do not call ajax/product, init of fields is done few lines later");
} else {
global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?>
if (isNaN(pbq)) { console.log("We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we could not get the id of pbq from product combo list, so load of price may be 0 if product has differet prices"); }
@@ -735,7 +737,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
$.post('/product/ajax/products.php?action=fetch',
{ 'id': $(this).val(), 'socid': socid; ?> },
function(data) {
- console.log("Load unit price end, we got value ht="+data.price_ht+" ttc="+data.price_ttc+" pricebasetype="+data.pricebasetype);
+ console.log("objectline_create.tpl Load unit price end, we got value ht="+data.price_ht+" ttc="+data.price_ttc+" pricebasetype="+data.pricebasetype);
$('#date_start').removeAttr('type');
$('#date_end').removeAttr('type');
@@ -757,8 +759,10 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
}
if ( == 1 && data.pricebasetype == 'TTC') {
+ console.log("objectline_create.tpl set content of price_ttc");
jQuery("#price_ttc").val(data.price_ttc);
} else {
+ console.log("objectline_create.tpl set content of price_ht");
jQuery("#price_ht").val(data.price_ht);
}
rights->margins->creer) {
var proddesc = data.desc;
- console.log("Load desciption into text area : "+proddesc);
+ console.log("objectline_create.tpl Load desciption into text area : "+proddesc);
global->FCKEDITOR_ENABLE_DETAILS)) { ?>
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
@@ -790,7 +794,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
global->PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES)) { ?>
jQuery.each(data.array_options, function( key, value ) {
- jQuery('div[class$="det'+key.replace('options_','_extras_')+'"] > #'+key).val(value);
+ jQuery('div[class*="det'+key.replace('options_','_extras_')+'"] > #'+key).val(value);
});
@@ -834,7 +838,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
print 'costprice';
}
} ?>';
- console.log("we will set the field for margin. defaultbuyprice="+defaultbuyprice);
+ console.log("objectline_create.tpl we will set the field for margin. defaultbuyprice="+defaultbuyprice);
var i = 0;
$(data).each(function() {
@@ -945,11 +949,16 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
- //Deal with supplier
- if (jQuery('#idprodfournprice').val() >0)
+ // Deal with supplier
+ if (jQuery('#idprodfournprice').val() > 0)
{
+ console.log("objectline_create.tpl #idprodfournprice is > 0, so we set some properties into page");
+
var up = parseFloat($('option:selected', this).attr('data-up')); // When select is done from HTML select
- if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with autocomplete
+ if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with ajax autocomplete
+
+ var up_locale = $('option:selected', this).attr('data-up-locale'); // When select is done from HTML select
+ if (typeof up_locale === 'undefined') { up_locale = jQuery('#idprodfournprice').attr('data-up-locale');} // When select is done from HTML input with ajax autocomplete
var qty = parseFloat($('option:selected', this).attr('data-qty'));
if (isNaN(qty)) { qty = parseFloat(jQuery('#idprodfournprice').attr('data-qty'));}
@@ -958,11 +967,15 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));}
var tva_tx = parseFloat($('option:selected', this).attr('data-tvatx')); // When select is done from HTML select
- if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with autocomplete
+ if (isNaN(tva_tx)) { tva_tx = parseFloat(jQuery('#idprodfournprice').attr('data-tvatx'));} // When select is done from HTML input with ajax autocomplete
- console.log("We find supplier price :"+up+" qty: "+qty+" tva_tx="+tva_tx+" discount: "+discount+" for product "+jQuery('#idprodfournprice').val());
+ console.log("objectline_create.tpl We find supplier price : up = "+up+", up_locale = "+up_locale+", qty = "+qty+", tva_tx = "+tva_tx+", discount = "+discount+" for product "+jQuery('#idprodfournprice').val());
- jQuery("#price_ht").val(up);
+ if (typeof up_locale === 'undefined') {
+ jQuery("#price_ht").val(up);
+ } else {
+ jQuery("#price_ht").val(up_locale);
+ }
/* $('#tva_tx option').removeAttr('selected').filter('[value='+tva_tx+']').prop('selected', true); */
$('#tva_tx option').val(tva_tx);
@@ -970,8 +983,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
if (jQuery("#qty").val() < qty) {
jQuery("#qty").val(qty);
}
- if (jQuery("#remise_percent").val() < discount)
- {
+ if (jQuery("#remise_percent").val() < discount) {
jQuery("#remise_percent").val(discount);
}
@@ -1038,7 +1050,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
/* Function to set fields from choice */
function setforfree() {
- console.log("Call setforfree. We show most fields");
+ console.log("objectline_create.tpl::setforfree. We show most fields");
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
jQuery("#prod_entry_mode_free").prop('checked',true).change();
jQuery("#prod_entry_mode_predef").prop('checked',false).change();
@@ -1049,7 +1061,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
}
function setforpredef() {
- console.log("Call setforpredef. We hide some fields and show dates");
+ console.log("objectline_create.tpl::setforpredef We hide some fields, show dates");
jQuery("#select_type").val(-1);
jQuery("#prod_entry_mode_free").prop('checked',false).change();
jQuery("#prod_entry_mode_predef").prop('checked',true).change();
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index a344b5b5f44..aba48b939be 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -3525,7 +3525,7 @@ class Product extends CommonObject
global $db, $conf, $user, $hookmanager;
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,";
- $sql .= " COUNT(fd.rowid) as nb_rows, SUM('fd.qty') as qty";
+ $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet_rec as fd";
$sql .= ", ".MAIN_DB_PREFIX."facture_rec as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php
index 707549655e0..66e673567a6 100644
--- a/htdocs/product/stats/bom.php
+++ b/htdocs/product/stats/bom.php
@@ -259,12 +259,11 @@ if ($id > 0 || !empty($ref)) {
}
$db->free($result);
+ $option .= '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php
index ed5216f85d1..5559eaf8413 100644
--- a/htdocs/product/stats/commande.php
+++ b/htdocs/product/stats/commande.php
@@ -185,13 +185,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
- $option = '';
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php
index f3353fa3d5d..6ae1d7881ef 100644
--- a/htdocs/product/stats/commande_fournisseur.php
+++ b/htdocs/product/stats/commande_fournisseur.php
@@ -185,13 +185,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
- $option = '';
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
@@ -228,7 +226,7 @@ if ($id > 0 || !empty($ref)) {
$i = 0;
print '';
- print '
';
+ print '';
print '';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "c.rowid", "", $option, '', $sortfield, $sortorder);
print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php
index 196831a5466..bcf9c8c0737 100644
--- a/htdocs/product/stats/contrat.php
+++ b/htdocs/product/stats/contrat.php
@@ -170,12 +170,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php
index 4ee1e4f95b2..3ff0b00d56a 100644
--- a/htdocs/product/stats/facture.php
+++ b/htdocs/product/stats/facture.php
@@ -201,12 +201,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option .= '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php
index 6e5ed524ad9..20bb56a3c19 100644
--- a/htdocs/product/stats/facture_fournisseur.php
+++ b/htdocs/product/stats/facture_fournisseur.php
@@ -184,12 +184,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option .= '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php
index 9415f2d6546..9b982407825 100644
--- a/htdocs/product/stats/facturerec.php
+++ b/htdocs/product/stats/facturerec.php
@@ -202,12 +202,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php
index a4947db1085..085a6687f5c 100644
--- a/htdocs/product/stats/mo.php
+++ b/htdocs/product/stats/mo.php
@@ -163,12 +163,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php
index 42467368b91..4919ffdba84 100644
--- a/htdocs/product/stats/propal.php
+++ b/htdocs/product/stats/propal.php
@@ -186,12 +186,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php
index ff14c764af6..538fc6aa362 100644
--- a/htdocs/product/stats/supplier_proposal.php
+++ b/htdocs/product/stats/supplier_proposal.php
@@ -185,12 +185,11 @@ if ($id > 0 || !empty($ref)) {
if ($result) {
$num = $db->num_rows($result);
+ $option = '&id='.$product->id;
+
if ($limit > 0 && $limit != $conf->liste_limit) {
$option .= '&limit='.urlencode($limit);
}
- if (!empty($id)) {
- $option .= '&id='.$product->id;
- }
if (!empty($search_month)) {
$option .= '&search_month='.urlencode($search_month);
}
diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php
index 62921f0a6e0..144c638a1cf 100644
--- a/htdocs/product/stock/tpl/extrafields_add.tpl.php
+++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php
@@ -38,13 +38,13 @@ if (empty($conf) || !is_object($conf)) {
// Other attributes
if (!isset($parameters)) $parameters = array();
-$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $movement, $action); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook)) {
$params = array();
if (isset($tpl_context)) $params['tpl_context'] = $tpl_context;
$params['cols'] = $parameters['colspanvalue'];
- print $movement->showOptionals($extrafields, 'create', $params);
+ print $object->showOptionals($extrafields, 'create', $params);
}
?>
diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php
index 8f522bb8107..1867eb368de 100644
--- a/htdocs/variants/ajax/get_attribute_values.php
+++ b/htdocs/variants/ajax/get_attribute_values.php
@@ -74,7 +74,7 @@ if ($prodattr->fetch($id) < 0) {
$prodattrval = new ProductAttributeValue($db);
-$res = $prodattrval->fetchAllByProductAttribute($id);
+$res = $prodattrval->fetchAllByProductAttribute($id, false, 1);
if ($res == -1) {
print json_encode(array(
diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php
index 99eef366345..734e82b7c27 100644
--- a/htdocs/variants/class/ProductAttributeValue.class.php
+++ b/htdocs/variants/class/ProductAttributeValue.class.php
@@ -261,9 +261,10 @@ class ProductAttributeValue extends CommonObjectLine
*
* @param int $prodattr_id Product attribute id
* @param bool $only_used Fetch only used attribute values
+ * @param int $returnonlydata 0: return object, 1: return only data
* @return ProductAttributeValue[] Array of object
*/
- public function fetchAllByProductAttribute($prodattr_id, $only_used = false)
+ public function fetchAllByProductAttribute($prodattr_id, $only_used = false, $returnonlydata = 0)
{
$return = array();
@@ -290,7 +291,12 @@ class ProductAttributeValue extends CommonObjectLine
$query = $this->db->query($sql);
while ($result = $this->db->fetch_object($query)) {
- $tmp = new ProductAttributeValue($this->db);
+ if (empty($returnonlydata)) {
+ $tmp = new ProductAttributeValue($this->db);
+ } else {
+ $tmp = new stdClass();
+ }
+
$tmp->fk_product_attribute = $result->fk_product_attribute;
$tmp->id = $result->rowid;
$tmp->ref = $result->ref;
diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php
index 0f149a4dd6a..64a18cf2a74 100644
--- a/htdocs/variants/combinations.php
+++ b/htdocs/variants/combinations.php
@@ -496,7 +496,7 @@ if (!empty($id) || !empty($ref)) {
}
if ($action == 'add') {
- $prodattr_all = $prodattr->fetchAll();
+ $prodattr_all = $prodattr->fetchAll(1);
if (!$selected) {
$selected = $prodattr_all[key($prodattr_all)]->id;
@@ -507,7 +507,6 @@ if (!empty($id) || !empty($ref)) {
foreach ($prodattr_all as $each) {
$prodattr_alljson[$each->id] = $each;
}
-
?>