function fix($bill_id) { $products = $this->getByBillId($bill_id); $product = new Product(); $price = new Price(); $tax = new Tax(); $bill = new Bill(); $tmp = $bill->get($bill_id); $bill_data = $tmp[0]; $customer = new Customer(); $tmp = $customer->get($bill_data[1]); $customer_data = $tmp[0]; for ($i = 0; $i < count($products); $i++) { $tmp = $this->getByBillIdAndProductId($bill_id, $products[$i][2]); $bill_product_data = $tmp[0]; $tmp = $product->get($products[$i][2]); $product_data = $tmp[0]; $tmp = $price->getPrice($customer_data[11], $product_data[0]); $price_data = $tmp[0]; $tmp = $tax->get($product_data[4]); $tax_data = $tmp[0]; $this->update($bill_product_data[0], array($bill_product_data[1], $bill_product_data[2], $bill_product_data[3], $bill_product_data[4], $bill_product_data[5], $price_data[3], $tax_data[2])); } }
function index_get() { $filters = $this->get("filter")["filters"]; $page = $this->get('page') !== false ? $this->get('page') : 1; $limit = $this->get('limit') !== false ? $this->get('limit') : 50; $sort = $this->get("sort"); $data["results"] = array(); $data["count"] = 0; $obj = new Contact(null, $this->entity); //Sort if (!empty($sort) && isset($sort)) { foreach ($sort as $value) { $obj->order_by($value["field"], $value["dir"]); } } //Filter if (!empty($filters) && isset($filters)) { $deleted = 0; foreach ($filters as $value) { if (!empty($value["operator"]) && isset($value["operator"])) { if ($value["operator"] == "where_in") { $obj->where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_in") { $obj->or_where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "where_not_in") { $obj->where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_not_in") { $obj->or_where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "like") { $obj->like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_like") { $obj->or_like($value["field"], $value["value"]); } else { if ($value["operator"] == "not_like") { $obj->not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_not_like") { $obj->or_not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "startswith") { $obj->like($value["field"], $value["value"], "after"); } else { if ($value["operator"] == "endswith") { $obj->like($value["field"], $value["value"], "before"); } else { if ($value["operator"] == "contains") { $obj->like($value["field"], $value["value"], "both"); } else { if ($value["operator"] == "or_where") { $obj->or_where($value["field"], $value["value"]); } else { if ($value["operator"] == "search") { $obj->like("number", $value["value"], "after"); $obj->or_like("surname", $value["value"], "after"); $obj->or_like("name", $value["value"], "after"); $obj->or_like("company", $value["value"], "after"); } else { $obj->where($value["field"] . ' ' . $value["operator"], $value["value"]); } } } } } } } } } } } } } } else { if ($value["field"] == "deleted") { $deleted = $value["value"]; } else { $obj->where($value["field"], $value["value"]); } } } $obj->where("deleted", $deleted); } if (!empty($limit) && !empty($page)) { $obj->get_paged_iterated($page, $limit); $data["count"] = $obj->paged->total_rows; } if ($obj->result_count() > 0) { foreach ($obj as $value) { $bal = new Bill(null, $this->entity); $bal->select_sum("amount"); $bal->where("contact_id", $value->id); $bal->where("status", 0); if ($value->contact_type_id == 5) { $bal->where("type", "bill"); } else { $bal->where("type", "invoice"); } $bal->get(); //Fullname $fullname = $value->surname . ' ' . $value->name; if ($value->contact_type_id == 3 || $value->contact_type_id == 5) { $fullname = $value->company; } $data["results"][] = array("id" => $value->id, "currency_id" => $value->currency_id, "user_id" => $value->user_id, "contact_type_id" => $value->contact_type_id, "number" => $value->number, "surname" => $value->surname, "name" => $value->name, "gender" => $value->gender, "dob" => $value->dob, "pob" => $value->pob, "address" => $value->address, "family_member" => $value->family_member, "id_number" => $value->id_number, "phone" => $value->phone, "email" => $value->email, "job" => $value->job, "company" => $value->company, "image_url" => $value->image_url, "memo" => $value->memo, "credit_limit" => $value->credit_limit, "status" => $value->status, "registered_date" => $value->registered_date, "deleted" => $value->deleted, "fullname" => $fullname, "fullIdName" => $value->number . ' ' . $fullname, "contact_type" => $value->contact_type->get_raw()->result(), "balance" => floatval($bal->amount)); } } // //Response Data $this->response($data, 200); }
<?php require_once "util.php"; require_once "DataBase/Product.php"; require_once "DataBase/Bill.php"; require_once "DataBase/Tour.php"; require_once "DataBase/Bill_Product.php"; $tour_id = var_get("tour_id", ""); $date = var_get("date", ""); $bill = new Bill(); $bill_data = $bill->get("", array("bill_id"), "tour_id='" . $tour_id . "' AND date='" . $date . "'"); $tour = new Tour(); $tmp = $tour->get($tour_id); $tour_data = $tmp[0]; $bill_product = new Bill_Product(); $product = new Product(); $product_data = $product->get(); include "Druckvorlagen/tour.php"; ?>
} if (var_post("date_from", "")) { if ($search) { $search .= " AND (date >='" . var_post("date_from", "") . "') "; } else { $search .= "(date >='" . var_post("date_from", "") . "') "; } } if (var_post("date_to", "")) { if ($search) { $search .= " AND (date <='" . var_post("date_to", "") . "') "; } else { $search .= "(date <='" . var_post("date_to", "") . "') "; } } $bill_data = $bill->get("", array("bill_id"), $search); $bill_product = new Bill_Product(); $tour_data[1] = "( Alle Touren )"; $product = new Product(); $product_data = $product->get(); include "Druckvorlagen/tour.php"; } else { $toolbar_box = new NTKVBox("toolbar_box", 0, 0, False); $main_box = new NTKTable("main_box", 5, 4, False); $main_box->setStyle("background-color: #dfe7f3;"); $main_box->add(new NTKLabel("", "<b>Rechnungszusammenfassung nach Datum</b>"), 0, 0); $main_box->add(new NTKLabel("", "Von:"), 2, 0); $main_box->add(new NTKEntry("date_from", ""), 2, 1); $main_box->add(new NTKLabel("", "Bis:"), 2, 2); $main_box->add(new NTKEntry("date_to", ""), 2, 3); $main_box->add(new NTKButton("submit", "Druckvorschau", "document.forms['print_re'].submit();"), 4, 3);
<?php require_once "util.php"; require_once "DataBase/Bill.php"; require_once "DataBase/Assistant.php"; require_once "DataBase/Customer.php"; require_once "DataBase/Product.php"; require_once "DataBase/Bill_Product.php"; require_once "DataBase/Price.php"; require_once "DataBase/Priceset.php"; require_once "DataBase/Tax.php"; $bill_id = var_get_post("bill_id", ""); $bill = new Bill(); $tmp = $bill->get($bill_id); $bill_data = $tmp[0]; $customer = new Customer(); $tmp = $customer->get($bill_data[1]); $customer_data = $tmp[0]; $assistant = new Assistant(); $tmp = $assistant->get($bill_data[4]); $assistant_data = $tmp[0]; $priceset = new Priceset(); $tmp = $priceset->get($customer_data[11]); $priceset_data = $tmp[0]; $bill_product = new Bill_Product(); $bill_product_data = $bill_product->getByBillId($bill_id); $product = new Product(); $price = new Price(); $tax = new Tax(); include "Druckvorlagen/zeilen.php"; include "Druckvorlagen/rechnung.php";
function amount_get() { $filters = $this->get("filter")["filters"]; $page = $this->get('page') !== false ? $this->get('page') : 1; $limit = $this->get('limit') !== false ? $this->get('limit') : 50; $sort = $this->get("sort"); $data["results"] = []; $data["count"] = 0; $obj = new Bill(null, $this->entity); //Sort if (!empty($sort) && isset($sort)) { foreach ($sort as $value) { $obj->order_by($value["field"], $value["dir"]); } } //Filter if (!empty($filters) && isset($filters)) { $deleted = 0; foreach ($filters as $value) { if (!empty($value["operator"]) && isset($value["operator"])) { if ($value["operator"] == "where_in") { $obj->where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_in") { $obj->or_where_in($value["field"], $value["value"]); } else { if ($value["operator"] == "where_not_in") { $obj->where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "or_where_not_in") { $obj->or_where_not_in($value["field"], $value["value"]); } else { if ($value["operator"] == "like") { $obj->like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_like") { $obj->or_like($value["field"], $value["value"]); } else { if ($value["operator"] == "not_like") { $obj->not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "or_not_like") { $obj->or_not_like($value["field"], $value["value"]); } else { if ($value["operator"] == "startswith") { $obj->like($value["field"], $value["value"], "after"); } else { if ($value["operator"] == "endswith") { $obj->like($value["field"], $value["value"], "before"); } else { if ($value["operator"] == "contains") { $obj->like($value["field"], $value["value"], "both"); } else { if ($value["operator"] == "or_where") { $obj->or_where($value["field"], $value["value"]); } else { $obj->where($value["field"] . ' ' . $value["operator"], $value["value"]); } } } } } } } } } } } } } else { if ($value["field"] == "deleted") { $deleted = $value["value"]; } else { $obj->where($value["field"], $value["value"]); } } } $obj->where("deleted", $deleted); } //Results $obj->select_sum("amount"); $obj->get(); $data["results"][] = floatval($obj->amount); //Response Data $this->response($data, 200); }
} break; case "set_number": $bill->setNumber(var_get("bill_id", "")); $bill_product->fix(var_get("bill_id", "")); global $onload; $onload .= "window.open('print_bill.php?bill_id=" . var_get("bill_id", "") . "', '', '');"; break; case "delete": $bill->delete(var_get("bill_id", "")); if ($fp_tour_id != "") { $onload .= "location.href = 'tour.php?action=list_tour&tour_id=" . $fp_tour_id . "&date=" . $fp_date . "';"; } break; case "position_add": $bill_data = $bill->get(var_post("bill_id", "")); /* autoset anmerkung vom produkt, wenn nichts als anmerkung gegeben */ $details = var_post("details", ""); if ($details == "") { $product_data = $product->get(var_post("product_id", "")); $details = $product_data[0][8]; } if ($bill_data[0][5] == -1) { $bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), 0, 0)); } else { $customer_data = $customer->get($bill_data[0][1]); $price_data = $price->getPrice($customer_data[0][11], var_post("product_id", "")); $product_data = $product->get(var_post("product_id", "")); $tax_data = $tax->get($product_data[0][4]); $bill_product->create(array(var_post("bill_id", ""), var_post("product_id", ""), var_post("amount", ""), $details, var_post("rabatt", ""), $price_data[0][3], $tax_data[0][2])); }