Beispiel #1
0
					<br/><?php 
        echo htmlspecialchars($subscription->name, ENT_COMPAT, 'UTF-8');
        ?>
				</a>
	        </td>
	        <td>
				<?php 
        echo sprintf('%2.2f', (double) $subscription->net_amount);
        ?>
 <?php 
        echo AkeebasubsHelperCparams::getParam('currencysymbol', '€');
        ?>
	        </td>
	        <td>
				<?php 
        echo AkeebasubsHelperFormat::date($subscription->created_on, 'Y-m-d H:i');
        ?>
	        </td>
		</tr>
		<?php 
    }
    ?>
		<?php 
} else {
    ?>
		<tr>
			<td colspan="5">
				<?php 
    echo JText::_('COM_AKEEBASUBS_COMMON_NORECORDS');
    ?>
			</td>
Beispiel #2
0
                echo AkeebasubsHelperFormat::date($subscription->publish_up);
                ?>
					<?php 
            }
            ?>
				</td>
				<td>
					<?php 
            if (empty($subscription->publish_up) || $subscription->publish_down == '0000-00-00 00:00:00') {
                ?>
					&mdash;
					<?php 
            } else {
                ?>
					<?php 
                echo AkeebasubsHelperFormat::date($subscription->publish_down);
                ?>
					<?php 
            }
            ?>
				</td>
				<td align="center">
					<?php 
            if ($subscription->enabled) {
                ?>
					<img src="<?php 
                echo JURI::base();
                ?>
/media/com_akeebasubs/images/frontend/enabled.png" align="center" title="<?php 
                echo JText::_('COM_AKEEBASUBS_SUBSCRIPTIONS_ENABLED_ACTIVE');
                ?>
Beispiel #3
0
 /**
  * Create or update an invoice from a subscription
  *
  * @param   object  $sub  The subscription record
  *
  * @return  bool
  */
 public function createInvoice($sub)
 {
     // Do we already have an invoice record?
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select('*')->from($db->qn('#__akeebasubs_invoices'))->where($db->qn('akeebasubs_subscription_id') . ' = ' . $db->q($sub->akeebasubs_subscription_id));
     $db->setQuery($query);
     $invoiceRecord = $db->loadObject();
     $existingRecord = is_object($invoiceRecord);
     // Flag to know if the template allows me to create an invoice
     $preventInvoice = false;
     $invoiceData = array();
     // Preload helper classes
     if (!class_exists('AkeebasubsHelperCparams')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/cparams.php';
     }
     if (!class_exists('AkeebasubsHelperFormat')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/format.php';
     }
     if (!class_exists('AkeebasubsHelperMessage')) {
         require_once JPATH_ROOT . '/components/com_akeebasubs/helpers/message.php';
     }
     // Get the template
     $templateRow = $this->findTemplate($sub);
     if (is_object($templateRow)) {
         $template = $templateRow->template;
         $templateId = $templateRow->akeebasubs_invoicetemplate_id;
         $globalFormat = $templateRow->globalformat;
         $globalNumbering = $templateRow->globalnumbering;
         // Do I have a "no invoice" flag?
         $preventInvoice = (bool) $templateRow->noinvoice;
     } else {
         $template = '';
         $templateId = 0;
         $globalFormat = true;
         $globalNumbering = true;
     }
     // Do I have a "no invoice" flag on template or subscription?
     $sub_params = new JRegistry($sub->params);
     if ($preventInvoice || $sub_params->get('noinvoice', false)) {
         $sub_params->set('noinvoice', true);
         // I have to manually update the db, using the table object will cause an endless loop
         $query = $db->getQuery(true)->update('#__akeebasubs_subscriptions')->set($db->qn('params') . ' = ' . $db->quote((string) $sub_params))->where($db->qn('akeebasubs_subscription_id') . ' = ' . $sub->akeebasubs_subscription_id);
         $db->setQuery($query)->query();
         return false;
     }
     if ($globalFormat) {
         $numberFormat = AkeebasubsHelperCparams::getParam('invoice_number_format', '[N:5]');
     } else {
         $numberFormat = $templateRow->format;
     }
     if ($globalNumbering) {
         $numberOverride = AkeebasubsHelperCparams::getParam('invoice_override', 0);
     } else {
         $numberOverride = $templateRow->number_reset;
     }
     // Get the configuration variables
     if (!$existingRecord) {
         $jInvoiceDate = JFactory::getDate();
         $invoiceData = array('akeebasubs_subscription_id' => $sub->akeebasubs_subscription_id, 'extension' => 'akeebasubs', 'invoice_date' => $jInvoiceDate->toSql(), 'enabled' => 1, 'created_on' => $jInvoiceDate->toSql(), 'created_by' => $sub->user_id);
         if ($numberOverride) {
             // There's an override set. Use it and reset the override to 0.
             $invoice_no = $numberOverride;
             if ($globalNumbering) {
                 // Global number override reset
                 AkeebasubsHelperCparams::setParam('invoice_override', 0);
             } else {
                 // Invoice template number override reset
                 $templateTable = F0FModel::getTmpInstance('Invoicetemplates', 'AkeebasubsModel')->getItem($templateRow->akeebasubs_invoicetemplate_id);
                 $templateTable->save(array('number_reset' => 0));
             }
         } else {
             if ($globalNumbering) {
                 // Find all the invoice template IDs using Global Numbering and filter by them
                 $q = $db->getQuery(true)->select($db->qn('akeebasubs_invoicetemplate_id'))->from($db->qn('#__akeebasubs_invoicetemplates'))->where($db->qn('globalnumbering') . ' = ' . $db->q(1));
                 $db->setQuery($q);
                 $rawIDs = $db->loadColumn();
                 $gnitIDs = array();
                 foreach ($rawIDs as $id) {
                     $gnitIDs[] = $db->q($id);
                 }
             }
             // Get the new invoice number by adding one to the previous number
             $query = $db->getQuery(true)->select($db->qn('invoice_no'))->from($db->qn('#__akeebasubs_invoices'))->where($db->qn('extension') . ' = ' . $db->q('akeebasubs'))->order($db->qn('created_on') . ' DESC');
             // When not using global numbering search only invoices using this specific invoice template
             if (!$globalNumbering) {
                 $query->where($db->qn('akeebasubs_invoicetemplate_id') . ' = ' . $db->q($templateId));
             } else {
                 $query->where($db->qn('akeebasubs_invoicetemplate_id') . ' IN(' . implode(',', $gnitIDs) . ')');
             }
             $db->setQuery($query, 0, 1);
             $invoice_no = (int) $db->loadResult();
             if (empty($invoice_no)) {
                 $invoice_no = 0;
             }
             $invoice_no++;
         }
         // Parse the invoice number
         $formated_invoice_no = $this->formatInvoiceNumber($numberFormat, $invoice_no, $jInvoiceDate->toUnix());
         // Add the invoice number (plain and formatted) to the record
         $invoiceData['invoice_no'] = $invoice_no;
         $invoiceData['display_number'] = $formated_invoice_no;
         // Add the invoice template ID to the record
         $invoiceData['akeebasubs_invoicetemplate_id'] = $templateId;
     } else {
         // Existing record, make sure it's extension=akeebasubs or quit
         if ($invoiceRecord->extension != 'akeebasubs') {
             $this->setId(0);
             return false;
         }
         $invoice_no = $invoiceRecord->invoice_no;
         $formated_invoice_no = $invoiceRecord->display_number;
         if (empty($formated_invoice_no)) {
             $formated_invoice_no = $invoice_no;
         }
         $jInvoiceDate = JFactory::getDate($invoiceRecord->invoice_date);
         $invoiceData = (array) $invoiceRecord;
     }
     // Get the custom variables
     $vat_notice = '';
     $cyprus_tag = 'TRIANGULAR TRANSACTION';
     $cyprus_note = 'We are obliged by local tax laws to write the words "triangular transaction" on all invoices issued in Euros. This doesn\'t mean anything in particular about your transaction.';
     $kuser = F0FModel::getTmpInstance('Users', 'AkeebasubsModel')->user_id($sub->user_id)->getFirstItem();
     $country = $kuser->country;
     $isbusiness = $kuser->isbusiness;
     $viesregistered = $kuser->viesregistered;
     $inEU = in_array($country, array('AT', 'BE', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'GB', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'));
     if ($inEU && $isbusiness && $viesregistered) {
         $vat_notice = AkeebasubsHelperCparams::getParam('invoice_vatnote', 'VAT liability is transferred to the recipient, pursuant EU Directive nr 2006/112/EC and local tax laws implementing this directive.');
         $cyprus_tag = 'REVERSE CHARGE';
         $cyprus_note = 'We are obliged by local and European tax laws to write the words "reverse charge" on all invoices issued to EU business when no VAT is charged. This is supposed to serve as a reminder that the recipient of the invoice (you) have to be registered to your local VAT office so as to apply to YOUR business\' VAT form the VAT owed by this transaction on the reverse charge basis, as described above. The words "reverse charge" DO NOT indicate a problem with your transaction, a cancellation or a refund.';
     }
     $extras = array('[INV:ID]' => $invoice_no, '[INV:PLAIN_NUMBER]' => $invoice_no, '[INV:NUMBER]' => $formated_invoice_no, '[INV:INVOICE_DATE]' => AkeebasubsHelperFormat::date($jInvoiceDate->toUnix()), '[INV:INVOICE_DATE_EU]' => $jInvoiceDate->format('d/m/Y', true), '[INV:INVOICE_DATE_USA]' => $jInvoiceDate->format('m/d/Y', true), '[INV:INVOICE_DATE_JAPAN]' => $jInvoiceDate->format('Y/m/d', true), '[VAT_NOTICE]' => $vat_notice, '[CYPRUS_TAG]' => $cyprus_tag, '[CYPRUS_NOTE]' => $cyprus_note);
     // Render the template into HTML
     $invoiceData['html'] = AkeebasubsHelperMessage::processSubscriptionTags($template, $sub, $extras);
     // Save the record
     if ($existingRecord) {
         $o = (object) $invoiceData;
         $db->updateObject('#__akeebasubs_invoices', $o, 'akeebasubs_subscription_id');
     } else {
         $o = (object) $invoiceData;
         $db->insertObject('#__akeebasubs_invoices', $o);
     }
     // Set up the return value
     $ret = $invoice_no;
     $this->setId($sub->akeebasubs_subscription_id);
     // Create PDF
     $this->createPDF();
     // Update subscription record with the invoice number without saving the
     // record through the Model, as this triggers the integration plugins,
     // which in turn causes double emails to be sent out. Baazinga!
     $query = $db->getQuery(true)->update($db->qn('#__akeebasubs_subscriptions'))->set($db->qn('akeebasubs_invoice_id') . ' = ' . $db->q($invoice_no))->where($db->qn('akeebasubs_subscription_id') . ' = ' . $db->q($sub->akeebasubs_subscription_id));
     $db->setQuery($query);
     $db->execute();
     $sub->akeebasubs_invoice_id = $invoice_no;
     // If auto-send is enabled, send the invoice by email
     $autoSend = AkeebasubsHelperCparams::getParam('invoice_autosend', 1);
     if ($autoSend) {
         $this->emailPDF();
     }
     return true;
 }
Beispiel #4
0
			<?php 
    echo AkeebasubsHelperCparams::getParam('currencysymbol', '€');
    ?>
			<?php 
}
?>
		</td>
	</tr>
	<tr>
		<td class="subscription-label"><?php 
echo JText::_('COM_AKEEBASUBS_SUBSCRIPTION_SUBSCRIBED_ON');
?>
</td>
		<td class="subscription-info">
			<?php 
echo AkeebasubsHelperFormat::date($this->item->created_on);
?>
		</td>
	</tr>
</table>

<?php 
$args = array(array('useredit' => true, 'subscriptionlevel' => $this->item->akeebasubs_level_id, 'subcustom' => $this->item->params));
$jResponse = $app->triggerEvent('onSubscriptionFormRenderPerSubFields', $args);
@ob_start();
if (is_array($jResponse) && !empty($jResponse)) {
    foreach ($jResponse as $customFields) {
        if (is_array($customFields) && !empty($customFields)) {
            foreach ($customFields as $field) {
                $customField_class = '';
                $validationClass = '';