示例#1
0
 public function test_main()
 {
     $this->assertEquals(0, tofloat(''));
     $this->assertEquals(1, tofloat(1));
     $this->assertEquals(-1, tofloat(-1));
     $this->assertEquals(1, tofloat('1'));
     $this->assertEquals(-1, tofloat('-1'));
     $this->assertEquals(1.1, tofloat('1.1'));
     $this->assertEquals(-1.1, tofloat('-1.1'));
     $this->assertEquals(1.1, tofloat('1,1'));
     $this->assertEquals(-1.1, tofloat('-1,1'));
     $this->assertEquals(0, tofloat(''));
     $this->assertEquals(0, tofloat('-'));
     $this->assertEquals(1999.369, tofloat('1.999,369€'));
     $this->assertEquals(-1999.369, tofloat('-1.999,369€'));
     $this->assertEquals(126564789.33, tofloat('126,564,789.33 m²'));
     $this->assertEquals(-126564789.33, tofloat('-126,564,789.33 m²'));
     $this->assertEquals(126564789.33, tofloat(126564789.33));
     $this->assertEquals(-126564789.33, tofloat(-126564789.33));
     $this->assertEquals(122.34343, tofloat('122.34343The'));
     $this->assertEquals(-122.34343, tofloat('-122.34343The'));
     $this->assertEquals(122.34343, tofloat(' 122.34343 The '));
     $this->assertEquals(122.34343, tofloat('The122.34343'));
     $this->assertEquals(-122.34343, tofloat('The-122.34343'));
     $this->assertEquals(0, tofloat('some string not containing numbers'));
     $this->assertEquals(1234, tofloat('01234'));
     $this->assertEquals(-1234, tofloat('-01234'));
     $this->assertEquals([12.341, 56.7811111], tofloat([12.341, '56,7811111']));
     $this->assertEquals([12.341, -56.7811111], tofloat([12.341, '-56,7811111']));
     $this->assertEquals([-12.341, -56.7811111], tofloat([-12.341, '-56,7811111']));
     $this->assertEquals(['k1' => 12.341, 'k2' => 56.7811111], tofloat(['k1' => 12.341, 'k2' => '56,7811111']));
     $this->assertEquals(['k1' => 12.341, 'k2' => [[56.7811111]]], tofloat(['k1' => 12.341, 'k2' => [['56,7811111']]]));
     $this->assertEquals(['k1' => 12.341, 'k2' => [[-56.7811111]]], tofloat(['k1' => 12.341, 'k2' => [['-56,7811111']]]));
 }
示例#2
0
/**
 * Das eigentliche Parsen der Tabelle
 * @param  [type] $table [description]
 * @param  [type] $dates [description]
 * @return [type]        [description]
 */
function tableToArr($table, $dates)
{
    foreach ($table->find('tr') as $rowNo => $row) {
        if ($rowNo == 0) {
            continue;
        }
        foreach ($row->find('td') as $clmNo => $clm) {
            if ($clmNo == 0) {
                $categoryPrice = trim(preg_replace('/^\\D*/', '', $clm->plaintext));
                $category = trim(str_replace(array($categoryPrice, "-\r\n ", "\t", "\r", "\n", "           ", "    "), '', $clm->plaintext));
            } else {
                foreach ($clm->find('div.speise_eintrag') as $article) {
                    if (empty($article)) {
                        continue;
                    }
                    $title = $article->plaintext;
                    $allergies = $price = array();
                    preg_match('/\\(([0-9A-Za-z,]+)\\)/', $title, $allergies);
                    // Matcht eingeklammerten Text
                    // Parse Allergiestoffe
                    if (array_key_exists(1, $allergies)) {
                        $title = str_replace($allergies[0], '', $title);
                    }
                    // entferne Allergiestoffe aus Titel
                    $allergies = array_key_exists(1, $allergies) ? explode(",", trim($allergies[0], "()")) : NULL;
                    preg_match('/(\\d{1,2},\\d{2})/', $title, $price);
                    // Matcht Dezimalzahlen
                    // Parse den Preis
                    if (array_key_exists(1, $price)) {
                        $title = str_replace($price[1], '', $title);
                    }
                    // entferne Preis aus Titel
                    $price = empty($price[1]) ? $categoryPrice : $price[1];
                    $title = trim(str_replace("  ", " ", $title));
                    $price = tofloat($price);
                    if (!array_key_exists($clmNo - 1, $dates) || empty($category) || empty($title)) {
                        continue;
                    }
                    $arr[$dates[$clmNo - 1]][$category][] = array('name' => $title, 'price' => $price, 'allergies' => $allergies);
                    unset($title, $price, $allergies);
                }
            }
        }
    }
    return $arr;
}
示例#3
0
 /**
  */
 function unit_edit()
 {
     $_GET['id'] = intval($_GET['id']);
     if (empty($_GET['id'])) {
         return _e('Empty ID!');
     }
     $unit_info = db()->query_fetch('SELECT * FROM ' . db('shop_product_units') . ' WHERE id=' . $_GET['id']);
     if (main()->is_post()) {
         if (!$_POST['title']) {
             _re('Unit title must be filled');
         }
         if (!common()->_error_exists()) {
             $sql_array = ['title' => $_POST['title'], 'description' => $_POST['description'], 'step' => intval($_POST['step']), 'k' => tofloat($_POST['k'])];
             db()->update('shop_product_units', _es($sql_array), 'id=' . $_GET['id']);
             common()->admin_wall_add(['shop product unit updated: ' . $_POST['title'], $_GET['id']]);
         }
         return js_redirect('./?object=' . main()->_get('object') . '&action=units');
     }
     $replace = ['title' => $unit_info['title'], 'description' => $unit_info['description'], 'step' => $unit_info['step'], 'k' => $unit_info['k'], 'form_action' => './?object=' . main()->_get('object') . '&action=unit_edit&id=' . $unit_info['id'], 'back_url' => './?object=' . main()->_get('object') . '&action=units'];
     return form($replace)->text('title')->textarea('description', 'Description')->text('step')->text('k')->save_and_back();
 }
