| // | Support: http://www.modernsupport.com/modernbill/ | // +----------------------------------------------------------------------+ // | ModernGigabyte and ModernBill are trademarks of ModernGigabyte, LLC. | // +----------------------------------------------------------------------+ require_once dirname(__FILE__)."/".str_repeat("../",4)."lib-tk/shield.php"; /** * This class is a child class of MB_Action. It will display a mini invoice report using the reports wizard. * * @author Michael Fountain */ class ShowInvoiceStats extends MB_Action { public function execute() { global $CONF; parent::execute(); loadConfigs("billing"); $invoiceSettings =& $CONF["billing"]["invoice"]; $now = time()-(time()%(60*60*24)) + (60*60*24)-1; $this->generateOffset = $invoiceSettings["invoice_generate_offset"]*(60*60*24); $genTime = $now + $this->generateOffset; $data = dispatchMBAPI(toXML(array( "mbapi" => array( "command" => "GetInvoiceStats", ), )), 1); if($this->addMBAPIErrors($data) === 0) { $this->smartyVars["invoiceStats"] = collapseArrayElements($data["mbapi"][0]["results"][0]["stats"][0]); $query = $this->getMBAPIQuery("ProcessInvoices", "", array( "getActiveClients" => 1, "getActivePackages" => 1, "packageDateNextRenewalLessThan" => $genTime, "domainDateNextRenewalLessThan" => $genTime, "countInvoicesToBeGeneratedOnly" => 1, )); dbg("Action Command", htmlentities($query), __FILE__, __LINE__); $data = dispatchMBAPI($query, 1); dbg("Action Result", $data, __FILE__, __LINE__); $this->smartyVars["numInovicesToBeGenerated"] = $data["mbapi"][0]["header"][0]["numInvoicesGenerated"][0]; require_once("objects/Invoice.php"); $statusLabels = Invoice::statuses(); $this->smartyVars["statusLabels"] = array(); foreach ($statusLabels as $statusID=>$name){ $this->smartyVars["statusLabels"][getAPIStatusName("invoice", $statusID)] = $name; } $this->addTemplate("invoices/ShowInvoiceStats", $this->smartyVars); } $this->addErrorTemplates(); return $this->hasExecutedSuccessfully(); } }