WIP Contract/Billing/Invoice 2024-06-28
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
class BillingModel {
|
||||
public $invoice_id;
|
||||
public $invoice_date;
|
||||
public $contract_id;
|
||||
public $start_date;
|
||||
public $end_date;
|
||||
public $owner_id;
|
||||
public $billingaddress_id;
|
||||
public $customer_number;
|
||||
public $company;
|
||||
@@ -30,8 +30,8 @@ class BillingModel {
|
||||
public $amount;
|
||||
public $price;
|
||||
public $price_setup;
|
||||
public $billing_period;
|
||||
|
||||
public $vatrate;
|
||||
|
||||
public $create_by;
|
||||
public $edit_by;
|
||||
public $create;
|
||||
@@ -117,6 +117,31 @@ class BillingModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getInvoiceBaseData($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$items = [];
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT owner_id, billingaddress_id, billing_type, billing_delivery FROM Billing
|
||||
WHERE $where
|
||||
GROUP BY owner_id, billingaddress_id, billing_type, billing_delivery
|
||||
ORDER BY owner_id, billingaddress_id, billing_type, billing_delivery";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = [
|
||||
"owner_id" => $data->owner_id,
|
||||
"billingaddress_id" => $data->billingaddress_id,
|
||||
"billing_type" => $data->billing_type,
|
||||
"billing_delivery" => $data->billing_delivery
|
||||
];
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -196,16 +221,11 @@ class BillingModel {
|
||||
$invoice_id = $filter['invoice_id'];
|
||||
if(is_numeric($invoice_id)) {
|
||||
$where .= " AND Billing.invoice_id=$invoice_id";
|
||||
} elseif($invoice_id === null || $invoice_id === false) {
|
||||
$where .= " AND (Billing.invoice_id IS NULL OR Billing.invoice_id=0)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("invoice_date", $filter)) {
|
||||
$invoice_date = $filter['invoice_date'];
|
||||
if($invoice_date) {
|
||||
$where .= " AND Billing.invoice_date='$invoice_date'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
@@ -237,7 +257,7 @@ class BillingModel {
|
||||
if(array_key_exists("start_date>=", $filter)) {
|
||||
$start_date = FronkDB::singleton()->escape($filter['start_date>=']);
|
||||
if($start_date) {
|
||||
$where .= " AND Billing.start_date >='$start_date'";
|
||||
$where .= " AND Billing.start_date >= '$start_date'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,6 +268,13 @@ class BillingModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("owner_id", $filter)) {
|
||||
$owner_id = $filter['owner_id'];
|
||||
if(is_numeric($owner_id)) {
|
||||
$where .= " AND Billing.owner_id=$owner_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billingaddress_id", $filter)) {
|
||||
$billingaddress_id = $filter['billingaddress_id'];
|
||||
if(is_numeric($billingaddress_id)) {
|
||||
@@ -384,10 +411,24 @@ class BillingModel {
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("billing_period", $filter)) {
|
||||
$billing_period = $filter['billing_period'];
|
||||
if(is_numeric($billing_period)) {
|
||||
$where .= " AND Billing.billing_period = $billing_period";
|
||||
if(array_key_exists("billing_type", $filter)) {
|
||||
$billing_type = $filter['billing_type'];
|
||||
if(is_numeric($billing_type)) {
|
||||
$where .= " AND Billing.billing_type = $billing_type";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billing_type", $filter)) {
|
||||
$billing_type = $db->escape($filter['billing_type']);
|
||||
if($billing_type) {
|
||||
$where .= " AND Billing.billing_type = '$billing_type'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("billing_delivery", $filter)) {
|
||||
$billing_delivery = $db->escape($filter['billing_delivery']);
|
||||
if($billing_delivery) {
|
||||
$where .= " AND Billing.billing_delivery = '$billing_delivery'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user