function transpose_ledger($tab_label, $tab_color)
{
global $db, $ledger_list_cols;
$vbox = create_master_box($tab_label, $tab_color);
$liststore = new GtkListStore(GObject::TYPE_LONG, GObject::TYPE_STRING, GObject::TYPE_STRING,
GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING,
GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_STRING, GObject::TYPE_LONG);
$result = $db->query_limit('ledgers');
$m = 1;
foreach ($result as $record)
{
$iter = $liststore->append();
$liststore->set($iter,
0, $m,
1, $record['demandno'],
2, $record['censusno'],
3, $record['year'],
4, $record['name'],
5, $record['caste'],
6, $record['address'],
7, $record['mobile'],
8, $record['colony'],
9, $record['houseno'],
10, $record['wardno']
);
$m++;
}
$tree = new GtkTreeView();
$tree->set_model($liststore);
$i = 0;
foreach ($ledger_list_cols as $col_caption => $justification)
{
$renderer = new GtkCellRendererText();
$renderer->set_property('xalign', $justification);
$col = new GtkTreeViewColumn($col_caption, $renderer, 'text', $i);
$label = new GtkLabel($col_caption);
$label->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse('blue'));
$col->set_widget($label);
$label->show();
$tree->append_column($col);
$col->set_cell_data_func($renderer, "format_columns", $i);
$i++;
}
$scrolled_win = new GtkScrolledWindow();
$scrolled_win->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
$scrolled_win->add($tree);
$vbox->add($scrolled_win);
return $vbox;
} |