Beispiel #1
0
 function display($largeur = '100%', $hauteur = '100%')
 {
     $this->_key = $this->getKey();
     if (!is_array($this->data)) {
         return false;
     }
     /* Obtenir le controller courant */
     global $url;
     $urlArray = explode("/", $url);
     $controller = $urlArray[0];
     $str = "";
     //Obtenir la colonne ou se cachera l'id
     //$id = $this->colonnes[$this->id]->getid();
     $str .= "<div id = 'grid' style=\"max-height:" . $hauteur . ";max-width:" . $largeur . "\">";
     /* table de donnees */
     $str .= "<table class=\"dataTable\" id=\"" . $this->dataTable . "\">";
     //AFFICHAGE DES COLONNES
     $str .= "<thead><tr>";
     if ($this->selectbutton) {
         $str .= "<th><input type=\"checkbox\" onchange=\"checkall()\" id = 'chkall'></th>";
     }
     foreach ($this->colonnes as $col) {
         if ($col->visible) {
             $str .= "<th>" . $col->text . "</th>";
         }
     }
     if ($this->actionbutton) {
         if ($this->editbutton || $this->deletebutton) {
             $str .= "<th></th>";
         }
     }
     $str .= "</tr></thead><tbody>";
     //AFFICHAGE DES LIGNES
     $line_color = "even";
     foreach ($this->data as $line) {
         $str .= "<tr>";
         $j = 0;
         if ($this->selectbutton) {
             /* if (in_array($line[$this->id], $this->checkedbutton)) {
                print "<td><input type=\"checkbox\" name=\"chk[]\" checked = 'checked' value = \"" . $line[$this->id] . "\" /></td>";
                } else
                print "<td><input type=\"checkbox\" name=\"chk[]\" value = \"" . $line[$this->id] . "\" /></td>"; */
         }
         foreach ($this->colonnes as $col) {
             if ($col->visible) {
                 if (in_array($j, $this->coldate)) {
                     $d = new DateFR($line[$col->datafield]);
                     if ($this->formatdate == "long") {
                         $str .= "<td>" . $d->fullYear() . "</td>";
                     } else {
                         $str .= "<td>" . $d->getDateMessage(3) . "</td>";
                     }
                 } else {
                     $str .= "<td>" . $line[$col->datafield] . "</td>";
                 }
             }
             $j++;
         }
         if ($this->actionbutton) {
             if ($this->editbutton || $this->deletebutton) {
                 $str .= "<td style = 'width:50px;padding:0; margin:0;text-align:center;'>";
                 if ($this->editbutton) {
                     if (isAuth($this->droitedit)) {
                         $_url = url($controller, 'edit', $line[$this->_key]);
                         $str .= "<img style = 'cursor:pointer;' onclick = \"document.location='" . $_url . "';\"" . " src = '" . SITE_ROOT . "public/img/edit.png' title = \"" . $this->editbuttontext . "\" />&nbsp;&nbsp;";
                     } else {
                         $str .= "<img style = 'cursor:pointer;' src = '" . SITE_ROOT . "public/img/edit_disabled.png' />&nbsp;";
                     }
                 }
                 if ($this->deletebutton) {
                     if (isAuth($this->droitdelete)) {
                         $_url = url($controller, 'delete', $line[$this->_key]);
                         $str .= "<img style = 'cursor:pointer;' onclick = \"javascript:deleteRow('" . $_url . "', '" . $line[$this->_key] . "');\"" . " src = '" . SITE_ROOT . "public/img/delete.png' title = \"" . $this->deletebuttontext . "\" />";
                     } else {
                         $str .= "&nbsp;<img style = 'cursor:pointer;' src = '" . SITE_ROOT . "public/img/delete_disabled.png' />";
                     }
                 }
                 $str .= "</td>";
             }
         }
         $this->etat++;
         $str .= "</tr>";
     }
     $nb = $this->getNbColonneVisible();
     if ($this->editbutton || $this->deletebutton) {
         $nb += 1;
     }
     if ($this->selectbutton) {
         $nb += 1;
     }
     $str .= "</tbody><tfoot><tr><td colspan = \"" . $nb . "\"></td></tr></tfoot>";
     $str .= "</table></div>";
     return $str;
 }