Finished the selection of fields on bank account list

This commit is contained in:
Laurent Destailleur 2016-11-16 19:56:03 +01:00
parent 4768017662
commit 3dc9bc89d8
2 changed files with 128 additions and 31 deletions

View File

@ -848,6 +848,7 @@ class Account extends CommonObject
$sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,";
$sql.= " ba.account_number, ba.accountancy_journal, ba.currency_code,";
$sql.= " ba.min_allowed, ba.min_desired, ba.comment,";
$sql.= " ba.datec as date_creation, ba.tms as date_update,";
$sql.= ' c.code as country_code, c.label as country,';
$sql.= ' d.code_departement as state_code, d.nom as state';
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
@ -903,6 +904,9 @@ class Account extends CommonObject
$this->min_desired = $obj->min_desired;
$this->comment = $obj->comment;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_update = $this->db->jdate($obj->date_update);
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
@ -910,7 +914,6 @@ class Account extends CommonObject
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
return 1;
}
else

View File

@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("accountancy");
$action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha');
@ -82,9 +83,10 @@ $fieldstosearchall = array(
$checkedtypetiers=0;
$arrayfields=array(
'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1),
'accountype'=>array('label'=>$langs->trans("AccountType"), 'checked'=>1),
'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1),
'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled),
'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1),
'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
@ -137,7 +139,7 @@ $title=$langs->trans('BankAccounts');
// Load array of financial accounts (opened by default)
$accounts = array();
$sql = "SELECT rowid, label, courant, rappro";
$sql = "SELECT rowid, label, courant, rappro, account_number, datec as date_creation, tms as date_update";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@ -272,7 +274,7 @@ if (! empty($moreforfilter))
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -282,9 +284,8 @@ if (! empty($arrayfields['b.ref']['checked'])) print_liste_field_titr
if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'],$_SERVER["PHP_SELF"],'b.label','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'],$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'],$_SERVER["PHP_SELF"],'b.clos','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@ -301,6 +302,10 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'],$_SERVER["PHP_SELF"],"b.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'],$_SERVER["PHP_SELF"],"b.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'],$_SERVER["PHP_SELF"],'b.clos','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
@ -333,6 +338,12 @@ if (! empty($arrayfields['b.number']['checked']))
print '<input class="flat" size="6" type="text" name="search_number" value="'.$search_number.'">';
print '</td>';
}
// Number
if (! empty($arrayfields['b.account_number']['checked']))
{
print '<td class="liste_titre">';
print '</td>';
}
// Transactions to reconcile
if (! empty($arrayfields['toreconcile']['checked']))
{
@ -390,7 +401,10 @@ if (! empty($arrayfields['b.clos']['checked']))
print '</td>';
}
// Balance
print '<td></td>';
if (! empty($arrayfields['balance']['checked']))
{
print '<td></td>';
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
@ -415,32 +429,112 @@ foreach ($accounts as $key=>$type)
$solde = $acc->solde(1);
print '<tr '.$bc[$var].'>';
print '<td class="titlefield">'.$acc->getNomUrl(1).'</td>';
print '<td>'.$acc->label.'</td>';
print '<td>';
print $acc->type_lib[$acc->type];
print '</td>';
print '<td>'.$acc->number.'</td>';
print '<td align="center">';
if ($acc->rappro)
// Ref
if (! empty($arrayfields['b.ref']['checked']))
{
print '<td class="titlefield">'.$acc->getNomUrl(1).'</td>';
}
// Label
if (! empty($arrayfields['b.label']['checked']))
{
print '<td>'.$acc->label.'</td>';
}
// Account type
if (! empty($arrayfields['accountype']['checked']))
{
print '<td>';
print $acc->type_lib[$acc->type];
print '</td>';
}
// Number
if (! empty($arrayfields['b.number']['checked']))
{
print '<td>'.$acc->number.'</td>';
}
// Account number
if (! empty($arrayfields['b.account_number']['checked']))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
print '<td>'.length_accountg($acc->account_number).'</td>';
}
// Transactions to reconcile
if (! empty($arrayfields['toreconcile']['checked']))
{
print '<td align="center">';
if ($acc->rappro)
{
$result=$acc->load_board($user,$acc->id);
if ($result<0) {
setEventMessages($acc->error, $acc->errors, 'errors');
} else {
print $result->nbtodo;
if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
}
}
else print $langs->trans("FeatureDisabled");
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
$result=$acc->load_board($user,$acc->id);
if ($result<0) {
setEventMessages($acc->error, $acc->errors, 'errors');
} else {
print $result->nbtodo;
if ($result->nbtodolate) print ' &nbsp; ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
}
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
else print $langs->trans("FeatureDisabled");
print '</td>';
// Status
print '<td align="center">'.$acc->getLibStatut(5).'</td>';
//
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
print '</td>';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
if (! empty($arrayfields['b.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($acc->date_creation, 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['b.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($acc->date_update, 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Statut
if (! empty($arrayfields['b.clos']['checked']))
{
print '<td align="center">'.$acc->getLibStatut(5).'</td>';
}
// Balance
if (! empty($arrayfields['balance']['checked']))
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
print '</td>';
}
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined