5 include($path_to_root . "/includes/session.inc");
7 page(_("Credit Status"));
9 include($path_to_root . "/sales/includes/db/credit_status_db.inc");
11 include($path_to_root . "/includes/ui.inc");
13 simple_page_mode(true);
14 //-----------------------------------------------------------------------------------
16 function can_process()
19 if (strlen($_POST['reason_description']) == 0)
21 display_error(_("The credit status description cannot be empty."));
28 //-----------------------------------------------------------------------------------
30 if ($Mode=='ADD_ITEM' && can_process())
33 add_credit_status($_POST['reason_description'], $_POST['DisallowInvoices']);
34 display_notification(_('New credit status has been added'));
38 //-----------------------------------------------------------------------------------
40 if ($Mode=='UPDATE_ITEM' && can_process())
42 display_notification(_('Selected credit status has been updated'));
43 update_credit_status($selected_id, $_POST['reason_description'], $_POST['DisallowInvoices']);
47 //-----------------------------------------------------------------------------------
49 function can_delete($selected_id)
51 $sql= "SELECT COUNT(*) FROM ".TB_PREF."debtors_master
52 WHERE credit_status=$selected_id";
53 $result = db_query($sql, "could not query customers");
54 $myrow = db_fetch_row($result);
57 display_error(_("Cannot delete this credit status because customer accounts have been created referring to it."));
65 //-----------------------------------------------------------------------------------
67 if ($Mode == 'Delete')
70 if (can_delete($selected_id))
72 delete_credit_status($selected_id);
73 display_notification(_('Selected credit status has been deleted'));
83 //-----------------------------------------------------------------------------------
85 $result = get_all_credit_status();
88 start_table("$table_style width=40%");
89 $th = array(_("Description"), _("Dissallow Invoices"),'','');
93 while ($myrow = db_fetch($result))
96 alt_table_row_color($k);
98 if ($myrow["dissallow_invoices"] == 0)
100 $disallow_text = _("Invoice OK");
104 $disallow_text = "<b>" . _("NO INVOICING") . "</b>";
107 label_cell($myrow["reason_description"]);
108 label_cell($disallow_text);
109 edit_button_cell("Edit".$myrow['id'], _("Edit"));
110 edit_button_cell("Delete".$myrow['id'], _("Delete"));
118 //-----------------------------------------------------------------------------------
122 start_table("$table_style2 width=40%");
124 if ($selected_id != -1)
126 if ($Mode == 'Edit') {
127 //editing an existing status code
129 $myrow = get_credit_status($selected_id);
131 $_POST['reason_description'] = $myrow["reason_description"];
132 $_POST['DisallowInvoices'] = $myrow["dissallow_invoices"];
134 hidden('selected_id', $selected_id);
137 text_row_ex(_("Description:"), 'reason_description', 50);
139 yesno_list_row(_("Dissallow invoicing ?"), 'DisallowInvoices', null);
143 submit_add_or_update_center($selected_id == -1, '', true);
147 //------------------------------------------------------------------------------------