<?php
/**********************************************************************
- Copyright (C) FrontAccounting, LLC.
+ Copyright (C) FrontAccounting, LLC.
Released under the terms of the GNU General Public License, GPL,
as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
$page_security = 'SA_SALESINVOICE';
$path_to_root = "..";
function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no, $date, $from, $to, $memo)
{
- global $Refs;
+ global $Refs, $SysPrefs;
update_last_sent_recurrent_invoice($tmpl_no, $to);
$doc = new Cart(ST_SALESORDER, array($order_no));
-
+
+ if (!empty($SysPrefs->prefs['dim_on_recurrent_invoice']))
+ $doc->trans_type = ST_SALESINVOICE;
+
get_customer_details_to_order($doc, $customer_id, $branch_id);
$doc->trans_type = ST_SALESORDER;
$doc->reference = $Refs->get_next($doc->trans_type, null, array('customer' => $customer_id, 'branch' => $branch_id,
'date' => $date));
+ if (!empty($doc->Comments))
+ $memo .= "\n" . $doc->Comments;
$doc->Comments = $memo;
foreach ($doc->line_items as $line_no=>$item) {
whole invoiced time is <begin, end>
invoices are issued _after_ invoiced period is gone, eg:
begin 1.1
- end 31.3
- period: invoice ready for issue since:
- 1.1-31.1 - 1.2
- 1.2-28.2 - 1.3
- 1.3-31.3 - 1.4
+ end 31.3
+ period: invoice ready for issue since:
+ 1.1-31.1 - 1.2
+ 1.2-28.2 - 1.3
+ 1.3-31.3 - 1.4
In example above, when end is set to 1.4 will generate additional invoice on 1.5 !
*/
$invs = array();
if (recurrent_invoice_ready($id, $date))
{
- begin_transaction();
+ begin_transaction();
if ($myrow['debtor_no'] == 0)
{
if (count($invs) > 0)
{
$ar = array('PARAM_0' => $min."-".ST_SALESINVOICE, 'PARAM_1' => $max."-".ST_SALESINVOICE, 'PARAM_2' => "",
- 'PARAM_3' => 0, 'PARAM_4' => 0, 'PARAM_5' => "", 'PARAM_6' => user_def_print_orientation());
+ 'PARAM_3' => 0, 'PARAM_4' => 0, 'PARAM_5' => "", 'PARAM_6' => "", 'PARAM_7' => user_def_print_orientation());
display_note(print_link(sprintf(_("&Print Recurrent Invoices # %s - # %s"), $min, $max), 107, $ar), 0, 1);
- $ar['PARAM_6'] = 1; // orygina³
$ar['PARAM_3'] = 1; // email
display_note(print_link(sprintf(_("&Email Recurrent Invoices # %s - # %s"), $min, $max), 107, $ar), 0, 1);
}
$_POST['trans_date'] = $to;
start_form();
- start_table(TABLESTYLE, "width=50%");
- label_row(_('Description:'), $myrow["description"]);
- label_row(_('Template:'), get_customer_trans_view_str(30, $myrow["order_no"]));
- label_row(_('Number of invoices:'), $count);
- date_row(_('Invoice date:'), 'trans_date');
- text_row(_('Invoice notice:'), 'memo', sprintf(_("Recurrent Invoice covers period %s - %s."), $from, add_days($to, -1)),
- 100, 100);
- end_table();
- hidden('from', $from, true);
- hidden('to', $to, true);
- br();
+ start_table(TABLESTYLE, "width=50%");
+ label_row(_('Description:'), $myrow["description"]);
+ label_row(_('Template:'), get_customer_trans_view_str(ST_SALESORDER, $myrow["order_no"]));
+ label_row(_('Number of invoices:'), $count);
+ date_row(_('Invoice date:'), 'trans_date');
+ $newto = add_months($to, $myrow['monthly']);
+ $newto = add_days($newto, $myrow['days']);
+ text_row(_('Invoice notice:'), 'memo', sprintf(_("Recurrent Invoice covers period %s - %s."), $to, add_days($newto, -1)), 100, 100);
+ //text_row(_('Invoice notice:'), 'memo', sprintf(_("Recurrent Invoice covers period %s - %s."), //$from, add_days($to, -1)), 100, 100);
+ end_table();
+ hidden('from', $from, true);
+ hidden('to', $to, true);
+ br();
submit_center_first('confirmed'.$id, _('Create'), _('Create recurrent invoices'), false, ICON_OK);
submit_center_last('cancel', _('Cancel'), _('Return to recurrent invoices'), false, ICON_ESCAPE);
submit_js_confirm("do_create".$id, sprintf(_("You are about to issue %s invoices.\n Do you want to continue?"), $count));
alt_table_row_color($k);
label_cell($myrow["description"]);
- label_cell(get_customer_trans_view_str(30, $myrow["order_no"]));
+ label_cell(get_customer_trans_view_str(ST_SALESORDER, $myrow["order_no"]), "nowrap align='right'");
if ($myrow["debtor_no"] == 0)
{
label_cell("");
label_cell($myrow["days"]);
label_cell($myrow['monthly']);
label_cell(sql2date($myrow['begin']), "align='center'");
- label_cell(sql2date($myrow['end']), "align='center'");
- label_cell(calculate_next($myrow), "align='center'");
- if ($myrow['overdue'])
- {
+ label_cell(sql2date($myrow['end']), "align='center'");
+ label_cell(calculate_next($myrow), "align='center'");
+ if ($myrow['overdue'])
+ {
$count = recurrent_invoice_count($myrow['id']);
- if ($count)
- {
+ if ($count)
+ {
button_cell("create".$myrow["id"], sprintf(_("Create %s Invoice(s)"), $count), "", ICON_DOC, 'process');
} else {
label_cell('');
}
}
- else
- label_cell("");
+ else
+ label_cell("");
end_row();
}
end_table();