Move style to style section
[infodrom.org/service.infodrom.org] / class / spritmachine.class.php
1 <?php
2
3 class SpritMachine extends DatabaseTable {
4
5   public function __construct($id=false)
6   {
7     parent::__construct('sprit_machine', $id);
8   }
9
10   public function ajaxList(Array $data)
11   {
12     $out = '';
13     $sql = "SELECT id,name FROM sprit_machine WHERE active = 1 ORDER BY name";
14     foreach ($this->fetchObjectList($sql) as $row) {
15       $out .= sprintf('<li>%s ', $row->name);
16       $out .= '<form action="list.php" method="POST" style="display:inline;">';
17       $out .= sprintf('<input type="hidden" name="machine" value="%d">', $row->id);
18       $out .= sprintf('<img src="%spix/arrowrightmonth.gif" onclick="machine_list(this);" style="margin-bottom:-4px;" title="Liste zeigen">',
19                       $this->rootPath);
20       $out .= '</form>';
21       $out .= '</li>';
22     }
23
24     return array('html' => array('machines' => $out));
25   }
26
27   public function ajaxSave(Array $data)
28   {
29     if ($this->id) {
30       $sql = sprintf("UPDATE sprit_machine SET name=%s,sys_edit=now(),sys_user=%s WHERE id = %d",
31                      $this->quote(utf8_decode($data['name'])),
32                      $this->quote($_SERVER['REMOTE_USER']),
33                      $this->id);
34     } else {
35       $sql = sprintf("INSERT INTO sprit_machine (name,active,sys_user,sys_edit) " .
36                      "VALUES (%s,1,%s,now())",
37                      $this->quote(utf8_decode($data['name'])),
38                      $this->quote($_SERVER['REMOTE_USER']));
39     }
40
41     return $this->execute($sql);
42   }
43
44 }
45