Skip to content

Commit

Permalink
NEW Add accounting code for eec sales and export sales on products
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Apr 24, 2019
1 parent aa91849 commit e5c2027
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 75 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/class/extrafields.class.php
Expand Up @@ -1837,7 +1837,7 @@ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjec
$out='';

// Only if something to display (perf)
if ($value) // If we have -1 here, pb is into sert, not into ouptu
if ($value) // If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate)
{
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'

Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/en_US/products.lang
Expand Up @@ -294,7 +294,7 @@ ProductSheet=Product sheet
ServiceSheet=Service sheet
PossibleValues=Possible values
GoOnMenuToCreateVairants=Go on menu %s - %s to prepare attribute variants (like colors, size, ...)
UseProductFournDesc=Use vendor descriptions of products in vendor documents
UseProductFournDesc=Add a feature to define the descriptions of products defined by the vendors in addition to descriptions for customers
ProductSupplierDescription=Vendor description for the product
#Attributes
VariantAttributes=Variant attributes
Expand Down
119 changes: 54 additions & 65 deletions htdocs/product/card.php
Expand Up @@ -1218,21 +1218,19 @@
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.'">';
print '</td></tr>';

if ($conf->global->MAIN_FEATURES_LEVEL)
// Accountancy_code_sell_intra
if ($mysoc->isInEEC())
{
// Accountancy_code_sell_intra
if ($mysoc->isInEEC()) {
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.'">';
print '</td></tr>';
}

// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.'">';
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.'">';
print '</td></tr>';
}

// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.'">';
print '</td></tr>';

// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.'">';
Expand Down Expand Up @@ -1514,24 +1512,21 @@
print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
print '</td></tr>';

if ($conf->global->MAIN_FEATURES_LEVEL)
// Accountancy_code_sell_intra
if ($mysoc->isInEEC())
{
// Accountancy_code_sell_intra
if ($mysoc->isInEEC())
{
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td>';
print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1);
print '</td></tr>';
}

// Accountancy_code_sell_export
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td>';
print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1);
print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1);
print '</td></tr>';
}

// Accountancy_code_sell_export
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<td>';
print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1);
print '</td></tr>';

// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td>';
Expand All @@ -1545,22 +1540,19 @@
print '<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.'">';
print '</td></tr>';

if ($conf->global->MAIN_FEATURES_LEVEL)
// Accountancy_code_sell_intra
if ($mysoc->isInEEC())
{
// Accountancy_code_sell_intra
if ($mysoc->isInEEC())
{
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.$object->accountancy_code_sell_intra.'">';
print '</td></tr>';
}

// Accountancy_code_sell_export
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.$object->accountancy_code_sell_export.'">';
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.$object->accountancy_code_sell_intra.'">';
print '</td></tr>';
}

// Accountancy_code_sell_export
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
print '<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.$object->accountancy_code_sell_export.'">';
print '</td></tr>';

// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.'">';
Expand Down Expand Up @@ -1687,48 +1679,45 @@
}
print '</td></tr>';

if ($conf->global->MAIN_FEATURES_LEVEL)
// Accountancy sell code intra-community
if ($mysoc->isInEEC())
{
// Accountancy sell code intra-community
if ($mysoc->isInEEC())
{
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancySellIntraCode");
print '</td><td colspan="2">';
if (! empty($conf->accounting->enabled))
{
if (! empty($object->accountancy_code_sell_intra))
{
$accountingaccount2 = new AccountingAccount($db);
$accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1);

print $accountingaccount2->getNomUrl(0, 1, 1, '', 1);
}
} else {
print $object->accountancy_code_sell_intra;
}
print '</td></tr>';
}

// Accountancy sell code export
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancySellExportCode");
print $langs->trans("ProductAccountancySellIntraCode");
print '</td><td colspan="2">';
if (! empty($conf->accounting->enabled))
{
if (! empty($object->accountancy_code_sell_export))
if (! empty($object->accountancy_code_sell_intra))
{
$accountingaccount3 = new AccountingAccount($db);
$accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1);
$accountingaccount2 = new AccountingAccount($db);
$accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1);

