updated Invoice PDF generation task for more performance
This commit is contained in:
@@ -837,7 +837,7 @@ class InvoiceController extends mfBaseController {
|
||||
public function createPDFs($limit = false) {
|
||||
$invoice_path_base = MFUPLOAD_FILE_SAVE_PATH."/".TT_INVOICE_SAVE_SUBFOLDER;
|
||||
$created = 0;
|
||||
foreach(InvoiceModel::getAll() as $invoice) {
|
||||
foreach(InvoiceModel::search(["invoice_file" => false]) as $invoice) {
|
||||
if($limit && $created >= $limit) {
|
||||
return $created;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,11 @@ class InvoiceModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Invoice", "*", "1 = 1 ORDER BY invoice_number");
|
||||
$sql = "SELECT Invoice.* FROM Invoice
|
||||
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
|
||||
ORDER BY invoice_number";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Invoice($data);
|
||||
@@ -252,7 +256,8 @@ class InvoiceModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM Invoice
|
||||
$sql = "SELECT Invoice.* FROM Invoice
|
||||
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
|
||||
WHERE $where
|
||||
ORDER BY invoice_number LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
@@ -273,7 +278,8 @@ class InvoiceModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM Invoice
|
||||
$sql = "SELECT Invoice.* FROM Invoice
|
||||
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
|
||||
WHERE $where
|
||||
ORDER BY invoice_number DESC LIMIT 1";
|
||||
|
||||
@@ -297,6 +303,7 @@ class InvoiceModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Invoice
|
||||
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
|
||||
WHERE $where";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
@@ -320,7 +327,8 @@ class InvoiceModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM Invoice
|
||||
$sql = "SELECT Invoice.* FROM Invoice
|
||||
LEFT JOIN InvoiceFile ON (InvoiceFile.invoice_id = Invoice.id)
|
||||
WHERE $where
|
||||
ORDER BY $order";
|
||||
|
||||
@@ -358,6 +366,15 @@ class InvoiceModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("invoice_file", $filter)) {
|
||||
$invoice_file = $filter['invoice_file'];
|
||||
if($invoice_file === true) {
|
||||
$where .= " AND InvoiceFile.id > 0'";
|
||||
} elseif($invoice_file === false || $invoice_file === null) {
|
||||
$where .= " AND InvoiceFile.id IS NOT NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("invoice_number", $filter)) {
|
||||
$invoice_number = $filter['invoice_number'];
|
||||
if($invoice_number === true) {
|
||||
|
||||
@@ -14,7 +14,7 @@ final class CreateInvoiceJob extends AbstractMigration
|
||||
$table->addColumn("to_date", "date", ["null" => false]);
|
||||
$table->addColumn("started", "datetime", ["null" => true, "default" => null]);
|
||||
$table->addColumn("finished", "datetime", ["null" => true, "default" => null]);
|
||||
$table->addColumn("status", "string", ["null" => true, "default" => true, "limit" => 64]);
|
||||
$table->addColumn("status", "string", ["null" => true, "default" => null, "limit" => 64]);
|
||||
$table->addColumn("result", "json", ["null" => true, "default" => null]);
|
||||
|
||||
$table->addColumn("create_by", "integer", ["null" => false]);
|
||||
|
||||
Reference in New Issue
Block a user