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."));
22 set_focus('reason_description');
29 //-----------------------------------------------------------------------------------
31 if ($Mode=='ADD_ITEM' && can_process())
34 add_credit_status($_POST['reason_description'], $_POST['DisallowInvoices']);
35 display_notification(_('New credit status has been added'));
39 //-----------------------------------------------------------------------------------
41 if ($Mode=='UPDATE_ITEM' && can_process())
43 display_notification(_('Selected credit status has been updated'));
44 update_credit_status($selected_id, $_POST['reason_description'], $_POST['DisallowInvoices']);
48 //-----------------------------------------------------------------------------------
50 function can_delete($selected_id)
52 $sql= "SELECT COUNT(*) FROM ".TB_PREF."debtors_master
53 WHERE credit_status=$selected_id";
54 $result = db_query($sql, "could not query customers");
55 $myrow = db_fetch_row($result);
58 display_error(_("Cannot delete this credit status because customer accounts have been created referring to it."));
66 //-----------------------------------------------------------------------------------
68 if ($Mode == 'Delete')
71 if (can_delete($selected_id))
73 delete_credit_status($selected_id);
74 display_notification(_('Selected credit status has been deleted'));
84 //-----------------------------------------------------------------------------------
86 $result = get_all_credit_status();
89 start_table("$table_style width=40%");
90 $th = array(_("Description"), _("Dissallow Invoices"),'','');
94 while ($myrow = db_fetch($result))
97 alt_table_row_color($k);
99 if ($myrow["dissallow_invoices"] == 0)
101 $disallow_text = _("Invoice OK");
105 $disallow_text = "<b>" . _("NO INVOICING") . "</b>";
108 label_cell($myrow["reason_description"]);
109 label_cell($disallow_text);
110 edit_button_cell("Edit".$myrow['id'], _("Edit"));
111 edit_button_cell("Delete".$myrow['id'], _("Delete"));
119 //-----------------------------------------------------------------------------------
123 start_table("$table_style2 width=40%");
125 if ($selected_id != -1)
127 if ($Mode == 'Edit') {
128 //editing an existing status code
130 $myrow = get_credit_status($selected_id);
132 $_POST['reason_description'] = $myrow["reason_description"];
133 $_POST['DisallowInvoices'] = $myrow["dissallow_invoices"];
135 hidden('selected_id', $selected_id);
138 text_row_ex(_("Description:"), 'reason_description', 50);
140 yesno_list_row(_("Dissallow invoicing ?"), 'DisallowInvoices', null);
144 submit_add_or_update_center($selected_id == -1, '', true);
148 //------------------------------------------------------------------------------------