protected function generateInvoiceData($data, array $client) { require_once dirname(__DIR__) . '/OnAppvCD.php'; $module = new OnAppvCDModule(); $lang = $module->loadLang()->Invoice; //check if invoice should be generated $fromTime = strtotime($this->fromDate); $tillTime = strtotime($this->tillDate); if ($fromTime >= $tillTime) { return false; } if (empty($client['dueDate'])) { $dueDate = $this->dueDate; } else { $dueDate = date('Ymd', time() + $client['dueDate'] * 86400); } # check if the item should be taxed $taxed = empty($client['taxexempt']) && (int) $client['tax']; if ($taxed) { $taxrate = getTaxRate(1, $client['state'], $client['country']); $taxrate = $taxrate['rate']; } else { $taxrate = ''; } $timeZone = ' UTC'; if ($this->timeZoneOffset > 0) { $timeZone .= '+' . $this->timeZoneOffset / 3600; } elseif ($this->timeZoneOffset < 0) { $timeZone .= $this->timeZoneOffset / 3600; } $this->fromDate = date($lang->DateFormat, $fromTime); $this->tillDate = date($lang->DateFormat, $tillTime); $invoiceDescription = array($lang->Product . $client['packagename'], $lang->Period . $this->fromDate . ' - ' . $this->tillDate . $timeZone); $invoiceDescription = implode(PHP_EOL, $invoiceDescription); $return = array('userid' => $client['WHMCSUserID'], 'date' => $this->dueDate, 'duedate' => $dueDate, 'paymentmethod' => $client['paymentmethod'], 'taxrate' => $taxrate, 'sendinvoice' => true, 'itemdescription1' => $invoiceDescription, 'itemamount1' => 0, 'itemtaxed1' => $taxed); unset($data->total_cost); $i = 1; foreach ($data as $key => $value) { if ($value > 0) { $tmp = array('itemdescription' . ++$i => $lang->{$key}, 'itemamount' . $i => $value, 'itemtaxed' . $i => $taxed); $return = array_merge($return, $tmp); } } if ($this->printEnabled) { print_r($return); } return $return; }
function OnAppvCD_AdminServicesTabFieldsSave($params) { if ($_POST[OnAppvCDModule::MODULE_NAME . '_Prev'] === 'null') { $module = new OnAppvCDModule($params); $OnAppUser = $module->getObject('User'); $OnAppUser->id = $_POST[$module::MODULE_NAME]['OnAppUserID']; $OnAppUser = $OnAppUser->load(); if (!is_null($OnAppUser->error)) { $lang = $module->loadLang()->Admin; $errorMsg = $lang->Error_LinkUser . ":\\n"; $errorMsg .= $OnAppUser->getErrorsAsString("\\n"); echo '<script>alert("' . $errorMsg . '");</script><meta http-equiv="refresh" content="0">'; exit; } else { $id = $OnAppUser->id; $login = $OnAppUser->login; } # save user link Capsule::table(OnAppvCDModule::MODULE_NAME . '_Users')->insert(['serviceID' => $params['serviceid'], 'WHMCSUserID' => $params['userid'], 'OnAppUserID' => $id, 'serverID' => $params['serverid'], 'billingType' => $params['configoption2']]); $password = $module::generatePassword(); $OnAppUser = $module->getObject('User'); $OnAppUser->id = $id; $OnAppUser->password = $password; $OnAppUser->save(); # save OnApp login and password Capsule::table('tblhosting')->where('id', $params['serviceid'])->update(['password' => encrypt($password), 'username' => $login]); } else { $prev = json_decode(html_entity_decode($_POST[OnAppvCDModule::MODULE_NAME . '_Prev'])); # check server change if ($prev->serverID != $_POST['server']) { $_POST[OnAppvCDModule::MODULE_NAME]['serverID'] = $_POST['server']; } Capsule::table(OnAppvCDModule::MODULE_NAME . '_Users')->where('id', $prev->id)->update($_POST[OnAppvCDModule::MODULE_NAME]); } }