Changeset 866 for trunk/Modules/Finance/Manage.php
- Timestamp:
- Dec 23, 2019, 1:08:17 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Finance/Manage.php
r833 r866 28 28 case 'GenerateBills': 29 29 $Output = $this->GenerateBills(); 30 break; 31 case 'RegenerateInvoice': 32 $Output = $this->GenerateInvoice('AND (Id='.$_GET['i'].')'); 33 break; 34 case 'RegenerateOperation': 35 $Output = $this->GenerateOperation('AND (Id='.$_GET['i'].')'); 30 36 break; 31 37 default: … … 406 412 } 407 413 408 function GenerateBills() 409 { 410 $Output = ''; 411 412 // FinanceInvoice 414 function GenerateInvoice($Where) 415 { 416 $Output = ''; 413 417 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. 414 'AND (`Value` != 0) AND (` File` IS NULL) AND (`Generate` = 1)');418 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 415 419 while($Row = $DbResult->fetch_assoc()) 416 420 { 417 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 418 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 419 $FileId = $this->Database->insert_id; 421 if ($Row['File'] == null) 422 { 423 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 424 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 425 $FileId = $this->Database->insert_id; 426 } else $FileId = $Row['File']; 420 427 $FileName = 'doklad-'.$FileId.'.pdf'; 421 428 $Bill = new BillInvoice($this->System); … … 425 432 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName; 426 433 $Bill->SaveToFile($FullFileName); 427 if (file_exists($FullFileName))434 if (file_exists($FullFileName)) 428 435 { 429 436 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); 430 437 $this->Database->update('FinanceInvoice', 'Id='.$Row['Id'], array('File' => $FileId)); 431 $Output .= ' .';438 $Output .= 'Faktura '.$Row['Id'].' vygenerována do souboru '.$FileName.'<br/>'."\n"; 432 439 } else $Output .= 'Soubor "'.$FullFileName.'" se nepodařilo uložit.'; 433 440 } 434 435 // FinanceOperations 441 return $Output; 442 } 443 444 function GenerateOperation($Where) 445 { 446 $Output = ''; 436 447 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. 437 'AND (`Value` != 0) AND (` File` IS NULL) AND (`Generate` = 1)');448 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 438 449 while($Row = $DbResult->fetch_assoc()) 439 450 { 440 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 451 if ($Row['File'] == null) 452 { 453 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 441 454 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 442 $FileId = $this->Database->insert_id; 455 $FileId = $this->Database->insert_id; 456 } else $FileId = $Row['File']; 443 457 $FileName = 'doklad2-'.$FileId.'.pdf'; 444 458 $Bill = new BillOperation($this->System); … … 452 466 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); 453 467 $this->Database->update('FinanceOperation', 'Id='.$Row['Id'], array('File' => $FileId)); 454 $Output .= ' .';468 $Output .= 'Doklad pro platbu '.$Row['Id'].' vygenerován do souboru '.$FileName.'<br/>'."\n"; 455 469 } else $Output .= 'Soubor "'.$FullFileName.'" se nepodařilo uložit.'; 456 470 } 471 return $Output; 472 } 473 474 function GenerateBills() 475 { 476 $Output = ''; 477 // Generate PDF files for new invoices and operations 478 $Output .= $this->GenerateInvoice(' AND (`File` IS NULL)'); 479 $Output .= $this->GenerateOperation(' AND (`File` IS NULL)'); 457 480 return($Output); 458 481 }
Note:
See TracChangeset
for help on using the changeset viewer.