X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fmanage%2Frecurrent_invoices.php;h=8a08a6d1c63d652b209346124afe2d2e18e1489a;hb=7e8df3a179c05c51085349e139aac9ce88b9378d;hp=dea4ef3fdb9bb6755dd7d25275d0f7611d56122c;hpb=963bc21ea092322d5750d4c0914b5e532e7d2467;p=fa-stable.git diff --git a/sales/manage/recurrent_invoices.php b/sales/manage/recurrent_invoices.php index dea4ef3f..8a08a6d1 100644 --- a/sales/manage/recurrent_invoices.php +++ b/sales/manage/recurrent_invoices.php @@ -16,9 +16,9 @@ include($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); $js = ""; -if ($use_popup_windows) +if ($SysPrefs->use_popup_windows) $js .= get_js_open_window(900, 600); -if ($use_date_picker) +if (user_use_date_picker()) $js .= get_js_date_picker(); page(_($help_context = "Recurrent Invoices"), false, false, "", $js); @@ -30,24 +30,47 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') $input_error = 0; + if (strlen($_POST['order_no']) == 0) + { + $input_error = 1; + display_error(_("No order has been selected as a template for recurrent invoicing.")); + set_focus('order_no'); + } if (strlen($_POST['description']) == 0) { $input_error = 1; - display_error(_("The area description cannot be empty.")); + display_error(_("The invoice description cannot be empty.")); set_focus('description'); } + if (!is_date($_POST['begin'])) { + $input_error = 1; + display_error(_("The entered date is invalid.")); + set_focus('begin'); + } + if (!is_date($_POST['end'])) { + $input_error = 1; + display_error(_("The entered date is invalid.")); + set_focus('end'); + } + if (isset($_POST['last_sent']) && !is_date($_POST['last_sent'])) { + $input_error = 1; + display_error(_("The entered date is invalid.")); + set_focus('last_sent'); + } if ($input_error != 1) { if ($selected_id != -1) { - update_recurrent_invoice($selected_id, $_POST['description'], $_POST['order_no'], $_POST['debtor_no'], - $_POST['group_no'], input_num('days', 0), input_num('monthly', 0), $_POST['begin'], $_POST['end']); + update_recurrent_invoice($selected_id, $_POST['description'], $_POST['order_no'], input_num('debtor_no'), + input_num('group_no'), input_num('days', 0), input_num('monthly', 0), $_POST['begin'], $_POST['end']); + if (isset($_POST['last_sent'])) + update_last_sent_recurrent_invoice($selected_id, $_POST['last_sent']); $note = _('Selected recurrent invoice has been updated'); } else { - add_recurrent_invoice($_POST['description'], $_POST['order_no'], $_POST['debtor_no'], $_POST['group_no'], + add_recurrent_invoice($_POST['description'], $_POST['order_no'], input_num('debtor_no'), input_num('group_no'), input_num('days', 0), input_num('monthly', 0), $_POST['begin'], $_POST['end']); $note = _('New recurrent invoice has been added'); } @@ -81,7 +104,7 @@ if ($Mode == 'RESET') $result = get_recurrent_invoices(); start_form(); -start_table("$table_style width=70%"); +start_table(TABLESTYLE, "width=70%"); $th = array(_("Description"), _("Template No"),_("Customer"),_("Branch")."/"._("Group"),_("Days"),_("Monthly"),_("Begin"),_("End"),_("Last Created"),"", ""); table_header($th); $k = 0; @@ -89,7 +112,7 @@ while ($myrow = db_fetch($result)) { $begin = sql2date($myrow["begin"]); $end = sql2date($myrow["end"]); - $last_sent = sql2date($myrow["last_sent"]); + $last_sent = $myrow["last_sent"] == '0000-00-00' ? '' : sql2date($myrow["last_sent"]); alt_table_row_color($k); @@ -123,7 +146,7 @@ echo '
'; start_form(); -start_table($table_style2); +start_table(TABLESTYLE2); if ($selected_id != -1) { @@ -139,6 +162,7 @@ if ($selected_id != -1) $_POST['monthly'] = $myrow["monthly"]; $_POST['begin'] = sql2date($myrow["begin"]); $_POST['end'] = sql2date($myrow["end"]); + $_POST['last_sent'] = ($myrow['last_sent']=="0000-00-00"?"":sql2date($myrow["last_sent"])); } hidden("selected_id", $selected_id); } @@ -163,6 +187,9 @@ date_row(_("Begin:"), 'begin'); date_row(_("End:"), 'end', null, null, 0, 0, 5); +if ($selected_id != -1 && $_POST['last_sent'] != "") + date_row(_("Last Created"), 'last_sent'); + end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); @@ -170,4 +197,3 @@ submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); end_page(); -?>