2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
13 function add_recurrent_invoice($description, $order_no, $debtor_no, $group_no, $days, $monthly,
16 $sql = "INSERT INTO ".TB_PREF."recurrent_invoices (description, order_no, debtor_no,
17 group_no, days, monthly, begin, end, last_sent) VALUES (".db_escape($description) . ", "
18 .db_escape($order_no).", ".db_escape($debtor_no).", "
19 .db_escape($group_no).", ".$days.", ".$monthly.", '"
20 .date2sql($begin)."', '".date2sql($end)."', '".date2sql(Add_Years($begin, -5))."')";
21 db_query($sql,"The recurrent invoice could not be added");
24 function update_recurrent_invoice($selected_id, $description, $order_no, $debtor_no, $group_no, $days, $monthly,
27 $sql = "UPDATE ".TB_PREF."recurrent_invoices SET
28 description=".db_escape($description).",
29 order_no=".db_escape($order_no).",
30 debtor_no=".db_escape($debtor_no).",
31 group_no=".db_escape($group_no).",
34 begin='".date2sql($begin)."',
35 end='".date2sql($end)."'
36 WHERE id = ".db_escape($selected_id);
37 db_query($sql,"The recurrent invoice could not be updated");
40 function update_last_sent_recurrent_invoice($id, $date)
42 $date = date2sql($date);
43 $sql = "UPDATE ".TB_PREF."recurrent_invoices SET last_sent='$date' WHERE id=".db_escape($id);
44 db_query($sql,"The recurrent invoice could not be updated");
47 function delete_recurrent_invoice($selected_id)
49 $sql="DELETE FROM ".TB_PREF."recurrent_invoices WHERE id=".db_escape($selected_id);
50 db_query($sql,"could not delete recurrent invoice");
53 function get_recurrent_invoices()
55 $sql = "SELECT * FROM ".TB_PREF."recurrent_invoices ORDER BY description, group_no, debtor_no";
56 return db_query($sql,"could not get recurrent invoices");
59 function get_recurrent_invoice($selected_id)
61 $sql = "SELECT * FROM ".TB_PREF."recurrent_invoices WHERE id=".db_escape($selected_id);
63 $result = db_query($sql,"could not get recurrent invoice");
64 return db_fetch($result);