示例#4
0
    /**
     */
    function view_order()
    {
        $_GET['id'] = intval($_GET['id']);
        if ($_GET['id']) {
            if ($this->SUPPLIER_ID) {
                $sql = 'SELECT o.* FROM ' . db('shop_orders') . ' AS o
						INNER JOIN ' . db('shop_order_items') . ' AS i ON i.order_id = o.id
						INNER JOIN ' . db('shop_products') . ' AS p ON i.product_id = p.id
						INNER JOIN ' . db('shop_admin_to_supplier') . ' AS m ON m.supplier_id = p.supplier_id
						WHERE
							o.id=' . intval($_GET['id']) . '
							AND m.admin_id=' . intval(main()->ADMIN_ID) . '
						GROUP BY o.id';
            } else {
                $sql = 'SELECT * FROM ' . db('shop_orders') . ' WHERE id=' . intval($_GET['id']);
            }
            $order_info = db()->query_fetch($sql);
        }
        if (empty($order_info)) {
            return _e('No such order');
        }
        $recount_price = false;
        $_class_price = _class('_shop_price', 'modules/shop/');
        $_class_units = _class('_shop_product_units', 'modules/shop/');
        $_class_basket = _class('shop_basket', 'modules/shop/');
        if (main()->is_post()) {
            module('manage_shop')->_product_check_first_revision('order', intval($_GET['id']));
            $order_id = (int) $_GET['id'];
            foreach ($_POST as $k => $v) {
                if ($k == 'status_item') {
                    foreach ($v as $k1 => $status) {
                        list($product_id, $param_id) = explode('_', $k1);
                        db()->UPDATE(db('shop_order_items'), ['status' => $status], ' order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id));
                    }
                } elseif ($k == 'delete') {
                    foreach ($v as $k1 => $is_del) {
                        list($product_id, $param_id) = explode('_', $k1);
                        if ($is_del == 1) {
                            db()->query('DELETE FROM ' . db('shop_order_items') . ' WHERE order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id));
                        }
                    }
                    $recount_price = true;
                } elseif ($k == 'qty') {
                    foreach ($v as $k1 => $qty) {
                        list($product_id, $param_id) = explode('_', $k1);
                        if (intval($qty) == 0) {
                            db()->query('DELETE FROM ' . db('shop_order_items') . ' WHERE order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id));
                        } else {
                            db()->UPDATE(db('shop_order_items'), ['quantity' => intval($qty)], ' order_id=' . $_GET['id'] . ' AND product_id=' . intval($product_id) . ' AND param_id=' . intval($param_id));
                        }
                        $recount_price = true;
                    }
                } elseif ($k == 'unit') {
                    foreach ($v as $k1 => $unit) {
                        $unit = (int) $unit;
                        list($product_id, $param_id) = explode('_', $k1);
                        $product_id = (int) $product_id;
                        $param_id = (int) $param_id;
                        if ($unit > 0) {
                            $units = $_class_units->get_by_product_ids($product_id);
                            if (isset($units[$product_id][$unit])) {
                                db()->UPDATE(db('shop_order_items'), ['unit' => $unit], ' order_id=' . $order_id . ' AND product_id=' . $product_id . ' AND param_id=' . $param_id);
                                $products = db_get_all('SELECT * FROM ' . db('shop_products') . ' WHERE id = ' . $product_id);
                                $product = $products[$product_id];
                                list($price) = $_class_price->markup_down($product['price'], $product_id);
                                $item = ['price' => $price, 'unit' => $unit, 'units' => $units[$product_id]];
                                $price_one = $_class_basket->_get_price_one($item);
                                $item = ['order_id' => $order_id, 'product_id' => $product_id, 'param_id' => $param_id];
                                $item_price = $item + ['price' => $price_one];
                                $this->_item_update_price_unit($item_price);
                                $recount_price = true;
                            }
                        }
                    }
                } elseif ($k == 'price_unit') {
                    foreach ($v as $k1 => $price) {
                        list($product_id, $param_id) = explode('_', $k1);
                        $this->_item_update_price_unit(['price' => $price, 'order_id' => $order_id, 'product_id' => (int) $product_id, 'param_id' => (int) $param_id]);
                        $recount_price = true;
                    }
                }
            }
            $sql = [];
            foreach (['address', 'phone', 'address', 'house', 'apartment', 'floor', 'porch', 'intercom', 'delivery_price', 'status', 'region', 'discount', 'discount_add', 'delivery_type', 'delivery_id', 'delivery_location'] as $f) {
                if (isset($_POST[$f])) {
                    $sql[$f] = $_POST[$f];
                    if ($f == 'delivery_price' && $_POST['delivery_price'] != $order_info['delivery_price']) {
                        $sql['is_manual_delivery_price'] = 1;
                        $order_info['is_manual_delivery_price'] = 1;
                        $order_info['delivery_price'] = $sql['delivery_price'];
                        $recount_price = true;
                    }
                    if ($f == 'discount') {
                        $discount = $_class_price->_number_mysql($sql['discount']);
                        $order_info['discount'] = $discount;
                        $sql['discount'] = $discount;
                        $recount_price = true;
                    }
                    if ($f == 'discount_add') {
                        $discount = $_class_price->_number_mysql($sql['discount_add']);
                        $order_info['discount_add'] = $discount;
                        $sql['discount_add'] = $discount;
                    }
                    if ($f == 'delivery_id') {
                        $value = (int) $sql[$f];
                        $value = $value > 0 ? $value : $order_info[$f];
                        $sql[$f] = $value;
                    }
                    if ($f == 'delivery_type') {
                        $value = (int) $sql[$f];
                        $order_info['payment'] = $value;
                        $sql['payment'] = $value;
                    }
                }
            }
            if (count($sql) > 0) {
                db()->update_safe(db('shop_orders'), $sql, 'id=' . intval($_GET['id']));
            }
            if ($recount_price) {
                list($order_info['total_sum'], $order_info['delivery_price']) = $this->_order_recount_price($order_info['id'], $order_info);
            }
            module('manage_shop')->_order_add_revision('edit', intval($_GET['id']));
            return js_redirect('./?object=' . main()->_get('object') . '&action=view_order&id=' . $order_info['id']);
        }
        $products_ids = [];
        $Q = db()->query('SELECT * FROM ' . db('shop_order_items') . ' WHERE `order_id`=' . intval($order_info['id']));
        while ($_info = db()->fetch_assoc($Q)) {
            if ($_info['product_id']) {
                $products_ids[$_info['product_id']] = $_info['product_id'];
            }
            $order_items[$_info['product_id'] . "_" . $_info['param_id']] = $_info;
        }
        if (!empty($products_ids)) {
            $products_infos = db()->query_fetch_all('SELECT * FROM ' . db('shop_products') . ' WHERE id IN(' . implode(',', $products_ids) . ')');
            $products_atts = module('manage_shop')->_get_products_attributes($products_ids);
        }
        $price_total = 0;
        foreach ((array) $order_items as $_info) {
            $_product = $products_infos[$_info['product_id']];
            $_units = [];
            if (intval($_info['type']) == 1) {
                $images[0]['thumb'] = _class('_shop_products', 'modules/shop/')->_product_set_image($_info["product_id"], $_product['cat_id'], 'thumb', false);
                $link = './?object=' . main()->_get('object') . '&action=product_set_edit&id=' . $_info['product_id'];
            } else {
                $images = _class('_shop_products', 'modules/shop/')->_product_image($_info["product_id"], false, false);
                $link = './?object=' . main()->_get('object') . '&action=product_edit&id=' . $_info['product_id'];
                $_units = $_class_units->get_by_product_ids($_info['product_id']);
            }
            $image = $images[0]['thumb'] ?: _class('_shop_categories', 'modules/shop/')->get_icon_url($_product['cat_id'], 'item');
            $dynamic_atts = [];
            if (strlen($_info['attributes']) > 3) {
                foreach ((array) unserialize($_info['attributes']) as $_attr_id) {
                    $_attr_info = $products_atts[$_info['product_id']][$_attr_id];
                    $dynamic_atts[$_attr_id] = '- ' . $_attr_info['name'] . ' ' . $_attr_info['value'];
                    $price += $_attr_info['price'];
                }
            }
            $product_id = (int) $_info['product_id'];
            $param_id = (int) $_info['param_id'];
            $price_one = tofloat($_info['price']);
            $quantity = (int) $_info['quantity'];
            $price_item = $price_one * $quantity;
            // product unit
            $unit = (int) $_info['unit'];
            $units = null;
            $unit_name = 'шт.';
            if ($_units[$product_id]) {
                $units = $_units[$product_id];
                $units[$unit] && ($unit_name = $units[$unit]['title']);
            }
            $products[$_info['product_id'] . '_' . $_info['param_id']] = ['product_id' => intval($_info['product_id']), 'param_id' => intval($_info['param_id']), 'param_name' => _class('_shop_product_params', 'modules/shop/')->_get_name_by_option_id($_info['param_id']), 'name' => _prepare_html($_product['name']), 'image' => $image, 'link' => $link, 'unit' => $unit, 'unit_name' => $unit_name, 'units' => $units, 'price_unit' => $price_one, 'price' => $price_item, 'currency' => _prepare_html(module('manage_shop')->CURRENCY), 'quantity' => intval($_info['quantity']), 'details_link' => process_url('./?object=' . main()->_get('object') . '&action=view&id=' . $_product['id']), 'dynamic_atts' => !empty($dynamic_atts) ? implode('<br />' . PHP_EOL, $dynamic_atts) : '', 'status' => module('manage_shop')->_box('status_item', $_info['status']), 'delete' => ''];
            $price_total += $price_item;
        }
        // discount
        $discount = $order_info['discount'];
        $discount_add = $order_info['discount_add'];
        $_discount = $discount;
        $discount_price = $_class_price->apply_price($price_total, $_discount);
        $discount_price -= $price_total;
        $discount_price = $_class_price->_number_round($discount_price);
        $_discount = $discount_add;
        $discount_add_price = $_class_price->apply_price($price_total, $_discount);
        $discount_add_price -= $price_total;
        $total_price = tofloat($order_info['total_sum']);
        $replace = my_array_merge($replace, _prepare_html($order_info));
        $replace = my_array_merge($replace, ['form_action' => './?object=' . main()->_get('object') . '&action=' . $_GET['action'] . '&id=' . $_GET['id'], 'order_id' => $order_info['id'], 'price_total_info' => module('manage_shop')->_format_price($price_total), 'discount' => $_class_price->_number_format($discount), 'discount_add' => $_class_price->_number_format($discount_add), 'discount_price_info' => $_class_price->_price_format($discount_price), 'discount_add_price_info' => $_class_price->_price_format($discount_add_price), 'delivery_info' => module('manage_shop')->_format_price($order_info['delivery_price']), 'total_sum' => module('manage_shop')->_format_price($total_price), 'user_link' => _profile_link($order_info['user_id']), 'user_name' => _display_name(user($order_info['user_id'])), 'error_message' => _e(), 'products' => (array) $products, 'total_price' => module('manage_shop')->_format_price($total_price), 'ship_type' => module('manage_shop')->_ship_types[$order_info['ship_type']], 'pay_type' => module('manage_shop')->_pay_types[$order_info['pay_type']], 'date' => $order_info['date'], 'status_box' => module('manage_shop')->_box('status', $order_info['status']), 'back_url' => './?object=' . main()->_get('object') . '&action=show_orders', 'print_url' => './?object=' . main()->_get('object') . '&action=show_print&id=' . $order_info['id'], 'payment' => common()->get_static_conf('payment_methods', $order_info['payment'])]);
        $link_invoice = './?object=manage_shop&action=invoice&id=' . $replace['id'];
        $link_invoice_add = $link_invoice . '&with_discount_add=y';
        $link_pdf_invoice = $link_invoice . '&pdf=y';
        $link_pdf_invoice_add = $link_invoice_add . '&pdf=y';
        $region = _class('_shop_region', 'modules/shop/')->_get_list();
        array_unshift($region, '- регион не выбран -');
        $out = form2($replace, ['dd_mode' => 1, 'big_labels' => true])->info('id')->info('price_total_info', ['desc' => 'Сумма'])->row_start(['desc' => 'Скидка, %'])->number('discount', ['desc' => 'Скидка, %'])->info('discount_price_info')->link('Invoice', $link_invoice, ['title' => 'Накладная без учета добавочной скидки', 'icon' => 'fa fa-file-o', 'target' => '_blank'])->link('PDF', $link_pdf_invoice, ['title' => 'Накладная PDF без учета добавочной скидки', 'icon' => 'fa fa-file-text-o', 'target' => '_blank'])->row_end()->row_start(['desc' => 'Скидка добавочная, %'])->number('discount_add', ['desc' => 'Скидка добавочная, %'])->info('discount_add_price_info', ['desc' => ' '])->link(t('Invoice') . '+', $link_invoice_add, ['title' => 'Накладная с учетом добавочной скидки', 'icon' => 'fa fa-file-o', 'target' => '_blank'])->link(t('PDF') . '+', $link_pdf_invoice_add, ['title' => 'Накладная PDF с учетом добавочной скидки', 'icon' => 'fa fa-file-text-o', 'target' => '_blank'])->row_end()->info('delivery_info', ['desc' => 'Доставка'])->info('total_sum', '', ['desc' => 'Итоговая сумма', 'tip' => 'Итоговая сумма без учета добавочной скидки', 'no_escape' => 1])->info_date('date', ['format' => 'full'])->info('name')->email('email')->info('phone')->container('<a href="./?object=' . main()->_get('object') . '&action=send_sms&phone=' . urlencode($replace["phone"]) . '" class="btn">Send SMS</a><br /><br />')->select_box('region', $region, ['desc' => 'Регион доставки', 'class_add_wrapper' => 'region_type_wrap'])->select_box('delivery_type', _class('_shop_delivery', 'modules/shop/')->_get_types(), ['desc' => 'Тип доставки', 'class_add_wrapper' => 'delivery_type_wrap'])->select_box('delivery_id', _class('_shop_delivery', 'modules/shop/')->_get_locations_by_type($replace['delivery_type']), ['class' => 'delivery_id', 'class_add_wrapper' => 'delivery_id_wrap', 'desc' => 'Отделение'])->text('delivery_location', 'Отделение доставки', ['class' => 'delivery_location', 'class_add_wrapper' => 'delivery_location_wrap'])->text('address')->text('house')->text('apartment')->text('floor')->text('porch')->text('intercom')->info('comment')->text('delivery_time')->price('delivery_price')->user_info('user_id')->info('payment', 'Payment method')->info('transaction_id', 'Transaction id')->container(table2($products)->image('product_id', ['width' => '50px', 'no_link' => true, 'web_path' => '', 'img_path_check' => false, 'img_path_callback' => function ($_p1, $_p2, $row) {
            return $row['image'];
        }])->func('link', function ($f, $p, $row) {
            $result = "<a class='btn' href='{$row[link]}'>{$row[product_id]}</a>";
            return $result;
        })->func('name', function ($f, $p, $row) {
            $row['name'] = $row['name'] . ($row['param_name'] != '' ? "<br /><small>" . $row['param_name'] . "</small>" : '');
            return $row['name'];
        })->func('unit', function ($f, $p, $row) {
            $values = [];
            if (!empty($row['units'])) {
                $values[0] = ' - ';
                foreach ($row['units'] as $id => $item) {
                    $values[$id] = $item['title'];
                }
            }
            $desc = 'Ед. измерения';
            $width = '7em';
            $result = sprintf('
									<style>
										.unit_current {
											width: %s;
										}
									</style>
									<div class="unit_current">
										%s
										<span class="btn btn-mini unit_change">
											<i class="icon-edit fa fa-edit"></i>
										</span>
									</div>
									', $width, $row['unit_name']) . _class('html')->select2_box(['desc' => $desc, 'name' => 'unit[' . $row['product_id'] . '_' . $row['param_id'] . ']', 'values' => $values, 'js_options' => ['width' => $width, 'containerCssClass' => 'select2_box']]);
            return $result;
        })->func('quantity', function ($f, $p, $row) {
            $row['quantity'] = "<input type='text' name='qty[" . $row['product_id'] . "_" . $row['param_id'] . "]' value='" . intval($row['quantity']) . "' style='width:50px;'>";
            return $row['quantity'];
        })->func('price_unit', function ($f, $p, $row) {
            $row['price_unit'] = "<input type='text' name='price_unit[" . $row['product_id'] . "_" . $row['param_id'] . "]' value='" . $row['price_unit'] . "' style='width:100px;'>";
            return $row['price_unit'];
        })->text('price')->func('status', function ($f, $p, $row) {
            $row['status'] = str_replace("status_item", "status_item[" . $row['product_id'] . "_" . $row['param_id'] . "]", $row['status']);
            return $row['status'];
        })->func('delete', function ($f, $p, $row) {
            $row['delete'] = "<input type='checkbox' name='delete[" . $row['product_id'] . "_" . $row['param_id'] . "]' value='1'>";
            return $row['delete'];
        }), ['wide' => 1])->container(tpl()->parse('manage_shop/product_search_order', ['order_id' => $_GET['id']]), 'Add product')->box('status_box', 'Status order', ['selected' => $order_info['status']])->save_and_back();
        // misc handlers
        css('
			.select2_box {
				display: none;
			}
			.unit_current {
				position : relative;
			}
			.btn.unit_change {
				display  : none;
				position : absolute;
				right    : 0;
			}
		');
        jquery('
			$(".delivery_id").on( "change", function( event ) {
				var location =  $(this).find( "option:selected" ).text();
				$(".delivery_location").val( location );
			});
			var delivery_type__on_change = function( target ) {
				var value = +$(target).find( "option:selected" ).val();
				if( value == 1 ) {
					$(".delivery_id_wrap").hide();
					$(".delivery_location_wrap").hide();
				} else if( value == 2 ) {
					var count = +$(".delivery_id_wrap").find( "option" ).length;
					if( count > 1 ) {
						$(".delivery_id_wrap").show();
						$(".delivery_location_wrap").show();
					}
				}
			}
			delivery_type__on_change( $(".delivery_type_wrap") );

			$(".delivery_type_wrap").on( "change", function( event ) {
				delivery_type__on_change( event.target );
			});
			$( ".unit_change" ).on( "click", function( event ) {
				var $this = $( this );
				var $select2 = $this.parent().next();
				$select2.toggle()
			}).each( function( i ) {
				var $this = $( this );
				if( $this.parent().next().length ) {
					$this.show();
				}
			});
		');
        // get similar orders
        $sql = "SELECT o.*, COUNT(*) AS num_items FROM `" . db('shop_orders') . "` AS `o`\n\t\t\t\tINNER JOIN " . db('shop_order_items') . " AS i ON i.order_id = o.id\n\t\t\t\tWHERE `o`.`id`!='" . $order_info['id'] . "'\n\t\t\t\t\tAND `o`.`phone`='" . $order_info['phone'] . "'\n\t\t\t\t\tAND `o`.`status`='" . $order_info['status'] . "'\n\t\t\t\tGROUP BY o.id ORDER BY o.id DESC";
        $out .= "<br /><br /><h3>" . t('Similar orders') . "</h3>" . table($sql)->text('id')->date('date', ['format' => 'full', 'nowrap' => 1])->user('user_id')->text('name')->text('phone')->text('total_sum', ['nowrap' => 1])->text('num_items')->btn_edit('', './?object=' . main()->_get('object') . '&action=view_order&id=%d', ['no_ajax' => 1])->btn('Merge', './?object=' . main()->_get('object') . '&action=merge_order&id=' . $order_info['id'] . '&merge_id=%d', ['no_ajax' => 1]);
        //		$out .= tpl()->parse('manage_shop/product_search',array());
        return $out;
    }
示例#5
0
 function displayMachineriesList($machineriesList)
 {
     $this->tpl->set_block("rptsTemplate", "MachineriesDBEmpty", "MachineriesDBEmptyBlock");
     $this->tpl->set_var("MachineriesDBEmptyBlock", "");
     $this->tpl->set_block("rptsTemplate", "defaultMachineriesList", "defaultMachineriesListBlock");
     $this->tpl->set_block("rptsTemplate", "toggleMachineriesList", "toggleMachineriesListBlock");
     if (count($machineriesList)) {
         //$this->tpl->set_block("rptsTemplate", "hideMachineriesList", "hideMachineriesListBlock");
         $this->tpl->set_block("rptsTemplate", "MachineriesList", "MachineriesListBlock");
         $i = 0;
         $totalMarketValue = 0;
         $totalAssessedValue = 0;
         foreach ($machineriesList as $key => $value) {
             $totalMarketValue += tofloat($value->getAdjustedMarketValue());
             $totalAssessedValue += tofloat($value->getAssessedValue());
             $this->displayDetails($value);
             foreach ($value as $lkey => $lvalue) {
                 if (is_numeric($lvalue)) {
                     switch ($lkey) {
                         //case "kind":
                         //	$machineriesClasses = new MachineriesClasses;
                         //	$machineriesClasses->selectRecord($lvalue);
                         //	$this->tpl->set_var("kind", $machineriesClasses->getDescription());
                         //	break;
                         case "actualUse":
                             $machineriesActualUses = new MachineriesActualUses();
                             $machineriesActualUses->selectRecord($lvalue);
                             $this->tpl->set_var("actualUse", $machineriesActualUses->getDescription());
                             break;
                     }
                 }
             }
             $this->tpl->set_var("ctr", $i);
             $this->tpl->parse("defaultMachineriesListBlock", "defaultMachineriesList", true);
             $this->tpl->parse("toggleMachineriesListBlock", "toggleMachineriesList", true);
             //$this->tpl->parse("hideMachineriesListBlock", "hideMachineriesList", true);
             $this->setMachineriesListBlockPerms();
             $this->tpl->parse("MachineriesListBlock", "MachineriesList", true);
             $i++;
         }
         $this->formArray["totalMarketValue"] += $totalMarketValue;
         $this->formArray["totalAssessedValue"] += $totalAssessedValue;
         $this->formArray["machTotalMarketValue"] = $totalMarketValue;
         $this->formArray["machTotalAssessedValue"] = $totalAssessedValue;
         $this->tpl->set_var("machineriesCtr", $i);
     } else {
         $this->tpl->set_var("defaultMachineriesListBlock", "");
         $this->tpl->set_var("toggleMachineriesListBlock", "");
     }
 }
示例#6
0
 function todecimal($num = 0, $digits = 2)
 {
     if (is_array($num)) {
         return array_map(__FUNCTION__, $num);
     }
     return str_replace(',', '.', round(tofloat($num), $digits));
 }
示例#7
0
文件: about.php 项目: nofuyun/tool
    <h2>Full name for user <b>john</b>:</h2>
    <?php 
echo $data['user']['john'];
?>

    <hr/>
    <h2>Full name for user <b>john</b> UPPER case:</h2>
    <?php 
echo upper($data['user']['john']);
?>

    <hr/>
    <h2>Total user:</h2>
    <p>Associative array usage</p>
    Male = <?php 
echo tofloat($data['member']['total']['male']);
?>
 <br/>
    Female = <?php 
echo $data['member']['total']['female'];
?>
<br/>
    Female = <?php 
echo sample_with_args($data['member']['total']['female'], 'we female');
?>
<br/>
    Female = <?php 
echo TRIPLE($data['member']['total']['female'], ' x3 female + ', 1000);
?>
<br/>
    <br/>
示例#8
0
文件: TDDetails.php 项目: armic/erpts
 function Main()
 {
     $this->tpl->set_block("rptsTemplate", "TDList", "TDListBlock");
     $this->tpl->set_block("rptsTemplate", "TDDBEmpty", "TDDBEmptyBlock");
     $this->tpl->set_var("TDDBEmptyBlock", "");
     $this->tpl->set_block("TDList", "Land", "LandBlock");
     $this->tpl->set_block("TDList", "PlantsTrees", "PlantsTreesBlock");
     $this->tpl->set_block("TDList", "ImprovementsBuildings", "ImprovementsBuildingsBlock");
     $this->tpl->set_block("TDList", "Machineries", "MachineriesBlock");
     $propertyType = $this->formArray["propertyType"];
     $propertyID = $this->formArray["propertyID"];
     switch ($propertyType) {
         case "Land":
             $LandDetails = new SoapObject(NCCBIZ . "LandDetails.php", "urn:Object");
             if (!($xmlStr = $LandDetails->getLand($propertyID))) {
                 echo "xml failed";
             } else {
                 //echo $xmlStr;
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                     $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                 } else {
                     $land = new Land();
                     $land->parseDomDocument($domDoc);
                     //$land->selectRecord($propertyID);
                     $this->formArray["landTotalMarketValue"] += tofloat($land->getMarketValue());
                     $this->formArray["landTotalAssessedValue"] += tofloat($land->getAssessedValue());
                     $this->displayLand($land);
                     //echo $this->formArray["landTotalAssessedValue"];
                 }
             }
             $this->tpl->set_var("PlantsTreesBlock", "");
             $this->tpl->set_var("ImprovementsBuildingsBlock", "");
             $this->tpl->set_var("MachineriesBlock", "");
             break;
         case "PlantsTrees":
             $PlantsTreesDetails = new SoapObject(NCCBIZ . "PlantsTreesDetails.php", "urn:Object");
             if (!($xmlStr = $PlantsTreesDetails->getPlantsTrees($propertyID))) {
                 echo "xml failed";
             } else {
                 //echo $xmlStr;
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                     $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                 } else {
                     $plantsTrees = new PlantsTrees();
                     $plantsTrees->parseDomDocument($domDoc);
                     //$plantsTrees->selectRecord($propertyID);
                     $this->formArray["plantTotalMarketValue"] += tofloat($plantsTrees->getMarketValue());
                     $this->formArray["plantTotalAssessedValue"] += tofloat($plantsTrees->getAssessedValue());
                     $this->displayPlantsTrees($plantsTrees);
                 }
             }
             $this->tpl->set_var("LandBlock", "");
             $this->tpl->set_var("ImprovementsBuildingsBlock", "");
             $this->tpl->set_var("MachineriesBlock", "");
             break;
         case "ImprovementsBuildings":
             $ImprovementsBuildingsDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsDetails.php", "urn:Object");
             if (!($xmlStr = $ImprovementsBuildingsDetails->getImprovementsBuildings($propertyID))) {
                 echo "xml failed";
             } else {
                 //echo $xmlStr;
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                     $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                 } else {
                     $improvementsBuildings = new ImprovementsBuildings();
                     $improvementsBuildings->parseDomDocument($domDoc);
                     //$improvementsBuildings->selectRecord($propertyID);
                     $this->formArray["bldgTotalMarketValue"] += tofloat($improvementsBuildings->getMarketValue());
                     $this->formArray["bldgTotalAssessedValue"] += tofloat($improvementsBuildings->getAssessedValue());
                     $this->displayImprovementsBuildings($improvementsBuildings);
                 }
             }
             $this->tpl->set_var("LandBlock", "");
             $this->tpl->set_var("PlantsTreesBlock", "");
             $this->tpl->set_var("MachineriesBlock", "");
             break;
         case "Machineries":
             $MachineriesDetails = new SoapObject(NCCBIZ . "MachineriesDetails.php", "urn:Object");
             if (!($xmlStr = $MachineriesDetails->getMachineries($propertyID))) {
                 echo "xml failed";
             } else {
                 //echo $xmlStr;
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                     $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                 } else {
                     $machineries = new Machineries();
                     $machineries->parseDomDocument($domDoc);
                     //$machineries->selectRecord($propertyID);
                     $this->formArray["machTotalMarketValue"] += tofloat($machineries->getMarketValue());
                     $this->formArray["machTotalAssessedValue"] += tofloat($machineries->getAssessedValue());
                     $this->displayMachineries($machineries);
                 }
             }
             $this->tpl->set_var("LandBlock", "");
             $this->tpl->set_var("PlantsTreesBlock", "");
             $this->tpl->set_var("ImprovementsBuildingsBlock", "");
             break;
         default:
             $this->tpl->set_block("TDList", "Land", "LandBlock");
             $this->tpl->set_var("LandBlock", "");
             $this->tpl->set_block("TDList", "PlantsTrees", "PlantsTreesBlock");
             $this->tpl->set_var("PlantsTreesBlock", "");
             $this->tpl->set_block("TDList", "ImprovementsBuildings", "ImprovementsBuildingsBlock");
             $this->tpl->set_var("ImprovementsBuildingsBlock", "");
             $this->tpl->set_block("TDList", "Machineries", "MachineriesBlock");
             $this->tpl->set_var("MachineriesBlock", "");
             $this->tpl->set_block("TDList", "TD", "TDBlock");
             $this->tpl->set_var("TDBlock", "");
     }
     $TDEncode = new SoapObject(NCCBIZ . "TDEncode.php", "urn:Object");
     $this->formArray["afsID"] = $TDEncode->getAfsID($this->formArray["tdID"]);
     $afs = new AFS();
     $this->formArray["odID"] = $afs->checkOdID($this->formArray["afsID"]);
     $ODEncode = new SoapObject(NCCBIZ . "ODEncode.php", "urn:Object");
     $this->formArray["ownerID"] = $ODEncode->getOwnerID($this->formArray["odID"]);
     $OwnerList = new SoapObject(NCCBIZ . "OwnerList.php", "urn:Object");
     if (!($xmlStr = $OwnerList->getOwnerList($this->formArray["ownerID"]))) {
         //exit(print_r($OwnerList));
         $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
         $this->tpl->set_var("OwnerListTableBlock", "");
     } else {
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
             $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
         } else {
             $this->displayOwnerList($domDoc);
         }
     }
     $this->setForm();
     $this->tpl->parse("TDListBlock", "TDList", true);
     $this->tpl->set_var("Session", $this->sess->url("") . $this->sess->add_query(array("tdID" => $this->formArray["rtdID"])));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
示例#9
0
 function Main()
 {
     $propertyType = $this->formArray["propertyType"];
     $propertyID = $this->formArray["propertyID"];
     switch ($propertyType) {
         case "Land":
             $LandDetails = new SoapObject(NCCBIZ . "LandDetails.php", "urn:Object");
             if (!($xmlStr = $LandDetails->getLand($propertyID))) {
                 echo "xml failed";
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     echo "error open xml";
                 } else {
                     $land = new Land();
                     $land->parseDomDocument($domDoc);
                     $this->formArray["landTotalMarketValue"] += tofloat($land->getMarketValue());
                     $this->formArray["landTotalAssessedValue"] += tofloat($land->getAssessedValue());
                     $this->displayLand($land);
                 }
             }
             break;
         case "PlantsTrees":
             $PlantsTreesDetails = new SoapObject(NCCBIZ . "PlantsTreesDetails.php", "urn:Object");
             if (!($xmlStr = $PlantsTreesDetails->getPlantsTrees($propertyID))) {
                 echo "xml failed";
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     echo "error open xml";
                 } else {
                     $plantsTrees = new PlantsTrees();
                     $plantsTrees->parseDomDocument($domDoc);
                     //$plantsTrees->selectRecord($propertyID);
                     $this->formArray["plantTotalMarketValue"] += tofloat($plantsTrees->getMarketValue());
                     $this->formArray["plantTotalAssessedValue"] += tofloat($plantsTrees->getAssessedValue());
                     $this->displayPlantsTrees($plantsTrees);
                 }
             }
             break;
         case "ImprovementsBuildings":
             $ImprovementsBuildingsDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsDetails.php", "urn:Object");
             if (!($xmlStr = $ImprovementsBuildingsDetails->getImprovementsBuildings($propertyID))) {
                 echo "xml failed";
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     echo "error open xml";
                 } else {
                     $improvementsBuildings = new ImprovementsBuildings();
                     $improvementsBuildings->parseDomDocument($domDoc);
                     $this->formArray["bldgTotalMarketValue"] += tofloat($improvementsBuildings->getMarketValue());
                     $this->formArray["bldgTotalAssessedValue"] += tofloat($improvementsBuildings->getAssessedValue());
                     $this->displayImprovementsBuildings($improvementsBuildings);
                 }
             }
             break;
         case "Machineries":
             $MachineriesDetails = new SoapObject(NCCBIZ . "MachineriesDetails.php", "urn:Object");
             if (!($xmlStr = $MachineriesDetails->getMachineries($propertyID))) {
                 echo "xml failed";
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     echo "error open xml";
                 } else {
                     $machineries = new Machineries();
                     $machineries->parseDomDocument($domDoc);
                     $this->formArray["machTotalMarketValue"] += tofloat($machineries->getMarketValue());
                     $this->formArray["machTotalAssessedValue"] += tofloat($machineries->getAssessedValue());
                     $this->displayMachineries($machineries);
                 }
             }
             break;
         default:
             echo "wrong property type";
     }
     //$this->setForm();
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $testpdf = new PDFWriter();
     $testpdf->setOutputXML($this->tpl->get("templatePage"), "test");
     if (isset($this->formArray["print"])) {
         $testpdf->writePDF($name);
         //,$this->formArray["print"]);
     } else {
         $testpdf->writePDF($name);
     }
     header("location: " . $testpdf->pdfPath);
     exit;
 }
