本文整理汇总了PHP中add_days函数的典型用法代码示例。如果您正苦于以下问题:PHP add_days函数的具体用法?PHP add_days怎么用?PHP add_days使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_days函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_trial_balance
function display_trial_balance()
{
global $table_style, $path_to_root;
start_table($table_style);
$tableheader = "<tr>\n <td rowspan=2 class='tableheader'>" . tr("Account") . "</td>\n <td rowspan=2 class='tableheader'>" . tr("Account Name") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("Brought Forward") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("This Period") . "</td>\n\t\t<td colspan=2 class='tableheader'>" . tr("Balance") . "</td>\n\t\t</tr><tr>\n\t\t<td class='tableheader'>" . tr("Debit") . "</td>\n <td class='tableheader'>" . tr("Credit") . "</td>\n\t\t<td class='tableheader'>" . tr("Debit") . "</td>\n\t\t<td class='tableheader'>" . tr("Credit") . "</td>\n <td class='tableheader'>" . tr("Debit") . "</td>\n <td class='tableheader'>" . tr("Credit") . "</td>\n </tr>";
echo $tableheader;
$k = 0;
$accounts = get_gl_accounts();
while ($account = db_fetch($accounts)) {
if (is_account_balancesheet($account["account_code"])) {
$begin = null;
} else {
$begin = begin_fiscalyear();
if ($_POST['TransFromDate'] < $begin) {
$begin = $_POST['TransFromDate'];
}
$begin = add_days($begin, -1);
}
$prev_balance = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false);
$curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']);
if (check_value("NoZero") && !$prev_balance && !$curr_balance) {
continue;
}
alt_table_row_color($k);
$url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?" . SID . "TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "'>" . $account["account_code"] . "</a>";
label_cell($url);
label_cell($account["account_name"]);
display_debit_or_credit_cells($prev_balance);
display_debit_or_credit_cells($curr_balance);
display_debit_or_credit_cells($prev_balance + $curr_balance);
end_row();
}
end_table(1);
}
示例2: create_recurrent_invoices
function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no, $date, $from, $to)
{
global $Refs;
$doc = new Cart(ST_SALESORDER, array($order_no));
get_customer_details_to_order($doc, $customer_id, $branch_id);
$doc->trans_type = ST_SALESORDER;
$doc->trans_no = 0;
$doc->document_date = $date;
$doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date);
$doc->reference = $Refs->get_next($doc->trans_type);
if ($doc->Comments != "") {
$doc->Comments .= "\n";
}
$doc->Comments .= sprintf(_("Recurrent Invoice covers period %s - %s."), $from, add_days($to, -1));
foreach ($doc->line_items as $line_no => $item) {
$line =& $doc->line_items[$line_no];
$line->price = get_price($line->stock_id, $doc->customer_currency, $doc->sales_type, $doc->price_factor, $doc->document_date);
}
$cart = $doc;
$cart->trans_type = ST_SALESINVOICE;
$cart->reference = $Refs->get_next($cart->trans_type);
$invno = $cart->write(1);
if ($invno == -1) {
display_error(_("The entered reference is already in use."));
display_footer_exit();
}
update_last_sent_recurrent_invoice($tmpl_no, $to);
return $invno;
}
示例3: render
function render($id, $title)
{
global $path_to_root, $systypes_array;
include_once $path_to_root . "/includes/ui.inc";
$start_date = add_days(Today(), -$this->days_past);
$end_date = add_days(Today(), $this->days_future);
$result = get_bank_trans_for_bank_account($this->bank_act, $start_date, $end_date);
start_table(TABLESTYLE, 'width=98%');
$th = array(_("#"), _("Date"), _("Receipt"), _("Payment"), _("Balance"), _("Person/Item"), _("Memo"), "");
table_header($th);
$bfw = get_balance_before_for_bank_account($this->bank_act, $start_date);
$credit = $debit = 0;
start_row("class='inquirybg' style='font-weight:bold'");
label_cell(_("Opening Balance") . " - " . $start_date, "colspan=4");
display_debit_or_credit_cells($bfw);
label_cell("");
label_cell("", "colspan=2");
end_row();
$running_total = $bfw;
if ($bfw > 0) {
$debit += $bfw;
} else {
$credit += $bfw;
}
$j = 1;
$k = 0;
//row colour counter
while ($myrow = db_fetch($result)) {
alt_table_row_color($k);
$running_total += $myrow["amount"];
label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
$trandate = sql2date($myrow["trans_date"]);
label_cell($trandate);
display_debit_or_credit_cells($myrow["amount"]);
amount_cell($running_total);
label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"]));
label_cell(get_comments_string($myrow["type"], $myrow["trans_no"]));
label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
end_row();
if ($myrow["amount"] > 0) {
$debit += $myrow["amount"];
} else {
$credit += $myrow["amount"];
}
if ($j == 12) {
$j = 1;
table_header($th);
}
$j++;
}
//end of while loop
start_row("class='inquirybg' style='font-weight:bold'");
label_cell(_("Ending Balance") . " - " . $end_date, "colspan=4");
amount_cell($debit + $credit);
label_cell("");
label_cell("", "colspan=2");
end_row();
end_table(2);
}
示例4: render
function render($id, $title)
{
global $path_to_root;
include_once $path_to_root . "/includes/ui.inc";
$end_date = date2sql(add_days(Today(), $this->days_future));
$role_id = $_SESSION["wa_current_user"]->access;
$sql = "SELECT id, description, next_date FROM " . TB_PREF . "dashboard_reminders " . " WHERE next_date < '{$end_date}'" . " AND role_id = '{$role_id}'";
if ($this->data_filter != '') {
$sql .= ' AND ' . $this->data_filter;
}
$sql .= " ORDER BY next_date";
$result = db_query($sql);
br();
$th = array(_("Actioned"), _("Date"), _("Description"));
start_table(TABLESTYLE, "id='reminder' width=98%");
table_header($th);
$k = 0;
//row colour counter
while ($myrow = db_fetch($result)) {
$nextdate = sql2date($myrow["next_date"]);
if (date1_greater_date2(Today(), $nextdate)) {
$extra = "class='reminder_overdue'";
} elseif (Today() == $nextdate) {
$extra = "class='reminder_due'";
} else {
$extra = "class='reminder'";
}
alt_table_row_color($k);
$js = 'setTimeout(function(){updateToDoData(' . $myrow["id"] . ');}, 0);';
check_cells(null, null, null, $js);
label_cell($nextdate, $extra);
label_cell("<pre>" . $myrow["description"] . "</pre>", $extra);
end_row();
}
end_table(1);
}
示例5: display_type
function display_type($type, $typename, &$dec, &$rep, $from, $to, $zero, $balances, $dimension, $dimension2)
{
global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal, $clear_trial_balance_opening;
$printtitle = 0;
//Flag for printing type name
//Get Accounts directly under this group/type
$accounts = get_gl_accounts(null, null, $type);
$begin = get_fiscalyear_begin_for_date($from);
if (date1_greater_date2($begin, $from)) {
$begin = $from;
}
$begin = add_days($begin, -1);
while ($account = db_fetch($accounts)) {
//Print Type Title if it has atleast one non-zero account
if (!$printtitle) {
$rep->row -= 4;
$rep->TextCol(0, 8, _("Group") . " - " . $type . " - " . $typename);
$printtitle = 1;
$rep->row -= 4;
$rep->Line($rep->row);
$rep->NewLine();
}
// FA doesn't really clear the closed year, therefore the brought forward balance includes all the transactions from the past, even though the balance is null.
// If we want to remove the balanced part for the past years, this option removes the common part from from the prev and tot figures.
if (@$clear_trial_balance_opening) {
$open = get_balance($account["account_code"], $dimension, $dimension2, $begin, $begin, false, true);
$offset = min($open['debit'], $open['credit']);
} else {
$offset = 0;
}
$prev = get_balance($account["account_code"], $dimension, $dimension2, $begin, $from, false, false);
$curr = get_balance($account["account_code"], $dimension, $dimension2, $from, $to, true, true);
$tot = get_balance($account["account_code"], $dimension, $dimension2, $begin, $to, false, true);
if ($zero == 0 && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) {
continue;
}
$rep->TextCol(0, 1, $account['account_code']);
$rep->TextCol(1, 2, $account['account_name']);
if ($balances != 0) {
if ($prev['balance'] >= 0.0) {
$rep->AmountCol(2, 3, $prev['balance'], $dec);
} else {
$rep->AmountCol(3, 4, abs($prev['balance']), $dec);
}
if ($curr['balance'] >= 0.0) {
$rep->AmountCol(4, 5, $curr['balance'], $dec);
} else {
$rep->AmountCol(5, 6, abs($curr['balance']), $dec);
}
if ($tot['balance'] >= 0.0) {
$rep->AmountCol(6, 7, $tot['balance'], $dec);
} else {
$rep->AmountCol(7, 8, abs($tot['balance']), $dec);
}
} else {
$rep->AmountCol(2, 3, $prev['debit'] - $offset, $dec);
$rep->AmountCol(3, 4, $prev['credit'] - $offset, $dec);
$rep->AmountCol(4, 5, $curr['debit'], $dec);
$rep->AmountCol(5, 6, $curr['credit'], $dec);
$rep->AmountCol(6, 7, $tot['debit'] - $offset, $dec);
$rep->AmountCol(7, 8, $tot['credit'] - $offset, $dec);
$pdeb += $prev['debit'] - $offset;
$pcre += $prev['credit'] - $offset;
$cdeb += $curr['debit'];
$ccre += $curr['credit'];
$tdeb += $tot['debit'] - $offset;
$tcre += $tot['credit'] - $offset;
}
$pbal += $prev['balance'];
$cbal += $curr['balance'];
$tbal += $tot['balance'];
$rep->NewLine();
if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
$rep->Line($rep->row - 2);
$rep->NewPage();
}
}
//Get Account groups/types under this group/type
$result = get_account_types(false, false, $type);
while ($accounttype = db_fetch($result)) {
//Print Type Title if has sub types and not previously printed
if (!$printtitle) {
$rep->row -= 4;
$rep->TextCol(0, 8, _("Group") . " - " . $type . " - " . $typename);
$printtitle = 1;
$rep->row -= 4;
$rep->Line($rep->row);
$rep->NewLine();
}
display_type($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')', $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2);
}
}
示例6: array
$first_cols = array(_("Type"), "#", _("Date"));
if ($dim == 2) {
$dim_cols = array(_("Dimension") . " 1", _("Dimension") . " 2");
} else {
if ($dim == 1) {
$dim_cols = array(_("Dimension"));
} else {
$dim_cols = array();
}
}
$remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo"));
$th = array_merge($first_cols, $dim_cols, $remaining_cols);
table_header($th);
$end = $_GET['date'];
$account = $_GET['act'];
$begin = add_days($end, -30);
$result = get_gl_transactions($begin, $end, -1, $account, 0, 0, null);
$j = 0;
$k = 1;
while ($myrow = db_fetch($result)) {
alt_table_row_color($k);
$trandate = sql2date($myrow["tran_date"]);
label_cell($systypes_array[$myrow["type"]]);
$amount = price_format($myrow["amount"]);
$str = "<a href='#' onclick='return WindowClose(\"{$amount}\", \"{$trandate}\");' >" . $myrow['type_no'] . "</a>";
label_cell($str);
label_cell($trandate);
if ($dim >= 1) {
label_cell(get_dimension_string($myrow['dimension_id'], true));
}
if ($dim > 1) {
示例7: show_results
function show_results()
{
global $path_to_root, $table_style;
if (!isset($_POST["account"]) || $_POST["account"] == "") {
return;
}
$act_name = get_gl_account_name($_POST["account"]);
$dim = get_company_pref('use_dimension');
/*Now get the transactions */
if (!isset($_POST['Dimension'])) {
$_POST['Dimension'] = 0;
}
if (!isset($_POST['Dimension2'])) {
$_POST['Dimension2'] = 0;
}
$result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']);
$colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4");
//echo "\nDimension =". $_POST['Dimension'];
display_heading($_POST["account"] . " " . $act_name);
start_table($table_style);
if ($dim == 2) {
$th = array(tr("Type"), tr("#"), tr("Date"), tr("Dimension") . " 1", tr("Dimension") . " 2", tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo"));
} else {
if ($dim == 1) {
$th = array(tr("Type"), tr("#"), tr("Date"), tr("Dimension"), tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo"));
} else {
$th = array(tr("Type"), tr("#"), tr("Date"), tr("Person/Item"), tr("Debit"), tr("Credit"), tr("Balance"), tr("Memo"));
}
}
table_header($th);
if (is_account_balancesheet($_POST["account"])) {
$begin = "";
} else {
$begin = begin_fiscalyear();
if ($_POST['TransFromDate'] < $begin) {
$begin = $_POST['TransFromDate'];
}
$begin = add_days($begin, -1);
}
$bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']);
start_row("class='inquirybg'");
label_cell("<b>" . tr("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}");
display_debit_or_credit_cells($bfw);
label_cell("");
end_row();
//$running_total =0;
$running_total = $bfw;
$j = 1;
$k = 0;
//row colour counter
while ($myrow = db_fetch($result)) {
alt_table_row_color($k);
$running_total += $myrow["amount"];
$trandate = sql2date($myrow["tran_date"]);
label_cell(systypes::name($myrow["type"]));
label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true));
label_cell($trandate);
if ($dim >= 1) {
label_cell(get_dimension_string($myrow['dimension_id'], true));
}
if ($dim > 1) {
label_cell(get_dimension_string($myrow['dimension2_id'], true));
}
label_cell(payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"]));
display_debit_or_credit_cells($myrow["amount"]);
amount_cell($running_total);
label_cell($myrow['memo_']);
end_row();
$j++;
if ($j == 12) {
$j = 1;
table_header($th);
}
}
//end of while loop
start_row("class='inquirybg'");
label_cell("<b>" . tr("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}");
display_debit_or_credit_cells($running_total);
label_cell("");
end_row();
end_table(2);
if (db_num_rows($result) == 0) {
display_note(tr("No general ledger transactions have been created for this account on the selected dates."), 0, 1);
}
}
示例8: print_subsidiary_ledger
function print_subsidiary_ledger()
{
global $path_to_root, $systypes_array;
$dim = get_company_pref('use_dimension');
$dimension = $dimension2 = 0;
$from = $_POST['PARAM_0'];
$to = $_POST['PARAM_1'];
$fromacc = $_POST['PARAM_2'];
$comments = $_POST['PARAM_3'];
$orientation = $_POST['PARAM_4'];
$destination = $_POST['PARAM_5'];
if ($destination) {
include_once $path_to_root . "/reporting/includes/excel_report.inc";
} else {
include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
}
$orientation = $orientation ? 'L' : 'P';
$rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, $orientation);
$dec = user_price_dec();
//$headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2",
// _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
//$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
$cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525);
//------------0--1---2---3----4----5----6----7----8----9----10-------
//-----------------------dim1-dim2-----------------------------------
//-----------------------dim1----------------------------------------
//-------------------------------------------------------------------
$aligns = array('left', 'left', 'left', 'center', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
$headers = array(_('Account Name'), '', '', '', '', '', _('Debit'), _('Credit'), '', _('Balance'));
$params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc));
if ($orientation == 'L') {
recalculate_cols($cols);
}
$rep->SetHeaderType('Header_custom');
$rep->Font();
$rep->Info($params, $cols, $headers, $aligns);
$rep->NewPage();
$accounts = get_gl_accounts($fromacc, $fromacc);
while ($account = db_fetch($accounts)) {
if (is_account_balancesheet($account["account_code"])) {
$begin = "";
} else {
$begin = get_fiscalyear_begin_for_date($from);
if (date1_greater_date2($begin, $from)) {
$begin = $from;
}
$begin = add_days($begin, -1);
}
$prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
$trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2);
$rows = db_num_rows($trans);
if ($prev_balance == 0.0 && $rows == 0) {
continue;
}
$rep->Font('bold');
$rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2);
$rep->TextCol(4, 6, _('Opening Balance'));
if ($prev_balance > 0.0) {
$rep->AmountCol(7, 8, abs($prev_balance), $dec);
} else {
$rep->AmountCol(8, 9, abs($prev_balance), $dec);
}
$rep->Font();
$total = $prev_balance;
$rep->NewLine(2);
if ($rows > 0) {
$previous = '';
while ($myrow = db_fetch($trans)) {
$total += $myrow['amount'];
$txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false);
$current = $txt;
$memo = $myrow['memo_'];
if ($txt != "") {
if ($previous == $current) {
$txt = '';
} else {
$rep->NewLine(1);
$rep->Line($rep->row - $rep->lineHeight + 4);
$rep->NewLine(2, 0);
$rep->TextCol(3, 8, $txt, -2);
$rep->Line($rep->row - $rep->lineHeight + 4);
$rep->NewLine(2, 1);
$rep->NewLine(1);
}
$previous = $current;
}
$rep->TextCol(0, 3, $systypes_array[$myrow["type"]], -2);
$rep->DateCol(4, 6, $myrow["tran_date"], true);
if ($myrow['amount'] > 0.0) {
$rep->AmountCol(6, 7, abs($myrow['amount']), $dec);
} else {
$rep->AmountCol(7, 8, abs($myrow['amount']), $dec);
}
$rep->TextCol(8, 10, number_format2($total, $dec));
$rep->NewLine();
if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
$rep->Line($rep->row - 2);
$rep->NewPage();
}
}
//.........这里部分代码省略.........
示例9: db_query
$result = db_query($sql, "item code could not be retrieved");
$row = db_fetch_row($result);
if (!$row) {
add_item_code($code, $id, $description, $cat, $qty, $foreign);
} else {
update_item_code($row[0], $code, $id, $description, $cat, $qty, $foreign);
}
$k++;
}
if ($type == 'ITEM') {
$dim = 0;
if ($qty != '') {
$dim = get_dimension_by_name($qty);
if ($dim == -1) {
$date = Today();
$due = add_days($date, sys_prefs::default_dimension_required_by());
$ref = references::get_next(systypes::dimension());
$dim = add_dimension($ref, $qty, 1, $date, $due, "Added due to Item Import");
$dim_n++;
}
}
$sql = "SELECT stock_id FROM " . TB_PREF . "stock_master WHERE stock_id='{$id}'";
$result = db_query($sql, "item could not be retrieved");
$row = db_fetch_row($result);
if (!$row) {
$sql = "INSERT INTO " . TB_PREF . "stock_master (stock_id, description, long_description, category_id,\n\t\t\t\t\t tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,\n\t\t\t\t\t adjustment_account, assembly_account, dimension_id, dimension2_id)\n\t\t\t\t\t VALUES ('{$id}', " . db_escape($description) . ", '',\n\t\t\t\t\t '{$cat}', {$_POST['tax_type_id']}, '{$units}', '{$mb_flag}',\n\t\t\t\t\t '{$_POST['sales_account']}', '{$_POST['inventory_account']}', '{$_POST['cogs_account']}',\n\t\t\t\t\t '{$_POST['adjustment_account']}', '{$_POST['assembly_account']}', {$dim}, 0)";
db_query($sql, "The item could not be added");
if ($mb_flag == "M" || $mb_flag == "B") {
$sql = "INSERT INTO " . TB_PREF . "loc_stock (loc_code, stock_id) VALUES ('{$_POST['location']}', '{$id}')";
db_query($sql, "The item locstock could not be added");
}
示例10: render
function render($id, $title)
{
global $path_to_root;
include_once $path_to_root . "/reporting/includes/class.graphic.inc";
$today = date2sql(Today());
if (!isset($data->days_past)) {
$this->days_past = 30;
}
if (!isset($data->days_future)) {
$this->days_future = 30;
}
$sql = "SELECT bank_act, bank_account_name, trans_date, amount" . " FROM (" . " SELECT bank_act, bank_account_name, null trans_date, SUM(amount) amount" . " FROM " . TB_PREF . "bank_trans bt" . " INNER JOIN " . TB_PREF . "bank_accounts ba ON bt.bank_act = ba.id" . " WHERE bank_act = " . $this->bank_act . " AND trans_date < now() - INTERVAL " . $this->days_past . " DAY" . " GROUP BY bank_act, bank_account_name" . " UNION ALL" . " SELECT bank_act, bank_account_name, trans_date, SUM(amount) amount" . " FROM 0_bank_trans bt" . " INNER JOIN " . TB_PREF . "bank_accounts ba ON bt.bank_act = ba.id" . " WHERE bank_act = " . $this->bank_act . " AND trans_date < now() + INTERVAL " . $this->days_future . " DAY" . " AND trans_date > now() - INTERVAL " . $this->days_past . " DAY" . " GROUP BY bank_act, trans_date, bank_account_name" . " ) trans" . " ORDER BY bank_account_name, trans_date";
$result = db_query($sql);
$rows = array();
//flag is not needed
$flag = true;
$table = array();
$table['cols'] = array(array('label' => 'Date', 'type' => 'string'), array('label' => 'Balance', 'type' => 'number'));
$rows = array();
$total = 0;
$last_day = 0;
$date = add_days(Today(), -$this->days_past);
$balance_date = $date;
while ($r = db_fetch_assoc($result)) {
if ($r['trans_date'] == null) {
$total = $r['amount'];
} else {
$balance_date = sql2date($r['trans_date']);
while (date1_greater_date2($balance_date, $date)) {
$temp = array();
$temp[] = array('v' => (string) $date, 'f' => $date);
$temp[] = array('v' => (double) $total, 'f' => number_format2($total, user_price_dec()));
$rows[] = array('c' => $temp);
$date = add_days($date, 1);
}
$total += $r['amount'];
$temp = array();
$temp[] = array('v' => (string) $balance_date, 'f' => $balance_date);
$temp[] = array('v' => (double) $total, 'f' => number_format2($total, user_price_dec()));
$rows[] = array('c' => $temp);
$date = $balance_date;
}
}
$end_date = add_days(Today(), $this->days_future);
while (date1_greater_date2($end_date, $date)) {
$temp = array();
$temp[] = array('v' => (string) $date, 'f' => $date);
$temp[] = array('v' => (double) $total, 'f' => number_format2($total, user_price_dec()));
$rows[] = array('c' => $temp);
$last_day++;
$date = add_days($date, 1);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
$js = "google.load('visualization', '1', {'packages':['corechart','table']});\ngoogle.setOnLoadCallback(drawChart" . $id . ");\nfunction drawChart" . $id . "() {\n var data = new google.visualization.DataTable(" . $jsonTable . ");\n var options = {";
if ($this->graph_type != 'Table') {
$js .= "height: 300, ";
}
$js .= "title: '" . $title . "'\n };\n var chart" . $id . " = new google.visualization." . $this->graph_type . "(document.getElementById('widget_div_" . $id . "'));\n chart" . $id . ".draw(data, options);\n}";
add_js_source($js);
}
示例11: show_results
function show_results()
{
global $path_to_root, $systypes_array;
if (!isset($_POST["account"])) {
$_POST["account"] = null;
}
$act_name = $_POST["account"] ? get_gl_account_name($_POST["account"]) : "";
$dim = get_company_pref('use_dimension');
/*Now get the transactions */
if (!isset($_POST['Dimension'])) {
$_POST['Dimension'] = 0;
}
if (!isset($_POST['Dimension2'])) {
$_POST['Dimension2'] = 0;
}
$result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1, $_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], null, input_num('amount_min'), input_num('amount_max'));
$colspan = $dim == 2 ? "6" : ($dim == 1 ? "5" : "4");
if ($_POST["account"] != null) {
display_heading($_POST["account"] . " " . $act_name);
}
// Only show balances if an account is specified AND we're not filtering by amounts
$show_balances = $_POST["account"] != null && input_num("amount_min") == 0 && input_num("amount_max") == 0;
start_table(TABLESTYLE);
$first_cols = array(_("Type"), _("#"), _("Date"));
if ($_POST["account"] == null) {
$account_col = array(_("Account"));
} else {
$account_col = array();
}
if ($dim == 2) {
$dim_cols = array(_("Dimension") . " 1", _("Dimension") . " 2");
} else {
if ($dim == 1) {
$dim_cols = array(_("Dimension"));
} else {
$dim_cols = array();
}
}
if ($show_balances) {
$remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo"));
} else {
$remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo"));
}
$th = array_merge($first_cols, $account_col, $dim_cols, $remaining_cols);
table_header($th);
if ($_POST["account"] != null && is_account_balancesheet($_POST["account"])) {
$begin = "";
} else {
$begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
if (date1_greater_date2($begin, $_POST['TransFromDate'])) {
$begin = $_POST['TransFromDate'];
}
$begin = add_days($begin, -1);
}
$bfw = 0;
if ($show_balances) {
$bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']);
start_row("class='inquirybg'");
label_cell("<b>" . _("Opening Balance") . " - " . $_POST['TransFromDate'] . "</b>", "colspan={$colspan}");
display_debit_or_credit_cells($bfw, true);
label_cell("");
label_cell("");
end_row();
}
$running_total = $bfw;
$j = 1;
$k = 0;
//row colour counter
while ($myrow = db_fetch($result)) {
alt_table_row_color($k);
$running_total += $myrow["amount"];
$trandate = sql2date($myrow["tran_date"]);
label_cell($systypes_array[$myrow["type"]]);
label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true));
label_cell($trandate);
if ($_POST["account"] == null) {
label_cell($myrow["account"] . ' ' . get_gl_account_name($myrow["account"]));
}
if ($dim >= 1) {
label_cell(get_dimension_string($myrow['dimension_id'], true));
}
if ($dim > 1) {
label_cell(get_dimension_string($myrow['dimension2_id'], true));
}
label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"]));
display_debit_or_credit_cells($myrow["amount"]);
if ($show_balances) {
amount_cell($running_total);
}
if ($myrow['memo_'] == "") {
$myrow['memo_'] = get_comments_string($myrow['type'], $myrow['type_no']);
}
label_cell($myrow['memo_']);
end_row();
$j++;
if ($j == 12) {
$j = 1;
table_header($th);
}
}
//.........这里部分代码省略.........
示例12: print_GL_transactions
function print_GL_transactions()
{
global $path_to_root;
include_once $path_to_root . "reporting/includes/pdf_report.inc";
$rep = new FrontReport(tr('GL Account Transactions'), "GLAccountTransactions.pdf", user_pagesize());
$dim = get_company_pref('use_dimension');
$dimension = $dimension2 = 0;
$from = $_REQUEST['PARAM_0'];
$to = $_REQUEST['PARAM_1'];
$fromacc = $_REQUEST['PARAM_2'];
$toacc = $_REQUEST['PARAM_3'];
if ($dim == 2) {
$dimension = $_REQUEST['PARAM_4'];
$dimension2 = $_REQUEST['PARAM_5'];
$comments = $_REQUEST['PARAM_6'];
} else {
if ($dim == 1) {
$dimension = $_REQUEST['PARAM_4'];
$comments = $_REQUEST['PARAM_5'];
} else {
$comments = $_REQUEST['PARAM_4'];
}
}
$dec = user_price_dec();
$cols = array(0, 70, 90, 140, 210, 280, 340, 400, 450, 510, 570);
//------------0--1---2---3----4----5----6----7----8----9----10-------
//-----------------------dim1-dim2-----------------------------------
//-----------------------dim1----------------------------------------
//-------------------------------------------------------------------
$aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right');
if ($dim == 2) {
$headers = array(tr('Type'), tr('#'), tr('Date'), tr('Dimension') . " 1", tr('Dimension') . " 2", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance'));
} else {
if ($dim == 1) {
$headers = array(tr('Type'), tr('#'), tr('Date'), tr('Dimension'), "", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance'));
} else {
$headers = array(tr('Type'), tr('#'), tr('Date'), "", "", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance'));
}
}
if ($dim == 2) {
$params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''));
} else {
if ($dim == 1) {
$params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
} else {
$params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc));
}
}
$rep->Font();
$rep->Info($params, $cols, $headers, $aligns);
$rep->Header();
$accounts = get_gl_accounts($fromacc, $toacc);
while ($account = db_fetch($accounts)) {
if (is_account_balancesheet($account["account_code"])) {
$begin = "";
} else {
if ($from < $begin) {
$begin = add_days($from, -1);
} else {
$begin = add_days(begin_fiscalyear(), -1);
}
}
$prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
$trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2);
$rows = db_num_rows($trans);
if ($prev_balance == 0.0 && $rows == 0) {
continue;
}
$rep->Font('bold');
$rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']);
$rep->TextCol(3, 5, tr('Opening Balance'));
if ($prev_balance > 0.0) {
$rep->TextCol(6, 7, number_format2(abs($prev_balance), $dec));
} else {
$rep->TextCol(7, 8, number_format2(abs($prev_balance), $dec));
}
$rep->Font();
$total = $prev_balance;
$rep->NewLine(2);
if ($rows > 0) {
while ($myrow = db_fetch($trans)) {
$total += $myrow['amount'];
$rep->TextCol(0, 1, systypes::name($myrow["type"]));
$rep->TextCol(1, 2, $myrow['type_no']);
$rep->TextCol(2, 3, sql2date($myrow["tran_date"]));
if ($dim >= 1) {
$rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id']));
}
if ($dim > 1) {
$rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id']));
}
$rep->TextCol(5, 6, payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"], false));
if ($myrow['amount'] > 0.0) {
$rep->TextCol(6, 7, number_format2(abs($myrow['amount']), $dec));
} else {
$rep->TextCol(7, 8, number_format2(abs($myrow['amount']), $dec));
}
$rep->TextCol(8, 9, number_format2($total, $dec));
$rep->NewLine();
if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
//.........这里部分代码省略.........
示例13: stripslashes
$post = stripslashes($_POST["data"]);
$id = json_decode($post);
$page_security = 'SA_DASHBOARDREMINDERS';
$path_to_root = "../..";
include_once $path_to_root . "/includes/session.inc";
include_once $path_to_root . "/modules/dashboard/includes/dashboard_db.inc";
add_access_extensions();
$myrow = get_dashboard_reminder($id);
$role_id = $myrow["role_id"];
$next_date = sql2date($myrow["next_date"]);
$description = $myrow["description"];
$frequency = $myrow["frequency"];
$param = $myrow["param"];
$data = json_decode(html_entity_decode($param));
$occurrence = intval(coalesce($data, 'occurence', '1'));
switch ($frequency) {
case 'daily':
$next_date = add_days($next_date, 1);
break;
case 'weekly':
$next_date = add_days($next_date, 7 * $occurrence);
break;
case 'monthly':
$next_date = add_months($next_date, $occurrence);
break;
case 'yearly':
$next_date = add_months($next_date, 12);
break;
}
update_dashboard_reminder($id, $role_id, $next_date, $description, $frequency, $param);
echo "success";
示例14: display_trial_balance
function display_trial_balance($type, $typename)
{
global $path_to_root;
global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;
$printtitle = 0;
//Flag for printing type name
$k = 0;
//$accounts = get_gl_accounts();
//Get Accounts directly under this group/type
$accounts = get_gl_accounts(null, null, $type);
$begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
//$begin = begin_fiscalyear();
if (date1_greater_date2($begin, $_POST['TransFromDate'])) {
$begin = $_POST['TransFromDate'];
}
$begin = add_days($begin, -1);
while ($account = db_fetch($accounts)) {
//Print Type Title if it has atleast one non-zero account
if ($type == 3502) {
continue;
}
if (!$printtitle) {
start_row("class='inquirybg' style='font-weight:bold'");
label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8");
end_row();
$printtitle = 1;
}
$prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false);
$curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true);
$tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true);
if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) {
continue;
}
alt_table_row_color($k);
$url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "&Dimension=" . $_POST["Dimension"] . "&Dimension2=" . $_POST["Dimension2"] . "'>" . $account["account_code"] . "</a>";
label_cell($url);
label_cell($account["account_name"]);
if (check_value('Balance')) {
display_debit_or_credit_cells($prev['balance']);
display_debit_or_credit_cells($curr['balance']);
display_debit_or_credit_cells($tot['balance']);
} else {
amount_cell($prev['debit']);
amount_cell($prev['credit']);
amount_cell($curr['debit']);
amount_cell($curr['credit']);
amount_cell($tot['debit']);
amount_cell($tot['credit']);
$pdeb += $prev['debit'];
$pcre += $prev['credit'];
$cdeb += $curr['debit'];
$ccre += $curr['credit'];
$tdeb += $tot['debit'];
$tcre += $tot['credit'];
}
$pbal += $prev['balance'];
$cbal += $curr['balance'];
$tbal += $tot['balance'];
end_row();
}
//Get Account groups/types under this group/type
$result = get_account_types(false, false, $type);
while ($accounttype = db_fetch($result)) {
//Print Type Title if has sub types and not previously printed
if (!$printtitle) {
start_row("class='inquirybg' style='font-weight:bold'");
label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8");
end_row();
$printtitle = 1;
}
display_trial_balance($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')');
}
}
示例15: display_trial_balance
function display_trial_balance($type, $typename)
{
global $path_to_root, $clear_trial_balance_opening;
global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal;
$printtitle = 0;
//Flag for printing type name
$k = 0;
//$accounts = get_gl_accounts();
//Get Accounts directly under this group/type
$accounts = get_gl_accounts(null, null, $type);
$begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
//$begin = begin_fiscalyear();
if (date1_greater_date2($begin, $_POST['TransFromDate'])) {
$begin = $_POST['TransFromDate'];
}
$begin = add_days($begin, -1);
while ($account = db_fetch($accounts)) {
//Print Type Title if it has atleast one non-zero account
if (!$printtitle) {
start_row("class='inquirybg' style='font-weight:bold'");
label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8");
end_row();
$printtitle = 1;
}
// FA doesn't really clear the closed year, therefore the brought forward balance includes all the transactions from the past, even though the balance is null.
// If we want to remove the balanced part for the past years, this option removes the common part from from the prev and tot figures.
if (@$clear_trial_balance_opening) {
$open = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $begin, false, true);
$offset = min($open['debit'], $open['credit']);
} else {
$offset = 0;
}
$prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false);
$curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true);
$tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true);
if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) {
continue;
}
alt_table_row_color($k);
$url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "&Dimension=" . $_POST["Dimension"] . "&Dimension2=" . $_POST["Dimension2"] . "'>" . $account["account_code"] . "</a>";
label_cell($url);
label_cell($account["account_name"]);
if (check_value('Balance')) {
display_debit_or_credit_cells($prev['balance']);
display_debit_or_credit_cells($curr['balance']);
display_debit_or_credit_cells($tot['balance']);
} else {
amount_cell($prev['debit'] - $offset);
amount_cell($prev['credit'] - $offset);
amount_cell($curr['debit']);
amount_cell($curr['credit']);
amount_cell($tot['debit'] - $offset);
amount_cell($tot['credit'] - $offset);
$pdeb += $prev['debit'];
$pcre += $prev['credit'];
$cdeb += $curr['debit'];
$ccre += $curr['credit'];
$tdeb += $tot['debit'];
$tcre += $tot['credit'];
}
$pbal += $prev['balance'];
$cbal += $curr['balance'];
$tbal += $tot['balance'];
end_row();
}
//Get Account groups/types under this group/type
$result = get_account_types(false, false, $type);
while ($accounttype = db_fetch($result)) {
//Print Type Title if has sub types and not previously printed
if (!$printtitle) {
start_row("class='inquirybg' style='font-weight:bold'");
label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8");
end_row();
$printtitle = 1;
}
display_trial_balance($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')');
}
}