['8 mal bestellen', '8', 8],
['10 mal bestellen', '10', 10],
['12 mal bestellen', '12', 12],
- ['14 mal bestellen', '14', 14]
+ ['Wert eingeben', 'Bitte geben Sie die gewünschte Menge ein', 'prompt']
]
};
return false;
}
+function import_callback(data)
+{
+ if (data.status == true) {
+ info('Ordersatz aktualisiert');
+
+ if (data.count > 0)
+ grid_update(grid);
+
+ confirm(data.count + ' Artikel zum Ordersatz hinzugefügt.');
+ }
+}
+
+function import()
+{
+ var source = document.getElementById('source');
+ if (!source) return false;
+
+ var parms = 'source=' + source.innerHTML + '&callback=import';
+ ajax_request('function', parms, import_callback);
+ return false;
+}
+
EOC;
$buttons = <<<EOC
<p style="margin-top: 0px; margin-bottom: 4px; text-align: center;">
+<button onclick="return import()">Artikel importieren</button>
+
<button onclick="return build_pdf()">PDF erstellen</button>
<button onclick="return finish()">Abschließen</button>
'anzahl' => array(
'name' => 'Anzahl',
'width' => 60,
- 'specs' => "ClassName: 'alignrightpad', filterUI: 't'",
+ 'specs' => "ClassName: 'alignrightpad'",
),
'artnr' => array(
'name' => 'Artnr',
),
'bezeichnung' => array(
'name' => 'Bezeichnung',
- 'width' => 260,
+ 'width' => 300,
'specs' => "filterUI: 't'",
),
+ 'preis' => array(
+ 'name' => 'Preis',
+ 'width' => 60,
+ 'type' => 'number',
+ 'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+ 'sql' => '(SELECT preis * ((100 + steuersatz)/100) FROM metro_artikel_preis ' .
+ 'WHERE artikel = metro_artikel.id ORDER BY datum DESC LIMIT 1)',
+ ),
'hersteller' => array(
'name' => 'Hersteller',
'width' => 80,
'width' => 80,
'specs' => "ClassName: 'aligncenter', filterUI: 's'",
'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_abteilung','id','name').", 0, '')",
+ 'visible' => false,
),
'gang' => array(
'name' => 'Gang',
'sql' => 'abteilung',
'specs' => "ClassName: 'aligncenter', filterUI: 's'",
'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_abteilung','id','gang').", 0, '')",
+ 'visible' => false,
),
),
'edit' => array(
'cellsave' => cb_cellsave,
'pdf' => cb_pdf,
'send' => cb_send,
+ 'import' => cb_import,
),
'files' => array(
'download' => process_download,
'save' => false,
'insert' => false,
'delete' => false,
+ 'changes' => false,
),
);
$tmpdir = mk_tempdir();
$result = ordersatz_write($_SESSION['ordersatz'], $tmpdir, false);
- if ($result !== true)
+ if ($result !== true) {
+ rm_tempdir($tmpdir);
return array('error' => $result);
+ }
return array('tmpdir' => substr($tmpdir,strlen($_SESSION['sys']['basedir'])));
}
return array('status' => true);
}
+function cb_import()
+{
+ global $db;
+
+ $sql = sprintf("SELECT count(*) AS count FROM metro_ordersatz_pos WHERE ordersatz = %d",
+ $_SESSION['ordersatz']);
+ $sth = $db->query($sql);
+ $row = $sth->fetch();
+ $old = $row['count'];
+
+ $sql = sprintf("INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) " .
+ "SELECT %d,metro_artikel.id,%s,now() FROM metro_artikel " .
+ "LEFT JOIN metro_ordersatz_pos ON artikel = metro_artikel.id AND ordersatz = %d " .
+ "WHERE metro_ordersatz_pos.id IS NULL",
+ $_SESSION['ordersatz'],
+ $db->quote($_SESSION['sys']['login']),
+ $_SESSION['ordersatz']);
+ $db->query($sql);
+
+ $sql = sprintf("SELECT count(*) AS count FROM metro_ordersatz_pos WHERE ordersatz = %d",
+ $_SESSION['ordersatz']);
+ $sth = $db->query($sql);
+ $row = $sth->fetch();
+ $new = $row['count'];
+
+ return array('status' => true, 'count' => $new - $old);
+}
+
?>