diff --git a/airtime_mvc/application/controllers/BillingController.php b/airtime_mvc/application/controllers/BillingController.php index 5406ffee5..ffe90234f 100644 --- a/airtime_mvc/application/controllers/BillingController.php +++ b/airtime_mvc/application/controllers/BillingController.php @@ -9,6 +9,10 @@ class BillingController extends Zend_Controller_Action { public function upgradeAction() { + $CC_CONFIG = Config::getConfig(); + $baseUrl = Application_Common_OsPath::getBaseDir(); + $this->view->headLink()->appendStylesheet($baseUrl.'css/billing.css?'.$CC_CONFIG['airtime_version']); + $request = $this->getRequest(); $form = new Application_Form_BillingUpgradeDowngrade(); if ($request->isPost()) { @@ -29,11 +33,9 @@ class BillingController extends Zend_Controller_Action { $postfields["username"] = $credentials["username"]; $postfields["password"] = md5($credentials["password"]); $postfields["action"] = "upgradeproduct"; - $postfields["clientid"] = Application_Model_Preference::GetClientId(); $postfields["serviceid"] = self::getClientServiceId(); - $postfields["type"] = "product"; $postfields["newproductid"] = $formData["newproductid"]; $postfields["newproductbillingcycle"] = $formData["newproductbillingcycle"]; @@ -41,20 +43,17 @@ class BillingController extends Zend_Controller_Action { $postfields["responsetype"] = "json"; $upgrade_query_string = ""; - foreach ($postfields as $k=>$v) $upgrade_query_string .= "$k=".urlencode($v)."&"; + foreach ($postfields AS $k=>$v) $upgrade_query_string .= "$k=".urlencode($v)."&"; //update client info $clientfields = array(); $clientfields["username"] = $credentials["username"]; $clientfields["password"] = md5($credentials["password"]); - $clientfields["action"] = "updateclient"; - + $clientfields["action"] = "updateclient"; $clientfields["clientid"] = Application_Model_Preference::GetClientId(); - $clientfields["customfields"] = base64_encode(serialize($formData["customfields"])); unset($formData["customfields"]); - $clientfields["responsetype"] = "json"; unset($formData["newproductid"]); unset($formData["newproductbillingcycle"]); @@ -64,10 +63,10 @@ class BillingController extends Zend_Controller_Action { unset($clientfields["password2verify"]); unset($clientfields["submit"]); $client_query_string = ""; - foreach ($clientfields as $k=>$v) $client_query_string .= "$k=".urlencode($v)."&"; + foreach ($clientfields AS $k=>$v) $client_query_string .= "$k=".urlencode($v)."&"; $result = $this->makeRequest($credentials["url"], $client_query_string); - + Logging::info($result); if ($result["result"] == "error") { $this->setErrorMessage(); $this->view->form = $form; @@ -164,7 +163,7 @@ class BillingController extends Zend_Controller_Action { { $whmcsurl = "https://account.sourcefabric.com/dologin.php"; $autoauthkey = $_SERVER["WHMCS_AUTOAUTH_KEY"]; - $timestamp = time(); + $timestamp = time(); //whmcs timezone? $client = self::getClientDetails(); $email = $client["email"]; $hash = sha1($email.$timestamp.$autoauthkey); @@ -179,7 +178,7 @@ class BillingController extends Zend_Controller_Action { if ($request->isPost()) { $formData = $request->getPost(); if ($form->isValid($formData)) { - + $credentials = self::getAPICredentials(); $postfields = array(); @@ -191,14 +190,13 @@ class BillingController extends Zend_Controller_Action { unset($formData["customfields"]); $postfields["clientid"] = Application_Model_Preference::GetClientId(); - $postfields["responsetype"] = "json"; $postfields = array_merge($postfields, $formData); unset($postfields["password2verify"]); unset($postfields["submit"]); - + $query_string = ""; - foreach ($postfields as $k=>$v) $query_string .= "$k=".urlencode($v)."&"; + foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $result = $this->makeRequest($credentials["url"], $query_string); @@ -230,7 +228,7 @@ class BillingController extends Zend_Controller_Action { $postfields["clientid"] = Application_Model_Preference::GetClientId(); $query_string = ""; - foreach ($postfields as $k=>$v) $query_string .= "$k=".urlencode($v)."&"; + foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $result = self::makeRequest($credentials["url"], $query_string); @@ -244,10 +242,9 @@ class BillingController extends Zend_Controller_Action { self::viewInvoice($invoice_id); } - private static function getClientServiceId() + //TODO: this does not return a service id. why? + private static function getClientInstanceId() { - $service_id = null; - $credentials = self::getAPICredentials(); $postfields = array(); @@ -258,21 +255,10 @@ class BillingController extends Zend_Controller_Action { $postfields["clientid"] = Application_Model_Preference::GetClientId(); $query_string = ""; - foreach ($postfields as $k=>$v) $query_string .= "$k=".urlencode($v)."&"; + foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $result = self::makeRequest($credentials["url"], $query_string); - if (empty($result["products"])) { - Logging::info($_SERVER['HTTP_HOST']." - Account upgrade failed - Could not find service id"); - } else { - foreach ($result["products"]["product"] as $product) { - if (array_key_exists("groupname", $product) && $product["groupname"] == "Airtime") { - $service_id = $product["id"]; - } - break; - } - } - - return $service_id; + Logging::info($result); } public static function getProducts() @@ -288,7 +274,7 @@ class BillingController extends Zend_Controller_Action { $postfields["gid"] = "15"; $query_string = ""; - foreach ($postfields as $k=>$v) $query_string .= "$k=".urlencode($v)."&"; + foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $result = self::makeRequest($credentials["url"], $query_string); return $result["products"]["product"]; @@ -308,7 +294,7 @@ class BillingController extends Zend_Controller_Action { $postfields["responsetype"] = "json"; $query_string = ""; - foreach ($postfields as $k=>$v) $query_string .= "$k=".urlencode($v)."&"; + foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $arr = self::makeRequest($credentials["url"], $query_string); return $arr["client"]; diff --git a/airtime_mvc/application/forms/BillingClient.php b/airtime_mvc/application/forms/BillingClient.php index d0cb60729..8ade507f2 100644 --- a/airtime_mvc/application/forms/BillingClient.php +++ b/airtime_mvc/application/forms/BillingClient.php @@ -4,7 +4,7 @@ require_once 'Zend/Locale.php'; class Application_Form_BillingClient extends Zend_Form { public function init() - { + { /*$this->setDecorators(array( array('ViewScript', array('viewScript' => 'form/billing-purchase.phtml'))));*/ $client = BillingController::getClientDetails(); diff --git a/airtime_mvc/application/forms/BillingUpgradeDowngrade.php b/airtime_mvc/application/forms/BillingUpgradeDowngrade.php index 8a7d8a084..10f2b8be7 100644 --- a/airtime_mvc/application/forms/BillingUpgradeDowngrade.php +++ b/airtime_mvc/application/forms/BillingUpgradeDowngrade.php @@ -6,7 +6,7 @@ class Application_Form_BillingUpgradeDowngrade extends Zend_Form $productPrices = array(); $productTypes = array(); $products = BillingController::getProducts(); - + foreach ($products as $k => $p) { $productPrices[$p["name"]] = array( "monthly" => $p["pricing"]["USD"]["monthly"], @@ -18,23 +18,26 @@ class Application_Form_BillingUpgradeDowngrade extends Zend_Form //$currentPlanType = ucfirst(Application_Model_Preference::GetPlanLevel()); $currentPlanType = "Hobbyist"; if (($key = array_search($currentPlanType, $productTypes)) !== false) { - unset($productTypes[$key]); + //unset($productTypes[$key]); } $pid = new Zend_Form_Element_Radio('newproductid'); $pid->setLabel(_('Plan type:')) ->setMultiOptions($productTypes) + ->setRequired(true) ->setValue(26); - $this->addElement($pid); - + $this->addElement($pid); + $billingcycle = new Zend_Form_Element_Radio('newproductbillingcycle'); $billingcycle->setLabel(_('Billing cycle:')) ->setMultiOptions(array('monthly' => 'monthly', 'annually' => 'annually')) + ->setRequired(true) ->setValue('monthly'); $this->addElement($billingcycle); $paymentmethod = new Zend_Form_Element_Radio('paymentmethod'); $paymentmethod->setLabel(_('Payment method:')) + ->setRequired(true) ->setMultiOptions(array( 'paypal' => _('PayPal'), 'tco' => _('Credit Card via 2Checkout'))) diff --git a/airtime_mvc/application/views/scripts/billing/upgrade.phtml b/airtime_mvc/application/views/scripts/billing/upgrade.phtml index 6d40d3b0d..c111765b5 100644 --- a/airtime_mvc/application/views/scripts/billing/upgrade.phtml +++ b/airtime_mvc/application/views/scripts/billing/upgrade.phtml @@ -1,8 +1,86 @@ +form; + $form->setAttrib('id', 'upgrade-downgrade'); +?>
+

Account Plans

+
+pricing grid here +
errorMessage)) {?>
errorMessage ?>
Plan Level:
-form ?> + + + +
+ +
+ newproductid ?> +
+
+ newproductbillingcycle ?> +
+
+ paymentmethod ?> +
+ +
+ getSubform("billing_client_info") ?> +
+ firstname?> +
+
+ lastname?> +
+
+ companyname?> +
+
+ email?> +
+
+ address1?> +
+
+ address2?> +
+
+ city?> +
+
+ state?> +
+
+ postcode?> +
+
+ country?> +
+
+ phonenumber?> +
+
+ securityqid?> +
+
+ securityqans?> +
+
+ getElement("7"); ?> +
+
+ getElement("71"); ?> +
+
+ password2?> +
+
+ password2verify?> +
+ +




\ No newline at end of file diff --git a/airtime_mvc/public/css/billing.css b/airtime_mvc/public/css/billing.css new file mode 100644 index 000000000..da9ab49be --- /dev/null +++ b/airtime_mvc/public/css/billing.css @@ -0,0 +1,33 @@ +@CHARSET "UTF-8"; + +#upgrade-downgrade dl +{ + width: 300px; +} + +#upgrade-downgrade dt, #upgrade-downgrade dd +{ + margin: 0px; +} + +#upgrade-downgrade dd +{ + margin-bottom: 10px; +} + +#plantype +{ + float: left; + +} + +#billingcycle +{ + float: left; +} + +#paymentmethod +{ + float: left; + +} \ No newline at end of file