10 var photoPopup = false;
12 function photoLoad_callback(data)
15 photoPopup.closePopup();
19 var source = document.getElementById('source');
20 if (!source) return false;
22 var width = data.width;
23 var height = data.height;
25 maxWidth = Math.floor(RicoUtil.windowWidth() / 100 * 60);
26 maxHeight = Math.floor(RicoUtil.windowHeight() / 100 * 60);
29 if (width > maxWidth) {
30 factor = maxWidth / width;
31 if ((height * factor) > maxHeight)
32 factor = maxHeight / height;
34 if ((height * factor) > maxHeight)
35 factor = maxHeight / height;
38 width = Math.floor(width * factor);
39 height = Math.floor(height * factor);
42 var photo = document.getElementById('photo');
43 photo.height = height;
46 photo.src = 'ajax/ajax.php?source='+source.innerHTML+'&func=file&name=photo&id=' + data.id;
48 var name = document.getElementById('photo_name');
49 name.innerHTML = data.name;
51 var x = photoPopup.divPopup.style.left.substr(0,photoPopup.divPopup.style.left.length-2);
52 var y = photoPopup.divPopup.style.top.substr(0,photoPopup.divPopup.style.top.length-2);
54 if (x == 0 || y == 0) {
55 x = Math.floor(RicoUtil.windowWidth()/2 - width/2);
56 y = Math.floor(RicoUtil.windowHeight()/2 - height/2);
59 photoPopup.openPopup(x,y);
62 function photoLoad(id)
64 var source = document.getElementById('source');
65 if (!source) return false;
67 var parms = 'source=' + source.innerHTML + '&callback=photo&id=' + id;
68 ajax_request('function', parms, photoLoad_callback);
77 photoPopup = new Rico.Popup(options);
78 photoPopup.createWindow('<b>Photo</b>','','auto','auto');
80 photoPopup.contentDiv.style.backgroundColor = '#FFFFFF';
81 photoPopup.contentDiv.style.color = '#000000';
82 photoPopup.contentDiv.innerHTML = '<img id="photo" src="" height="" width="" /><div id="photo_name"></div>';
90 'table' => 'work_geraete',
91 'title' => 'Gerätestammdaten',
101 'specs' => "filterUI: 't'",
103 'hersteller' => array(
104 'name' => 'Hersteller',
106 'specs' => "filterUI: 't'",
112 'specs' => "decPlaces: 0, canSort: false, filterUI: 's', thouSep: ''",
114 'anschaffung' => array(
115 'name' => 'Anschaffung',
122 'specs' => "decPlaces: 2, ClassName: 'alignright', canSort: false",
126 'name' => 'Gerätenummer',
128 'specs' => "filterUI: 't'",
134 'specs' => "ClassName: 'aligncenter', canSort: false",
135 'control' => "new Rico.TableColumn.link('javascript:show({0})')",
136 'sql' => "'<img src=\"images/icons/download.gif\" title=\"Photo anzeigen\" border=\"0\">'",
146 'hersteller' => array(
147 'name' => 'Hersteller',
158 'lieferant' => array(
159 'name' => 'Lieferant',
161 'options' => 'SELECT id,name AS text FROM lieferanten ORDER BY name',
162 'option_empty' => '-- select --',
172 'name' => 'Leistung',
178 'name' => 'Gerätenummer',
183 'anschaffung' => array(
184 'name' => 'Anschaffungsdatum',
189 'path_photo' => array(
192 'path' => 'werkstatt',
196 'name' => 'Bemerkung',
197 'type' => 'textarea',
200 'callbacks' => array(
201 'photo' => photo_details,
208 function photo_details()
212 $sql = sprintf("SELECT path_photo,name FROM work_geraete WHERE id = %d", $_POST['id']);
214 $sth = pg_query($sql);
215 $row = pg_fetch_assoc($sth);
217 if ($row['path_photo'] == NULL) return false;
219 $fname = $_SESSION['sys']['basedir'] . 'archive/' . $mask['edit']['path_photo']['path'] . '/' . $row['path_photo'];
221 if (!is_file($fname)) return false;
223 $imgsize = getimagesize($fname);
225 $data = array('id' => $_POST['id'],
226 'width' => $imgsize[0],
227 'height' => $imgsize[1],
228 'name' => $row['name']);
237 download_file($mask['table'],'path_photo',$mask['edit']['path_photo']['path'],$_GET['id']);