Exemple #1
0
 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;
 }
Exemple #2
0
function OnAppvCD_Custom_OutstandingDetails($params = '')
{
    $module = new OnAppvCDModule();
    $data = $module->getAmount($params);
    if ($data) {
        header('Content-Type: application/json; charset=utf-8');
        echo json_encode($data);
    } else {
        header('HTTP/1.1 404 No Data Found');
    }
    exit;
}