Skip to content

Commit

Permalink
FIX If product account not suggested during bind, it is not preselected
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 9, 2019
1 parent 9f4aada commit 9da1d50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 12 additions & 5 deletions htdocs/accountancy/customer/list.php
Expand Up @@ -425,7 +425,6 @@

$objp->code_sell_l = '';
$objp->code_sell_p = '';
$objp->aarowid_suggest = '';

$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
Expand All @@ -437,7 +436,7 @@
$facture_static->type = $objp->ftype;

$code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
$objp->aarowid_suggest = ''; // Will be set later

$isBuyerInEEC = isInEEC($objp);

Expand Down Expand Up @@ -471,8 +470,9 @@
}
if ($objp->code_sell_l == -1) $objp->code_sell_l='';

// Search suggested account for product/service
$suggestedaccountingaccountfor = '';
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = '';
Expand Down Expand Up @@ -561,12 +561,19 @@

// Suggested accounting account
print '<td>';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
$suggestedid = $objp->aarowid_suggest;
if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && ! empty($conf->global->ACCOUNTANCY_AUTOFILL_ACCOUNT_WITH_GENERIC))
{
//$suggestedid = // id of $objp->code_sell_l
}
print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>';

// Column with checkbox
print '<td class="center">';
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
//var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest);
$ischecked = $objp->aarowid_suggest;
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($ischecked ? "checked" : "") . '/>';
print '</td>';

print '</tr>';
Expand Down
6 changes: 4 additions & 2 deletions htdocs/accountancy/supplier/list.php
Expand Up @@ -533,12 +533,14 @@

// Suggested accounting account
print '<td>';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
$suggestedid = $objp->aarowid_suggest;
print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>';

// Column with checkbox
print '<td class="center">';
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
$ischecked = $objp->aarowid_suggest;
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($ischecked ? "checked" : "") . '/>';
print '</td>';

print '</tr>';
Expand Down

0 comments on commit 9da1d50

Please sign in to comment.