$_POST['amount' . $i] = number_format2(get_only_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']), 0); label_cell($date_); if (!isset($_POST['amount' . $i])) { $_POST['amount' . $i] = '0'; } amount_cells(null, 'amount' . $i, null, 15, null, 0); if ($showdims) { $d = get_budget_trans_from_to($date_, $date_, $_POST['account'], $_POST['dim1'], $_POST['dim2']); label_cell(number_format2($d, 0), "nowrap align=right"); $btotal += $d; } $lamount = get_gl_trans_from_to(add_years($date_, -1), add_years(end_month($date_), -1), $_POST['account'], $_POST['dim1'], $_POST['dim2']); $total += input_num('amount' . $i); $ltotal += $lamount; label_cell(number_format2($lamount, 0), "nowrap align=right"); $date_ = add_months($date_, 1); end_row(); } start_row(); label_cell("<b>" . tr("Total") . "</b>"); label_cell("<b>" . number_format2($total, 0) . "</b>", 'align=right'); if ($showdims) { label_cell("<b>" . number_format2($btotal, 0) . "</b>", "nowrap align=right"); } label_cell("<b>" . number_format2($ltotal, 0) . "</b>", "nowrap align=right"); end_row(); end_table(1); submit_center_first('add', tr("Save")); submit_center_last('delete', tr("Delete")); } end_form();
function print_annual_balance_breakdown_detail() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $title = _("Annual Balance Breakdown - Detailed"); $output_filename = "AnnualBalanceBreakDownDetail"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 12; // 12 amount columns for ($i = 2; $i < 15; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } /* $header_row[] = "Fiscal Year Begin"; $header_row[] = "Fiscal YTD"; for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i+2] - $cols[$i+1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } */ if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->NewLine(); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $oldFontSize = $rep->fontSize; $rep->fontSize = 12; $rep->Font('b'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->fontSize = $oldFontSize; $rep->SetCellPadding($oldcMargin); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 5; $rep->Line($rep->row - 3); $rep->NewLine(); $rep->Font('b'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $fill = 0; $rep->TextCol(0, 1, _('Total') . " " . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $ctotal[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Net Assets (Liabilities)'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $sales[$i] * -1, $dec, 0, 4, 0, $fill, NULL, 1, true); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $convert = get_class_type_convert($class["ctype"]); //Print Class Name $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->Font('b'); $rep->TextCol(0, 1, _("Total ") . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); $typeresult = get_account_types(false, $class['cid']); while ($accounttype = db_fetch($typeresult)) { $result = get_gl_accounts(null, null, $accounttype['id']); while ($account = db_fetch($result)) { $bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2); $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); for ($i = 1; $i <= 12; $i++) { $total[$i] += $balance[$i]; } } } for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $total[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $calc[$i] += $total[$i]; $total[$i] = 0; } $rep->NewLine(2); } $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Total Profit/Loss'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, -$calc[$i], $dec, 0, 4, 0, $fill, NULL, 1, true); // no convert } $rep->Font(); $rep->End(); }
start_table(TABLESTYLE_NOBORDER); start_row(); date_cells(_("Invoice date:"), 'date', ''); end_row(); end_table(); start_table(TABLESTYLE, "width=70%"); $th = array(_("Description"), _("Template No"), _("Customer"), _("Branch") . "/" . _("Group"), _("Days"), _("Monthly"), _("Begin"), _("End"), _("Last Created"), ""); table_header($th); $k = 0; $today = add_days($_POST['date'], 1); $due = false; while ($myrow = db_fetch($result)) { $begin = sql2date($myrow["begin"]); $end = sql2date($myrow["end"]); $last_sent = calculate_from($myrow); $due_date = add_months($last_sent, $myrow['monthly']); $due_date = add_days($due_date, $myrow['days']); $overdue = date1_greater_date2($today, $due_date) && date1_greater_date2($today, $begin) && date1_greater_date2($end, $today); if ($overdue) { start_row("class='overduebg'"); $due = true; } else { alt_table_row_color($k); } label_cell($myrow["description"]); label_cell(get_customer_trans_view_str(30, $myrow["order_no"])); if ($myrow["debtor_no"] == 0) { label_cell(""); label_cell(get_sales_group_name($myrow["group_no"])); } else { label_cell(get_customer_name($myrow["debtor_no"]));
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}"); } }
$js .= get_js_date_picker(); } page(_($help_context = "Tax Inquiry (Cash Basis)"), false, false, '', $js); //---------------------------------------------------------------------------------------------------- // Ajax updates // if (get_post('Show')) { $Ajax->activate('trans_tbl'); } if (get_post('TransFromDate') == "" && get_post('TransToDate') == "") { $date = Today(); $row = get_company_prefs(); $edate = add_months($date, -$row['tax_last']); $edate = end_month($edate); $bdate = begin_month($edate); $bdate = add_months($bdate, -$row['tax_prd'] + 1); $_POST["TransFromDate"] = $bdate; $_POST["TransToDate"] = $edate; } //---------------------------------------------------------------------------------------------------- function tax_inquiry_controls() { start_form(); start_table(TABLESTYLE_NOBORDER); start_row(); date_cells(_("from:"), 'TransFromDate', '', null, -30); date_cells(_("to:"), 'TransToDate'); check_cells(_("Net Output/Input:"), 'NetAmounts', null); submit_cells('Show', _("Show"), '', '', 'default'); end_row(); end_table();
function print_profit_and_loss_statement() { global $comp_path, $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']; $compare = $_REQUEST['PARAM_2']; if ($dim == 2) { $dimension = $_REQUEST['PARAM_3']; $dimension2 = $_REQUEST['PARAM_4']; $graphics = $_REQUEST['PARAM_5']; $comments = $_REQUEST['PARAM_6']; } else { if ($dim == 1) { $dimension = $_REQUEST['PARAM_3']; $graphics = $_REQUEST['PARAM_4']; $comments = $_REQUEST['PARAM_5']; } else { $graphics = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; } } if ($graphics) { include_once $path_to_root . "reporting/includes/class.graphic.inc"; $pg = new graph(); } $dec = 0; $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(tr('Account'), tr('Account Name'), tr('Period'), tr('Accumulated'), tr('Achieved %')); $aligns = array('left', 'left', '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)); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = tr('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = tr('Period Y-1'); } $rep = new FrontReport(tr('Profit and Loss Statement'), "ProfitAndLoss.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $totalper = 0.0; $totalacc = 0.0; $classper = 0.0; $classacc = 0.0; $salesper = 0.0; $salesacc = 0.0; $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($compare == 2) { $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } else { $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); } if (!$per_balance && !$acc_balance) { continue; } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $totalper = $totalacc = 0.0; $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->Font(); $salesper += $classper; $salesacc += $classacc; $classper = $classacc = 0.0; $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $per_balance *= -1; $acc_balance *= -1; $totalper += $per_balance; $totalacc += $acc_balance; $classper += $per_balance; $classacc += $acc_balance; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); $rep->TextCol(2, 3, number_format2($per_balance, $dec)); $rep->TextCol(3, 4, number_format2($acc_balance, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($per_balance, $acc_balance), $pdec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); $rep->TextCol(2, 3, number_format2($totalper, $dec)); $rep->TextCol(3, 4, number_format2($totalacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec)); if ($graphics) { $pg->x[] = $group; $pg->y[] = abs($totalper); $pg->z[] = abs($totalacc); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $calculateper = $salesper + $classper; $calculateacc = $salesacc + $classacc; $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); $rep->TextCol(2, 3, number_format2($classper, $dec)); $rep->TextCol(3, 4, number_format2($classacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec)); $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); $rep->TextCol(2, 3, number_format2($calculateper, $dec)); $rep->TextCol(3, 4, number_format2($calculateacc, $dec)); $rep->TextCol(4, 5, number_format2(Achieve($calculateper, $calculateacc), $pdec)); if ($graphics) { $pg->x[] = tr('Calculated Return'); $pg->y[] = abs($calculateper); $pg->z[] = abs($calculateacc); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = tr("Group"); $pg->axis_y = tr("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf"; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->Header(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $rep->End(); }
function display_profit_and_loss() { global $path_to_root, $sel; if (!isset($_POST['Dimension'])) { $_POST['Dimension'] = 0; } if (!isset($_POST['Dimension2'])) { $_POST['Dimension2'] = 0; } $dimension = $_POST['Dimension']; $dimension2 = $_POST['Dimension2']; $from = $_POST['TransFromDate']; $to = $_POST['TransToDate']; $compare = $_POST['Compare']; if (isset($_POST["AccGrp"]) && strlen($_POST['AccGrp']) > 0) { $drilldown = 1; } else { $drilldown = 0; } // Root level $dec = 0; $pdec = user_percent_dec(); if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); } div_start('pl_tbl'); start_table(TABLESTYLE, "width=50%"); $tableheader = "<tr>\n <td class='tableheader'>" . _("Group/Account Name") . "</td>\n <td class='tableheader'>" . _("Period") . "</td>\n\t\t<td class='tableheader'>" . $sel[$compare] . "</td>\n\t\t<td class='tableheader'>" . _("Achieved %") . "</td>\n </tr>"; if (!$drilldown) { $parent = -1; $classper = 0.0; $classacc = 0.0; $salesper = 0.0; $salesacc = 0.0; //Get classes for PL $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $class_per_total = 0; $class_acc_total = 0; $convert = get_class_type_convert($class["ctype"]); //Print Class Name table_section_title($class["class_name"], 4); echo $tableheader; //Get Account groups/types under this group/type $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $TypeTotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root); $class_per_total += $TypeTotal[0]; $class_acc_total += $TypeTotal[1]; if ($TypeTotal[0] != 0 || $TypeTotal[1] != 0) { $url = "<a href='{$path_to_root}/gl/inquiry/profit_loss.php?TransFromDate=" . $from . "&TransToDate=" . $to . "&Compare=" . $compare . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 . "&AccGrp=" . $accounttype['id'] . "'>" . $accounttype['id'] . " " . $accounttype['name'] . "</a>"; alt_table_row_color($k); label_cell($url); amount_cell($TypeTotal[0] * $convert); amount_cell($TypeTotal[1] * $convert); amount_cell(Achieve($TypeTotal[0], $TypeTotal[1])); end_row(); } } //Print Class Summary start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_('Total') . " " . $class["class_name"]); amount_cell($class_per_total * $convert); amount_cell($class_acc_total * $convert); amount_cell(Achieve($class_per_total, $class_acc_total)); end_row(); $salesper += $class_per_total; $salesacc += $class_acc_total; } start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_('Calculated Return')); amount_cell($salesper * -1); amount_cell($salesacc * -1); amount_cell(achieve($salesper, $salesacc)); end_row(); } else { //Level Pointer : Global variable defined in order to control display of root global $levelptr; $levelptr = 0; $accounttype = get_account_type($_POST["AccGrp"]); $classid = $accounttype["class_id"]; $class = get_account_class($classid); $convert = get_class_type_convert($class["ctype"]); //Print Class Name table_section_title($_POST["AccGrp"] . " " . get_account_type_name($_POST["AccGrp"]), 4); echo $tableheader; $classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root); } end_table(1); // outer table div_end(); }
function display_fiscalyear_edit($selected_id) { global $Mode; start_form(); start_table(TABLESTYLE2); if ($selected_id != -1) { if ($Mode == 'Edit') { $myrow = get_fiscalyear($selected_id); $_POST['from_date'] = sql2date($myrow["begin"]); $_POST['to_date'] = sql2date($myrow["end"]); $_POST['closed'] = $myrow["closed"]; } hidden('from_date'); hidden('to_date'); label_row(_("Fiscal Year Begin:"), $_POST['from_date']); label_row(_("Fiscal Year End:"), $_POST['to_date']); } else { $begin = next_begin_date(); if ($begin && $Mode != 'ADD_ITEM') { $_POST['from_date'] = $begin; $_POST['to_date'] = end_month(add_months($begin, 11)); } date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001); date_row(_("Fiscal Year End:"), 'to_date', '', null, 0, 0, 1001); } hidden('selected_id', $selected_id); yesno_list_row(_("Is Closed:"), 'closed', null, "", "", false); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); }
function display_fiscalyear_edit($selected_id) { global $Mode; start_form(); start_table(TABLESTYLE2); $company_year = get_company_pref('f_year'); $result = get_all_fiscalyears(); $row_cnt = db_num_rows($result); if ($selected_id != -1) { if ($Mode == 'Edit') { $myrow = get_fiscalyear($selected_id); $_POST['from_date'] = sql2date($myrow["begin"]); $_POST['to_date'] = sql2date($myrow["end"]); $_POST['closed'] = $myrow["closed"]; } if ($row_cnt == 1) { date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001); } else { hidden('from_date'); label_row(_("Fiscal Year Begin:"), $_POST['from_date']); } hidden('to_date'); label_row(_("Fiscal Year End:"), $_POST['to_date']); if ($myrow["id"] != $company_year) { yesno_list_row(_("Is Closed:"), 'closed', null, "", "", false); } else { hidden('closed'); label_row(_("Is Closed:"), yesno_value($_POST['closed'])); } } else { $begin = next_begin_date(); if ($begin && $Mode != 'ADD_ITEM') { $_POST['from_date'] = $begin; $_POST['to_date'] = end_month(add_months($begin, 11)); $_POST['closed'] = 0; } hidden('from_date'); hidden('to_date'); hidden('closed'); } hidden('selected_id', $selected_id); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); }
$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";
$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); add_audit_trail(ST_JOURNAL, $id, $date); add_comments(ST_JOURNAL, $id, $date, $memo); $Refs->save(ST_JOURNAL, $id, $ref); } else { alt_table_row_color($k); label_cell($date);
function print_cash_flow_statement() { global $path_to_root, $date_system, $comp_path; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $destination = $_POST['PARAM_3']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_1']; $destination = $_POST['PARAM_2']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } if ($comments) { $comments .= ". - "; } $comments .= _("Balances in Home Currency"); $title = _("Cash Flow Statement"); $output_filename = "CashFlowStatement"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 14; // 14 amount columns for ($i = 2; $i < 17; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } $header_row[] = _("Fiscal YTD"); $header_row[] = _("12 Mo. to Date"); for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i + 2] - $cols[$i + 1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $rep->row += 8; display_bank_trans($yr, $mo, $dec, $rep, $dimension, $dimension2, $enddate); $rep->Font(); $rep->End(); }
public function Save_repeat_transactions($checkAudits = true) { $repeat = $this->m_repeat_count; if ($this->m_trans_id > -1) { // Updating an existing record; do not repeat. $repeat = 1; } $error = ''; for ($i = 0; $i < $repeat; $i++) { $error = $this->Save_transaction($checkAudits); if ($error != '') { return $error; } if ($i + 1 < $repeat) { // There is at least another repetition; // Increment month by 1 (transaction & accounting dates) // and reset the transaction ID to force another INSERT $this->m_trans_id = -1; $error = add_months($this->m_trans_time, 1); $error = add_months($this->m_accounting_time, 1); if ($error != '') { return $error; } } } return $error; }
function date_cells($label, $name, $title = null, $check = null, $inc_days = 0, $inc_months = 0, $inc_years = 0, $params = null, $submit_on_change = false) { global $use_date_picker, $path_to_root, $Ajax; if (!isset($_POST[$name]) || $_POST[$name] == "") { if ($inc_years == 1001) { $_POST[$name] = null; } else { $dd = Today(); if ($inc_days != 0) { $dd = add_days($dd, $inc_days); } if ($inc_months != 0) { $dd = add_months($dd, $inc_months); } if ($inc_years != 0) { $dd = add_years($dd, $inc_years); } $_POST[$name] = $dd; } } if ($use_date_picker) { $calc_image = file_exists("{$path_to_root}/themes/" . user_theme() . "/images/cal.gif") ? "{$path_to_root}/themes/" . user_theme() . "/images/cal.gif" : "{$path_to_root}/themes/default/images/cal.gif"; $post_label = "<a tabindex='-1' href=\"javascript:date_picker(document.getElementsByName('{$name}')[0]);\">" . "\t<img src='{$calc_image}' width='15' height='15' border='0' alt='" . _('Click Here to Pick up the date') . "'></a>\n"; } else { $post_label = ""; } $class = $submit_on_change ? 'date active form-control' : 'date form-control'; $aspect = $check ? 'aspect="cdate"' : ''; if ($check && get_post($name) != Today()) { $aspect .= ' style="color:#FF0000"'; } default_focus($name); $size = user_date_format() > 3 ? 11 : 10; $controlAsString = "<div class=\"input-group\">" . "<input type=\"text\" name=\"{$name}\" class=\"{$class}\" {$aspect} size=\"{$size}\" maxlength=\"12\" value=\"" . $_POST[$name] . "\"" . ($title ? " title='{$title}'" : '') . " > " . "<span class=\"input-group-addon\">{$post_label}</span>" . "</div>"; View::get()->addControl(View::controlFromRenderedString(View::CONTROL_DATE, $label, $controlAsString)); // CONTROL_DATE? CP 2014-11 $Ajax->addUpdate($name, $name, $_POST[$name]); }
function print_profit_and_loss_statement() { global $path_to_root; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $compare = $_POST['PARAM_2']; if ($dim == 2) { $dimension = $_POST['PARAM_3']; $dimension2 = $_POST['PARAM_4']; $tags = isset($_POST['PARAM_5']) ? $_POST['PARAM_5'] : -1; $decimals = $_POST['PARAM_6']; $graphics = $_POST['PARAM_7']; $comments = $_POST['PARAM_8']; $orientation = $_POST['PARAM_9']; $destination = $_POST['PARAM_10']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_3']; $tags = isset($_POST['PARAM_4']) ? $_POST['PARAM_4'] : -1; $decimals = $_POST['PARAM_5']; $graphics = $_POST['PARAM_6']; $comments = $_POST['PARAM_7']; $orientation = $_POST['PARAM_8']; $destination = $_POST['PARAM_9']; } else { $tags = isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1; $decimals = $_POST['PARAM_4']; $graphics = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } } 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 ($graphics) { include_once $path_to_root . "/reporting/includes/class.graphic.inc"; $pg = new graph(); } if (!$decimals) { $dec = 0; } else { $dec = user_price_dec(); } $pdec = user_percent_dec(); $cols = array(0, 50, 200, 350, 425, 500); //------------0--1---2----3----4----5-- $headers = array(_('Account'), _('Account Name'), _('Period'), _('Accumulated'), _('Achieved %')); $aligns = array('left', 'left', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => '')); } } if ($compare == 0 || $compare == 2) { $end = $to; if ($compare == 2) { $begin = $from; $headers[3] = _('Budget'); } else { $begin = begin_fiscalyear(); } } elseif ($compare == 1) { $begin = add_months($from, -12); $end = add_months($to, -12); $headers[3] = _('Period Y-1'); } $rep = new FrontReport(_('Profit and Loss Statement'), "ProfitAndLoss", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $salesper = 0.0; $salesacc = 0.0; $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $class_per_total = 0; $class_acc_total = 0; $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->Font('bold'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $tags, $pg, $graphics); $class_per_total += $classtotal[0]; $class_acc_total += $classtotal[1]; } //Print Class Summary $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $class["class_name"]); $rep->AmountCol(2, 3, $class_per_total * $convert, $dec); $rep->AmountCol(3, 4, $class_acc_total * $convert, $dec); $rep->AmountCol(4, 5, Achieve($class_per_total, $class_acc_total), $pdec); $rep->Font(); $rep->NewLine(2); $salesper += $class_per_total; $salesacc += $class_acc_total; } $rep->Font('bold'); $rep->TextCol(0, 2, _('Calculated Return')); $rep->AmountCol(2, 3, $salesper * -1, $dec); // always convert $rep->AmountCol(3, 4, $salesacc * -1, $dec); $rep->AmountCol(4, 5, Achieve($salesper, $salesacc), $pdec); if ($graphics) { $pg->x[] = _('Calculated Return'); $pg->y[] = abs($salesper); $pg->z[] = abs($salesacc); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); if ($graphics) { global $decseps, $graph_skin; $pg->title = $rep->title; $pg->axis_x = _("Group"); $pg->axis_y = _("Amount"); $pg->graphic_1 = $headers[2]; $pg->graphic_2 = $headers[3]; $pg->type = $graphics; $pg->skin = $graph_skin; $pg->built_in = false; $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != "."; $filename = company_path() . "/pdf_files/" . uniqid("") . ".png"; $pg->display($filename, true); $w = $pg->width / 1.5; $h = $pg->height / 1.5; $x = ($rep->pageWidth - $w) / 2; $rep->NewLine(2); if ($rep->row - $h < $rep->bottomMargin) { $rep->NewPage(); } $rep->AddImage($filename, $x, $rep->row - $h, $w, $h); } $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}"); } }