function get_stats_w($cmd, $options)
{
    $cmd = "{$cmd} w";
    $str = `{$cmd}`;
    $result = array('STAT_loadavg' => null, 'STAT_numusers' => null);
    foreach (explode("\n", $str) as $line) {
        if (preg_match_all('/\\S+/', $line, $words)) {
            $words = $words[0];
            if ($words[1] == "up") {
                for ($i = 0; $i < count($words); ++$i) {
                    if ($words[$i] == 'users,' || $words[$i] == 'user,') {
                        $result['STAT_numusers'] = $words[$i - 1];
                    } elseif ($words[$i] == 'average:') {
                        # TODO should it choose 5/1 minute avg based on poll interval?
                        $result['STAT_loadavg'] = tofloat($words[$i + 1]);
                    }
                }
            }
        }
    }
    return $result;
}
示例#11
0
 function displayMachineriesList($machineriesList)
 {
     $this->tpl->set_block("rptsTemplate", "MachineriesDBEmpty", "MachineriesDBEmptyBlock");
     $this->tpl->set_var("MachineriesDBEmptyBlock", "");
     $this->tpl->set_block("rptsTemplate", "defaultMachineriesList", "defaultMachineriesListBlock");
     $this->tpl->set_block("rptsTemplate", "toggleMachineriesList", "toggleMachineriesListBlock");
     if (count($machineriesList)) {
         //$this->tpl->set_block("rptsTemplate", "hideMachineriesList", "hideMachineriesListBlock");
         $this->tpl->set_block("rptsTemplate", "MachineriesList", "MachineriesListBlock");
         $i = 0;
         $totalMarketValue = 0;
         $totalAssessedValue = 0;
         foreach ($machineriesList as $key => $value) {
             $totalMarketValue += tofloat($value->getMarketValue());
             $totalAssessedValue += tofloat($value->getAssessedValue());
             $this->displayDetails($value);
             $this->tpl->set_var("ctr", $i);
             $this->tpl->parse("defaultMachineriesListBlock", "defaultMachineriesList", true);
             $this->tpl->parse("toggleMachineriesListBlock", "toggleMachineriesList", true);
             //$this->tpl->parse("hideMachineriesListBlock", "hideMachineriesList", true);
             $this->tpl->parse("MachineriesListBlock", "MachineriesList", true);
             $i++;
         }
         $this->formArray["totalMarketValue"] += $totalMarketValue;
         $this->formArray["totalAssessedValue"] += $totalAssessedValue;
         $this->formArray["machTotalMarketValue"] = $totalMarketValue;
         $this->formArray["machTotalAssessedValue"] = $totalAssessedValue;
         $this->tpl->set_var("machineriesCtr", $i);
     } else {
         $this->tpl->set_var("defaultMachineriesListBlock", "");
         $this->tpl->set_var("toggleMachineriesListBlock", "");
     }
 }
