Merge pull request #4252 from aspangaro/develop-a4
Accountancy Add a list to select accounting account on product card
This commit is contained in:
commit
2bb2f22955
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
/* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -94,7 +94,7 @@ class FormVentilation extends Form
|
|||||||
* @param array $event Event options
|
* @param array $event Event options
|
||||||
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
|
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
|
||||||
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
|
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
|
||||||
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by
|
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
|
||||||
*
|
*
|
||||||
* @return string String with HTML select
|
* @return string String with HTML select
|
||||||
*/
|
*/
|
||||||
@ -126,7 +126,7 @@ class FormVentilation extends Form
|
|||||||
if ($num) {
|
if ($num) {
|
||||||
while ( $i < $num ) {
|
while ( $i < $num ) {
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$label = $obj->account_number . ' - ' . $obj->label;
|
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
||||||
$label = dol_trunc($label, $trunclength);
|
$label = dol_trunc($label, $trunclength);
|
||||||
if ($select_in == 0 ) $select_value_in = $obj->rowid;
|
if ($select_in == 0 ) $select_value_in = $obj->rowid;
|
||||||
if ($select_in == 1 ) $select_value_in = $obj->account_number;
|
if ($select_in == 1 ) $select_value_in = $obj->account_number;
|
||||||
|
|||||||
@ -43,9 +43,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||||
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||||
|
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||||
|
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||||
|
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
@ -155,6 +157,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if ($action == 'setaccountancy_code_buy') {
|
if ($action == 'setaccountancy_code_buy') {
|
||||||
|
|
||||||
$result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy'));
|
$result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy'));
|
||||||
@ -168,6 +171,7 @@ if (empty($reshook))
|
|||||||
if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors');
|
if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors');
|
||||||
$action="";
|
$action="";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Add a product or service
|
// Add a product or service
|
||||||
if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
|
if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
|
||||||
@ -259,8 +263,12 @@ if (empty($reshook))
|
|||||||
$object->volume_units = GETPOST('volume_units');
|
$object->volume_units = GETPOST('volume_units');
|
||||||
$object->finished = GETPOST('finished');
|
$object->finished = GETPOST('finished');
|
||||||
$object->fk_unit = GETPOST('units');
|
$object->fk_unit = GETPOST('units');
|
||||||
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
|
|
||||||
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
|
$accountancy_code_sell = GETPOST('accountancy_code_sell');
|
||||||
|
$accountancy_code_buy = GETPOST('accountancy_code_buy');
|
||||||
|
|
||||||
|
if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
|
||||||
|
if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
|
||||||
|
|
||||||
// MultiPrix
|
// MultiPrix
|
||||||
if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
if (! empty($conf->global->PRODUIT_MULTIPRICES))
|
||||||
@ -369,8 +377,11 @@ if (empty($reshook))
|
|||||||
$object->barcode_type_coder = $stdobject->barcode_type_coder;
|
$object->barcode_type_coder = $stdobject->barcode_type_coder;
|
||||||
$object->barcode_type_label = $stdobject->barcode_type_label;
|
$object->barcode_type_label = $stdobject->barcode_type_label;
|
||||||
|
|
||||||
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
|
$accountancy_code_sell = GETPOST('accountancy_code_sell');
|
||||||
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
|
$accountancy_code_buy = GETPOST('accountancy_code_buy');
|
||||||
|
|
||||||
|
if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
|
||||||
|
if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
@ -729,6 +740,7 @@ llxHeader('', $title, $helpurl);
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formproduct = new FormProduct($db);
|
$formproduct = new FormProduct($db);
|
||||||
|
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
|
||||||
|
|
||||||
|
|
||||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||||
@ -1013,20 +1025,34 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
if (! empty($conf->accounting->enabled))
|
||||||
|
{
|
||||||
|
// Accountancy_code_sell
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 0, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy_code_sell
|
// Accountancy_code_buy
|
||||||
print '<tr><td>'.$langs->trans("ProductAccountancySellCode").'</td>';
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
||||||
print '<td><input name="accountancy_code_sell" size="16" value="'.$object->accountancy_code_sell.'">';
|
print '<td>';
|
||||||
print '</td></tr>';
|
print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 0, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else // For external software
|
||||||
|
{
|
||||||
|
// Accountancy_code_sell
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
||||||
|
print '<td><input name="accountancy_code_sell" size="16" value="'.$object->accountancy_code_sell.'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy_code_buy
|
// Accountancy_code_buy
|
||||||
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
||||||
print '<td><input name="accountancy_code_buy" size="16" value="'.$object->accountancy_code_buy.'">';
|
print '<td><input name="accountancy_code_buy" size="16" value="'.$object->accountancy_code_buy.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
@ -1273,14 +1299,24 @@ else
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
/*if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled))
|
print '<table class="border" width="100%">';
|
||||||
{
|
|
||||||
// Don't show accounting field when accounting id disabled.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
print '<table class="border" width="100%">';
|
|
||||||
|
|
||||||
|
if (! empty($conf->accounting->enabled))
|
||||||
|
{
|
||||||
|
// Accountancy_code_sell
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Accountancy_code_buy
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else // For external software
|
||||||
|
{
|
||||||
// Accountancy_code_sell
|
// Accountancy_code_sell
|
||||||
print '<tr><td width="20%">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancySellCode").'</td>';
|
||||||
print '<td><input name="accountancy_code_sell" size="16" value="'.$object->accountancy_code_sell.'">';
|
print '<td><input name="accountancy_code_sell" size="16" value="'.$object->accountancy_code_sell.'">';
|
||||||
@ -1290,9 +1326,8 @@ else
|
|||||||
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
print '<tr><td width="20%">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
|
||||||
print '<td><input name="accountancy_code_buy" size="16" value="'.$object->accountancy_code_buy.'">';
|
print '<td><input name="accountancy_code_buy" size="16" value="'.$object->accountancy_code_buy.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
//}
|
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
@ -1340,7 +1375,7 @@ else
|
|||||||
print '<tr><td class="nowrap">';
|
print '<tr><td class="nowrap">';
|
||||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
print $langs->trans("BarcodeType");
|
print $langs->trans("BarcodeType");
|
||||||
print '<td>';
|
print '</td>';
|
||||||
if (($action != 'editbarcodetype') && ! empty($user->rights->barcode->creer)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
|
if (($action != 'editbarcodetype') && ! empty($user->rights->barcode->creer)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
print '</td><td colspan="2">';
|
print '</td><td colspan="2">';
|
||||||
@ -1361,7 +1396,7 @@ else
|
|||||||
print '<tr><td class="nowrap">';
|
print '<tr><td class="nowrap">';
|
||||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
print $langs->trans("BarcodeValue");
|
print $langs->trans("BarcodeValue");
|
||||||
print '<td>';
|
print '</td>';
|
||||||
if (($action != 'editbarcode') && ! empty($user->rights->barcode->creer)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
|
if (($action != 'editbarcode') && ! empty($user->rights->barcode->creer)) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'),1).'</a></td>';
|
||||||
print '</tr></table>';
|
print '</tr></table>';
|
||||||
print '</td><td colspan="2">';
|
print '</td><td colspan="2">';
|
||||||
@ -1382,13 +1417,23 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accountancy sell code
|
// Accountancy sell code
|
||||||
print '<tr><td>'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').'</td><td colspan="2">';
|
print '<tr><td class="nowrap">';
|
||||||
print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string');
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
|
print $langs->trans("ProductAccountancySellCode");
|
||||||
|
print '</td>';
|
||||||
|
print '</tr></table>';
|
||||||
|
print '</td><td colspan="2">';
|
||||||
|
print length_accountg($object->accountancy_code_sell);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Accountancy buy code
|
// Accountancy buy code
|
||||||
print '<tr><td>'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').'</td><td colspan="2">';
|
print '<tr><td class="nowrap">';
|
||||||
print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string');
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
|
print $langs->trans("ProductAccountancyBuyCode");
|
||||||
|
print '</td>';
|
||||||
|
print '</tr></table>';
|
||||||
|
print '</td><td colspan="2">';
|
||||||
|
print length_accountg($object->accountancy_code_buy);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Status (to sell)
|
// Status (to sell)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user