function createBill() { $bill = new Bill(); $customer = new Customer(); $tour = new Tour(); $bill_product = new Bill_Product(); $customer_data = $customer->get($this->customer_id); if (count($customer_data) == 0) { echo "<div class=\"error\">Fehler in Session, bitte neu anmelden</div><br>\n"; return -1; } $tour_data = $tour->getByAssistant($customer_data[0][12]); $bill_id = $bill->create("", array($this->customer_id, $customer_data[0][12], "", $tour_data[0][2], -2, time())); $list = $this->getItems(); for ($i = 0; $i < count($list); $i++) { if ($list[$i][2] > 0) { $bill_product->create(array($bill_id, $list[$i][0], $list[$i][2], $list[$i][5], "", 0, 0, time())); } } return 0; }
<?php require_once "DataBase_Net/Bill_Net.php"; require_once "DataBase_Net/Bill_Product_Net.php"; require_once "DataBase/Bill.php"; require_once "DataBase/Bill_Product.php"; // sync Bill database $bill = new Bill(); $bill_net = new Bill_Net(); $bill_product = new Bill_Product(); $bill_product_net = new Bill_Product_Net(); $new_bills_count = 0; $new_position_count = 0; // fetch all remote bills $remote_bills = $bill_net->getPlainBills(); foreach ($remote_bills as $tmp) { $new_bill_id = $bill->create("", array_slice($tmp, 1)); $new_bills_count++; // check for bill_products $remote_bill_products = $bill_product_net->getByBillId($tmp[0]); foreach ($remote_bill_products as $tmp1) { $tmp1[1] = $new_bill_id; $bill_product->create(array_slice($tmp1, 1)); $new_position_count++; } } $main_box->add(new NTKLabel("", "neue Rechnungen: " . $new_bills_count), 200, 0, "background-color: #dfe7f3;"); $main_box->add(new NTKLabel("", "neue Positionen: " . $new_position_count), 200, 0, "background-color: #dfe7f3;"); // now we should have added all bills let's delete them remote $bill_net->clearTable(); $bill_product_net->clearTable();
public static function createBillForTests($tests, $lab_config_id) { # Create a new bill and associate all of the desired tests with it. // The way we call the bill constructor here is awkward and assumes that the tests are all for the same patient. // While that's true for now, it's not necessarily going to stay that way, so this may need to be revisited. -Robert. $bill = new Bill(Specimen::getById($tests[0]->specimenId)->patientId); $bill->create($lab_config_id); foreach ($tests as $test) { $association = new BillsTestsAssociationObject($bill->id, $test->testId); $association->create($lab_config_id); } return $bill; }
$bill_product_import = new Bill_Product_Import(); $customer = new Customer(); $tour = new Tour(); if ($bill_import->import("mysql_import/bill.csv") == 0 && $bill_product_import->import("mysql_import/bill_product.csv") == 0) { /* import bills from bill_import and products from bill_product_import */ $bills = $bill_import->get(); for ($i = 0; $i < count($bills); $i++) { if (!$bill->hasTimestamp($bills[$i][6])) { $customer_data = $customer->get($bills[$i][1]); if (count($customer_data) == 0) { echo "Fehler: websync.php import bills from bill_import no customer data"; continue; } $tour_data = $tour->get($customer_data[0][12]); $date = getdate(time()); $new_bill_id = $bill->create("", array($bills[$i][1], $customer_data[0][12], $date['year'] . "-" . $date['mon'] . "-" . $date['mday'], $tour_data[0][2], -2, $bills[$i][6])); $bill_products = $bill_product_import->getByBillId($bills[$i][0]); for ($j = 0; $j < count($bill_products); $j++) { $bill_product->create(array($new_bill_id, $bill_products[$j][2], $bill_products[$j][3], $bill_products[$j][4], 0, 0, 0)); } } } $main_box->add($spacer, True, True, "background-color: #dfe7f3;"); $main_box->add(new NTKLabel("", "Fertig"), False, False, "font-style: bold; background-color: #dfe7f3;"); $main_box->add($spacer, True, True, "background-color: #dfe7f3;"); } else { $main_box->add($spacer, True, True, "background-color: #dfe7f3;"); $main_box->add(new NTKLabel("", "neue Bestellungen laden schlug fehl.<br>In ein paar Minuten nochmal versuchen."), False, False, "color: #ff0000; font-style: bold; background-color: #dfe7f3;"); $main_box->add($spacer, True, True, "background-color: #dfe7f3;"); } } else {
require_once "DataBase/Assistant.php"; require_once "DataBase/Bill_Product.php"; $db_action = var_get_post("db_action", ""); $tour = new Tour(); $bill = new Bill(); $assistant = new Assistant(); switch ($db_action) { case "new": $tour->create(array(var_post("name", ""), var_post("assistant_id", ""))); break; case "edit": $tour->update(var_post("tour_id", ""), array(var_post("name", ""), var_post("assistant_id", ""))); break; case "delete": $tour->delete(var_get("tour_id", "")); break; case "tour_to_bill": $tour = new Tour(); $tmp = $tour->get(var_get("tour_id", "")); $tour_data = $tmp[0]; $bill = new Bill(); $new_bill_id = $bill->create('', array(var_post("customer_id", ""), var_post("tour_id", ""), var_post("date", ""), var_post("assistant_id", ""), -1, 0)); $bill_product = new Bill_Product(); $product = new Product(); $product_data = $product->get(); $result = $bill_product->getTourZusammenfassung(var_post("current_tour_id", ""), var_post("date", "")); for ($i = 0; $i < count($result); $i++) { $bill_product->create(array($new_bill_id, $result[$i][0], $result[$i][2], '', '', '', '')); } break; }
$db_action = var_get_post("db_action", ""); $bill = new Bill(); $tour = new Tour(); $assistant = new Assistant(); $bill_product = new Bill_Product(); $product = new Product(); $customer = new Customer(); $price = new Price(); $tax = new Tax(); switch ($db_action) { case "new": $customer_data = $customer->get(var_post("customer_id", "")); if (count($customer_data) > 0) { $tour_data = $tour->getByAssistant($customer_data[0][12]); if (count($tour_data) > 0) { $bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), $tour_data[0][2], -1, 0)); } else { $bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), $customer_data[0][12], var_post("date", ""), 1, -1, 0)); } } else { $bill_id = $bill->create(var_post("bill_id", ""), array(var_post("customer_id", ""), '', var_post("date", ""), var_post("assistant_id", "1"), -1, 0)); } $action = "edit"; break; case "edit": $bill->update(var_post("bill_id", ""), array(var_post("customer_id", ""), var_post("tour_id", ""), var_post("date", ""), var_post("assistant_id", ""), var_post("bill_number", ""))); if ($fp_tour_id != "") { $onload .= "location.href = 'tour.php?action=list_tour&tour_id=" . $fp_tour_id . "&date=" . $fp_date . "';"; } break; case "set_number":