parent
540b9167a1
commit
40f2796972
|
@ -12,49 +12,66 @@ class BillingController extends Zend_Controller_Action {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$form = new Application_Form_BillingUpgradeDowngrade();
|
$form = new Application_Form_BillingUpgradeDowngrade();
|
||||||
if ($request->isPost()) {
|
if ($request->isPost()) {
|
||||||
|
//$formData = $form->getValues();
|
||||||
$formData = $request->getPost();
|
$formData = $request->getPost();
|
||||||
|
if ($form->isValid($formData)) {
|
||||||
$accessKey = $_SERVER["WHMCS_ACCESS_KEY"];
|
|
||||||
$username = $_SERVER["WHMCS_USERNAME"];
|
$credentials = self::getAPICredentials();
|
||||||
$password = $_SERVER["WHMCS_PASSWORD"];
|
|
||||||
$url = "https://account.sourcefabric.com/includes/api.php?accesskey=" . $accessKey;
|
$postfields = array();
|
||||||
|
$postfields["username"] = $credentials["username"];
|
||||||
$postfields = array();
|
$postfields["password"] = md5($credentials["password"]);
|
||||||
$postfields["username"] = $username;
|
$postfields["action"] = "upgradeproduct";
|
||||||
$postfields["password"] = md5($password);
|
//$postfields["clientid"] = Application_Model_Preference::GetClientId();
|
||||||
$postfields["action"] = "upgradeproduct";
|
$postfields["clientid"] = 1846;
|
||||||
//$postfields["clientid"] = Application_Model_Preference::GetClientId();
|
//TODO: do not hardcode
|
||||||
$postfields["clientid"] = 1846;
|
//$postfields["serviceid"] = self::getClientInstanceId();
|
||||||
//TODO: do not hardcode
|
$postfields["serviceid"] = "1678";
|
||||||
//$postfields["serviceid"] = self::getClientInstanceId();
|
$postfields["type"] = "product";
|
||||||
$postfields["serviceid"] = "1678";
|
$postfields["newproductid"] = $formData["newproductid"];
|
||||||
$postfields["type"] = "product";
|
$postfields["newproductbillingcycle"] = $formData["newproductbillingcycle"];
|
||||||
$postfields["newproductid"] = $formData["newproductid"];
|
$postfields["paymentmethod"] = $formData["paymentmethod"];
|
||||||
$postfields["newproductbillingcycle"] = $formData["newproductbillingcycle"];
|
$postfields["responsetype"] = "json";
|
||||||
$postfields["paymentmethod"] = $formData["paymentmethod"];
|
|
||||||
$postfields["responsetype"] = "json";
|
$query_string = "";
|
||||||
|
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";
|
||||||
$query_string = "";
|
|
||||||
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";
|
//update client info
|
||||||
|
|
||||||
//$result = $this->makeRequest($url, $query_string);
|
|
||||||
//$invoiceUrl = "https://account.sourcefabric.com/viewinvoice.php?id=".$result["invoiceid"];
|
//$result = $this->makeRequest($credentials["url"], $query_string);
|
||||||
|
//self::viewInvoice($result["invoiceid"]);
|
||||||
$whmcsurl = "https://account.sourcefabric.com/dologin.php";
|
self::viewInvoice(5108);
|
||||||
$autoauthkey = $_SERVER["WHMCS_AUTOAUTH_KEY"];
|
} else {
|
||||||
$timestamp = time(); //whmcs timezone?
|
$this->view->form = $form;
|
||||||
$client = self::getClientDetails();
|
}
|
||||||
$email = $client["email"];
|
|
||||||
$hash = sha1($email.$timestamp.$autoauthkey);
|
|
||||||
//$goto = "viewinvoice.php?id=".$result["invoiceid"];
|
|
||||||
$goto="viewinvoice.php?id=5108";
|
|
||||||
$this->_redirect($whmcsurl."?email=$email×tamp=$timestamp&hash=$hash&goto=$goto");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function getAPICredentials()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
"access_key" => $_SERVER["WHMCS_ACCESS_KEY"],
|
||||||
|
"username" => $_SERVER["WHMCS_USERNAME"],
|
||||||
|
"password" => $_SERVER["WHMCS_PASSWORD"],
|
||||||
|
"url" => "https://account.sourcefabric.com/includes/api.php?accesskey=".$_SERVER["WHMCS_ACCESS_KEY"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function viewInvoice($invoice_id)
|
||||||
|
{
|
||||||
|
$whmcsurl = "https://account.sourcefabric.com/dologin.php";
|
||||||
|
$autoauthkey = $_SERVER["WHMCS_AUTOAUTH_KEY"];
|
||||||
|
$timestamp = time(); //whmcs timezone?
|
||||||
|
$client = self::getClientDetails();
|
||||||
|
$email = $client["email"];
|
||||||
|
$hash = sha1($email.$timestamp.$autoauthkey);
|
||||||
|
$goto = "viewinvoice.php?id=".$invoice_id;
|
||||||
|
header("Location: ".$whmcsurl."?email=$email×tamp=$timestamp&hash=$hash&goto=$goto");
|
||||||
|
}
|
||||||
|
|
||||||
public function clientAction()
|
public function clientAction()
|
||||||
{
|
{
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
@ -88,7 +105,7 @@ class BillingController extends Zend_Controller_Action {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoiceAction()
|
public function invoicesAction()
|
||||||
{
|
{
|
||||||
$accessKey = $_SERVER["WHMCS_ACCESS_KEY"];
|
$accessKey = $_SERVER["WHMCS_ACCESS_KEY"];
|
||||||
$username = $_SERVER["WHMCS_USERNAME"];
|
$username = $_SERVER["WHMCS_USERNAME"];
|
||||||
|
@ -98,7 +115,23 @@ class BillingController extends Zend_Controller_Action {
|
||||||
$postfields = array();
|
$postfields = array();
|
||||||
$postfields["username"] = $username;
|
$postfields["username"] = $username;
|
||||||
$postfields["password"] = md5($password);
|
$postfields["password"] = md5($password);
|
||||||
$postfields["action"] = "updateclient";
|
$postfields["action"] = "getinvoices";
|
||||||
|
$postfields["responsetype"] = "json";
|
||||||
|
$postfields["userid"] = 1846;
|
||||||
|
//$postfields["clientid"] = Application_Model_Preference::GetClientId();
|
||||||
|
|
||||||
|
$query_string = "";
|
||||||
|
foreach ($postfields AS $k=>$v) $query_string .= "$k=".urlencode($v)."&";
|
||||||
|
|
||||||
|
$result = self::makeRequest($url, $query_string);
|
||||||
|
$this->view->invoices = $result["invoices"]["invoice"];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function invoiceAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$invoice_id = $request->getParam('invoiceid');
|
||||||
|
self::viewInvoice($invoice_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: this does not return a service id. why?
|
//TODO: this does not return a service id. why?
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Application_Form_BillingClient extends Zend_Form
|
||||||
->addFilter('StringTrim');
|
->addFilter('StringTrim');
|
||||||
$this->addElement($phonenumber);
|
$this->addElement($phonenumber);
|
||||||
|
|
||||||
/*$securityqid = new Zend_Form_Element_Select('securityqid');
|
$securityqid = new Zend_Form_Element_Select('securityqid');
|
||||||
$securityqid->setLabel(_('Please choose a security question:'))
|
$securityqid->setLabel(_('Please choose a security question:'))
|
||||||
->setValue($client["securityqid"])
|
->setValue($client["securityqid"])
|
||||||
->setAttrib('class', 'input_text')
|
->setAttrib('class', 'input_text')
|
||||||
|
@ -137,7 +137,7 @@ class Application_Form_BillingClient extends Zend_Form
|
||||||
->setRequired(true)
|
->setRequired(true)
|
||||||
->addValidator($notEmptyValidator)
|
->addValidator($notEmptyValidator)
|
||||||
->addFilter('StringTrim');
|
->addFilter('StringTrim');
|
||||||
$this->addElement($securityqans);*/
|
$this->addElement($securityqans);
|
||||||
|
|
||||||
foreach ($client["customfields"] as $field) {
|
foreach ($client["customfields"] as $field) {
|
||||||
if ($field["id"] == 7) {
|
if ($field["id"] == 7) {
|
||||||
|
@ -151,8 +151,8 @@ class Application_Form_BillingClient extends Zend_Form
|
||||||
$vat->setLabel(_('VAT/Tax ID (EU only)'))
|
$vat->setLabel(_('VAT/Tax ID (EU only)'))
|
||||||
->setValue($vatvalue)
|
->setValue($vatvalue)
|
||||||
->setAttrib('class', 'input_text')
|
->setAttrib('class', 'input_text')
|
||||||
->setRequired(true)
|
//->setRequired(true)
|
||||||
->addValidator($notEmptyValidator)
|
//->addValidator($notEmptyValidator)
|
||||||
->addFilter('StringTrim');
|
->addFilter('StringTrim');
|
||||||
$this->addElement($vat);
|
$this->addElement($vat);
|
||||||
|
|
||||||
|
@ -168,6 +168,7 @@ class Application_Form_BillingClient extends Zend_Form
|
||||||
$password = new Zend_Form_Element_Password('password2');
|
$password = new Zend_Form_Element_Password('password2');
|
||||||
$password->setLabel(_('Password:'));
|
$password->setLabel(_('Password:'));
|
||||||
$password->setAttrib('class', 'input_text');
|
$password->setAttrib('class', 'input_text');
|
||||||
|
$password->setValue("xxxxxx");
|
||||||
$password->setRequired(true);
|
$password->setRequired(true);
|
||||||
$password->addFilter('StringTrim');
|
$password->addFilter('StringTrim');
|
||||||
$password->addValidator($notEmptyValidator);
|
$password->addValidator($notEmptyValidator);
|
||||||
|
@ -176,8 +177,11 @@ class Application_Form_BillingClient extends Zend_Form
|
||||||
$passwordVerify = new Zend_Form_Element_Password('password2verify');
|
$passwordVerify = new Zend_Form_Element_Password('password2verify');
|
||||||
$passwordVerify->setLabel(_('Verify Password:'));
|
$passwordVerify->setLabel(_('Verify Password:'));
|
||||||
$passwordVerify->setAttrib('class', 'input_text');
|
$passwordVerify->setAttrib('class', 'input_text');
|
||||||
|
$passwordVerify->setValue("xxxxxx");
|
||||||
$passwordVerify->setRequired(true);
|
$passwordVerify->setRequired(true);
|
||||||
$passwordVerify->addFilter('StringTrim');
|
$passwordVerify->addFilter('StringTrim');
|
||||||
|
//$passwordVerify->addValidator($notEmptyValidator);
|
||||||
|
$passwordVerify->addValidator('Identical', false, array('token' => 'password2'));
|
||||||
$passwordVerify->addValidator($notEmptyValidator);
|
$passwordVerify->addValidator($notEmptyValidator);
|
||||||
$this->addElement($passwordVerify);
|
$this->addElement($passwordVerify);
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,12 @@ class Application_Form_BillingUpgradeDowngrade extends Zend_Form
|
||||||
->setValue('paypal');
|
->setValue('paypal');
|
||||||
$this->addElement($paymentmethod);
|
$this->addElement($paymentmethod);
|
||||||
|
|
||||||
$submit = new Zend_Form_Element_Submit("submit");
|
/*$submit = new Zend_Form_Element_Submit("submit");
|
||||||
$submit->setIgnore(true)
|
$submit->setIgnore(true)
|
||||||
->setLabel(_("Save"));
|
->setLabel(_("Save"));
|
||||||
$this->addElement($submit);
|
$this->addElement($submit);*/
|
||||||
|
|
||||||
|
$client = new Application_Form_BillingClient();
|
||||||
|
$this->addSubForm($client, 'billing_client_info');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<div class="ui-widget ui-widget-content block-shadow clearfix padded-strong">
|
||||||
|
<?php
|
||||||
|
foreach ($this->invoices as $invoice) {?>
|
||||||
|
<div>
|
||||||
|
<a href="invoice?invoiceid=<?php echo $invoice["id"]?>">View Invoice</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php }?>
|
||||||
|
</div>
|
Loading…
Reference in New Issue