Vylepsena podpora carovych kodu
authorThomas Mudrunka <tomas@mudrunka.cz>
Mon, 22 Aug 2011 18:37:23 +0000 (20:37 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Mon, 22 Aug 2011 18:37:23 +0000 (20:37 +0200)
assistants/go.inc.php [new file with mode: 0644]
index.php
sklad.conf.php.example

diff --git a/assistants/go.inc.php b/assistants/go.inc.php
new file mode 100644 (file)
index 0000000..c74bbae
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+//$script = $_SERVER['SCRIPT_NAME'].'/assistant/go';
+
+$id=$_GET['q'];
+$barcode_prefix_regexp = '/^'.preg_replace('/\//', '\/', BARCODE_PREFIX).'/';
+if(preg_match($barcode_prefix_regexp, $id)) $id=preg_replace($barcode_prefix_regexp, '', $id);
+if(preg_match('/\//', $id)) $this->post_redirect_get($id);
+       else $this->post_redirect_get('?q='.urlencode($id));
index 8f37200644000085749f7c776b3cf8c5e281608d..63633b022bcbb411401e5a2e02bc86e89d66af45 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -181,7 +181,11 @@ class Sklad_HTML extends HTML {
        </menu>
 
        <div style="float: right;">
-               <form action="?" method="GET">
+               <form action="$script/assistant/go" method="GET" style="float: left;"><!-- TODO: Display only when go plugin available -->
+                       <input type="text" name="q" placeholder="smart id..." />
+                       <input type="submit" value="go" />
+               </form>
+               <form action="?" method="GET" style="float: left;">
                        <input type="text" name="q" placeholder="regexp..." value="$search" />
                        <input type="submit" value="filter" />
                </form>
@@ -622,7 +626,8 @@ class Sklad_UI {
        }
 
        function post_redirect_get($location, $message='', $error=false) {
-               $location = $this->html->internal_url($location).'?message='.urlencode($message);
+               $url_args = $message != '' ? '?message='.urlencode($message) : '';
+               $location = $this->html->internal_url($location).$url_args;
                header('Location: '.$location);
                if($error) trigger_error($message);
                $location=htmlspecialchars($location);
index 64a62f2979a78cab34a907f68500d51bbb4e339e..bd8376837b57bdf8771b67186f5cb075e5009d80 100755 (executable)
@@ -7,11 +7,16 @@ define('DB_DSN',              'mysql:host='.DB_HOST.';dbname='.DB_NAME);
 
 define('DIR_HOME',             './');
 define('DIR_IMAGES',           DIR_HOME.'/images');
-define('DIR_TEMPLATES',                DIR_HOME.'/templates');
+define('DIR_BARCODES',         DIR_HOME.'/barcodes');
+define('DIR_TEMPLATES',        DIR_HOME.'/templates');
 define('DIR_ASSISTANTS',       DIR_HOME.'/assistants');
 
 define('URL_HOME',             dirname($_SERVER['SCRIPT_NAME']));
 define('URL_IMAGES',           URL_HOME.'/images');
+define('URL_BARCODES',         URL_HOME.'/barcodes');
+
+define('BARCODE_TYPE',         'code128b');
+define('BARCODE_PREFIX',       'STORE/');
 
 $fake_lms_users = array( //You can specify multiple users in this array
        DB_USER => DB_PASS
This page took 0.157107 seconds and 4 git commands to generate.