Curly braces {} in arrays replaced, by @kvvaradha.
[fa-stable.git] / admin / db / printers_db.inc
index 4d3fa96cc3a8607f9e838fc378485e278dd417e0..28c98a56b4b5d56c190d7634e76daca481fb2f64 100644 (file)
@@ -1,26 +1,27 @@
 <?php
 /**********************************************************************
     Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU Affero General Public License,
-       AGPL, as published by the Free Software Foundation, either version 
-       of the License, or (at your option) any later version.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
+
 function write_printer_def($id, $name, $descr, $queue, $host, $port, $timeout)
 {
        if ($id>0)
                $sql = "UPDATE ".TB_PREF."printers SET description=".db_escape($descr)
                .",name=".db_escape($name).",queue=".db_escape($queue)
-               .",host=".db_escape($host).",port='$port',timeout='$timeout' "
-               ."WHERE id=$id";
+               .",host=".db_escape($host).",port=".db_escape($port).",timeout=".db_escape($timeout)
+               ." WHERE id=".db_escape($id);
        else 
                $sql = "INSERT INTO ".TB_PREF."printers ("
                        ."name,description,queue,host,port,timeout) "
                        ."VALUES (".db_escape($name).",".db_escape($descr).","
-                       .db_escape($queue).",".db_escape($host).",'$port','$timeout')";
+                       .db_escape($queue).",".db_escape($host).",".db_escape($port).",".db_escape($timeout).")";
 
        return db_query($sql,"could not write printer definition");
 }
@@ -34,12 +35,17 @@ function get_all_printers()
 function get_printer($id)
 {
                $sql = "SELECT * FROM ".TB_PREF."printers
-                       WHERE id=$id";
+                       WHERE id=".db_escape($id);
 
                $result = db_query($sql,"could not get printer definition");
                return  db_fetch($result);
 }
 
+function delete_printer($id)
+{
+       $sql="DELETE FROM ".TB_PREF."printers WHERE id=".db_escape($id);
+       db_query($sql,"could not delete printer definition");
+}
 //============================================================================
 // printer profiles functions
 //
@@ -51,7 +57,7 @@ function update_printer_profile($name, $dest)
                        ."(profile, report, printer) VALUES ("
                        .db_escape($name).","
                        .db_escape($rep).","
-                       .db_escape($printer).")";
+                       .db_escape($printer ? $printer: null, true).")";
                } else {
                        $sql = "DELETE FROM ".TB_PREF."print_profiles WHERE ("
                                ."report=" . db_escape($rep)
@@ -100,4 +106,3 @@ function get_print_profile($name)
        return db_query($sql,"could not get printing profile");
 }
 
-?>
\ No newline at end of file