function draw_index($url, $datatable = "", $idxchamps = "", $post_char = "", $title = "Index", $opt = 'std') { global $app; if ($datatable != "") { $var = explode(";", $datatable); if (isset($var[1]) && $var[1] != "") { $condition = $var[1]; } else { $condition = ""; } if ($condition != "") { $condition = " WHERE " . $condition; } $db = new Tdb(); $Tindexexist = array(); $db->Execute("SELECT DISTINCT(" . $idxchamps . ") as 'indexfor' FROM " . $var[0] . " {$condition}"); while ($db->Get_line()) { //print "<b>INDEX : ".$db->Get_field('indexfor')."<br></b>"; $Tindexexist[$db->Get_field('indexfor')] = true; } $db->close(); } $nb_col = 0; $old = $this->direct; $r = ''; $this->direct = false; $r .= "<br>"; $r .= $this->beg_cell(); $r .= "<br>"; $r .= $this->beg_tbl('form'); $r .= $this->beg_line(); if ($post_char == "all") { $r .= $this->cell("<span class=\"lien_inactif\"><font color=red>Tous</font></span>"); } else { $r .= $this->cell($this->link('Tous', $url . '&charIndex=all', 'lien')); } $nb_col++; if ($post_char == "0") { $r .= $this->cell("<span class=\"lien_inactif\"><font color=red>#</font></span>"); } else { if ($datatable == "" || isset($Tindexexist['!']) || isset($Tindexexist['0'])) { $r .= $this->cell($this->link('#', $url . '&charIndex=other', 'lien')); } else { $r .= $this->cell("<span class=\"lien_inactif\">#</span>"); } } $nb_col++; $l = ord("A"); for ($i = $l; $i < $l + 26; $i++) { if ($post_char == chr($i)) { $r .= $this->cell("<span class=\"lien_inactif\"><font color=red>" . chr($i) . "</font></span>"); } else { if ($datatable == "" || isset($Tindexexist[chr($i)])) { $r .= $this->cell($this->link(chr($i), $url . '&charIndex=' . chr($i), 'lien')); } else { $r .= $this->cell("<span class=\"lien_inactif\">" . chr($i) . "</span>"); } } $nb_col++; } $r .= $this->end_line(); $r .= $this->end_tbl(); $r .= $this->end_cell(); if ($title) { $r = $this->end_line() . $r; $r = $this->Cell($title, -1, '', $nb_col) . $r; $r = $this->beg_line('formheader0') . $r; } $r = $this->beg_tbl('formcadre') . $r; $r .= $this->end_tbl(); $r .= "<br>"; $this->direct = $old; if ($this->direct) { echo $r; } else { return $r; } }
private function set_line(&$TChamps, &$TParam, $currentLine) { $row = array(); $trans = array(); foreach ($currentLine as $field => $value) { if (is_object($value)) { if (get_class($value) == 'stdClass') { $value = print_r($value, true); } else { $value = (string) $value; } } if (isset($TParam['subQuery'][$field])) { $dbSub = new Tdb(); $dbSub->Execute(strtr($TParam['subQuery'][$field], array_merge($trans, array('@val@' => $value)))); $subResult = ''; while ($dbSub->Get_line()) { $subResult .= implode(', ', $dbSub->currentLine) . '<br />'; } $value = $subResult; $dbSub->close(); } $trans['@' . $field . '@'] = $value; if (!empty($TParam['math'][$field])) { $this->TTotalTmp[$field][] = (double) strip_tags($value); } if (!in_array($field, $TParam['hide'])) { $row[$field] = $value; if (isset($TParam['link'][$field])) { if (empty($row[$field]) && $row[$field] !== 0 && $row[$field] !== '0') { $row[$field] = '(vide)'; } $row[$field] = strtr($TParam['link'][$field], array_merge($trans, array('@val@' => $row[$field]))); } if (isset($TParam['translate'][$field])) { $row[$field] = strtr($row[$field], $TParam['translate'][$field]); } if (isset($TParam['eval'][$field]) && in_array($field, array_keys($row))) { $strToEval = 'return ' . strtr($TParam['eval'][$field], array_merge($trans, array('@val@' => $row[$field]))) . ';'; $row[$field] = eval($strToEval); } if (isset($TParam['type'][$field])) { if ($TParam['type'][$field] == 'date') { $row[$field] = date('d/m/Y', strtotime($row[$field])); } if ($TParam['type'][$field] == 'datetime') { $row[$field] = date('d/m/Y H:i:s', strtotime($row[$field])); } if ($TParam['type'][$field] == 'hour') { $row[$field] = date('H:i', strtotime($row[$field])); } if ($TParam['type'][$field] == 'money') { $row[$field] = '<div align="right">' . number_format((double) $row[$field], 2, ',', ' ') . '</div>'; } if ($TParam['type'][$field] == 'number') { $row[$field] = '<div align="right">' . number_format((double) $row[$field], 2, ',', ' ') . '</div>'; } } } } /*if(!empty($TParam['search']) && !empty($row)) { $row['actions']= ''; }*/ $TChamps[] = $row; }
function get_tab_by_sql(&$db, $sql) { $Tab = array(); if (is_string($db) && $db == 'auto') { $db = new Tdb(); } $db->Execute($sql); $THeader = array_keys($db->Get_lineHeader()); while ($db->Get_line()) { $row = array(); foreach ($THeader as $key) { $row[$key] = $db->Get_field($key); } $Tab[] = $row; } return $Tab; }