示例#12
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "remove":
             //echo "removeOwnerRPTOP(".$this->formArray["rptopID"].",".$this->formArray["ownerID"].",".$this->formArray["personID"].",".$this->formArray["companyID"].")";
             $OwnerList = new SoapObject(NCCBIZ . "OwnerList.php", "urn:Object");
             if (count($this->formArray["personID"]) || count($this->formArray["companyID"])) {
                 if (!($deletedRows = $OwnerList->removeOwnerRPTOP($this->formArray["rptopID"], $this->formArray["ownerID"], $this->formArray["personID"], $this->formArray["companyID"]))) {
                     $this->tpl->set_var("msg", "SOAP failed");
                     //echo "SOAP failed";
                 } else {
                     $this->tpl->set_var("msg", $deletedRows . " records deleted");
                 }
             } else {
                 $this->tpl->set_var("msg", "0 records deleted");
             }
             /*
             				if (count($this->formArray["companyID"])) {
             					//print_r($this->formArray["companyID"]);
             					//exit;
             					if (!$deletedRows = $OwnerList->removeOwnerCompanyRPTOP($this->formArray["rptopID"],$this->formArray["ownerID"],$this->formArray["companyID"])){
             						$this->tpl->set_var("msg", "SOAP failed");
             						echo "SOAP failed";
             					}
             					else{
             						$this->tpl->set_var("msg", $deletedRows." records deleted");
             					}
             				}
             				else $this->tpl->set_var("msg", "0 records deleted");*/
             header("location: RPTOPDetails.php" . $this->sess->url("") . $this->sess->add_query(array("rptopID" => $this->formArray["rptopID"])));
             exit;
             break;
         default:
             $this->tpl->set_var("msg", "");
     }
     //select
     $RPTOPDetails = new SoapObject(NCCBIZ . "RPTOPDetails.php", "urn:Object");
     if (!($xmlStr = $RPTOPDetails->getRPTOP($this->formArray["rptopID"]))) {
         exit("xml failed");
     } else {
         //echo $xmlStr;
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
             $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
         } else {
             $rptop = new RPTOP();
             $rptop->parseDomDocument($domDoc);
             foreach ($rptop as $key => $value) {
                 switch ($key) {
                     case "owner":
                         //$RPTOPEncode = new SoapObject(NCCBIZ."RPTOPEncode.php", "urn:Object");
                         if (is_a($value, "Owner")) {
                             $this->formArray["ownerID"] = $rptop->owner->getOwnerID();
                             $xmlStr = $rptop->owner->domDocument->dump_mem(true);
                             if (!$xmlStr) {
                                 $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                                 $this->tpl->set_var("OwnerListTableBlock", "");
                             } else {
                                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                                     $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                                     $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                                 } else {
                                     $this->displayOwnerList($domDoc);
                                 }
                             }
                         } else {
                             $this->tpl->set_block("rptsTemplate", "PersonList", "PersonListBlock");
                             $this->tpl->set_var("PersonListBlock", "");
                             $this->tpl->set_block("rptsTemplate", "CompanyList", "CompanyListBlock");
                             $this->tpl->set_var("CompanyListBlock", "");
                         }
                         break;
                     case "cityAssessor":
                         if (is_numeric($value)) {
                             $cityAssessor = new Person();
                             $cityAssessor->selectRecord($value);
                             $this->tpl->set_var("cityAssessorID", $cityAssessor->getPersonID());
                             $this->tpl->set_var("cityAssessorName", $cityAssessor->getFullName());
                             $this->formArray["cityAssessorName"] = $cityAssessor->getFullName();
                         } else {
                             $cityAssessor = $value;
                             $this->tpl->set_var("cityAssessorID", $cityAssessor);
                             $this->tpl->set_var("cityAssessorName", $cityAssessor);
                             $this->formArray["cityAssessorName"] = $cityAssessor;
                         }
                         break;
                     case "cityTreasurer":
                         if (is_numeric($value)) {
                             $cityTreasurer = new Person();
                             $cityTreasurer->selectRecord($value);
                             $this->tpl->set_var("cityTreasurerID", $cityTreasurer->getPersonID());
                             $this->tpl->set_var("cityTreasurerName", $cityTreasurer->getFullName());
                             $this->formArray["cityTreasurerName"] = $cityTreasurer->getFullName();
                         } else {
                             $cityTreasurer = $value;
                             $this->tpl->set_var("cityTreasurerID", $cityTreasurer);
                             $this->tpl->set_var("cityTreasurerName", $cityTreasurer);
                             $this->formArray["cityTreasurerName"] = $cityTreasurer;
                         }
                         break;
                     case "tdArray":
                         $this->tpl->set_block("rptsTemplate", "defaultTDList", "defaultTDListBlock");
                         $this->tpl->set_block("rptsTemplate", "toggleTDList", "toggleTDListBlock");
                         $this->tpl->set_block("rptsTemplate", "TDList", "TDListBlock");
                         $tdCtr = 0;
                         if (count($value)) {
                             $this->tpl->set_block("rptsTemplate", "TDDBEmpty", "TDDBEmptyBlock");
                             $this->tpl->set_var("TDDBEmptyBlock", "");
                             $this->tpl->set_block("TDList", "Land", "LandBlock");
                             $this->tpl->set_block("TDList", "PlantsTrees", "PlantsTreesBlock");
                             $this->tpl->set_block("TDList", "ImprovementsBuildings", "ImprovementsBuildingsBlock");
                             $this->tpl->set_block("TDList", "Machineries", "MachineriesBlock");
                             foreach ($value as $tkey => $tvalue) {
                                 $propertyType = $tvalue->getPropertyType();
                                 $propertyID = $tvalue->getPropertyID();
                                 switch ($propertyType) {
                                     case "Land":
                                         $LandDetails = new SoapObject(NCCBIZ . "LandDetails.php", "urn:Object");
                                         if (!($xmlStr = $LandDetails->getLand($propertyID))) {
                                             echo "xml failed";
                                         } else {
                                             //echo $xmlStr;
                                             if (!($domDoc = domxml_open_mem($xmlStr))) {
                                                 $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                                                 $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                                             } else {
                                                 $land = new Land();
                                                 $land->parseDomDocument($domDoc);
                                                 //$land->selectRecord($propertyID);
                                                 $this->formArray["landTotalMarketValue"] += tofloat($land->getMarketValue());
                                                 $this->formArray["landTotalAssessedValue"] += tofloat($land->getAssessedValue());
                                                 $this->displayLand($land);
                                                 //echo $this->formArray["landTotalAssessedValue"];
                                             }
                                         }
                                         break;
                                     case "PlantsTrees":
                                         $PlantsTreesDetails = new SoapObject(NCCBIZ . "PlantsTreesDetails.php", "urn:Object");
                                         if (!($xmlStr = $PlantsTreesDetails->getPlantsTrees($propertyID))) {
                                             echo "xml failed";
                                         } else {
                                             //echo $xmlStr;
                                             if (!($domDoc = domxml_open_mem($xmlStr))) {
                                                 $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                                                 $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                                             } else {
                                                 $plantsTrees = new PlantsTrees();
                                                 $plantsTrees->parseDomDocument($domDoc);
                                                 //$plantsTrees->selectRecord($propertyID);
                                                 $this->formArray["plantTotalMarketValue"] += tofloat($plantsTrees->getMarketValue());
                                                 $this->formArray["plantTotalAssessedValue"] += tofloat($plantsTrees->getAssessedValue());
                                                 $this->displayPlantsTrees($plantsTrees);
                                             }
                                         }
                                         break;
                                     case "ImprovementsBuildings":
                                         $ImprovementsBuildingsDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsDetails.php", "urn:Object");
                                         if (!($xmlStr = $ImprovementsBuildingsDetails->getImprovementsBuildings($propertyID))) {
                                             echo "xml failed";
                                         } else {
                                             //echo $xmlStr;
                                             if (!($domDoc = domxml_open_mem($xmlStr))) {
                                                 $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                                                 $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                                             } else {
                                                 $improvementsBuildings = new ImprovementsBuildings();
                                                 $improvementsBuildings->parseDomDocument($domDoc);
                                                 //$improvementsBuildings->selectRecord($propertyID);
                                                 $this->formArray["bldgTotalMarketValue"] += tofloat($improvementsBuildings->getMarketValue());
                                                 $this->formArray["bldgTotalAssessedValue"] += tofloat($improvementsBuildings->getAssessedValue());
                                                 $this->displayImprovementsBuildings($improvementsBuildings);
                                             }
                                         }
                                         break;
                                     case "Machineries":
                                         $MachineriesDetails = new SoapObject(NCCBIZ . "MachineriesDetails.php", "urn:Object");
                                         if (!($xmlStr = $MachineriesDetails->getMachineries($propertyID))) {
                                             echo "xml failed";
                                         } else {
                                             //echo $xmlStr;
                                             if (!($domDoc = domxml_open_mem($xmlStr))) {
                                                 $this->tpl->set_block("rptsTemplate", "OwnerListTable", "OwnerListTableBlock");
                                                 $this->tpl->set_var("OwnerListTableBlock", "error xmlDoc");
                                             } else {
                                                 $machineries = new Machineries();
                                                 $machineries->parseDomDocument($domDoc);
                                                 //$machineries->selectRecord($propertyID);
                                                 $this->formArray["machTotalMarketValue"] += tofloat($machineries->getMarketValue());
                                                 $this->formArray["machTotalAssessedValue"] += tofloat($machineries->getAssessedValue());
                                                 $this->displayMachineries($machineries);
                                             }
                                         }
                                         break;
                                     default:
                                         /*
                                         $this->tpl->set_block("TDList", "Land", "LandBlock");
                                         $this->tpl->set_var("LandBlock", "");
                                         $this->tpl->set_block("TDList", "PlantsTrees", "PlantsTreesBlock");
                                         $this->tpl->set_var("PlantsTreesBlock", "");
                                         $this->tpl->set_block("TDList", "ImprovementsBuildings", "ImprovementsBuildingsBlock");
                                         $this->tpl->set_var("ImprovementsBuildingsBlock", "");
                                         $this->tpl->set_block("TDList", "Machineries", "MachineriesBlock");
                                         $this->tpl->set_var("MachineriesBlock", "");
                                         $this->tpl->set_block("TDList", "TD", "TDBlock");
                                         $this->tpl->set_var("TDBlock", "");
                                         */
                                 }
                                 $this->tpl->set_var("ctr", $tdCtr);
                                 $this->tpl->parse("defaultTDListBlock", "defaultTDList", true);
                                 $this->tpl->parse("toggleTDListBlock", "toggleTDList", true);
                                 $this->tpl->parse("TDListBlock", "TDList", true);
                                 $this->tpl->set_var("LandBlock", "");
                                 $this->tpl->set_var("PlantsTreesBlock", "");
                                 $this->tpl->set_var("ImprovementsBuildingsBlock", "");
                                 $this->tpl->set_var("MachineriesBlock", "");
                                 $tdCtr++;
                                 //echo $this->formArray["landTotalAssessedValue"]."<br>";
                             }
                         } else {
                             $this->tpl->set_var("defaultTDListBlock", "//no default");
                             $this->tpl->set_var("toggleTDListBlock", "//no Toggle");
                             $this->tpl->set_var("TDListBlock", "");
                         }
                         $this->tpl->set_var("tdCtr", $tdCtr);
                         break;
                     case "landTotalMarketValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "landTotalAssessedValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "plantTotalMarketValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "plantTotalAssessedValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "bldgTotalMarketValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "bldgTotalAssessedValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "machTotalMarketValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "machTotalAssessedValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "totalMarketValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     case "totalAssessedValue":
                         if (!$this->formArray[$key]) {
                             $this->formArray[$key] = $value;
                         }
                         break;
                     default:
                         $this->formArray[$key] = $value;
                 }
             }
             $this->formArray["totalMarketValue"] = $this->formArray["landTotalMarketValue"] + $this->formArray["plantTotalMarketValue"] + $this->formArray["bldgTotalMarketValue"] + $this->formArray["machTotalMarketValue"];
             $this->formArray["totalAssessedValue"] = $this->formArray["landTotalAssessedValue"] + $this->formArray["plantTotalAssessedValue"] + $this->formArray["bldgTotalAssessedValue"] + $this->formArray["machTotalAssessedValue"];
             unset($rptop);
             $AFSEncode = new SoapObject(NCCBIZ . "AFSEncode.php", "urn:Object");
             $rptop = new RPTOP();
             $rptop->setRptopID($this->formArray["rptopID"]);
             $rptop->setLandTotalMarketValue($this->formArray["landTotalMarketValue"]);
             $rptop->setLandTotalAssessedValue($this->formArray["landTotalAssessedValue"]);
             $rptop->setPlantTotalMarketValue($this->formArray["plantTotalMarketValue"]);
             $rptop->setPlantTotalPlantAssessedValue($this->formArray["plantTotalAssessedValue"]);
             $rptop->setBldgTotalMarketValue($this->formArray["bldgTotalMarketValue"]);
             $rptop->setBldgTotalAssessedValue($this->formArray["bldgTotalAssessedValue"]);
             $rptop->setMachTotalMarketValue($this->formArray["machTotalMarketValue"]);
             $rptop->setMachTotalAssessedValue($this->formArray["machTotalAssessedValue"]);
             $rptop->setTotalMarketValue($this->formArray["totalMarketValue"]);
             $rptop->setTotalAssessedValue($this->formArray["totalAssessedValue"]);
             $rptop->setCreatedBy($this->userID);
             $rptop->setModifiedBy($this->userID);
             $rptop->setDomDocument();
             $RPTOPEncode = new SoapObject(NCCBIZ . "RPTOPEncode.php", "urn:Object");
             $rptop->setDomDocument();
             $doc = $rptop->getDomDocument();
             $xmlStr = $doc->dump_mem(true);
             //echo $xmlStr;
             if (!($ret = $RPTOPEncode->updateRPTOPtotals($xmlStr))) {
                 echo "ret=" . $ret;
             }
             //echo $ret;
         }
     }
     $this->setForm();
     $this->tpl->set_var("Session", $this->sess->url("") . $this->sess->add_query(array("rptopID" => $this->formArray["rptopID"], "ownerID" => $this->formArray["ownerID"])));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }