X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fpayment_terms.php;h=ddc4c50945fca768af030f114027629028e7d0fa;hb=a39265e56d8242281a694fb619804c67388b13c5;hp=33ddf1189cc0bcc5fd911632224dfd62544dde50;hpb=f00216978947d0fd076550f1969430265a270ce7;p=fa-stable.git diff --git a/admin/payment_terms.php b/admin/payment_terms.php index 33ddf118..ddc4c509 100644 --- a/admin/payment_terms.php +++ b/admin/payment_terms.php @@ -1,5 +1,14 @@ . +***********************************************************************/ $page_security = 10; $path_to_root=".."; include($path_to_root . "/includes/session.inc"); @@ -8,21 +17,10 @@ page(_("Payment Terms")); include($path_to_root . "/includes/ui.inc"); - +simple_page_mode(true); //------------------------------------------------------------------------------------------- -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - -//------------------------------------------------------------------------------------------- - -if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { $inpug_error = 0; @@ -57,7 +55,7 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) if ($inpug_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { if (check_value('DaysOrFoll')) { @@ -73,7 +71,7 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) days_before_due=0 WHERE terms_indicator = " .db_escape( $selected_id ); } - + $note = _('Selected payment terms have been updated'); } else { @@ -92,16 +90,16 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) VALUES (" . db_escape($_POST['terms']) . ", 0, " . db_escape($_POST['DayNumber']) . ")"; } - + $note = _('New payment terms have been added'); } //run the sql from either of the above possibilites db_query($sql,"The payment term could not be added or updated"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification($note); + $Mode = 'RESET'; } } -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master @@ -127,20 +125,30 @@ if (isset($_GET['delete'])) $sql="DELETE FROM ".TB_PREF."payment_terms WHERE terms_indicator='$selected_id'"; db_query($sql,"could not delete a payment terms"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected payment terms have been deleted')); } } //end if payment terms used in customer or supplier accounts + $Mode = 'RESET'; } +if ($Mode == 'RESET') +{ + $selected_id = -1; + $sav = get_post('show_inactive'); + unset($_POST); + $_POST['show_inactive'] = $sav; +} //------------------------------------------------------------------------------------------------- $sql = "SELECT * FROM ".TB_PREF."payment_terms"; +if (!check_value('show_inactive')) $sql .= " WHERE !inactive"; $result = db_query($sql,"could not get payment terms"); +start_form(); start_table($table_style); $th = array(_("Description"), _("Following Month On"), _("Due After (Days)"), "", ""); +inactive_control_column($th); table_header($th); $k = 0; //row colour counter @@ -169,37 +177,36 @@ while ($myrow = db_fetch($result)) label_cell($myrow["terms"]); label_cell($full_text); label_cell($after_text); - edit_link_cell("selected_id=".$myrow["terms_indicator"]); - delete_link_cell("selected_id=".$myrow["terms_indicator"]."&delete=1"); + inactive_control_cell($myrow["terms_indicator"], $myrow["inactive"], 'payment_terms', "terms_indicator"); + edit_button_cell("Edit".$myrow["terms_indicator"], _("Edit")); + delete_button_cell("Delete".$myrow["terms_indicator"], _("Delete")); end_row(); } //END WHILE LIST LOOP -end_table(); - -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Payment Term")); +inactive_control_row($th); +end_table(1); //------------------------------------------------------------------------------------------------- -start_form(); - start_table($table_style2); $day_in_following_month = $days_before_due = 0; -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing payment terms - $sql = "SELECT * FROM ".TB_PREF."payment_terms - WHERE terms_indicator='$selected_id'"; + if ($Mode == 'Edit') { + //editing an existing payment terms + $sql = "SELECT * FROM ".TB_PREF."payment_terms + WHERE terms_indicator='$selected_id'"; - $result = db_query($sql,"could not get payment term"); - $myrow = db_fetch($result); - - $_POST['terms'] = $myrow["terms"]; - $days_before_due = $myrow["days_before_due"]; - $day_in_following_month = $myrow["day_in_following_month"]; + $result = db_query($sql,"could not get payment term"); + $myrow = db_fetch($result); + $_POST['terms'] = $myrow["terms"]; + $days_before_due = $myrow["days_before_due"]; + $day_in_following_month = $myrow["day_in_following_month"]; + } hidden('selected_id', $selected_id); } text_row(_("Terms Description:"), 'terms', null, 40, 40); @@ -218,7 +225,7 @@ text_row_ex(_("Days (Or Day In Following Month):"), 'DayNumber', 3); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', 'both'); end_form();