Cleanup: various random sql queries found in UI files moved to database interface...
[fa-stable.git] / sales / inquiry / sales_orders_view.php
index ae9a666ea6a17d04eaca5e0bb13ccf3c792e7ef2..7955d6c41e44b861d6d6c55a5fbbbb809ae75947 100644 (file)
@@ -201,27 +201,17 @@ function invoice_prep_link($row)
                "/sales/customer_invoice.php?InvoicePrepayments=" .$row['order_no'], ICON_DOC) : '';
 }
 
-//---------------------------------------------------------------------------------------------
-// Update db record if respective checkbox value has changed.
-//
-function change_tpl_flag($id)
+$id = find_submit('_chgtpl');
+if ($id != -1)
 {
-       global  $Ajax;
-       
-       $sql = "UPDATE ".TB_PREF."sales_orders SET type = !type WHERE order_no=$id";
-
-       db_query($sql, "Can't change sales order type");
+       sales_order_set_template($id, check_value('chgtpl'.$id));
        $Ajax->activate('orders_tbl');
 }
 
-$id = find_submit('_chgtpl');
-if ($id != -1)
-       change_tpl_flag($id);
-
 if (isset($_POST['Update']) && isset($_POST['last'])) {
        foreach($_POST['last'] as $id => $value)
                if ($value != check_value('chgtpl'.$id))
-                       change_tpl_flag($id);
+                       sales_order_set_template($id, !check_value('chgtpl'.$id));
 }
 
 $show_dates = !in_array($_POST['order_view_mode'], array('OutstandingOnly', 'InvoiceTemplates', 'DeliveryTemplates'));