Unpaid invoice usability hint and invoice page style fix - SAAS-1134
This commit is contained in:
parent
885f47c20e
commit
f79ca8650f
|
@ -329,4 +329,49 @@ class Billing
|
||||||
$result = Billing::makeRequest($credentials["url"], $query_string);
|
$result = Billing::makeRequest($credentials["url"], $query_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getInvoices()
|
||||||
|
{
|
||||||
|
Billing::ensureClientIdIsValid();
|
||||||
|
$credentials = Billing::getAPICredentials();
|
||||||
|
|
||||||
|
$postfields = array();
|
||||||
|
$postfields["username"] = $credentials["username"];
|
||||||
|
$postfields["password"] = md5($credentials["password"]);
|
||||||
|
$postfields["action"] = "getinvoices";
|
||||||
|
$postfields["responsetype"] = "json";
|
||||||
|
$postfields["userid"] = Application_Model_Preference::GetClientId();
|
||||||
|
|
||||||
|
$query_string = "";
|
||||||
|
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";
|
||||||
|
|
||||||
|
$result = Billing::makeRequest($credentials["url"], $query_string);
|
||||||
|
|
||||||
|
$invoices = array();
|
||||||
|
if ($result["invoices"]) {
|
||||||
|
$invoices = $result["invoices"]["invoice"];
|
||||||
|
}
|
||||||
|
return $invoices;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the customer has any unpaid invoices and if so, returns
|
||||||
|
* the ID of one of them. Returns 0 otherwise.
|
||||||
|
*/
|
||||||
|
public static function checkForUnpaidInvoice() {
|
||||||
|
$invoices = self::getInvoices();
|
||||||
|
$unpaidInvoice = 0;
|
||||||
|
$unpaidInvoices = 0;
|
||||||
|
foreach ($invoices as $invoice)
|
||||||
|
{
|
||||||
|
if ($invoice['status'] == 'Unpaid') {
|
||||||
|
$unpaidInvoices += 1;
|
||||||
|
$unpaidInvoice = $invoice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($unpaidInvoices > 0) {
|
||||||
|
return $unpaidInvoice;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ class Application_Common_UsabilityHints
|
||||||
|
|
||||||
$userIsOnCalendarPage = false;
|
$userIsOnCalendarPage = false;
|
||||||
$userIsOnAddMediaPage = false;
|
$userIsOnAddMediaPage = false;
|
||||||
|
$userIsOnShowbuilderPage = false;
|
||||||
|
$userIsSuperAdmin = Application_Model_User::getCurrentUser()->isSuperAdmin();
|
||||||
|
|
||||||
// If $userPath is set the request came from AJAX so the user's
|
// If $userPath is set the request came from AJAX so the user's
|
||||||
// current location inside Airtime gets passed in to this function.
|
// current location inside Airtime gets passed in to this function.
|
||||||
|
@ -36,6 +38,11 @@ class Application_Common_UsabilityHints
|
||||||
if (strpos(strtolower($userPath), 'schedule') !== false) {
|
if (strpos(strtolower($userPath), 'schedule') !== false) {
|
||||||
$userIsOnCalendarPage = true;
|
$userIsOnCalendarPage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strpos(strtolower($userPath), 'showbuilder') !== false) {
|
||||||
|
$userIsOnShowbuilderPage = true;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If $userPath is not set the request came from inside Airtime so
|
// If $userPath is not set the request came from inside Airtime so
|
||||||
// we can use Zend's Front Controller to get the user's current location.
|
// we can use Zend's Front Controller to get the user's current location.
|
||||||
|
@ -48,6 +55,10 @@ class Application_Common_UsabilityHints
|
||||||
if ($currentController == "plupload") {
|
if ($currentController == "plupload") {
|
||||||
$userIsOnAddMediaPage = true;
|
$userIsOnAddMediaPage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($currentController == 'showbuilder') {
|
||||||
|
$userIsOnShowbuilderPage = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::zeroFilesUploaded()) {
|
if (self::zeroFilesUploaded()) {
|
||||||
|
@ -92,10 +103,16 @@ class Application_Common_UsabilityHints
|
||||||
"<a href=\"/schedule\">",
|
"<a href=\"/schedule\">",
|
||||||
"</a>");
|
"</a>");
|
||||||
}
|
}
|
||||||
} else {
|
} else if ($userIsOnShowbuilderPage && $userIsSuperAdmin) {
|
||||||
return "";
|
$unpaidInvoice = Billing::checkForUnpaidInvoice();
|
||||||
|
if ($unpaidInvoice != null) {
|
||||||
|
$invoiceUrl = "/billing/invoice?invoiceid=" . $unpaidInvoice['id'];
|
||||||
|
$amount = $unpaidInvoice['currencyprefix'] . $unpaidInvoice['total'];
|
||||||
|
return _pro(sprintf("You have an unpaid invoice for %s due soon. <a href='%s'>Please pay it to keep your station on the air.</a>", $amount, $invoiceUrl));;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if no files have been uploaded.
|
* Returns true if no files have been uploaded.
|
||||||
|
|
|
@ -283,26 +283,7 @@ class BillingController extends Zend_Controller_Action {
|
||||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']);
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
|
||||||
Billing::ensureClientIdIsValid();
|
$this->view->invoices = Billing::getInvoices();
|
||||||
$credentials = Billing::getAPICredentials();
|
|
||||||
|
|
||||||
$postfields = array();
|
|
||||||
$postfields["username"] = $credentials["username"];
|
|
||||||
$postfields["password"] = md5($credentials["password"]);
|
|
||||||
$postfields["action"] = "getinvoices";
|
|
||||||
$postfields["responsetype"] = "json";
|
|
||||||
$postfields["userid"] = Application_Model_Preference::GetClientId();
|
|
||||||
|
|
||||||
$query_string = "";
|
|
||||||
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";
|
|
||||||
|
|
||||||
$result = Billing::makeRequest($credentials["url"], $query_string);
|
|
||||||
|
|
||||||
if ($result["invoices"]) {
|
|
||||||
$this->view->invoices = $result["invoices"]["invoice"];;
|
|
||||||
} else {
|
|
||||||
$this->view->invoices = array();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoiceAction()
|
public function invoiceAction()
|
||||||
|
@ -312,6 +293,4 @@ class BillingController extends Zend_Controller_Action {
|
||||||
$invoice_id = $request->getParam('invoiceid');
|
$invoice_id = $request->getParam('invoiceid');
|
||||||
self::viewInvoice($invoice_id);
|
self::viewInvoice($invoice_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ $topTextClass = "";
|
||||||
if (array_key_exists("planupdated", $_GET))
|
if (array_key_exists("planupdated", $_GET))
|
||||||
{
|
{
|
||||||
$topText = _pro("<b>Thank you!</b> Your plan has been updated and you will be invoiced during your next billing cycle.");
|
$topText = _pro("<b>Thank you!</b> Your plan has been updated and you will be invoiced during your next billing cycle.");
|
||||||
$topTextClass = "status-good";
|
$topTextClass = "invoice-status-good";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$topText = _pro("Tip: To pay an invoice, click \"View Invoice\" and look for the \"Checkout\" button.");
|
$topText = _pro("Tip: To pay an invoice, click \"View Invoice\" and look for the \"Checkout\" button.");
|
||||||
|
|
|
@ -225,6 +225,14 @@
|
||||||
color: #ff0000;
|
color: #ff0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.invoice-status-good {
|
||||||
|
background: #e3ffc9 url(images/stream_status.png) no-repeat 10px 10px;
|
||||||
|
border-color: #54b300;
|
||||||
|
padding: 2px 12px 4px 32px;
|
||||||
|
margin: 2px 1px 10px 0px;
|
||||||
|
color: #330;
|
||||||
|
}
|
||||||
|
|
||||||
/** This form is the separate one on the Billing Account Details page (BillingClient.php) */
|
/** This form is the separate one on the Billing Account Details page (BillingClient.php) */
|
||||||
#clientdetails_form {
|
#clientdetails_form {
|
||||||
width: 500px;
|
width: 500px;
|
||||||
|
|
Loading…
Reference in New Issue