print $accountingaccount3->getNomUrl(0, 1, 1, '', 1);
print $accountingaccount2->getNomUrl(0, 1, 1, '', 1);
}
} else {
print $object->accountancy_code_sell_export;
print $object->accountancy_code_sell_intra;
}
print '</td></tr>';
}

// Accountancy sell code export
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancySellExportCode");
print '</td><td colspan="2">';
if (! empty($conf->accounting->enabled))
{
if (! empty($object->accountancy_code_sell_export))
{
$accountingaccount3 = new AccountingAccount($db);
$accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1);

print $accountingaccount3->getNomUrl(0, 1, 1, '', 1);
}
} else {
print $object->accountancy_code_sell_export;
}
print '</td></tr>';

// Accountancy buy code
print '<tr><td class="nowrap">';
print $langs->trans("ProductAccountancyBuyCode");
Expand Down
46 changes: 38 additions & 8 deletions htdocs/product/list.php
Expand Up @@ -62,6 +62,8 @@
$catid = GETPOST('catid', 'int');
$search_tobatch = GETPOST("search_tobatch", 'int');
$search_accountancy_code_sell = GETPOST("search_accountancy_code_sell", 'alpha');
$search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intra", 'alpha');
$search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha');
$search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
$type=GETPOST("type", "int");
Expand Down Expand Up @@ -154,6 +156,8 @@
}
}

$isInEEC=isInEEC($mysoc);

// Definition of fields for lists
$arrayfields=array(
'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
Expand All @@ -175,8 +179,10 @@
'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')),
'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)),
'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))),
'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0),
'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0),
'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400),
'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401),
'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402),
'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0, 'position'=>403),
'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000),
Expand Down Expand Up @@ -227,6 +233,8 @@

$show_childproducts = '';
$search_accountancy_code_sell='';
$search_accountancy_code_sell_intra='';
$search_accountancy_code_sell_export='';
$search_accountancy_code_buy='';
$search_array_options=array();
}
Expand Down Expand Up @@ -321,8 +329,10 @@
if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL";
if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id;
if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch);
if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell);
if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy);
if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell);
if ($search_accountancy_code_sell_intra) $sql.= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra);
if ($search_accountancy_code_sell_export) $sql.= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export);
if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy);

// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
Expand Down Expand Up @@ -418,6 +428,8 @@
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier);
if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell);
if ($search_accountancy_code_sell_intra) $param="&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra);
if ($search_accountancy_code_sell_export) $param="&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export);
if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
Expand Down Expand Up @@ -630,8 +642,10 @@
// To batch
if (! empty($arrayfields['p.tobatch']['checked'])) print '<td class="liste_titre center">'.$form->selectyesno($search_tobatch, '', '', '', 1).'</td>';
// Accountancy code sell
if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_sell" size="6" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>';
// Accountancy code sell
if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>';
if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_intra" value="'.dol_escape_htmltag($search_accountancy_code_sell_intra).'"></td>';
if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print '<td class="liste_titre"><input class="flat maxwidth75" type="text" name="search_accountancy_code_sell_export" value="'.dol_escape_htmltag($search_accountancy_code_sell_export).'"></td>';
// Accountancy code buy
if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_buy" size="6" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>';
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
Expand Down Expand Up @@ -723,7 +737,13 @@
if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) {
print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder);
}
if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) {
if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) {
print_liste_field_titre($arrayfields['p.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder);
}
if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) {
print_liste_field_titre($arrayfields['p.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder);
}
if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) {
print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder);
}
// Extra fields
Expand Down Expand Up @@ -1032,7 +1052,17 @@
print '<td>'.$obj->accountancy_code_sell.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Accountancy code sell
if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked']))
{
print '<td>'.$obj->accountancy_code_sell_intra.'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['p.accountancy_code_sell_export']['checked']))
{
print '<td>'.$obj->accountancy_code_sell_export.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Accountancy code buy
if (! empty($arrayfields['p.accountancy_code_buy']['checked']))
{
print '<td>'.$obj->accountancy_code_buy.'</td>';
Expand Down

0 comments on commit e5c2027

Please sign in to comment.