maxWidth) { factor = maxWidth / width; if ((height * factor) > maxHeight) factor = maxHeight / height; } else if ((height * factor) > maxHeight) factor = maxHeight / height; if (factor) { width = Math.floor(width * factor); height = Math.floor(height * factor); } var photo = document.getElementById('photo'); photo.height = height; photo.width = width; photo.src = 'ajax/ajax.php?source='+source.innerHTML+'&func=file&name=photo&id=' + data.id; var name = document.getElementById('photo_name'); name.innerHTML = data.name; var x = photoPopup.divPopup.style.left.substr(0,photoPopup.divPopup.style.left.length-2); var y = photoPopup.divPopup.style.top.substr(0,photoPopup.divPopup.style.top.length-2); if (x == 0 || y == 0) { x = Math.floor(RicoUtil.windowWidth()/2 - width/2); y = Math.floor(RicoUtil.windowHeight()/2 - height/2); } photoPopup.openPopup(x,y); } function photoLoad(id) { var source = document.getElementById('source'); if (!source) return false; var parms = 'source=' + source.innerHTML + '&callback=photo&id=' + id; ajax_request('function', parms, photoLoad_callback); } function show(id) { if (!photoPopup) { var options = { hideOnClick: true, canDragFunc: true}; photoPopup = new Rico.Popup(options); photoPopup.createWindow('Photo','','auto','auto'); photoPopup.contentDiv.style.backgroundColor = '#FFFFFF'; photoPopup.contentDiv.style.color = '#000000'; photoPopup.contentDiv.innerHTML = '
'; } photoLoad(id); } EOC; $mask = array( 'table' => 'work_geraete', 'title' => 'Gerätestammdaten', 'list' => array( 'id' => array( 'name' => 'ID', 'visible' => false, 'sql' => 'id', ), 'name' => array( 'name' => 'Name', 'width' => 250, 'specs' => "filterUI: 't'", ), 'hersteller' => array( 'name' => 'Hersteller', 'width' => 180, 'specs' => "filterUI: 't'", ), 'baujahr' => array( 'name' => 'Baujahr', 'width' => 50, 'type' => 'number', 'specs' => "decPlaces: 0, canSort: false, filterUI: 's', thouSep: ''", ), 'anschaffung' => array( 'name' => 'Anschaffung', 'type' => 'date', 'width' => 70, ), 'preis' => array( 'name' => 'Preis', 'type' => 'number', 'specs' => "decPlaces: 2, ClassName: 'alignright', canSort: false", 'width' => 70, ), 'nummer' => array( 'name' => 'Gerätenummer', 'width' => 120, 'specs' => "filterUI: 't'", 'visible' => false, ), 'photo' => array( 'name' => 'Photo', 'width' => 30, 'specs' => "ClassName: 'aligncenter', canSort: false", 'control' => "new Rico.TableColumn.link('javascript:show({0})')", 'sql' => "''", ), ), 'edit' => array( 'name' => array( 'name' => 'Name', 'type' => 'text', 'size' => 24, 'required' => true, ), 'hersteller' => array( 'name' => 'Hersteller', 'type' => 'text', 'size' => 24, 'required' => true, ), 'baujahr' => array( 'name' => 'Baujahr', 'type' => 'number', 'size' => 4, 'required' => true, ), 'lieferant' => array( 'name' => 'Lieferant', 'type' => 'select', 'options' => 'SELECT id,name AS text FROM lieferanten ORDER BY name', 'option_empty' => '-- select --', 'required' => true, ), 'preis' => array( 'name' => 'Preis', 'type' => 'decimal', 'size' => 10, 'required' => true, ), 'leistung' => array( 'name' => 'Leistung', 'type' => 'decimal', 'size' => 10, 'comment' => 'KW', ), 'nummer' => array( 'name' => 'Gerätenummer', 'type' => 'text', 'size' => 20, 'required' => true, ), 'anschaffung' => array( 'name' => 'Anschaffungsdatum', 'type' => 'date', 'size' => 8, 'null' => true, ), 'path_photo' => array( 'name' => 'Foto', 'type' => 'file', 'path' => 'werkstatt', 'sql' => false, ), 'comment' => array( 'name' => 'Bemerkung', 'type' => 'textarea', ), ), 'callbacks' => array( 'photo' => photo_details, ), 'files' => array( 'photo' => download, ), ); function photo_details() { global $mask; $sql = sprintf("SELECT path_photo,name FROM work_geraete WHERE id = %d", $_POST['id']); $sth = pg_query($sql); $row = pg_fetch_assoc($sth); if ($row['path_photo'] == NULL) return false; $fname = $_SESSION['sys']['basedir'] . 'archive/' . $mask['edit']['path_photo']['path'] . '/' . $row['path_photo']; if (!is_file($fname)) return false; $imgsize = getimagesize($fname); $data = array('id' => $_POST['id'], 'width' => $imgsize[0], 'height' => $imgsize[1], 'name' => $row['name']); return $data; } function download() { global $mask; download_file($mask['table'],'path_photo',$mask['edit']['path_photo']['path'],$_GET['id']); } ?>