Skip to content

Commit

Permalink
Debug accounting menu. Can now edit product account if already set.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 4, 2016
1 parent 0f016bb commit e59c2bb
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 94 deletions.
6 changes: 2 additions & 4 deletions htdocs/accountancy/admin/account.php
Expand Up @@ -256,10 +256,8 @@
print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td align="right" colspan="2" class="liste_titre">';

print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '&nbsp;';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpitco;
print '</td>';
print '</tr>';

Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/admin/defaultaccounts.php
Expand Up @@ -138,7 +138,7 @@
$label = $langs->trans($key);
print '<td>' . $label . '</td>';
// Value
print '<td align="right">';
print '<td>'; // Do not force align=right, or it align also the content of the select box
print $formaccountancy->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>';
print '</tr>';
Expand Down
219 changes: 148 additions & 71 deletions htdocs/accountancy/admin/productaccount.php

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions htdocs/accountancy/class/html.formventilation.class.php
Expand Up @@ -65,7 +65,7 @@ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = ''
/**
* Return list of accounts with label by chart of accounts
*
* @param string $selectid Preselected chart of accounts
* @param string $selectid Preselected id or code of accounting accounts (depends on $select_in)
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
Expand Down Expand Up @@ -99,26 +99,28 @@ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event

$out = ajax_combobox($htmlname, $event);

// TODO Add $options in cache so next call will not execute the request
$selected = 0;
$options = array();
$selected = null;

while ($obj = $this->db->fetch_object($resql)) {
while ($obj = $this->db->fetch_object($resql))
{
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength);

$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;

// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->account_number;
}
if ($select_out == 1) {
$select_value_out = $obj->account_number;
}

// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
// Because same account_number can be share between different accounting_system and do have the same meaning
if (($selectid != '') && $selectid == $select_value_in) {
if ($selectid != '' && $selectid == $select_value_in) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected = $select_value_out;
}

Expand All @@ -127,6 +129,7 @@ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event

$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
$this->db->free($resql);

return $out;
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/functions.lib.php
Expand Up @@ -5197,7 +5197,7 @@ function dol_osencode($str)
* Store also Code-Id into a cache to speed up next request on same key.
*
* @param DoliDB $db Database handler
* @param string $key Code to get Id
* @param string $key Code or Id to get Id or Code
* @param string $tablename Table name without prefix
* @param string $fieldkey Field for code
* @param string $fieldid Field for id
Expand Down
10 changes: 8 additions & 2 deletions htdocs/langs/en_US/accountancy.lang
Expand Up @@ -16,6 +16,8 @@ Journaux=Journals
JournalFinancial=Financial journals
BackToChartofaccounts=Return chart of accounts
Chartofaccounts=Chart of accounts
CurrentDedicatedAccountingAccount=Current dedicated account
AssignDedicatedAccountingAccount=New account to assign

AccountancyArea=Accountancy area
AccountancyAreaDescIntro=Usage of the accountancy module is done in several step:
Expand Down Expand Up @@ -207,11 +209,15 @@ DefaultBindingDesc=This page can be used to set a default account to use to link
Options=Options
OptionModeProductSell=Mode sales
OptionModeProductBuy=Mode purchases
OptionModeProductSellDesc=Show all products with no accounting account defined for sales.
OptionModeProductBuyDesc=Show all products with no accounting account defined for purchases.
OptionModeProductSellDesc=Show all products with accounting account for sales.
OptionModeProductBuyDesc=Show all products with accounting account for purchases.
CleanFixHistory=Remove accountancy code from lines that not exists into charts of account
CleanHistory=Reset all bindings for selected year

WithoutValidAccount=Without valid dedicated account
WithValidAccount=With valid dedicated account
ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account

## Dictionary
Range=Range of accounting account
Calculated=Calculated
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/products.lang
Expand Up @@ -101,6 +101,7 @@ KeywordFilter=Keyword filter
CategoryFilter=Category filter
ProductToAddSearch=Search product to add
NoMatchFound=No match found
ListOfProductsServices=List of products/services
ProductAssociationList=List of products/services that are component of this virtual product/package
ProductParentList=List of virtual products/services with this product as a component
ErrorAssociationIsFatherOfThis=One of selected product is parent with current product
Expand Down
22 changes: 13 additions & 9 deletions htdocs/product/class/product.class.php
Expand Up @@ -3159,17 +3159,21 @@ function getNomUrl($withpicto=0,$option='',$maxlength=0)
if (! empty($this->label))
$label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label;

$tmptext='';
if ($this->weight) $tmptext.="<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units,"weight");
if ($this->length) $tmptext.="<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units,'length');
if ($this->surface) $tmptext.="<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units,'surface');
if ($this->volume) $tmptext.="<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units,'volume');
if ($tmptext) $label .= $tmptext;
if (! empty($conf->productbatch->enabled))
if ($this->type == Product::TYPE_PRODUCT)
{
$tmptext.="<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0,2);
if ($this->weight) $label.="<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units,"weight");
if ($this->length) $label.="<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units,'length');
if ($this->surface) $label.="<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units,'surface');
if ($this->volume) $label.="<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units,'volume');
if (! empty($conf->productbatch->enabled))
{
$label.="<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0,2);
}
}
if ($this->type == Product::TYPE_SERVICE)
{
//
}
$label.=$tmptext;
if (! empty($this->entity)) $label .= '<br>' . $this->show_photos($conf->product->multidir_output[$this->entity],1,1,0,0,0,80);


Expand Down

0 comments on commit e59c2bb

Please sign in to comment.