本文整理汇总了PHP中Invoice::Save方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::Save方法的具体用法?PHP Invoice::Save怎么用?PHP Invoice::Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice::Save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnPaid
public function OnPaid(Invoice $Invoice, AbstractPaymentModule $payment_module = null)
{
$db = Core::GetDBInstance();
if (!in_array($Invoice->Purpose, $this->HandledPurposes)) {
return;
}
Log::Log("RegistryInvoiceObserver::OnPaid(InvoiceID={$Invoice->ID})", E_USER_NOTICE);
// Get domain information
try {
$Domain = DBDomain::GetInstance()->Load($Invoice->ItemID);
} catch (Exception $e) {
Log::Log("RegistryInvoiceObserver::OnPaid() thown exception: {$e->getMessage()}", E_USER_ERROR);
}
if ($Domain) {
Log::Log("Invoice purpose: {$Invoice->Purpose}", E_USER_NOTICE);
// Get user information
$userinfo = $db->GetRow("SELECT * FROM users WHERE id=?", array($Domain->UserID));
// Check command
switch ($Invoice->Purpose) {
case INVOICE_PURPOSE::DOMAIN_TRADE:
try {
$Action = new UpdateDomainContactAction($Invoice);
try {
$Action->Run();
} catch (UpdateDomainContactAction_Exception $e) {
Log::Log(sprintf("Trade failed. %s", $e->getMessage()), E_ERROR);
DBDomain::GetInstance()->Save($Action->GetDomain());
// Send mail
$args = array("client" => $userinfo, "Invoice" => $Invoice, "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "domain_trade_failure_reason" => $e->getMessage());
mailer_send("domain_trade_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
}
} catch (LogicException $e2) {
Log::Log($e2->getMessage(), E_ERROR);
}
break;
case INVOICE_PURPOSE::DOMAIN_CREATE:
if ($Domain->Status == DOMAIN_STATUS::AWAITING_PAYMENT || $Domain->Status == DOMAIN_STATUS::REJECTED) {
$Domain->Status = DOMAIN_STATUS::PENDING;
$Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_CREATE;
$Domain = DBDomain::GetInstance()->Save($Domain);
// If domain has incomplete information skip domain creation. Update status to Pending.
if (count($Domain->GetContactList()) == 0 || count($Domain->GetNameserverList()) == 0) {
//
// Send mail
//
Log::Log("Domain registration process not completed. Need more information from client.", E_USER_NOTICE);
$args = array("client" => $userinfo, "Invoice" => $Invoice, "domain_name" => $Domain->Name, "extension" => $Domain->Extension);
mailer_send("domain_registration_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
// Write information in invoice
$Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
$Invoice->ActionFailReason = _('Domain registration process not completed. Need more information from client.');
} else {
Log::Log("Trying to register domain", E_USER_NOTICE);
///// get Registry instance and connect to registry server
try {
$Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($Domain->Extension);
} catch (Exception $e) {
Log::Log($e->getMessage(), E_ERROR);
return;
}
// Validate license for this module
if (!License::IsModuleLicensed($Registry->GetModuleName())) {
throw new LicensingException("Your license does not permit module {$Registry->ModuleName()}");
}
//
$extra_data = $db->GetAll("SELECT * FROM domains_data WHERE domainid=?", array($Domain->ID));
if ($extra_data && count($extra_data) > 0) {
foreach ($extra_data as $v) {
$extra[$v["key"]] = $v["value"];
}
} else {
$extra = array();
}
// Try to create domain name
try {
$cr = $Registry->CreateDomain($Domain, $Domain->Period, $extra);
} catch (Exception $e) {
$args = array("client" => $userinfo, "Invoice" => $Invoice, "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "domain_reg_failure_reason" => $e->getMessage());
mailer_send("domain_registration_action_required.eml", $args, $userinfo["email"], $userinfo["name"]);
// If domain not created
Log::Log("Cannot register domain name. Server return: " . $e->getMessage(), E_ERROR);
$Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
$Invoice->ActionFailReason = $e->getMessage();
}
if ($cr) {
// If domain created
Log::Log(sprintf("Domain %s successfully registered. Updating database", $Domain->GetHostName()), E_USER_NOTICE);
$Invoice->ActionStatus = INVOICE_ACTION_STATUS::COMPLETE;
}
}
} else {
Log::Log("Domain status '{$Domain->Status}'. Expected 'Awaiting payment'", E_ERROR);
$retval = false;
$Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
$Invoice->ActionFailReason = sprintf(_("Domain status '%s'. Expected 'Awaiting payment'"), $Domain->Status);
}
break;
case INVOICE_PURPOSE::DOMAIN_TRANSFER:
if ($Domain->Status == DOMAIN_STATUS::AWAITING_PAYMENT) {
//
//.........这里部分代码省略.........
示例2: HandleImpendingExpiration
public function HandleImpendingExpiration(Domain $domain)
{
// http://bugzilla.webta.net/show_bug.cgi?id=210
// Prevent domain expiration
$Config = $this->GetManifest()->GetSectionConfig();
$days = $Config->domain->xpath("//renewal/notifications/period");
$last_notification_period = (int) end($days);
$last_renewal_date = $domain->RenewalDate ? $domain->RenewalDate : $domain->ExpireDate;
$days_before_expire = (int) ceil(($last_renewal_date - time()) / 86400);
if ($days_before_expire <= $last_notification_period) {
if ($days_before_expire < 0) {
// Today will expire... OMG!
$days_before_expire = 0;
}
// Set renew period
$period = (int) $Config->domain->renewal->min_period;
$domain->Period = $period;
// Copypasta from class.RenewProcess.php
// Issue invoice for renew and send notification to client.
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $domain, $domain->UserID);
$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $domain->GetHostName(), $period);
$Invoice->Save();
if ($Invoice->Status == INVOICE_STATUS::PENDING) {
$userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID));
$args = array("domain_name" => $domain->Name, "extension" => $domain->Extension, "invoice" => $Invoice, "expDays" => $days_before_expire, "client" => $userinfo, "renewal_date" => $domain->RenewalDate);
mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]);
Application::FireEvent('DomainAboutToExpire', $domain, $days_before_expire);
}
}
}
示例3: OnStartForking
public function OnStartForking()
{
global $TLDs, $modules_config;
Log::Log("Starting 'Renew' cronjob...", E_USER_NOTICE);
$db = Core::GetDBInstance();
$RegFactory = RegistryModuleFactory::GetInstance();
$DbDomain = DBDomain::GetInstance();
$this->ThreadArgs = array();
// For each client send notice about expiring domains
$sql = "SELECT id FROM users";
foreach ($db->GetAll($sql) as $client_data)
{
try
{
$Client = Client::Load($client_data["id"]);
$sql = "
SELECT
d.id, d.name, d.TLD, d.end_date,
IF(dd.`key` IS NOT NULL, FROM_UNIXTIME(dd.`value`), DATE_SUB(end_date, INTERVAL 1 DAY)) AS last_renew_date
FROM domains d
LEFT JOIN domains_data dd ON (dd.domainid = d.id AND dd.`key` = 'RenewalDate')
WHERE d.status = '".DOMAIN_STATUS::DELEGATED."' AND d.userid = ? AND (TO_DAYS(end_date) - TO_DAYS(NOW()) BETWEEN 0 AND ?) AND renew_disabled != 1
ORDER BY d.end_date ASC";
$start_days = $Client->GetSettingValue(ClientSettings::EXPIRE_NOTIFY_START_DAYS);
$domains_data = $db->GetAll($sql, array($Client->ID, $start_days ? $start_days : 60));
// Send email to client
if ($domains_data)
{
$eml_args = array(
"client_name" => $Client->Name,
"domains" => array()
);
foreach ($domains_data as $domain_data)
{
$eml_args["domains"][] = array(
"name" => "{$domain_data["name"]}.{$domain_data["TLD"]}",
"expire_date" => date("Y-m-d", strtotime($domain_data["end_date"])),
"last_renew_date" => date("Y-m-d", strtotime($domain_data["last_renew_date"]))
);
}
mailer_send("bulk_renew_notice.eml", $eml_args, $Client->Email, $Client->Name);
}
foreach ($domains_data as $domain_data)
{
$Domain = $DbDomain->Load($domain_data['id']);
// Find more then 60 days invoice
// Legacy from old notification system.
// FIXME: Need to create a better solution to finding unpaid invoices for upgoing renew
$dtNearest = date("Y-m-d", $Domain->ExpireDate - 60*24*60*60);
$invoiceid = $db->GetOne("SELECT id FROM invoices
WHERE userid=? AND itemid=? AND purpose=? AND dtcreated >= ?",
array($Domain->UserID, $Domain->ID, INVOICE_PURPOSE::DOMAIN_RENEW, $dtNearest)
);
// Generate invoice
if (!$invoiceid && !$Domain->RenewDisabled)
{
$Registry = $RegFactory->GetRegistryByExtension($Domain->Extension);
$config = $Registry->GetManifest()->GetSectionConfig();
$period = (int)$config->domain->renewal->min_period;
$Domain->Period = $period;
$DbDomain->Save($Domain);
try
{
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $Domain->ID, $Domain->UserID);
$Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $Domain->GetHostName(), $period);
$Invoice->Cancellable = 1;
$Invoice->Save();
if ($Invoice->Status == INVOICE_STATUS::PENDING)
{
$diff_days = ceil(($Domain->ExpireDate - time())/(60*60*24));
Application::FireEvent('DomainAboutToExpire', $Domain, $diff_days);
}
}
catch(Exception $e)
{
Log::Log("Cannot create renew invoice. Caught: {$e->getMessage()}", E_USER_ERROR);
}
}
}
}
catch (Exception $e)
{
Log::Log("Caught: {$e->getMessage()}", E_USER_ERROR);
}
}
/*
//.........这里部分代码省略.........
示例4: Invoice
$Domain = DBDomain::GetInstance()->Save($Domain);
}
catch (Exception $e)
{
Log::Log($e->getMessage(), E_USER_ERROR);
$exception->AddMessage(_('Cannot save domain'));
throw $exception;
}
try
{
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_CREATE,$Domain->ID,$_SESSION['userid']);
$Invoice->Description = sprintf(_("%s domain name registration for %s year(s)"),
$Domain->GetHostName(), $Domain->Period
);
$Invoice->Save();
}
catch(Exception $e)
{
$exception->AddMessage(sprintf(_("Cannot create invoice: %s"), $e->getMessage()));
throw $exception;
}
$_SESSION["domaininfo"]["extension"] = false;
$_SESSION["regdomain"] = false;
$_SESSION["dInfo"] = false;
$_SESSION["invTotal"] = false;
$_SESSION["invID"] = false;
$_SESSION["invDescription"] = false;
$_SESSION["gate"] = false;
$_SESSION["success_payment_redirect_url"] = "domains_view.php";
示例5: catch
$res = $Registry->DomainCanBeRegistered($Domain)->Result;
} catch (Exception $e) {
throw new ApplicationException(sprintf(_("Cannot check availability of %s. %s")));
}
if ($res == true) {
throw new ApplicationException(sprintf(_("Domain %s not registered"), $Domain->GetHostName()));
}
// Save expiration date
$Domain->CreateDate = strtotime($expiredate);
// See if we have to issue invoice for this client
if (Client::Load($_SESSION['userid'])->GetSettingValue('bill_for_domain_preorder') != 1) {
$Domain->Status = DOMAIN_STATUS::AWAITING_PREREGISTRATION;
DBDomain::GetInstance()->Save($Domain);
} else {
$Domain->Status = DOMAIN_STATUS::AWAITING_PAYMENT;
$Domain = DBDomain::GetInstance()->Save($Domain);
$Invoice = new Invoice(INVOICE_PURPOSE::PREREGISTRATION_DROPCATCHING, $Domain->ID, $_SESSION['userid']);
$Invoice->Description = sprintf(_("Domain name %s pre-registration"), $Domain->GetHostName());
$invoices[] = $Invoice->Save()->ID;
}
if (count($err) == 0) {
if (count($invoices) != 0) {
$okmsg = _("Please pay the generated invoices below to add domains to pre-registration queue");
CoreUtils::Redirect("checkout.php?string_invoices=" . implode(",", $invoices));
} else {
$okmsg = _("Domain successfully added to pre-registration queue");
CoreUtils::Redirect("domains_view.php");
}
}
}
include_once "src/append.inc.php";
示例6: Run
/**
* Executor
*
* @throws UpdateDomainContactTask_Exception
*/
public function Run($userid = null)
{
try {
$Factory = RegistryModuleFactory::GetInstance();
$Registry = $Factory->GetRegistryByExtension($this->Domain->Extension);
$Manifest = $Registry->GetManifest();
if ($userid && $this->Domain->UserID != $userid) {
throw new UpdateDomainContactAction_Exception(_("You don't have permissions for manage this domain"), UpdateDomainContactAction_Exception::DOMAIN_NOT_BELONGS_TO_USER);
}
$OldContact = $this->Domain->GetContact($this->contact_type);
if ($this->NewContact && $this->NewContact->UserID != $this->Domain->UserID) {
throw new UpdateDomainContactAction_Exception(_("You don't have permissions for using this contact"), UpdateDomainContactAction_Exception::CONTACT_NOT_BELONGS_TO_USER);
}
$trade = $Manifest->GetRegistryOptions()->ability->trade == '1';
if ($this->contact_type != CONTACT_TYPE::REGISTRANT || !$trade) {
try {
$Registry->UpdateDomainContact($this->Domain, $this->contact_type, $OldContact, $this->NewContact);
return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK;
} catch (Exception $e) {
throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage()));
}
} else {
// Execute trade when:
// - Trade invoice is paid
// - Previous trade failed
if ($this->Domain->IncompleteOrderOperation == INCOMPLETE_OPERATION::DOMAIN_TRADE || $this->Invoice && $this->Invoice->Status == INVOICE_STATUS::PAID) {
$this->Domain->SetContact($this->NewContact, CONTACT_TYPE::REGISTRANT);
$this->Domain->IncompleteOrderOperation = null;
$extra["requesttype"] = "ownerChange";
try {
$trade = $Registry->ChangeDomainOwner($this->Domain, 1, $extra);
return $this->Domain->HasPendingOperation(Registry::OP_TRADE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK;
} catch (Exception $e) {
$this->Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_TRADE;
if ($this->Invoice) {
$this->Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED;
$this->Invoice->ActionFailReason = $e->getMessage();
}
throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage()));
}
} else {
// Issue an invoice for trade operation
$invoiceid = $this->Db->GetOne("SELECT * FROM invoices WHERE status=? AND itemid=? AND purpose=?", array(INVOICE_STATUS::PENDING, $this->Domain->ID, INVOICE_PURPOSE::DOMAIN_TRADE));
if (!$invoiceid) {
$this->Domain->SetExtraField("NewRegistrantCLID", $this->NewContact->CLID);
DBDomain::GetInstance()->Save($this->Domain);
$Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_TRADE, $this->Domain->ID, $userid);
$Invoice->Description = sprintf(_("%s domain name trade"), $this->Domain->GetHostName());
$Invoice->Save();
$this->Invoice = $Invoice;
return UpdateDomainContactAction_Result::INVOICE_GENERATED;
} else {
throw new UpdateDomainContactAction_Exception(_("Another domain trade is already initiated"));
}
}
}
} catch (Exception $e) {
throw new UpdateDomainContactAction_Exception($e->getMessage());
}
}
示例7: date
$invoice->date = date('Y-n-d H:i:s');
if (isset($_SESSION['user']['id'])) {
$invoice->user = $_SESSION['user']['id'];
} else {
$invoice->user = $guest;
}
$invoice->total = $totalamont;
$invoice->currency = $_SESSION['currency_unit'];
$invoice->voucher = '';
$invoice->reference = $result;
$invoice->date_in = $_SESSION['date-in'];
$invoice->date_out = $_SESSION['date-out'];
$invoice->hotel = 0;
$invoice->description = json_encode($passengers);
$invoice->status = 0;
$invc_num = $invoice->Save();
//var_dump($_POST['invoice']);exit;
if ($invc_num) {
// add invoice detail
foreach ($_POST['invoice'] as $detail) {
$invcdtl = new InvoiceDetail();
$invcdtl->invoice = $invc_num;
$invcdtl->room = $detail['id'];
$invcdtl->room_title = '';
$invcdtl->adult = 0;
$invcdtl->child = 0;
$invcdtl->amount = $detail['price'];
$invcdtl->save();
}
} else {
$app = new AppController();