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); }
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; }
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); }
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); }
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); } }
$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) {
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); } }
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(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(7, 8, abs($total), $dec); } else { $rep->AmountCol(8, 9, abs($total), $dec); } $rep->Font(); } $rep->End(); }
$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"); }
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); }
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); } } //end of while loop if ($show_balances) { start_row("class='inquirybg'"); label_cell("<b>" . _("Ending Balance") . " - " . $_POST['TransToDate'] . "</b>", "colspan={$colspan}"); display_debit_or_credit_cells($running_total, true); label_cell(""); label_cell(""); end_row(); } end_table(2); if (db_num_rows($result) == 0) { display_note(_("No general ledger transactions have been created for the specified criteria."), 0, 1); } }
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) { $rep->Line($rep->row - 2); $rep->Header(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(3, 5, tr("Ending Balance")); if ($total > 0.0) { $rep->TextCol(6, 7, number_format2(abs($total), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($total), $dec)); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
$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";
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 . ')'); } }
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 . ')'); } }
function display_type($type, $typename, &$dec, &$rep, $from, $to, $zero, $balances, $dimension, $dimension2) { global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $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(); } $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'], $dec); $rep->AmountCol(3, 4, $prev['credit'], $dec); $rep->AmountCol(4, 5, $curr['debit'], $dec); $rep->AmountCol(5, 6, $curr['credit'], $dec); $rep->AmountCol(6, 7, $tot['debit'], $dec); $rep->AmountCol(7, 8, $tot['credit'], $dec); $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']; $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); } }
function print_trial_balance() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_REQUEST['PARAM_0']; $to = $_REQUEST['PARAM_1']; $zero = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } else { $comments = $_REQUEST['PARAM_3']; } } $dec = user_price_dec(); $cols2 = array(0, 50, 230, 330, 430, 530); //-------------0--1---2----3----4----5-- $headers2 = array('', '', tr('Brought Forward'), tr('This Period'), tr('Balance')); $aligns2 = array('left', 'left', 'left', 'left', 'left'); $cols = array(0, 50, 200, 250, 300, 350, 400, 450, 500, 550); //------------0--1---2----3----4----5----6----7----8----9-- $headers = array(tr('Account'), tr('Account Name'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => 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('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(tr('Trial Balance'), "TrialBalance.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->Header(); $accounts = get_gl_accounts(); 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); $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($zero == 0 && !$prev_balance && !$curr_balance) { continue; } $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); if ($prev_balance > 0.0) { $rep->TextCol(2, 3, number_format2(abs($prev_balance), $dec)); } else { $rep->TextCol(3, 4, number_format2(abs($prev_balance), $dec)); } if ($curr_balance > 0.0) { $rep->TextCol(4, 5, number_format2(abs($curr_balance), $dec)); } else { $rep->TextCol(5, 6, number_format2(abs($curr_balance), $dec)); } if ($curr_balance + $prev_balance > 0.0) { $rep->TextCol(6, 7, number_format2(abs($curr_balance + $prev_balance), $dec)); } else { $rep->TextCol(7, 8, number_format2(abs($curr_balance + $prev_balance), $dec)); } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } $rep->Line($rep->row); $rep->End(); }
function print_GL_transactions() { 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']; $toacc = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize(), 9, $orientation); $dec = 2; //$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', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension') . " 1", _('Dimension') . " 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } elseif ($dim == 1) { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } else { $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc)); } } if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $accounts = get_gl_accounts($fromacc, $toacc); 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) { while ($myrow = db_fetch($trans)) { $total += $myrow['amount']; $type_name = $systypes_array[$myrow["type"]]; if ($type_name == "Customer Payment") { $rep->TextCol(0, 1, "CRB", -2); } if ($type_name == "Cash Disbursement/Check Voucher") { $rep->TextCol(0, 1, "CDB", -2); } if ($type_name == "Journal Entry") { $rep->TextCol(0, 1, "JB", -2); } if ($type_name == "Customer Credit Note") { $type_name = "Credit Memo"; } if ($type_name == "Sales Invoice") { $type_name = "Invoice"; } else { if ($type_name != "Customer Payment" && $type_name != "Cash Disbursement/Check Voucher" && $type_name != "Journal Entry") { $rep->TextCol(0, 1, $type_name, -2); } } $reference = get_reference($myrow["type"], $myrow["type_no"]); $rep->TextCol(1, 2, $reference); $rep->TextCol(2, 3, $myrow['type_no'], -2); $rep->DateCol(3, 4, $myrow["tran_date"], true); if ($dim >= 1) { $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id'])); } if ($dim > 1) { $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id'])); } $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false); $memo = $myrow['memo_']; if ($txt != "") { if ($memo != "") { $txt = $txt . "/" . $memo; } } else { $txt = $memo; } $rep->TextCol(6, 7, $txt, -2); if ($myrow['amount'] > 0.0) { $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); } else { $rep->AmountCol(8, 9, abs($myrow['amount']), $dec); } $rep->TextCol(9, 10, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->NewPage(); } } $rep->NewLine(); } $rep->Font('bold'); $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) { $rep->AmountCol(7, 8, abs($total), $dec); } else { $rep->AmountCol(8, 9, abs($total), $dec); } $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); } $rep->End(); }
function process_form() { global $vars, $phpcdb, $phpc_cal, $phpcid, $phpc_script, $phpc_user; // When modifying events, this is the value of the checkbox that // determines if the date should change $modify_occur = !isset($vars['eid']) || !empty($vars['phpc-modify']); if ($modify_occur) { $start_ts = get_timestamp("start"); $end_ts = get_timestamp("end"); switch ($vars["time-type"]) { case 'normal': $time_type = 0; break; case 'full': $time_type = 1; break; case 'tba': $time_type = 2; break; default: soft_error(__("Unrecognized Time Type.")); } $duration = $end_ts - $start_ts; if ($duration < 0) { message(__("An event cannot have an end earlier than its start.")); return display_form(); } } verify_token(); if (0) { permission_error(__('You do not have permission to write to this calendar.')); } if ($phpc_cal->can_create_readonly() && !empty($vars['readonly'])) { $readonly = true; } else { $readonly = false; } $catid = empty($vars['catid']) ? false : $vars['catid']; if (!isset($vars['eid'])) { $modify = false; $eid = $phpcdb->create_event($phpcid, $phpc_user->get_uid(), $vars["subject"], $vars["description"], $readonly, $catid); } else { $modify = true; $eid = $vars['eid']; $phpcdb->modify_event($eid, $vars['subject'], $vars['description'], $readonly, $catid); if ($modify_occur) { $phpcdb->delete_occurrences($eid); } } if ($modify_occur) { $oid = $phpcdb->create_occurrence($eid, $time_type, $start_ts, $end_ts); $occurrences = 1; switch ($vars["repeats"]) { case "never": break; case 'daily': if (!isset($vars["every-day"])) { soft_error(__("Required field \"every-day\" is not set.")); } $ndays = $vars["every-day"]; if ($ndays < 1) { soft_error(__("every-day must be greater than 1")); } $daily_until = get_timestamp("daily-until"); while ($occurrences <= 730) { $start_ts = add_days($start_ts, $ndays); $end_ts = add_days($end_ts, $ndays); if (days_between($start_ts, $daily_until) < 0) { break; } $phpcdb->create_occurrence($eid, $time_type, $start_ts, $end_ts); $occurrences++; } break; case 'weekly': if (!isset($vars["every-week"])) { soft_error(__("Required field \"every-week\" is not set.")); } if ($vars["every-week"] < 1) { soft_error(__("every-week must be greater than 1")); } $ndays = $vars["every-week"] * 7; $weekly_until = get_timestamp("weekly-until"); while ($occurrences <= 730) { $start_ts = add_days($start_ts, $ndays); $end_ts = add_days($end_ts, $ndays); if (days_between($start_ts, $weekly_until) < 0) { break; } $phpcdb->create_occurrence($eid, $time_type, $start_ts, $end_ts); $occurrences++; } break; case 'monthly': if (!isset($vars["every-month"])) { soft_error(__("Required field \"every-month\" is not set.")); } if ($vars["every-month"] < 1) { soft_error(__("every-month must be greater than 1")); } $nmonths = $vars["every-month"]; $monthly_until = get_timestamp("monthly-until"); while ($occurrences <= 730) { $start_ts = add_months($start_ts, $nmonths); $end_ts = add_months($end_ts, $nmonths); if (days_between($start_ts, $monthly_until) < 0) { break; } $phpcdb->create_occurrence($eid, $time_type, $start_ts, $end_ts); $occurrences++; } break; case 'yearly': if (!isset($vars["every-year"])) { soft_error(__("Required field \"every-year\" is not set.")); } if ($vars["every-year"] < 1) { soft_error(__("every-month must be greater than 1")); } $nyears = $vars["every-year"]; $yearly_until = get_timestamp("yearly-until"); while ($occurrences <= 730) { $start_ts = add_years($start_ts, $nyears); $end_ts = add_years($end_ts, $nyears); if (days_between($start_ts, $yearly_until) < 0) { break; } $phpcdb->create_occurrence($eid, $time_type, $start_ts, $end_ts); $occurrences++; } break; default: soft_error(__("Invalid event type.")); } } if ($eid != 0) { if ($modify) { $message = __("Modified event: "); } else { $message = __("Created event: "); } /* before return message_redirect(tag($eid, $message, create_event_link('', 'display_event', $eid)), */ return message_redirect(tag('', $message, create_event_link('', 'display_event', '')), "{$phpc_script}?action=display_event&phpcid={$phpcid}&oid={$oid}"); /* <-- before last paremeter was &eid=$eid instead of &oid=$oid */ } else { return message_redirect(__('Error submitting event.'), "{$phpc_script}?action=display_month&phpcid={$phpcid}"); } }
label_row(_(" Gross Earning"), $gross, 'style="color:#A86A0B; background-color:#F2F6D5;"', 'style="color:#A86A0B; background-color:#F2F6D5;"'); table_section(2); table_section_title(_("Deduction")); label_row(_(" Provident Fund:"), $pf, null, 30, 30); label_row(_(" LOP Amount:"), $lop_amount, null, 30, 30); label_row(_(" Monthly Amount:"), $staff_loan, null, 30, 30); label_row(_(" Other Deduction:"), $tds, null, 30, 30); label_row(_(" Total Deductions"), $total_ded, 'style="color:#f55; background-color:#fed;"', 'style="color:#f55; background-color:#fed;"'); label_row(_(" "), '', null, 30, 30); label_row(_(" Net Salary Payable:"), $total_net, 'style="color:#107B0F; background-color:#B7DBC1;"', 'style="color:#107B0F; background-color:#B7DBC1;"'); end_outer_table(1); if (!db_has_employee_payslip($_POST['year'], $_POST['month'], $_POST['empl_id'])) { start_table(TABLESTYLE2); echo '<tr>'; $from = Today(); $from = add_days($from, 1); $bal = get_balance_before_for_bank_account(1, $from); //echo $trans_no = kv_get_next_trans_no(99) + 1; if ($total_net <= $bal) { submit_cells('pay_salary', _("Process Payout"), '', _('Show Results'), 'default'); } else { display_warning(" Your Current Account Balance is lower than the payout!."); } echo '</tr>'; end_table(); } else { display_warning(" Paid Already!."); } div_end(); } end_form();
} else { $dim_cols = array(); } $remaining_cols = array(_("Debit"), _("Credit"), _("Memo")); $th = array_merge($first_cols, $dim_cols, $remaining_cols); table_header($th); $k = 0; } for ($i = 0; $i < $periods; $i++) { if ($i > 0) { switch ($freq) { case 1: $date = add_days($date_, $i * 7); break; case 2: $date = add_days($date_, $i * 14); break; case 3: $date = add_months($date_, $i * 1); break; case 4: $date = add_months($date_, $i * 3); break; } $am0 = $am; } if (isset($_POST['go'])) { $id = get_next_trans_no(ST_JOURNAL); $ref = $Refs->get_next(ST_JOURNAL); add_gl_trans(ST_JOURNAL, $id, $date, get_post('acc_act'), 0, 0, $ref, $am0 * -1); add_gl_trans(ST_JOURNAL, $id, $date, get_post('res_act'), get_post('dimension_id'), get_post('dimension2_id'), $ref, $am0);
function bank_balance_row($bank_acc, $parms = '') { global $path_to_root; $to = add_days(Today(), 1); $bal = get_balance_before_for_bank_account($bank_acc, $to); $this->label_row(_("Bank Balance:"), "<a target='_blank' " . ($bal < 0 ? 'class="redfg"' : '') . "href='{$path_to_root}/gl/inquiry/bank_inquiry.php?bank_account=" . $bank_acc . "'" . " onclick=\"javascript:openWindow(this.href,this.target); return false;\" > " . price_format($bal) . "</a>", $parms); }
function inventory_movements() { global $path_to_root; $from_date = $_POST['PARAM_0']; $to_date = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($location == '') { $loc = _('All'); } else { $loc = get_location_name($location); } $cols = array(0, 60, 130, 160, 185, 215, 250, 275, 305, 340, 365, 395, 430, 455, 485, 520); $headers = array(_('Category'), _('Description'), _('UOM'), '', '', _('OpeningStock'), '', '', _('StockIn'), '', '', _('Delivery'), '', '', _('ClosingStock')); $headers2 = array("", "", "", _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value")); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from_date, 'to' => $to_date), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(_('Costed Inventory Movements'), "CostedInventoryMovements", user_pagesize(), 8, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $totval_open = $totval_in = $totval_out = $totval_close = 0; $result = fetch_items($category); $dec = user_price_dec(); $catgor = ''; while ($myrow = db_fetch($result)) { if ($catgor != $myrow['description']) { $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']); $catgor = $myrow['description']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $rep->TextCol(2, 3, $myrow['units']); $qoh_start = get_qoh_on_date($myrow['stock_id'], $location, add_days($from_date, -1)); $qoh_end = get_qoh_on_date($myrow['stock_id'], $location, $to_date); $inward = trans_qty($myrow['stock_id'], $location, $from_date, $to_date); $outward = trans_qty($myrow['stock_id'], $location, $from_date, $to_date, false); $openCost = avg_unit_cost($myrow['stock_id'], $location, $from_date); $unitCost = avg_unit_cost($myrow['stock_id'], $location, add_days($to_date, 1)); $rep->AmountCol(3, 4, $qoh_start, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(4, 5, $openCost, $dec); $openCost *= $qoh_start; $totval_open += $openCost; $rep->AmountCol(5, 6, $openCost); if ($inward > 0) { $rep->AmountCol(6, 7, $inward, get_qty_dec($myrow['stock_id'])); $unitCost_in = trans_qty_unit_cost($myrow['stock_id'], $location, $from_date, $to_date); $rep->AmountCol(7, 8, $unitCost_in, $dec); $unitCost_in *= $inward; $totval_in += $unitCost_in; $rep->AmountCol(8, 9, $unitCost_in); } if ($outward > 0) { $rep->AmountCol(9, 10, $outward, get_qty_dec($myrow['stock_id'])); $unitCost_out = trans_qty_unit_cost($myrow['stock_id'], $location, $from_date, $to_date, false); $rep->AmountCol(10, 11, $unitCost_out, $dec); $unitCost_out *= $outward; $totval_out += $unitCost_out; $rep->AmountCol(11, 12, $unitCost_out); } $rep->AmountCol(12, 13, $qoh_end, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(13, 14, $unitCost, $dec); $unitCost *= $qoh_end; $totval_close += $unitCost; $rep->AmountCol(14, 15, $unitCost); $rep->NewLine(0, 1); } $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 1, _("Total")); $rep->AmountCol(5, 6, $totval_open); $rep->AmountCol(8, 9, $totval_in); $rep->AmountCol(11, 12, $totval_out); $rep->AmountCol(14, 15, $totval_close); $rep->Line($rep->row - 4); $rep->End(); }
function get_opening_balance($where_clause, $date) { return get_turnover($where_clause, add_days($date, -1)); }
function inventory_movements() { global $path_to_root; $from_date = $_POST['PARAM_0']; $to_date = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } // if ($location == ALL_TEXT) // $location = ''; if ($location == '') { $loc = _('All'); } else { $loc = get_location_name($location); } //$cols = array(0, 100, 300, 365, 440, 540, 640, 715); $cols = array(0, 60, 220, 240, 310, 380, 450, 520); $headers = array(_('Category'), _('Description'), _('UOM'), _('Opening'), _('Quantity In'), _('Quantity Out'), _('Balance')); $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from_date, 'to' => $to_date), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => '')); $rep = new FrontReport(_('Inventory Movements'), "InventoryMovements", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $result = fetch_items($category); $catgor = ''; while ($myrow = db_fetch($result)) { if ($catgor != $myrow['description']) { $rep->Line($rep->row - $rep->lineHeight); $rep->NewLine(2); $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']); $catgor = $myrow['description']; $rep->fontSize -= 2; $rep->NewLine(); } $rep->NewLine(); $rep->TextCol(0, 1, $myrow['stock_id']); $rep->TextCol(1, 2, $myrow['name']); $rep->TextCol(2, 3, $myrow['units']); $qoh_start = $inward = $outward = $qoh_end = 0; $qoh_start += get_qoh_on_date($myrow['stock_id'], $location, add_days($from_date, -1)); $qoh_end += get_qoh_on_date($myrow['stock_id'], $location, $to_date); $inward += trans_qty($myrow['stock_id'], $location, $from_date, $to_date); $outward += trans_qty($myrow['stock_id'], $location, $from_date, $to_date, false); $rep->AmountCol(3, 4, $qoh_start, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(4, 5, $inward, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(5, 6, $outward, get_qty_dec($myrow['stock_id'])); $rep->AmountCol(6, 7, $qoh_end, get_qty_dec($myrow['stock_id'])); $rep->NewLine(0, 1); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function process_form() { global $vars, $phpcdb, $phpc_script, $phpc_user, $phpc_cal; // When modifying events, this is the value of the checkbox that // determines if the date should change $modify_occur = !isset($vars['eid']) || !empty($vars['phpc-modify']); if ($modify_occur) { $start_ts = get_timestamp("start"); $end_ts = get_timestamp("end"); switch ($vars["time-type"]) { case 'normal': $time_type = 0; break; case 'full': $time_type = 1; break; case 'tba': $time_type = 2; break; default: soft_error(__("Unrecognized Time Type.")); } $duration = $end_ts - $start_ts; if ($duration < 0) { throw new Exception(__("An event cannot have an end earlier than its start.")); } } verify_token(); if (!isset($vars['cid'])) { throw new Exception(__("Calendar ID is not set.")); } $cid = $vars['cid']; $calendar = $phpcdb->get_calendar($cid); if (!$calendar->can_write()) { permission_error(__('You do not have permission to write to this calendar.')); } if ($calendar->can_create_readonly() && !empty($vars['readonly'])) { $readonly = true; } else { $readonly = false; } $catid = empty($vars['catid']) ? false : $vars['catid']; if (!isset($vars['eid'])) { $modify = false; $eid = $phpcdb->create_event($cid, $phpc_user->get_uid(), $vars["subject"], $vars["description"], $readonly, $catid); } else { $modify = true; $eid = $vars['eid']; $phpcdb->modify_event($eid, $vars['subject'], $vars['description'], $readonly, $catid); if ($modify_occur) { $phpcdb->delete_occurrences($eid); } } foreach ($phpc_cal->get_fields() as $field) { $fid = $field['fid']; if (empty($vars["phpc-field-{$fid}"])) { if ($field['required']) { throw new Exception(sprintf(__('Field "%s" is required but was not set.'), $field['name'])); } continue; } $phpcdb->add_event_field($eid, $fid, $vars["phpc-field-{$fid}"]); } if ($modify_occur) { $occurrences = 0; $n = 1; $until = $start_ts; switch ($vars['repeats']) { case 'daily': check_input("every-day"); $n = $vars["every-day"]; $until = get_timestamp("daily-until"); break; case 'weekly': check_input("every-week"); $n = $vars["every-week"] * 7; $until = get_timestamp("weekly-until"); break; case 'monthly': check_input("every-month"); $n = $vars["every-month"]; $until = get_timestamp("monthly-until"); break; case 'yearly': check_input("every-year"); $n = $vars["every-year"]; $until = get_timestamp("yearly-until"); break; } if ($n < 1) { soft_error(__('Increment must be 1 or greater.')); } while ($occurrences <= 730 && days_between($start_ts, $until) >= 0) { $oid = $phpcdb->create_occurrence($eid, $time_type, $start_ts, $end_ts); $occurrences++; switch ($vars["repeats"]) { case 'daily': case 'weekly': $start_ts = add_days($start_ts, $n); $end_ts = add_days($end_ts, $n); break; case 'monthly': $start_ts = add_months($start_ts, $n); $end_ts = add_months($end_ts, $n); break; case 'yearly': $start_ts = add_years($start_ts, $n); $end_ts = add_years($end_ts, $n); break; default: break 2; } } } if ($eid != 0) { if ($modify) { $message = __("Modified event: "); } else { $message = __("Created event: "); } return message_redirect(tag('', $message, create_event_link($eid, 'display_event', $eid)), "{$phpc_script}?action=display_event&eid={$eid}"); } else { return message_redirect(__('Error submitting event.'), "{$phpc_script}?action=display_month&phpcid={$cid}"); } }