function _comments($id, $ref, $element)
{
    $element_tag = TTwiiit::getTag($element, $ref);
    $PDOdb = new TPDOdb();
    $r = '';
    $Tab = $PDOdb->ExecuteAsArray("SELECT DISTINCT t.rowid\n\tFROM " . MAIN_DB_PREFIX . "twiiit t  \n\t WHERE (t.fk_object=" . (int) $id . " AND t.type_object='" . $element . "') OR (t.comment LIKE '%" . $element_tag . "%')\n\t ORDER BY t.date_cre DESC");
    foreach ($Tab as &$row) {
        $twiiit = new TTwiiit();
        $twiiit->load($PDOdb, $row->rowid);
        $r .= '<div class="comm">';
        if ($id != $twiiit->fk_object || $element != $twiiit->type_object) {
            $origin_element = $twiiit->getNomUrl();
            if (!empty($origin_element)) {
                $r .= '<div class="object">' . $origin_element . '</div> ';
            }
        }
        $r .= $twiiit->getComment();
        $r .= '<div class="date">' . dol_print_date($twiiit->date_cre, 'dayhourtextshort') . '</div>';
        $r .= '</div>';
    }
    return $r;
}
 static function route($action, &$object)
 {
     $PDOdb = new TPDOdb();
     $sql = "SELECT rowid\n                FROM " . MAIN_DB_PREFIX . "routing\n                WHERE trigger_code='" . $action . "'";
     $Tab = $PDOdb->ExecuteAsArray($sql);
     foreach ($Tab as $row) {
         $route = new TRouting();
         $route->load($PDOdb, $row->rowid);
         $route->routeLines($object);
     }
     // mvt inverse pour annulation
     $sql = "SELECT rowid\n                FROM " . MAIN_DB_PREFIX . "routing\n                WHERE trigger_code_reverse='" . $action . "'";
     $Tab = $PDOdb->ExecuteAsArray($sql);
     foreach ($Tab as $row) {
         $route = new TRouting();
         $route->load($PDOdb, $row->rowid);
         $route->routeLines($object, -1);
     }
 }
    $TMonth[$i] = $langs->trans('month' . date('M', strtotime(date('Y-' . $i . '-01')))) . '-' . $year;
    $ColFormat[$TMonth[$i]] = 'number';
    $ColTotal[$TMonth[$i]] = 'sum';
}
$ColFormat['total'] = 'number';
$ColTotal['total'] = 'sum';
$mode = GETPOST('mode');
$TData = array();
if ($mode == 'order') {
    //commande non brouillon par date de livraison
    $sql = "SELECT commande.fk_soc, SUM(commande.total_ht) as total, MONTH(commande.date_livraison) as 'month' FROM " . MAIN_DB_PREFIX . "commande as commande\n\t\t\t\tINNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid=commande.fk_soc WHERE commande.fk_statut>0 AND YEAR(commande.date_livraison)=" . $year . "\n\t\t\t\tGROUP BY commande.fk_soc,soc.nom, MONTH(commande.date_livraison)\n                ORDER BY soc.nom,MONTH(commande.date_livraison)";
} else {
    //facture payée sur date de facturation
    $sql = "SELECT fact.fk_soc, SUM(fact.total) as total, MONTH(fact.datef) as 'month' FROM " . MAIN_DB_PREFIX . "facture as fact\n\t\t\t\tINNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid=fact.fk_soc\n\t\t\t\t\t\tWHERE fk_statut>0 AND paye=1 AND YEAR(datef)=" . $year . "\n\t\t\t\t\t\t\t\tGROUP BY fact.fk_soc,soc.nom, MONTH(fact.datef)\n\t\t\t\t\t\t\t\tORDER BY soc.nom,MONTH(fact.datef)";
}
$Tab = $PDOdb->ExecuteAsArray($sql);
foreach ($Tab as &$row) {
    if (!isset($TData[$row->fk_soc])) {
        $TData[$row->fk_soc] = _init_line();
    }
    $TData[$row->fk_soc][$TMonth[(int) $row->month]] = (double) $row->total;
    $TData[$row->fk_soc]['total'] += (double) $row->total;
}
_get_company_object($TData);
//usort($TData, '_sort_company');
?>
	<style type="text/css">
		*[field=total],tr.liste_total td {
			font-weight: bold;
		}
	</style>
<?php

require '../config.php';
$PDOdb = new TPDOdb();
$QB = new TQueryBuilder();
$sql = $QB->select('user', array('login', 'pass'))->where("datelastlogin>'2010-01-01'")->build();
echo $sql;
var_dump($PDOdb->ExecuteAsArray($sql));