/** * Читаем входные данные из файла * и записываем их в переменную класса data * @return null */ private function readfile() { if (!is_file($this->path)) { echo 'Нет такого файла'; return null; } $handle = fopen($this->path, "r"); $this->data = []; if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { $dots = explode(' ', $buffer); foreach ($dots as $cord) { $cord = (int) Abs($cord); if ($cord < 1 || $cord > 10000) { continue 2; } } // Если 4 координаты if (count($dots) == 4) { $this->data[] = [[$dots[0], $dots[1]], [$dots[2], $dots[3]]]; } } fclose($handle); } }
function Color_Shift($ColorA, $ColorB, $Shift) { /****************************************************************************/ $__args_types = array('integer'); #----------------------------------------------------------------------------- $__args__ = Func_Get_Args(); eval(FUNCTION_INIT); /****************************************************************************/ $RGB1 = Color_RGB_Explode($ColorA); $RGB2 = Color_RGB_Explode($ColorB); #----------------------------------------------------------------------------- $R = $RGB1['R'] == $RGB2['R'] ? $RGB1['R'] : (int) (Abs($RGB2['R'] - $RGB1['R']) * ($RGB2['R'] > $RGB1['R'] ? $Shift : 100 - $Shift) / 100) + ($RGB2['R'] > $RGB1['R'] ? $RGB1['R'] : $RGB2['R']); $G = $RGB1['G'] == $RGB2['G'] ? $RGB1['G'] : (int) (Abs($RGB2['G'] - $RGB1['G']) * ($RGB2['G'] > $RGB1['G'] ? $Shift : 100 - $Shift) / 100) + ($RGB2['G'] > $RGB1['G'] ? $RGB1['G'] : $RGB2['G']); $B = $RGB1['B'] == $RGB2['B'] ? $RGB1['B'] : (int) (Abs($RGB2['B'] - $RGB1['B']) * ($RGB2['B'] > $RGB1['B'] ? $Shift : 100 - $Shift) / 100) + ($RGB2['B'] > $RGB1['B'] ? $RGB1['B'] : $RGB2['B']); #----------------------------------------------------------------------------- return Color_RGB_Implode($R, $G, $B); }
function print_customer_balances() { global $path_to_root, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $fromcust = $_POST['PARAM_2']; $show_balance = $_POST['PARAM_3']; $currency = $_POST['PARAM_4']; $no_zeros = $_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 ($fromcust == ALL_TEXT) { $cust = _('All'); } else { $cust = get_customer_name($fromcust); } $dec = user_price_dec(); if ($currency == ALL_TEXT) { $convert = true; $currency = _('Balances in Home Currency'); } else { $convert = false; } if ($no_zeros) { $nozeros = _('Yes'); } else { $nozeros = _('No'); } $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(_('Trans Type'), _('#'), _('Date'), _('Due Date'), _('Charges'), _('Credits'), _('Allocated'), _('Outstanding')); if ($show_balance) { $headers[7] = _('Balance'); } $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Customer'), 'from' => $cust, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => '')); $rep = new FrontReport(_('Customer Balances'), "CustomerBalances", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $grandtotal = array(0, 0, 0, 0); $sql = "SELECT debtor_no, name, curr_code FROM " . TB_PREF . "debtors_master "; if ($fromcust != ALL_TEXT) { $sql .= "WHERE debtor_no=" . db_escape($fromcust); } $sql .= " ORDER BY name"; $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } $accumulate = 0; $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1; $bal = get_open_balance($myrow['debtor_no'], $from, $convert); $init[0] = $init[1] = 0.0; $init[0] = round2(abs($bal['charges'] * $rate), $dec); $init[1] = round2(Abs($bal['credits'] * $rate), $dec); $init[2] = round2($bal['Allocated'] * $rate, $dec); if ($show_balance) { $init[3] = $init[0] - $init[1]; $accumulate += $init[3]; } else { $init[3] = round2($bal['OutStanding'] * $rate, $dec); } $res = get_transactions($myrow['debtor_no'], $from, $to); if ($no_zeros && db_num_rows($res) == 0) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 2, $myrow['name']); if ($convert) { $rep->TextCol(2, 3, $myrow['curr_code']); } $rep->fontSize -= 2; $rep->TextCol(3, 4, _("Open Balance")); $rep->AmountCol(4, 5, $init[0], $dec); $rep->AmountCol(5, 6, $init[1], $dec); $rep->AmountCol(6, 7, $init[2], $dec); $rep->AmountCol(7, 8, $init[3], $dec); $total = array(0, 0, 0, 0); for ($i = 0; $i < 4; $i++) { $total[$i] += $init[$i]; $grandtotal[$i] += $init[$i]; } $rep->NewLine(1, 2); $rep->Line($rep->row + 4); if (db_num_rows($res) == 0) { $rep->NewLine(1, 2); continue; } while ($trans = db_fetch($res)) { if ($no_zeros && floatcmp($trans['TotalAmount'], $trans['Allocated']) == 0) { continue; } $rep->NewLine(1, 2); $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['reference']); $rep->DateCol(2, 3, $trans['tran_date'], true); if ($trans['type'] == ST_SALESINVOICE) { $rep->DateCol(3, 4, $trans['due_date'], true); } $item[0] = $item[1] = 0.0; if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) { $trans['TotalAmount'] *= -1; } if ($trans['TotalAmount'] > 0.0) { $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->AmountCol(4, 5, $item[0], $dec); $accumulate += $item[0]; } else { $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec); $rep->AmountCol(5, 6, $item[1], $dec); $accumulate -= $item[1]; } $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->AmountCol(6, 7, $item[2], $dec); if ($trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT) { $item[3] = $item[0] + $item[1] - $item[2]; } else { $item[3] = $item[0] - $item[1] + $item[2]; } if ($show_balance) { $rep->AmountCol(7, 8, $accumulate, $dec); } else { $rep->AmountCol(7, 8, $item[3], $dec); } for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; $grandtotal[$i] += $item[$i]; } if ($show_balance) { $total[3] = $total[0] - $total[1]; } } $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); for ($i = 0; $i < 4; $i++) { $rep->AmountCol($i + 4, $i + 5, $total[$i], $dec); } $rep->Line($rep->row - 4); $rep->NewLine(2); } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; if ($show_balance) { $grandtotal[3] = $grandtotal[0] - $grandtotal[1]; } for ($i = 0; $i < 4; $i++) { $rep->AmountCol($i + 4, $i + 5, $grandtotal[$i], $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
<?php include 'data/config.php'; //Выдача формы, если нажата кнопка map_links if (isset($_POST['map_links']) && isset($_POST['num_last_dors'])) { //Соединяемся с базой $cn = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect : " . mysql_error()); mysql_query("SET NAMES cp1251"); mysql_select_db($db_name, $cn) or die("Could not select database"); //Получаем параметр $num_last_dors = $_POST["num_last_dors"]; if (!is_numeric($num_last_dors)) { $num_last_dors = 10; } else { $num_last_dors = Abs(ceil(trim($num_last_dors))); } //Получаем массив доров $result = mysql_query("SELECT `index_urls`, `map_urls` FROM `dors` ORDER BY `dor_date` DESC LIMIT 0, {$num_last_dors}"); $index_urls = array(); $map_urls = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $index_st = explode('&', $row["index_urls"]); $map_st = explode('&', $row["map_urls"]); $index_urls = array_merge($index_urls, $index_st); $map_urls = array_merge($map_urls, $map_st); } mysql_free_result($result); mysql_close($cn); if (isset($index_urls) && count($index_urls)) { $index_str = implode("\n", $index_urls); $index_map_str = $index_str;
public function ConvertMinutes2Hours($Minutes) { if ($Minutes < 0) { $Min = Abs($Minutes); } else { $Min = $Minutes; } $iHours = Floor($Min / 60); $Minutes = ($Min - $iHours * 60) / 100; $tHours = $iHours + $Minutes; if ($Minutes < 0) { $tHours = $tHours * -1; } $aHours = explode(".", $tHours); $iHours = $aHours[0]; if (empty($aHours[1])) { $aHours[1] = "00"; } $Minutes = $aHours[1]; if (strlen($Minutes) < 2) { $Minutes = $Minutes . "0"; } $tHours = $iHours . ":" . $Minutes; return $tHours; }
} #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- } #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # перенос #------------------------------------------------------------------------------- $Deviation = $Schemes[$Key]['CostTransfer'] * (100 + $Settings['DomainPriceDeviationPercent']) / 100 - $Schemes[$Key]['CostTransfer']; #------------------------------------------------------------------------------- if ($Deviation < $Settings['DomainPriceDeviationSumm']) { $Deviation = $Settings['DomainPriceDeviationSumm']; } #------------------------------------------------------------------------------- if (Abs($Schemes[$Key]['CostTransfer'] - $NewPriceTransfer) > $Deviation) { #------------------------------------------------------------------------------- # прописываем новую цену в базе данных $IsUpdate = DB_Update('DomainSchemes', array('CostTransfer' => $NewPriceTransfer), array('ID' => $Schemes[$Key]['ID'])); if (Is_Error($IsUpdate)) { return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $Message = SPrintF('%s/%s: цена переноса изменена %s->%s', $Registrator['Params']['Name'], $Key, IntVal($Schemes[$Key]['CostTransfer']), $NewPriceTransfer); #------------------------------------------------------------------------------- Debug(SPrintF('[comp/Tasks/GC/DomainCheckPriceList]: %s', $Message)); #------------------------------------------------------------------------------- if ($Settings['IsEvent'] && $Schemes[$Key]['IsActive']) { #------------------------------------------------------------------------------- $Event = array('Text' => $Message, 'PriorityID' => 'Notice', 'IsReaded' => FALSE); $Event = Comp_Load('Events/EventInsert', $Event);
$y2 = ($radius - 6) * sin($angle_to_use); } else { $x1 = (-$radius + $dist_from_diameter2c) * cos($angle_to_use); $y1 = ($radius - $dist_from_diameter2c) * sin($angle_to_use); $x2 = (-$radius + 6) * cos($angle_to_use); $y2 = ($radius - 6) * sin($angle_to_use); } imageline($im, $x1 + $center_pt, $y1 + $center_pt, $x2 + $center_pt, $y2 + $center_pt, $black); $flag = !$flag; } // ------------------------------------------ // draw in the aspect lines for ($i = 0; $i <= $last_planet_num; $i++) { for ($j = 0; $j <= $last_planet_num; $j++) { $q = 0; $da = Abs($longitude1[$sort_pos1[$i]] - $longitude2[$sort_pos2[$j]]); if ($da > 180) { $da = 360 - $da; } // set orb - 8 if Sun or Moon, 6 if not Sun or Moon if ($sort_pos1[$i] == 0 or $sort_pos1[$i] == 1 or $sort_pos2[$j] == 0 or $sort_pos2[$j] == 1) { $orb = 8; } else { $orb = 6; } // is there an aspect within orb? if ($da <= $orb) { $q = 1; } elseif ($da <= 60 + $orb and $da >= 60 - $orb) { $q = 6; } elseif ($da <= 90 + $orb and $da >= 90 - $orb) {
function getPaginator($sql, $limit_find, $page_number = 1) { $rs = array(); $rs['records'] = 0; $rs['pages'] = 0; if ($limit_find < 10) { $limit_find = 20; } if ($sql != '') { $records = _executeSql('select', array($sql), array('single')); if ($records > 0) { $rs['records'] = $records; $rs['pages'] = Ceil($records / $limit_find); } } if ($rs['records'] > 0) { // vypocet pocatecni a koncove stranky (snazime se vypsat vzdy 10 odkazu) $rs['start_page'] = $page_number - 5; $rs['end_page'] = $page_number + 5; // oprava nekorektnich hodnot (zaporne nebo prilis velke) if ($rs['start_page'] < 1) { $rs['end_page'] += Abs($rs['start_page']) + 1; } if ($rs['end_page'] > $rs['pages']) { $rs['start_page'] = $rs['start_page'] - ($rs['end_page'] - $rs['pages']); $rs['end_page'] = $rs['pages']; } if ($rs['start_page'] < 1) { $rs['start_page'] = 1; } for ($x = $rs['start_page']; $x <= $rs['end_page']; $x++) { $rs['view_pages'][] = $x; } if ($page_number > $rs['end_page']) { $rs['page_number'] = $rs['end_page']; setSessionMickaSearchPage($rs['page_number']); } else { $rs['page_number'] = $page_number; } } return $rs; }
function print_statements() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $customer = $_REQUEST['PARAM_0']; $currency = $_REQUEST['PARAM_1']; $bankaccount = $_REQUEST['PARAM_2']; $email = $_REQUEST['PARAM_3']; $comments = $_REQUEST['PARAM_4']; $dec = user_price_dec(); $cols = array(4, 100, 130, 190, 250, 320, 385, 450, 515); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments, 'bankaccount' => $bankaccount); $baccount = get_bank_account($params['bankaccount']); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(tr('STATEMENT'), "StatementBulk.pdf", user_pagesize()); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); } $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, email, curr_code, curdate() AS tran_date, payment_terms FROM debtors_master"; if ($customer != reserved_words::get_all_numeric()) { $sql .= " WHERE debtor_no = {$customer}"; } else { $sql .= " ORDER by name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { $date = date('Y-m-d'); $myrow['order_'] = ""; $TransResult = getTransactions($myrow['debtor_no'], $date); if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("", "", user_pagesize()); $rep->currency = $cur; $rep->Font(); $rep->title = tr('STATEMENT'); $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $rep->Header2($myrow, null, null, $baccount, 12); $rep->NewLine(); $linetype = true; $doctype = 12; if ($rep->currency != $myrow['curr_code']) { include $path_to_root . "reporting/includes/doctext2.inc"; } else { include $path_to_root . "reporting/includes/doctext.inc"; } $rep->fontSize += 2; $rep->TextCol(0, 8, $doc_Outstanding); $rep->fontSize -= 2; $rep->NewLine(2); while ($myrow2 = db_fetch($TransResult)) { $DisplayTotal = number_format2(Abs($myrow2["TotalAmount"]), $dec); $DisplayAlloc = number_format2($myrow2["Allocated"], $dec); if ($myrow2['type'] == 10) { $DisplayNet = number_format2($myrow2["TotalAmount"] - $myrow2["Allocated"], $dec); } else { $DisplayNet = number_format2($myrow2["TotalAmount"] + $myrow2["Allocated"], $dec); } $rep->TextCol(0, 1, $myrow2['type_name'], -2); $rep->TextCol(1, 2, $myrow2['reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); if ($myrow2['type'] == 10) { $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); } if ($myrow2['TotalAmount'] > 0.0) { $rep->TextCol(4, 5, $DisplayTotal, -2); } else { $rep->TextCol(5, 6, $DisplayTotal, -2); } $rep->TextCol(6, 7, $DisplayAlloc, -2); $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->Header2($myrow, null, null, $baccount); } } $nowdue = "1-" . $PastDueDays1 . " " . $doc_Days; $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . $doc_Days; $pastdue2 = $doc_Over . " " . $PastDueDays2 . " " . $doc_Days; $CustomerRecord = get_customer_details($myrow['debtor_no']); $str = array($doc_Current, $nowdue, $pastdue1, $pastdue2, $doc_Total_Balance); $str2 = array(number_format2($CustomerRecord["Balance"] - $CustomerRecord["Due"], $dec), number_format2($CustomerRecord["Due"] - $CustomerRecord["Overdue1"], $dec), number_format2($CustomerRecord["Overdue1"] - $CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Balance"], $dec)); $col = array($rep->cols[0], $rep->cols[0] + 110, $rep->cols[0] + 210, $rep->cols[0] + 310, $rep->cols[0] + 410, $rep->cols[0] + 510); $rep->row = $rep->bottomMargin + 8 * $rep->lineHeight; for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str[$i], 'right'); } $rep->NewLine(); for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); } if ($email == 1) { $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, 12); } } if ($email == 0) { $rep->End(); } }
function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = date2sql($_POST['PARAM_0']); $to = date2sql($_POST['PARAM_1']); $customer = $_POST['PARAM_2']; $currency = $_POST['PARAM_3']; $email = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(4, 64, 180, 250, 320, 385, 450, 515); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('CUSTOMER ACCOUNT STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT b.debtor_no, b.name AS DebtorName, b.address, b.tax_id, b.curr_code, curdate() AS tran_date, CONCAT (d.name, d.name2) AS contactPerson, d.phone, d.phone2 FROM " . TB_PREF . "debtors_master b INNER JOIN\n" . TB_PREF . "crm_contacts c on b.debtor_no=c.entity_id INNER JOIN " . TB_PREF . "crm_persons d on c.person_id=d.id"; if ($customer != ALL_TEXT) { $sql .= " WHERE b.debtor_no = " . db_escape($customer); } else { $sql .= " ORDER by b.name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($debtor_row = db_fetch($result)) { $date = date('Y-m-d'); if ($from != $to) { // find the latest point where the balance was null $start = findLatestNullDate($debtor_row['debtor_no'], $from); // but not earlier than the $to date. if (date1_greater_date2(sql2date($start), sql2date($to))) { $start = $to; } if (date1_greater_date2(sql2date($from), sql2date($start))) { $start = $from; } } else { $start = $from; } $debtor_row['order_'] = ""; $TransResult = getTransactions($debtor_row['debtor_no'], $start, $date); $baccount = get_default_bank_account($debtor_row['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("CUSTOMER ACCOUNT STATEMENT", "", user_pagesize(), 9, $orientation); $rep->title = _('CUSTOMER ACCOUNT STATEMENT'); $rep->filename = "Statement" . $debtor_row['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $rep->filename = "ST-" . strtr($debtor_row['DebtorName'], " '", "__") . "--" . strtr(Today(), "/", "-") . ".pdf"; $contacts = get_customer_contacts($debtor_row['debtor_no'], 'invoice'); $rep->SetHeaderType(0); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); //= get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no']); $rep->SetCommonData($debtor_row, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $doctype = ST_STATEMENT; /* $rep->NewLine(); $rep->fontSize += 2; $rep->TextCol(0, 7, _("Overdue")); $rep->fontSize -= 2; $rep->NewLine(2); */ $rep->NewLine(10); $rep->TextCol(0, 5, $debtor_row['DebtorName']); $rep->NewLine(); $rep->TextCol(0, 5, $debtor_row['contactPerson']); $rep->NewLine(); $rep->TextCol(0, 5, $debtor_row['address']); $rep->NewLine(); $rep->TextCol(0, 5, $debtor_row['phone'] . " " . $debtor_row['phone2']); $rep->NewLine(5); $current = false; $balance = getInitialBalance($debtor_row['debtor_no'], $start); if (true || Abs($balance) > 1.0E-6) { // Display initial balance //$rep->TextCol(1, 4, 'Balance Brought Forward'); if (Abs($balance) < 1.0E-6) { $rep->SetTextColor(190, 190, 190); } else { if ($balance > 0) { $rep->SetTextColor(190, 0, 0); } } //$rep->TextCol(6, 7, number_format2(-$balance, $dec), -2); $rep->SetTextColor(0, 0, 0); //$rep->NewLine(); } $overdue = 0; while ($transaction_row = db_fetch($TransResult)) { if (!$current && !$transaction_row['OverDue'] == true) { $rep->fontSize += 2; //$rep->NewLine(2); //$rep->TextCol(0, 7, _("Due Soon")); $rep->fontSize -= 2; $current = true; $overdue = $balance; /* Reset the balance. so we have a separate balance for overdue * and current. However if the customer is in credit * don't reset the balance. * Example : A Customer has made a payment before the invoice * is overdue. The total balance after the invoice should be 0. */ if ($balance > 0) { $balance = 0; } else { $overdue = 0; } $rep->NewLine(2); } if ($current) { $rep->SetTextColor(0, 0, 190); } $DisplayTotal = number_format2(Abs($transaction_row["TotalAmount"]), $dec); $DisplayAlloc = number_format2($transaction_row["Allocated"], $dec); $DisplayNet = number_format2($transaction_row["TotalAmount"] - $transaction_row["Allocated"], $dec); $balance += $transaction_row["TotalAmount"]; if ($systypes_array[$transaction_row['type']] == "Customer Payment") { $invoice_no = get_custom_no($transaction_row['trans_no'], 53); } else { $invoice_no = get_custom_no($transaction_row['trans_no'], $transaction_row['type']); } if ($systypes_array[$transaction_row['type']] == "Sales Invoice") { $typename = "Charge Invoice"; } else { $typename = $systypes_array[$transaction_row['type']]; } $rep->TextCol(1, 1, $typename, -2); $rep->TextCol(2, 2, $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['EffectiveDate']), -2); if ($transaction_row['type'] == ST_SALESINVOICE) { $rep->TextCol(3, 4, sql2date($transaction_row['tran_date']), -2); } if ($transaction_row['type'] == ST_SALESINVOICE || $transaction_row['type'] == ST_BANKPAYMENT) { $rep->TextCol(4, 5, $DisplayTotal, -2); } else { $rep->TextCol(5, 6, $DisplayTotal, -2); } if (!$current) { if (Abs($balance) < 1.0E-6) { $rep->SetTextColor(190, 190, 190); } else { if ($balance > 0) { $rep->SetTextColor(190, 0, 0); } } } $rep->TextCol(6, 7, number_format2(-$balance, $dec), -2); $rep->SetTextColor(0, 0, 0); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->NewPage(); } } if (!$current) { $overdue = $balance; $balance = 0; } // Total $rep->NewLine(); $rep->SetTextColor(0, 0, 0); $rep->fontSize += 2; $rep->NewLine(18); $rep->TextCol(1, 2, 'Total Balance'); $rep->TextCol(2, 3, number_format2(-($balance + $overdue), $dec)); if ($overdue > 1.0E-6) { // $rep->fontSize += 2; $rep->NewLine(2); $rep->SetTextColor(190, 0, 0); $rep->TextCol(5, 6, 'Overdue'); $rep->TextCol(6, 7, number_format2($overdue, $dec)); $rep->TextCol(2, 5, 'PLEASE PAY NOW'); // $rep->fontSize -= 2; $rep->SetTextColor(0, 0, 0); $rep->NewLine(); } $rep->fontSize -= 2; /* $nowdue = "1-" . $PastDueDays1 . " " . _("Days"); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _("Days"); $pastdue2 = _("Over") . " " . $PastDueDays2 . " " . _("Days"); $CustomerRecord = get_customer_details($debtor_row['debtor_no'], null, $show_also_allocated); $str = array(_("Current"), $nowdue, $pastdue1, $pastdue2, _("Total Balance")); $str2 = array(number_format2(($CustomerRecord["Balance"] - $CustomerRecord["Due"]),$dec), number_format2(($CustomerRecord["Due"]-$CustomerRecord["Overdue1"]),$dec), number_format2(($CustomerRecord["Overdue1"]-$CustomerRecord["Overdue2"]) ,$dec), number_format2($CustomerRecord["Overdue2"],$dec), number_format2($CustomerRecord["Balance"],$dec)); $col = array($rep->cols[0], $rep->cols[0] + 110, $rep->cols[0] + 210, $rep->cols[0] + 310, $rep->cols[0] + 410, $rep->cols[0] + 510); $rep->row = $rep->bottomMargin + (10 * $rep->lineHeight - 6); for ($i = 0; $i < 5; $i++) $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str[$i], 'right'); $rep->NewLine(); for ($i = 0; $i < 5; $i++) $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); */ if ($email == 1) { $rep->End($email, _("Statement") . " " . _("as of") . " " . sql2date($date)); } } if ($email == 0) { $rep->End(); } }
$y2 = ($radius - 6) * sin($angle_to_use); } else { $x1 = (-$radius + $dist_from_diameter2a) * cos($angle_to_use); $y1 = ($radius - $dist_from_diameter2a) * sin($angle_to_use); $x2 = (-$radius + 6) * cos($angle_to_use); $y2 = ($radius - 6) * sin($angle_to_use); } imageline($im, $x1 + $center_pt, $y1 + $center_pt, $x2 + $center_pt, $y2 + $center_pt, $black); $flag = !$flag; } // ------------------------------------------ // draw in the aspect lines for ($i = 0; $i <= $last_planet_num - 1; $i++) { for ($j = $i + 1; $j <= $last_planet_num; $j++) { $q = 0; $da = Abs($longitude[$sort_pos[$i]] - $longitude[$sort_pos[$j]]); if ($da > 180) { $da = 360 - $da; } // set orb - 8 if Sun or Moon, 6 if not Sun or Moon if ($sort_pos[$i] == 0 or $sort_pos[$i] == 1 or $sort_pos[$j] == 0 or $sort_pos[$j] == 1) { $orb = 8; } else { $orb = 6; } // is there an aspect within orb? if ($da <= $orb) { $q = 1; } elseif ($da <= 60 + $orb and $da >= 60 - $orb) { $q = 6; } elseif ($da <= 90 + $orb and $da >= 90 - $orb) {
<tr><td colspan="3" class="b"> </td></tr> </table></form><br><br><br>'; echo $form; include 'data/d/footer.php'; } elseif (isset($_POST['maps']) && isset($_POST['dors']) && isset($_POST['min_links'])) { //Соединяемся с базой $cn = mysql_connect($db_host, $db_user, $db_pass) or die("Could not connect : " . mysql_error()); mysql_query("SET NAMES cp1251"); mysql_select_db($db_name, $cn) or die("Could not select database"); //Получаем параметры $sel_dors = $_POST['dors']; $min_links = $_POST["min_links"]; if (!is_numeric($min_links)) { $min_links = 100; } else { $min_links = Abs(ceil(trim($min_links))); } $links_in_map = $min_links; $index_urls = array(); foreach ($sel_dors as $dor_str) { $dor_par = explode('&', $dor_str); $id_dor = $dor_par[0]; $domen = $dor_par[1]; $result = mysql_query("SELECT `index_urls` FROM `dors` WHERE `id` = {$id_dor} LIMIT 1"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $index_st = explode('&', $row["index_urls"]); $index_urls = array_merge($index_urls, $index_st); } } mysql_free_result($result); mysql_close($cn);
public function rotate($rotate) { $RotSrc = $this->image; $width = imagesx($RotSrc); $height = imagesy($RotSrc); // - Zappo - Calculate correct rotated-image size... $theta = deg2rad($rotate); $CenterX = $width / 2; $CenterY = $height / 2; $XMin = $CenterX - 0.5 * ($width * Abs(cos($theta)) + $height * Abs(sin($theta))); $XMax = $CenterX + 0.5 * ($width * Abs(cos($theta)) + $height * Abs(sin($theta))); $YMin = $CenterY - 0.5 * ($width * Abs(sin($theta)) + $height * Abs(cos($theta))); $YMax = $CenterY + 0.5 * ($width * Abs(sin($theta)) + $height * Abs(cos($theta))); $newwidth = $XMax - $XMin; $newheight = $YMax - $YMin; $this->image = imagecreatetruecolor($newwidth, $newheight); $color = imagecolorallocate($this->image, 255, 255, 255); imagecolortransparent($this->image, $color); $this->image = imagerotate($RotSrc, $rotate, $color); imagealphablending($this->image, true); imagesavealpha($this->image, true); $this->transparent = true; $this->info['width'] = $newwidth; $this->info['height'] = $newheight; imagedestroy($RotSrc); }
function print_payment_report() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $to = $_REQUEST['PARAM_0']; $fromsupp = $_REQUEST['PARAM_1']; $currency = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; if ($fromsupp == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_supplier_name($fromsupp); } $dec = user_price_dec(); if ($currency == reserved_words::get_all()) { $convert = true; $currency = tr('Balances in Home Currency'); } else { $convert = false; } $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(tr('Trans Type'), tr('#'), tr('Due Date'), '', '', '', tr('Total'), tr('Balance')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => '')); $rep = new FrontReport(tr('Payment Report'), "PaymentReport.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $total = array(); $grandtotal = array(0, 0); $sql = "SELECT supplier_id, supp_name AS name, curr_code, payment_terms.terms FROM suppliers, payment_terms\n\t\tWHERE "; if ($fromsupp != reserved_words::get_all_numeric()) { $sql .= "supplier_id={$fromsupp} AND "; } $sql .= "suppliers.payment_terms = payment_terms.terms_indicator\n\t\tORDER BY supp_name"; $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 6, $myrow['name'] . " - " . $myrow['terms']); if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); $rep->TextCol(6, 7, $myrow['curr_code']); } else { $rate = 1.0; } $rep->fontSize -= 2; $rep->NewLine(1, 2); $res = getTransactions($myrow['supplier_id'], $to); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); $total[0] = $total[1] = 0.0; while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['supp_reference']); $rep->TextCol(2, 3, sql2date($trans['due_date'])); $item[0] = Abs($trans['TranTotal']) * $rate; $rep->TextCol(6, 7, number_format2($item[0], $dec)); $item[1] = $trans['Balance'] * $rate; $rep->TextCol(7, 8, number_format2($item[1], $dec)); for ($i = 0; $i < 2; $i++) { $total[$i] += $item[$i]; $grandtotal[$i] += $item[$i]; } } $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, tr('Total')); for ($i = 0; $i < 2; $i++) { $rep->TextCol($i + 6, $i + 7, number_format2($total[$i], $dec)); $total[$i] = 0.0; } $rep->Line($rep->row - 4); $rep->NewLine(2); } $rep->fontSize += 2; $rep->TextCol(0, 3, tr('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < 2; $i++) { $rep->TextCol($i + 6, $i + 7, number_format2($grandtotal[$i], $dec)); } $rep->Line($rep->row - 4); $rep->End(); }
/** * m2h * * Minutes to Hours * * @param mixed $mins * @access public * @return void */ public function m2h($mins) { /*{{{*/ // return an empty string, if no minutes are given // (or the value is zero) if (empty($mins)) { return ''; } if ($mins < 0) { $min = Abs($mins); } else { $min = $mins; } $H = Floor($min / 60); //$M = ($min - ($H * 60)) / 100; // set the part of an hour relative to 60, not to 100 $M = ($min - $H * 60) / 60; $M = round($M, 2); $hours = $H + $M; if ($mins < 0) { $hours = $hours * -1; } $expl = explode(".", $hours); $H = $expl[0]; if (empty($expl[1])) { $expl[1] = 00; } $M = $expl[1]; if (strlen($M) < 2) { $M = $M . 0; } $hours = $H . "," . $M; return $hours; }
function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report2.inc"; $from = date2sql($_POST['PARAM_0']); $to = date2sql($_POST['PARAM_1']); $customer = $_POST['PARAM_2']; $currency = $_POST['PARAM_3']; $email = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $orientation = $orientation ? 'L' : 'P'; $dec = 2; $cols = array(4, 64, 180, 250, 300, 350, 400, 480); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('CUSTOMER ACCOUNT STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT b.debtor_no, b.name AS DebtorName, b.address, b.tax_id, b.curr_code, cust.salesman, \n\tcurdate() AS tran_date, CONCAT (d.name, d.name2) AS contactPerson, d.phone, d.phone2 \n\tFROM " . TB_PREF . "debtors_master b INNER JOIN\n" . TB_PREF . "crm_contacts c on b.debtor_no=c.entity_id INNER JOIN " . TB_PREF . "crm_persons d on c.person_id=d.id\nINNER JOIN " . TB_PREF . "cust_branch cust on b.debtor_no=cust.debtor_no"; if ($customer != ALL_TEXT) { $sql .= " WHERE c.type='customer' and cust.salesman = " . db_escape($customer); } else { $sql .= " where c.type='customer' and cust.salesman = " . db_escape($customer) . " ORDER by b.name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($debtor_row = db_fetch($result)) { $date = date('Y-m-d'); if ($from != $to) { // find the latest point where the balance was null $start = findLatestNullDate($debtor_row['debtor_no'], $from); // but not earlier than the $to date. if (date1_greater_date2(sql2date($start), sql2date($to))) { $start = $to; } if (date1_greater_date2(sql2date($from), sql2date($start))) { $start = $from; } } else { $start = $from; } $debtor_row['order_'] = ""; $TransResult = getTransactions($debtor_row['debtor_no'], $start, $date); $baccount = get_default_bank_account($debtor_row['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("CUSTOMER ACCOUNT STATEMENT", "", user_pagesize(), 9, $orientation); $rep->title = _('STATEMENT OF ACCOUNT'); $rep->filename = "Statement" . $debtor_row['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $rep->filename = "ST-" . strtr($debtor_row['DebtorName'], " '", "__") . "--" . strtr(Today(), "/", "-") . ".pdf"; $contacts = get_customer_contacts($debtor_row['debtor_no'], 'invoice'); $rep->SetHeaderType('customheader'); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); $rep->SetCommonData($debtor_row, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $doctype = ST_STATEMENT; //$rep->TextCol(0,4,"yeah"); $current = false; $balance = getInitialBalance($debtor_row['debtor_no'], $start); if (true || Abs($balance) > 1.0E-6) { if (Abs($balance) < 1.0E-6) { $rep->SetTextColor(190, 190, 190); } else { if ($balance > 0) { $rep->SetTextColor(190, 0, 0); } } $rep->SetTextColor(0, 0, 0); } $overdue = 0; $prev = ''; $gross_amount = 0; $gross_amount2 = 0; $payment_tot = 0; $tots = 0; $discount_amount = 0; $percent = 0; while ($transaction_row = db_fetch($TransResult)) { if ($myrow['IsVoid'] == '') { $company_data = get_company_prefs(); $branch = get_branch($transaction_row["branch_code"]); $branch_data = get_branch_accounts($transaction_row['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $transaction_row['type'], $transaction_row['trans_no']); $DisplayTotal = number_format2(Abs($transaction_row["TotalAmount"] + $dt), $dec); $DisplayAlloc = number_format2($transaction_row["Allocated"], $dec); $DisplayNet = number_format2($transaction_row["TotalAmount"] - $transaction_row["Allocated"], $dec); /*if ($dt != 0 && $transaction_row['type'] == ST_SALESINVOICE || $transaction_row['type'] == ST_CUSTCREDIT) { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; }*/ $amount = $transaction_row["TotalAmount"] + $dt; $balance += $transaction_row["TotalAmount"]; $invoice_no = get_custom_no($transaction_row['trans_no'], $transaction_row['type']); $enter1 = 0; if ($systypes_array[$transaction_row['type']] == "Customer Payment") { $open_pay = get_payment_invoice_details($transaction_row["trans_no"], ST_CUSTPAYMENT); if ($open_pay) { $stat2 = false; } else { $stat2 = true; $payment_tot += $amount; $text = "pr#"; } } if ($systypes_array[$transaction_row['type']] == "Sales Invoice") { if ($transaction_row['ov_amount'] > $transaction_row['alloc'] || $transaction_row['alloc'] == 0) { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; $gross_amount += $amount; $text = ''; $stat3 = true; } else { $stat3 = false; } } if ($systypes_array[$transaction_row['type']] == "Customer Credit Note") { $open = get_sales_invoice_details($transaction_row['order_'], ST_SALESINVOICE); if ($open) { $stat = false; } else { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; $gross_amount2 += $amount; $stat = true; } $text = "cm#"; } $current = $text; $tot = $gross_amount + $gross_amount2 - $discount_amount; if ($current != '') { if ($prev == $current) { } else { if ($prev == "" && $text == "cm#" && $stat) { $rep->NewLine(); $rep->TextCol(1, 2, "Less Returns"); $rep->NewLine(); } if ($text == 'pr#' && $prev == "cm#" && $stat2) { $rep->AmountCol(6, 7, $tot, 2); $rep->NewLine(2); $rep->TextCol(1, 2, "Less Payments:"); $rep->NewLine(); } if ($prev == '' && $text == 'pr#' && $stat2) { $rep->TextCol(1, 2, "Less Payments:"); $rep->NewLine(); } } $prev = $current; } if ($transaction_row['type'] == ST_SALESINVOICE && $stat3) { $rep->TextCol(1, 2, $text . $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(3, 4, $DisplayTotal, -2); $rep->NewLine(); } if ($transaction_row['type'] == ST_CUSTCREDIT && $stat) { $rep->TextCol(1, 2, $text . $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(3, 4, $DisplayTotal, -2); $rep->NewLine(); } if ($transaction_row['type'] == ST_CUSTPAYMENT && $stat2) { if ($invoice_no == "") { $rep->TextCol(1, 2, $text . $transaction_row['reference'], -2); } else { $rep->TextCol(1, 2, $text . $invoice_no, -2); } $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(5, 6, $DisplayTotal, -2); $rep->NewLine(); } $rep->SetTextColor(0, 0, 0); //$rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->NewPage(); } } } if (!$current) { $overdue = $balance; $balance = 0; } $rep->NewLine(); $net = $gross_amount - abs($gross_amount2); $percent = $ctr / $net * 100; $per = number_format2($percent, 2); if ($per != 0) { $rep->TextCol(1, 2, "Less " . $ctr . "% discount"); $rep->AmountCol(5, 6, $discount_amount, 2); } $rep->SetTextColor(0, 0, 0); $rep->fontSize += 2; $rep->NewLine(5); $rep->TextCol(1, 2, 'Amount Due'); //$rep->TextCol(6,7, " ____________", -2); if ($payment_tot != 0) { $rep->TextCol(6, 7, number_format2($tot - abs($payment_tot), $dec)); } else { $rep->AmountCol(6, 7, $tot, 2); } $rep->NewLine(5); $rep->TextCol(2, 4, "Verified & Checked by:"); $rep->TextCol(4, 6, "___________________"); $rep->NewLine(); $rep->TextCol(4, 6, "Credit & Collection"); $rep->fontSize -= 2; } //$rep->NewPage(); if ($email == 0) { $rep->End(); } }
//display philosophy of astrology echo "<center><font size='+1' color='#0000ff'><b>PLANETARY TRANSIT ASPECTS</b></font></center>"; $file = "transit_files/aspect.txt"; $fh = fopen($file, "r"); $string = fread($fh, filesize($file)); fclose($fh); $p_aspect_interp = nl2br($string); echo "<font size=2>" . $p_aspect_interp . "</font>"; // loop through each planet for ($i = 0; $i <= 5; $i++) { for ($j = 0; $j <= 9; $j++) { if ($i == 1 or $j == 1 and $ubt1 == 1) { continue; // do not allow Moon aspects for transit planets, or for natal planets if birth time is unknown } $da = Abs($L3[$i] - $L1[$j]); if ($da > 180) { $da = 360 - $da; } $orb = 2.0; //orb = 2.0 degree // are planets within orb? $q = 1; if ($da <= $orb) { $q = 2; } elseif ($da <= 60 + $orb and $da >= 60 - $orb) { $q = 3; } elseif ($da <= 90 + $orb and $da >= 90 - $orb) { $q = 4; } elseif ($da <= 120 + $orb and $da >= 120 - $orb) { $q = 5;
function print_customer_balances() { global $path_to_root; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $to = $_REQUEST['PARAM_0']; $fromcust = $_REQUEST['PARAM_1']; $currency = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; if ($fromcust == reserved_words::get_all_numeric()) { $from = tr('All'); } else { $from = get_customer_name($fromcust); } $dec = user_price_dec(); if ($currency == reserved_words::get_all()) { $convert = true; $currency = tr('Balances in Home Currency'); } else { $convert = false; } $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(tr('Trans Type'), tr('#'), tr('Date'), tr('Due Date'), tr('Charges'), tr('Credits'), tr('Allocated'), tr('Outstanding')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => '')); $rep = new FrontReport(tr('Customer Balances'), "CustomerBalances.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $grandtotal = array(0, 0, 0, 0); $sql = "SELECT debtor_no, name, curr_code FROM debtors_master "; if ($fromcust != reserved_words::get_all_numeric()) { $sql .= "WHERE debtor_no={$fromcust} "; } $sql .= "ORDER BY name"; $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['name']); if ($convert) { $rep->TextCol(3, 4, $myrow['curr_code']); } $rep->fontSize -= 2; $rep->NewLine(1, 2); $res = get_transactions($myrow['debtor_no'], $to); if (db_num_rows($res) == 0) { continue; } $rep->Line($rep->row + 4); $total = array(0, 0, 0, 0); while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['reference']); $date = sql2date($trans['tran_date']); $rep->TextCol(2, 3, $date); if ($trans['type'] == 10) { $rep->TextCol(3, 4, sql2date($trans['due_date'])); } $item[0] = $item[1] = 0.0; if ($convert) { $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date); } else { $rate = 1.0; } if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) { $trans['TotalAmount'] *= -1; } if ($trans['TotalAmount'] > 0.0) { $item[0] = abs($trans['TotalAmount']) * $rate; $rep->TextCol(4, 5, number_format2($item[0], $dec)); } else { $item[1] = Abs($trans['TotalAmount']) * $rate; $rep->TextCol(5, 6, number_format2($item[1], $dec)); } $item[2] = $trans['Allocated'] * $rate; $rep->TextCol(6, 7, number_format2($item[2], $dec)); if ($trans['type'] == 10) { $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; } else { $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; } $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; $grandtotal[$i] += $item[$i]; } } $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, tr('Total')); for ($i = 0; $i < 4; $i++) { $rep->TextCol($i + 4, $i + 5, number_format2($total[$i], $dec)); } $rep->Line($rep->row - 4); $rep->NewLine(2); } $rep->fontSize += 2; $rep->TextCol(0, 3, tr('Grand Total')); $rep->fontSize -= 2; for ($i = 0; $i < 4; $i++) { $rep->TextCol($i + 4, $i + 5, number_format2($grandtotal[$i], $dec)); } $rep->Line($rep->row - 4); $rep->End(); }
function min2hour($mins) { if ($mins < 0) { $min = Abs($mins); } else { $min = $mins; } $H = Floor($min / 60); $M = ($min - $H * 60) / 100; $hours = $H + $M; if ($mins < 0) { $hours = $hours * -1; } $expl = explode(".", $hours); $H = $expl[0]; if (empty($expl[1])) { $expl[1] = 00; } $M = $expl[1]; if (strlen($M) < 2) { $M = $M . 0; } $hours = $H; if ($M > 0 && $H < 3) { $hours .= ":" . $M; } $s = $H > 1 || $M > 1 ? "s" : ""; $hours .= "h"; //.$s; return $hours; }
/** * Returns an array of elevations in metres given an array of lats & lons * as {lat1, lon1, ... latn, lonn}. Can optionally calculate intermediate locations at * 3" intervals and optionally use bilinear interpolation * * @param string $latLons * @param bool $addIntermediatelatLons * @param bool $interpolate */ public function getMultipleElevations($latLons, $addIntermediatelatLons = false, $interpolate = false) { $totNumSteps = 0; $numlatLons = count($latLons); //if ($numlatLons < 4) { // $this->handleError(__METHOD__ , "need at least two point locations in the latLons array"); //} // bale out if limit is reached $limit = $this->maxPoints; if ($numlatLons / 2 > $limit) { $this->handleError(__METHOD__, "maximum number of allowed point locations ({$limit}) exceeded"); } if ($numlatLons % 2 != 0) { $this->handleError(__METHOD__, "uneven number of lat and lon params "); } if ($addIntermediatelatLons) { // work out intermediate lats and lons for every 3" of arc for ($i = 2; $i < $numlatLons; $i += 2) { $startLat = $latLons[$i - 2]; $endLat = $latLons[$i]; $dlat = $endLat - $startLat; $startLon = $latLons[$i - 1]; $endLon = $latLons[$i + 1]; $dlon = $endLon - $startLon; Abs($dlat) >= Abs($dlon) ? $numSteps = floor(Abs($dlat) / self::PIXEL_DIST) : ($numSteps = floor(Abs($dlon) / self::PIXEL_DIST)); // calculate approximate intermediate positions for each 3" // by simple proportion of dlat and dlon - assumes flat earth! $totNumSteps += $numSteps; if ($totNumSteps >= $limit) { $this->handleError(__METHOD__, "maximum number of allowed point locations ({$limit}) exceeded while calculating intermediate points"); } for ($j = 0; $j < $numSteps; $j++) { $midLat = $startLat + $j * $dlat / $numSteps; $midLon = $startLon + $j * $dlon / $numSteps; $elevations[] = $this->getElevation($midLat, $midLon, $interpolate); } } $elevations[] = $this->getElevation($endLat, $endLon, $interpolate); } else { // just do the provided lats and lons, no intermediate positions are calculated for ($k = 0; $k < $numlatLons; $k += 2) { $elevations[] = $this->getElevation($latLons[$k], $latLons[$k + 1], $interpolate); } } $this->elevations = $elevations; $this->latLons = $latLons; return $elevations; }
public function lamPCBsmt(PartSMT $smtP, $CR, $alfaS, $zivot, $dt) { $piLC = $this->getLeadConfigValue($smtP->getLeadConfig()); $h = 5; $delka = $smtP->getHeight(); $sirka = $smtP->getWidth(); $d = sqrt(pow($delka, 2) + pow($sirka, 2)) / 2; $alfaCC = $this->getPackageValue($smtP->getTCEPackage()); $otepleni = $smtP->getTempDissipation(); $y = Abs($alfaS * $dt - $alfaCC * ($dt + $otepleni)) * pow(10, -6); $nf = $piLC * 3.5 * pow($d / (0.65 * $h) * $y, -2.26); $asmt = $nf / $CR; $x = $zivot * 8760 / $asmt; if ($x <= 0.1) { $ecf = 0.13; } else { if ($x > 0.1 && $x <= 0.2) { $ecf = 0.15; } else { if ($x > 0.2 && $x <= 0.3) { $ecf = 0.23; } else { if ($x > 0.3 && $x <= 0.4) { $ecf = 0.31; } else { if ($x > 0.4 && $x <= 0.5) { $ecf = 0.41; } else { if ($x > 0.5 && $x <= 0.6) { $ecf = 0.51; } else { if ($x > 0.6 && $x <= 0.7) { $ecf = 0.61; } else { if ($x > 0.7 && $x <= 0.8) { $ecf = 0.68; } else { if ($x > 0.8 && $x <= 0.9) { $ecf = 0.76; } else { $ecf = 1; } } } } } } } } } $LamSMT = $ecf / $asmt; $LamSMT *= $smtP->getCnt(); return $LamSMT; }
/** * 火星坐标经度偏移量辅助计算函数 * * @param float $lng * 经度,竖线,0-180,中国在东经72.004-137.8347 * @param float $lat * 纬度,横线,0-90,中国在北纬0.8293-55.8271 * @return number * @version 0.13.5.28 */ private function lng_offset($lng, $lat) { $lng -= 105; $lat -= 35; $ret = 300 + $lng + 2 * $lat + 0.1 * $lng * $lng + 0.1 * $lng * $lat + 0.1 * Sqrt(Abs($lng)); $ret += (20 * sin(6 * $lng * M_PI) + 20 * sin(2 * $lng * M_PI)) * 2 / 3; $ret += (20 * sin($lng * M_PI) + 40 * sin($lng / 3 * M_PI)) * 2 / 3; $ret += (150 * sin($lng / 12 * M_PI) + 300 * sin($lng / 30 * M_PI)) * 2 / 3; return $ret; }
function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $customer = $_POST['PARAM_0']; $currency = $_POST['PARAM_1']; $show_also_allocated = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(4, 100, 130, 190, 250, 320, 385, 450, 515); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, curr_code, curdate() AS tran_date FROM " . TB_PREF . "debtors_master"; if ($customer != ALL_TEXT) { $sql .= " WHERE debtor_no = " . db_escape($customer); } else { $sql .= " ORDER by name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { $date = date('Y-m-d'); $myrow['order_'] = ""; $TransResult = getTransactions($myrow['debtor_no'], $date, $show_also_allocated); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('STATEMENT'); $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $contacts = get_customer_contacts($myrow['debtor_no'], 'invoice'); $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); //= get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no']); $rep->SetCommonData($myrow, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $rep->NewLine(); $doctype = ST_STATEMENT; $rep->fontSize += 2; $rep->TextCol(0, 8, _("Outstanding Transactions")); $rep->fontSize -= 2; $rep->NewLine(2); while ($myrow2 = db_fetch($TransResult)) { $DisplayTotal = number_format2(Abs($myrow2["TotalAmount"]), $dec); $DisplayAlloc = number_format2($myrow2["Allocated"], $dec); $DisplayNet = number_format2($myrow2["TotalAmount"] - $myrow2["Allocated"], $dec); $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); $rep->TextCol(1, 2, $myrow2['reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); if ($myrow2['type'] == ST_SALESINVOICE) { $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); } if ($myrow2['type'] == ST_SALESINVOICE || $myrow2['type'] == ST_BANKPAYMENT) { $rep->TextCol(4, 5, $DisplayTotal, -2); } else { $rep->TextCol(5, 6, $DisplayTotal, -2); } $rep->TextCol(6, 7, $DisplayAlloc, -2); $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->NewPage(); } } $nowdue = "1-" . $PastDueDays1 . " " . _("Days"); $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _("Days"); $pastdue2 = _("Over") . " " . $PastDueDays2 . " " . _("Days"); $CustomerRecord = get_customer_details($myrow['debtor_no'], null, $show_also_allocated); $str = array(_("Current"), $nowdue, $pastdue1, $pastdue2, _("Total Balance")); $str2 = array(number_format2($CustomerRecord["Balance"] - $CustomerRecord["Due"], $dec), number_format2($CustomerRecord["Due"] - $CustomerRecord["Overdue1"], $dec), number_format2($CustomerRecord["Overdue1"] - $CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Overdue2"], $dec), number_format2($CustomerRecord["Balance"], $dec)); $col = array($rep->cols[0], $rep->cols[0] + 110, $rep->cols[0] + 210, $rep->cols[0] + 310, $rep->cols[0] + 410, $rep->cols[0] + 510); $rep->row = $rep->bottomMargin + (10 * $rep->lineHeight - 6); for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str[$i], 'right'); } $rep->NewLine(); for ($i = 0; $i < 5; $i++) { $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); } if ($email == 1) { $rep->End($email, _("Statement") . " " . _("as of") . " " . sql2date($date)); } } if ($email == 0) { $rep->End(); } }
mysql_select_db($db_name, $cn) or die("Could not select database"); //Получаем массив параметров $id_theme = $_POST["id_theme"]; $tpls_count = $_POST["tpls_count"]; //Получаем название тематики шаблонов $result = mysql_query("SELECT `id`, `name` FROM `themes` WHERE `id` = {$id_theme}"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $theme_name = $row["name"]; } mysql_free_result($result); if (trim($tpls_count) == '' && !is_numeric($tpls_count)) { mysql_close($cn); header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); exit; } $tpls_count = Abs(Ceil($tpls_count)); $W_H = get_baner_sizes($id_theme); for ($i = 0; $i < $tpls_count; $i++) { //запуск генерации шаблона $tpl = generate_tpl($W_H); $tpl_content = $tpl['content']; $tpl_style = $tpl['style']; $tpl_name = $theme_name . $i; //Добавляем шаблон в базу $result = mysql_query("INSERT INTO `dor_tpls` (`name`, `tpl_status`, `id_theme`) VALUES ('{$tpl_name}', 'blocked', '{$id_theme}')"); if (!$result) { echo "Ошибка вставки данных в базу" . mysql_error(); exit; } //Получаем id вставленной записи $result = mysql_query("SELECT LAST_INSERT_ID()");
//display philosophy of astrology echo "<center><font size='+1' color='#0000ff'><b>PLANETARY PROGRESSED ASPECTS</b></font></center>"; $file = "transit_files/aspect.txt"; $fh = fopen($file, "r"); $string = fread($fh, filesize($file)); fclose($fh); $p_aspect_interp = nl2br($string); echo "<font size=2>" . $p_aspect_interp . "</font>"; // loop through each planet for ($i = 0; $i <= 5; $i++) { for ($j = 0; $j <= 9; $j++) { if ($i == 1 or $j == 1 and $unknown_time1 == 1) { continue; // do not allow Moon aspects for progressed planets, or for natal planets if birth time is unknown } $da = Abs($L2[$i] - $L1[$j]); if ($da > 180) { $da = 360 - $da; } $orb = 1.0; //orb = 1.0 degree // are planets within orb? $q = 1; if ($da <= $orb) { $q = 2; } elseif ($da <= 60 + $orb and $da >= 60 - $orb) { $q = 3; } elseif ($da <= 90 + $orb and $da >= 90 - $orb) { $q = 4; } elseif ($da <= 120 + $orb and $da >= 120 - $orb) { $q = 5;
imagettftext($im, 10, 0, $margins + $left_margin_planet_table + $cell_width * 2, $cell_height + $cell_height * ($i + 1) - 3, $blue, ARIAL_TTF, $pl_name[$i]); $sign_num1 = floor($longitude1[$i] / 30) + 1; drawboldtext($im, 14, 0, $margins + $left_margin_planet_table + $cell_width * 5, $cell_height + $cell_height * ($i + 1), $black, HAMBURG_TTF, chr($sign_glyph[$sign_num1]), 0); imagettftext($im, 10, 0, $margins + $left_margin_planet_table + $cell_width * 6, $cell_height + $cell_height * ($i + 1) - 3, $blue, ARIAL_TTF, Convert_Longitude($longitude1[$i]) . " " . $rx1[$i]); $sign_num2 = floor($longitude2[$i] / 30) + 1; if ($i != $last_planet_num - 2) { drawboldtext($im, 14, 0, $margins + $left_margin_planet_table + $cell_width * 10, $cell_height + $cell_height * ($i + 1), $red, HAMBURG_TTF, chr($sign_glyph[$sign_num2]), 0); imagettftext($im, 10, 0, $margins + $left_margin_planet_table + $cell_width * 11, $cell_height + $cell_height * ($i + 1) - 3, $blue, ARIAL_TTF, Convert_Longitude($longitude2[$i]) . " " . $rx2[$i]); } } // ------------------------------------------ // display the aspect glyphs in the aspect grid for ($i = 0; $i <= $last_planet_num; $i++) { for ($j = 0; $j <= $last_planet_num; $j++) { $q = 0; $da = Abs($longitude2[$j] - $longitude1[$i]); if ($da > 180) { $da = 360 - $da; } // set orb - 3 if Sun or Moon, 3 if not Sun or Moon if ($i == 0 or $i == 1 or $j == 0 or $j == 1) { $orb = 1; } else { $orb = 1; } // is there an aspect within orb? if ($da <= $orb) { $q = 1; } elseif ($da <= 60 + $orb and $da >= 60 - $orb) { $q = 6; } elseif ($da <= 90 + $orb and $da >= 90 - $orb) {
echo '</tr>'; // include Ascendant and MC $longitude1[LAST_PLANET + 1] = $hc1[1]; $longitude1[LAST_PLANET + 2] = $hc1[10]; $pl_name[LAST_PLANET + 1] = "Ascendant"; $pl_name[LAST_PLANET + 2] = "Midheaven"; if ($ubt1 == 1) { $a1 = SE_TNODE; } else { $a1 = LAST_PLANET + 2; } for ($i = 0; $i <= $a1; $i++) { echo "<tr><td colspan='4'> </td></tr>"; for ($j = 0; $j <= $a1; $j++) { $q = 0; $da = Abs($longitude1[$i] - $longitude1[$j]); if ($da > 180) { $da = 360 - $da; } // set orb - 8 if Sun or Moon, 6 if not Sun or Moon if ($i == SE_POF or $j == SE_POF) { $orb = 2; } elseif ($i == SE_LILITH or $j == SE_LILITH) { $orb = 3; } elseif ($i == SE_TNODE or $j == SE_TNODE) { $orb = 3; } elseif ($i == SE_VERTEX or $j == SE_VERTEX) { $orb = 3; } elseif ($i == 0 or $i == 1 or $j == 0 or $j == 1) { $orb = 8; } else {
<?php #------------------------------------------------------------------------------- /** @author Великодный В.В. (Joonte Ltd.) */ /******************************************************************************/ /******************************************************************************/ $__args_list = array('Time'); /******************************************************************************/ eval(COMP_INIT); /******************************************************************************/ /******************************************************************************/ $Stamp = Abs($Time); #------------------------------------------------------------------------------- if (!$Stamp) { return '-'; } #------------------------------------------------------------------------------- return ($Time < 0 ? '-' : '') . (($Day = (int) ($Stamp / 86400)) ? SPrintF(' %u дн.', $Day) : (($Hour = (int) (($Stamp - $Day * 86400) / 3600)) ? SPrintF(' %u ч.', $Hour) : (($Minutes = (int) (($Stamp - $Day * 86400 - $Hour * 3600) / 60)) ? SPrintF(' %u мин.', $Minutes) : (($Seconds = $Stamp - $Day * 86400 - $Hour * 3600 - $Minutes * 60) ? SPrintF(' %u сек.', $Seconds) : '-')))); #-------------------------------------------------------------------------------