Exemplo n.º 1
0
		<div class="controls">
			<input type="text" name="vatnumber" id="vatnumber" class="longer" value="<?php 
echo $this->escape($this->item->vatnumber);
?>
" />
		</div>
	</div>

	<div class="control-group">
		<label for="viesregistered" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_USERS_FIELD_VIESREGISTERED');
?>
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::viesregistered('viesregistered', $this->item->viesregistered);
?>
		</div>
	</div>
</div>

</div>

<div class="row-fluid">

<div class="span6">
	<h3><?php 
echo JText::_('COM_AKEEBASUBS_USER_NOTES_TITLE');
?>
</h3>
Exemplo n.º 2
0
if ($eucountries) {
    $additionalCountries = AkeebasubsHelperEuVATInfo::$EuropeanUnionVATInformation;
    foreach ($additionalCountries as $code => $info) {
        if (!in_array($code, $countryCodes)) {
            $countryCodes[] = $code;
        }
    }
}
if ($eubusiness && !in_array('EU-VIES', $countryCodes)) {
    $countryCodes[] = 'EU-VIES';
}
if ($international && !in_array('XX', $countryCodes)) {
    $countryCodes[] = 'XX';
}
$options = array();
$countryNames = AkeebasubsHelperSelect::getCountries();
foreach ($countryCodes as $code) {
    switch ($code) {
        case 'XX':
            $options[] = JHtml::_('select.option', $code, JText::_('MOD_AKTAXCOUNTRY_LBL_INTERNATIONAL'));
            break;
        case 'EU-VIES':
            $options[] = JHtml::_('select.option', $code, JText::_('MOD_AKTAXCOUNTRY_LBL_EUBUSINES'));
            break;
        default:
            if (array_key_exists($code, $countryNames)) {
                $options[] = JHtml::_('select.option', $code, $countryNames[$code]);
            } else {
                $options[] = JHtml::_('select.option', $code, $code);
            }
            break;
Exemplo n.º 3
0
	<div class="row-fluid">
		<div class="span6">
			<h3><?php 
echo JText::_('COM_AKEEBASUBS_IMPORT_DETAILS');
?>
</h3>

			<div class="control-group">
				<label class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_IMPORT_DELIMITERS');
?>
</label>
				<div class="controls">
					<?php 
echo AkeebasubsHelperSelect::csvdelimiters('csvdelimiters', 1, array('class' => 'minwidth'));
?>
					<div class="help-block">
						<?php 
echo JText::_('COM_AKEEBASUBS_IMPORT_DELIMITERS_DESC');
?>
					</div>
				</div>
			</div>
			<div class="control-group" id="field_delimiter" style="display:none">
				<label class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_IMPORT_FIELD_DELIMITERS');
?>
</label>
				<div class="controls">
					<input type="text" name="field_delimiter" value="">
Exemplo n.º 4
0
				<div class="controls">
					<?php 
echo AkeebasubsHelperSelect::levels('subscriptions[]', empty($this->item->subscriptions) ? '-1' : explode(',', $this->item->subscriptions), array('multiple' => 'multiple', 'size' => 3));
?>
				</div>
			</div>

			<div class="control-group">
				<label for="usage_limits" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_APICOUPONS_FIELD_USAGE_LIMITS');
?>
</label>
				<div class="controls">
					<?php 
$selected = $this->item->creation_limit ? 1 : ($this->item->subscription_limit ? 2 : 3);
echo AkeebasubsHelperSelect::apicouponLimits('usage_limits', $selected);
?>

						<input type="text" style="width: 50px; display:none" id="creation_limit_field" name="creation_limit" value="<?php 
echo $this->escape($this->item->creation_limit);
?>
" />
						<input type="text" style="width: 50px; display:none" id="subscription_limit_field" name="subscription_limit" value="<?php 
echo $this->escape($this->item->subscription_limit);
?>
" />
						<input type="text" style="width: 50px; display:none" id="value_limit_field" name="value_limit" value="<?php 
echo $this->escape($this->item->value_limit);
?>
" />
Exemplo n.º 5
0
echo AkeebasubsHelperSelect::levels('akeebasubs_level_id[]', empty($this->item->akeebasubs_level_id) ? '-1' : explode(',', $this->item->akeebasubs_level_id), array('multiple' => 'multiple', 'size' => 5));
?>
				<p class="help-block"><?php 
echo JText::_('COM_AKEEBASUBS_CUSTOMFIELDS_HELP_LEVEL');
?>
</p>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="type"><?php 
echo JText::_('COM_AKEEBASUBS_CUSTOMFIELDS_FIELD_TYPE');
?>
</label>
			<div class="controls">
				<?php 
echo AkeebasubsHelperSelect::fieldtypes('type', $this->item->type);
?>
				<p class="help-block"><?php 
echo JText::_('COM_AKEEBASUBS_CUSTOMFIELDS_HELP_TYPE');
?>
</p>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="options"><?php 
echo JText::_('COM_AKEEBASUBS_CUSTOMFIELDS_FIELD_OPTIONS');
?>
</label>
			<div class="controls">
				<textarea name="options" id="options" cols="50" rows="7" class="input-xxlarge"><?php 
echo $this->item->options;
Exemplo n.º 6
0
if ($hidePaymentMethod) {
    ?>
	<div style="display: none;">
	<?php 
}
?>
	<div id="paymentmethod-container">
		<div class="control-group form-group">
			<label for="paymentmethod" class="control-label col-sm-2">
				<?php 
echo JText::_('COM_AKEEBASUBS_LEVEL_FIELD_METHOD');
?>
			</label>
			<div class="controls col-sm-3">
				<?php 
echo AkeebasubsHelperSelect::paymentmethods('paymentmethod', '', array('id' => 'paymentmethod', 'level_id' => $this->item->akeebasubs_level_id));
?>
			</div>
		</div>
	</div>
	<?php 
if ($hidePaymentMethod) {
    ?>
	</div>
	<?php 
}
?>

	<div class="well">
        <button id="subscribenow" class="btn btn-large btn-primary" type="submit" style="display:block;margin:auto">
            <?php 
Exemplo n.º 7
0
				<?php 
echo JText::_('COM_AKEEBASUBS_TAXCONFIGS_LBL_VIESREG_INFO');
?>
			</span>
		</div>
	</div>

	<div class="control-group">
		<label class="control-label" for="showvat">
			<?php 
echo JText::_('COM_AKEEBASUBS_TAXCONFIGS_LBL_SHOWVAT');
?>
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::booleanlist('showvat', array(), 0);
?>
			<span class="help-block">
				<?php 
echo JText::_('COM_AKEEBASUBS_TAXCONFIGS_LBL_SHOWVAT_INFO');
?>
			</span>
		</div>
	</div>

	<div class="form-actions">
		<button class="btn btn-primary btn-large">
			<i class="icon-white icon-check"></i>
			<?php 
echo JText::_('COM_AKEEBASUBS_TAXCONFIGS_LBL_SUBMIT');
?>
Exemplo n.º 8
0
AkeebaStrapper::addJSfile('media://com_akeebasubs/js/cpanelgraphs.js?' . AKEEBASUBS_VERSIONHASH);
JHTML::_('behavior.framework', true);
$this->loadHelper('select');
$graphDayFrom = gmdate('Y-m-d', time() - 30 * 24 * 3600);
$graphDayTo = gmdate('Y-m-d', time());
?>
<div class="well well-small">
	<div class="form form-inline">
		<?php 
echo JHTML::_('calendar', $graphDayFrom, 'akeebasubs_graph_datepicker', 'akeebasubs_graph_datepicker');
?>
		<?php 
echo JHTML::_('calendar', $graphDayTo, 'akeebasubs_graph_todatepicker', 'akeebasubs_graph_todatepicker');
?>
		<?php 
echo AkeebasubsHelperSelect::subscriptionlevels(0, 'akeebasubs_graph_level_id', array('class' => 'input-small'));
?>
		<button class="btn btn-primary btn-mini" id="akeebasubs_graph_reload" onclick="return false">
			<span class="icon icon-white icon-retweet"></span>
			<?php 
echo JText::_('COM_AKEEBASUBS_DASHBOARD_RELOADGRAPHS');
?>
		</button>
	</div>
</div>

<h3><?php 
echo JText::_('COM_AKEEBASUBS_DASHBOARD_SALES');
?>
</h3>
<div id="aksaleschart">
Exemplo n.º 9
0
" />
	<input type="hidden" name="<?php 
echo JFactory::getSession()->getFormToken();
?>
" value="1" />
	
<div class="row-fluid">
	
		<div class="control-group">
			<label for="country" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_STATES_FIELD_COUNTRY');
?>
</label>
			<div class="controls">
				<?php 
echo AkeebasubsHelperSelect::countries($this->item->country);
?>
				<p class="help-block">
					<?php 
echo JText::_('COM_AKEEBASUBS_STATES_FIELD_COUNTRY_HELP');
?>
				</p>
			</div>
		</div>
		
		<div class="control-group">
			<label for="label_field" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_STATES_FIELD_LABEL');
?>
</label>					
			<div class="controls">
Exemplo n.º 10
0
				<div class="controls">
					<?php 
echo AkeebasubsHelperSelect::flexitimecalc('flex_timecalculation', empty($this->item->flex_timecalculation) ? 'current' : $this->item->flex_timecalculation);
?>
				</div>
			</div>

			<div class="control-group">
				<label for="flex_rounding" class="control-label">
					<?php 
echo JText::_('COM_AKEEBASUBS_RELATIONS_FIELD_TIME_ROUNDING');
?>
				</label>
				<div class="controls">
					<?php 
echo AkeebasubsHelperSelect::flexirounding('time_rounding', empty($this->item->time_rounding) ? 'round' : $this->item->time_rounding);
?>
				</div>
			</div>

		</div>
	</div>

</form>

<script type="text/javascript">
	(function($) {
		$(document).ready(function(){
			akeebasubs_relations_mode_onChange();
		});
	})(akeeba.jQuery);
Exemplo n.º 11
0
function akeebasubsHelperSelect_init()
{
    $model = F0FModel::getTmpInstance('States', 'AkeebasubsModel');
    $rawstates = $model->enabled(1)->orderByLabels(1)->getItemList(true);
    $states = array();
    $current_country = '';
    $current_country_name = 'N/A';
    $current_states = array('' => 'N/A');
    foreach ($rawstates as $rawstate) {
        if ($rawstate->country != $current_country) {
            if (!empty($current_country_name)) {
                $states[$current_country_name] = $current_states;
                $current_states = array();
                $current_country = '';
                $current_country_name = '';
            }
            if (empty($rawstate->country) || empty($rawstate->state) || empty($rawstate->label)) {
                continue;
            }
            $current_country = $rawstate->country;
            $current_country_name = AkeebasubsHelperSelect::$countries[$current_country];
        }
        $current_states[$rawstate->state] = $rawstate->label;
    }
    if (!empty($current_country_name)) {
        $states[$current_country_name] = $current_states;
    }
    AkeebasubsHelperSelect::$states = $states;
}
Exemplo n.º 12
0
?>
		</label>
		<div class="controls">
			<?php 
echo JHTML::_('select.booleanlist', 'enabled', null, $this->item->enabled);
?>
		</div>
	</div>
	<div class="control-group">
		<label for="levels_field" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_COUPON_FIELD_SUBSCRIPTIONS');
?>
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::levels('levels[]', empty($this->item->levels) ? '0' : explode(',', $this->item->levels), array('multiple' => 'multiple', 'size' => 4, 'include_all' => true, 'include_none' => true));
?>
		</div>
	</div>
	<div class="control-group">
		<label for="globalformat" class="control-label" class="mainlabel">
			<?php 
echo JText::_('COM_AKEEBASUBS_INVOICETEMPLATES_FIELD_GLOBALFORMAT');
?>
		</label>
		<div class="controls">
			<?php 
echo JHTML::_('select.booleanlist', 'globalformat', null, $this->item->globalformat);
?>
			<span class="help-block">
				<?php 
Exemplo n.º 13
0
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::usergroups('usergroups[]', empty($this->item->usergroups) ? '-1' : explode(',', $this->item->usergroups), array('multiple' => 'multiple', 'size' => 3));
?>
		</div>
	</div>

	<div class="control-group">
		<label for="subscriptions_field" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_COUPON_FIELD_SUBSCRIPTIONS');
?>
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::levels('subscriptions[]', empty($this->item->subscriptions) ? '-1' : explode(',', $this->item->subscriptions), array('multiple' => 'multiple', 'size' => 3));
?>
		</div>
	</div>

	<div class="control-group">
		<label for="hitslimit_field" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_COUPON_FIELD_HITSLIMIT');
?>
</label>
		<div class="controls">
			<input type="text" size="5" id="hitslimit_field" name="hitslimit" value="<?php 
echo $this->escape($this->item->hitslimit);
?>
" />
		</div>
Exemplo n.º 14
0
 align="right" width="80">
				<?php 
    echo $r->gross_amount;
    ?>
 &euro;&nbsp;
			</td>
		</tr>
	<?php 
}
?>
	</tbody>
	<tfoot>
	<tr style="background-color: black; color: white; font-weight: bold;">
		<td colspan="4">
			<?php 
echo JText::sprintf('COM_AKEEBASUBS_REPORTS_INVOICES_LBL_COUNTRYTOTAL', AkeebasubsHelperSelect::formatCountry($lastCountry), $countryInvoicesShown);
?>
		</td>
		<td align="right">
			<?php 
echo $countryNet;
?>
 &euro;
		</td>
		<td></td>
		<td align="right">
			<?php 
echo $countryTax;
?>
 &euro;
		</td>
Exemplo n.º 15
0
			<div class="controls">
				<input type="text" name="processor_key" id="processor_key" value="<?php 
echo $this->item->processor_key;
?>
"/>
			</div>
		</div>

		<div class="control-group">
			<label for="state" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_SUBSCRIPTION_STATE');
?>
</label>
			<div class="controls">
				<?php 
echo AkeebasubsHelperSelect::paystates($this->item->state, 'state', array('class' => 'minwidth'));
?>
			</div>
		</div>

		<div class="control-group">
			<label for="net_amount" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_SUBSCRIPTION_NET_AMOUNT');
?>
</label>
			<div class="controls">
				<div class="input-<?php 
echo AkeebasubsHelperCparams::getParam('currencypos', 'before') == 'before' ? 'prepend' : 'append';
?>
">
					<?php 
Exemplo n.º 16
0
			<td>
				<?php 
echo JHTML::_('calendar', $this->getModel()->getState('publish_up', ''), 'publish_up', 'publish_up', '%Y-%m-%d', array('onchange' => 'this.form.submit();', 'class' => 'input-small'));
?>
				<br/><?php 
echo JHTML::_('calendar', $this->getModel()->getState('publish_down', ''), 'publish_down', 'publish_down', '%Y-%m-%d', array('onchange' => 'this.form.submit();', 'class' => 'input-small'));
?>
			</td>
			<td>
				<?php 
echo JHTML::_('calendar', $this->getModel()->getState('since', ''), 'since', 'since', '%Y-%m-%d', array('onchange' => 'this.form.submit();', 'class' => 'input-small'));
?>
			</td>
			<td>
				<?php 
echo AkeebasubsHelperSelect::published($this->getModel()->getState('enabled', ''), 'enabled', array('onchange' => 'this.form.submit();', 'class' => 'input-small'));
?>
			</td>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="20">
				<?php 
if ($this->pagination->total > 0) {
    echo $this->pagination->getListFooter();
}
?>
			</td>
		</tr>
	</tfoot>
Exemplo n.º 17
0
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::countries($this->item->country, 'country');
?>
		</div>
	</div>

	<div class="control-group">
		<label for="state" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_TAXRULES_STATE');
?>
</label>
		<div class="controls">
			<?php 
echo AkeebasubsHelperSelect::states($this->item->state, 'state');
?>
		</div>
	</div>

	<div class="control-group">
		<label for="city" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_TAXRULES_CITY');
?>
</label>
		<div class="controls">
			<input type="text" name="city" id="city" value="<?php 
echo $this->item->city;
?>
" />
		</div>
Exemplo n.º 18
0
				<div class="controls">
					<?php 
echo AkeebasubsHelperSelect::paymentmethods('payment_plugins[]', $this->item->payment_plugins, array('id' => 'payment_plugins', 'multiple' => 'multiple', 'always_dropdown' => 1, 'default_option' => 1));
?>
				</div>
			</div>

			<div class="control-group">
				<label for="akeebasubs_level_id" class="control-label">
					<?php 
echo JText::_('COM_AKEEBASUBS_LEVELS_FIELD_LEVELGROUP');
?>
				</label>
				<div class="controls">
					<?php 
echo AkeebasubsHelperSelect::levelgroups($this->item->akeebasubs_levelgroup_id);
?>
				</div>
			</div>

		</div>

		<!-- Actions -->
		<div class="tab-pane" id="maintab3">
			<?php 
JLoader::import('joomla.plugin.helper');
JPluginHelper::importPlugin('akeebasubs');
$app = JFactory::getApplication();
$params = $this->item->params;
if (is_array($params)) {
    $params = (object) $params;
Exemplo n.º 19
0
			<div class="controls">
				<input type="text" size="5" id="max_presence_field" name="max_presence" value="<?php 
echo $this->escape($this->item->max_presence);
?>
" />
			</div>
		</div>
		
		<div class="control-group">
			<label for="type" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_UPGRADES_FIELD_TYPE');
?>
</label>
			<div class="controls">
				<?php 
echo AkeebasubsHelperSelect::upgradetypes('type', $this->item->type);
?>
			</div>
		</div>
		
		<div class="control-group">
			<label for="value_field" class="control-label"><?php 
echo JText::_('COM_AKEEBASUBS_UPGRADES_FIELD_VALUE');
?>
</label>
			<div class="controls">
				<input type="text" size="10" id="value_field" name="value" value="<?php 
echo $this->escape($this->item->value);
?>
" />
			</div>
Exemplo n.º 20
0
		</div>
	</div>

	<div class="control-group form-group <?php 
    echo $group_classes['country'];
    ?>
">
		<label for="country" class="control-label col-sm-2">
			* <?php 
    echo JText::_('COM_AKEEBASUBS_LEVEL_FIELD_COUNTRY');
    ?>
		</label>
		<div class="controls">
            <span class="col-sm-3">
			    <?php 
    echo AkeebasubsHelperSelect::countries($field_data['country'], 'country', array('show' => $cparamShowCountries, 'hide' => $cparamHideCountries, 'class' => 'form-control'));
    ?>
            </span>
			<span id="country_empty" class="help-inline help-block" <?php 
    if (strpos($group_classes['country'], 'error') === false) {
        ?>
style="display:none"<?php 
    }
    ?>
>
				<?php 
    echo JText::_('COM_AKEEBASUBS_LEVEL_ERR_REQUIRED');
    ?>
			</span>
		</div>
	</div>
Exemplo n.º 21
0
 /**
  * Pre-processes the message text in $text, replacing merge tags with those
  * fetched based on subscription $sub
  *
  * @param   string  $text    The message to process
  * @param   AkeebasubsTableSubscription  $sub  A subscription object
  *
  * @return  string  The processed string
  */
 public static function processSubscriptionTags($text, $sub, $extras = array())
 {
     // Get the user object for this subscription
     $user = JFactory::getUser($sub->user_id);
     // Get the extra user parameters object for the subscription
     $kuser = F0FModel::getTmpInstance('Users', 'AkeebasubsModel')->user_id($sub->user_id)->getFirstItem();
     // Get the subscription level
     $level = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->getItem($sub->akeebasubs_level_id);
     // Merge the user objects
     $userdata = array_merge((array) $user, (array) $kuser->getData());
     // Create and replace merge tags for subscriptions. Format [SUB:KEYNAME]
     if ($sub instanceof AkeebasubsTableSubscription) {
         $subData = (array) $sub->getData();
     } else {
         $subData = (array) $sub;
     }
     foreach ($subData as $k => $v) {
         if (is_array($v) || is_object($v)) {
             continue;
         }
         if (substr($k, 0, 1) == '_') {
             continue;
         }
         if ($k == 'akeebasubs_subscription_id') {
             $k = 'id';
         }
         $tag = '[SUB:' . strtoupper($k) . ']';
         if (in_array($k, array('net_amount', 'gross_amount', 'tax_amount', 'prediscount_amount', 'discount_amount', 'affiliate_comission'))) {
             $v = sprintf('%.2f', $v);
         }
         $text = str_replace($tag, $v, $text);
     }
     // Create and replace merge tags for the subscription level. Format [LEVEL:KEYNAME]
     $levelData = (array) $level->getData();
     foreach ($levelData as $k => $v) {
         if (is_array($v) || is_object($v)) {
             continue;
         }
         if (substr($k, 0, 1) == '_') {
             continue;
         }
         if ($k == 'akeebasubs_level_id') {
             $k = 'id';
         }
         $tag = '[LEVEL:' . strtoupper($k) . ']';
         $text = str_replace($tag, $v, $text);
     }
     // Create and replace merge tags for custom per-subscription data. Format [SUBCUSTOM:KEYNAME]
     if (array_key_exists('params', $subData)) {
         if (is_string($subData['params'])) {
             $custom = json_decode($subData['params'], true);
         } elseif (is_array($subData['params'])) {
             $custom = $subData['params'];
         } elseif (is_object($subData['params'])) {
             $custom = (array) $subData['params'];
         } else {
             $custom = array();
         }
         // Extra check for subcustom params: if you save a subscription form the backend,
         // custom fields are inside an array named subcustom
         if (is_array($custom) && isset($custom['subcustom'])) {
             $custom = $custom['subcustom'];
         }
         if (!empty($custom)) {
             foreach ($custom as $k => $v) {
                 if (is_object($v)) {
                     continue;
                 }
                 if (substr($k, 0, 1) == '_') {
                     continue;
                 }
                 $tag = '[SUBCUSTOM:' . strtoupper($k) . ']';
                 if (is_array($v)) {
                     continue;
                 }
                 $text = str_replace($tag, $v, $text);
             }
         }
     }
     // Create and replace merge tags for user data. Format [USER:KEYNAME]
     foreach ($userdata as $k => $v) {
         if (is_object($v) || is_array($v)) {
             continue;
         }
         if (substr($k, 0, 1) == '_') {
             continue;
         }
         if ($k == 'akeebasubs_subscription_id') {
             $k = 'id';
         }
         $tag = '[USER:'******']';
         $text = str_replace($tag, $v, $text);
     }
     // Create and replace merge tags for custom fields data. Format [CUSTOM:KEYNAME]
     if (array_key_exists('params', $userdata)) {
         if (is_string($userdata['params'])) {
             $custom = json_decode($userdata['params']);
         } elseif (is_array($userdata['params'])) {
             $custom = $userdata['params'];
         } elseif (is_object($userdata['params'])) {
             $custom = (array) $userdata['params'];
         } else {
             $custom = array();
         }
         if (!empty($custom)) {
             foreach ($custom as $k => $v) {
                 if (substr($k, 0, 1) == '_') {
                     continue;
                 }
                 $tag = '[CUSTOM:' . strtoupper($k) . ']';
                 if (is_array($v)) {
                     $v = implode(', ', $v);
                 }
                 $text = str_replace($tag, $v, $text);
             }
         }
     }
     // Extra variables replacement
     // -- Coupon code
     $couponcode = '';
     if ($sub->akeebasubs_coupon_id) {
         $couponData = F0FModel::getTmpInstance('Coupons', 'AkeebasubsModel')->savestate(0)->getItem($sub->akeebasubs_coupon_id);
         $couponcode = $couponData->coupon;
     }
     // -- Get the site name
     $config = JFactory::getConfig();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $sitename = $config->get('sitename');
     } else {
         $sitename = $config->getValue('config.sitename');
     }
     // -- First/last name
     $fullname = $user->name;
     $nameParts = explode(' ', $fullname, 2);
     $firstname = array_shift($nameParts);
     $lastname = !empty($nameParts) ? array_shift($nameParts) : '';
     // -- Get the subscription level
     $level = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->setId($sub->akeebasubs_level_id)->getItem();
     // -- Site URL
     list($isCli, $isAdmin) = F0FDispatcher::isCliAdmin();
     if ($isCli) {
         JLoader::import('joomla.application.component.helper');
         $baseURL = JComponentHelper::getParams('com_akeebasubs')->get('siteurl', 'http://www.example.com');
         $temp = str_replace('http://', '', $baseURL);
         $temp = str_replace('https://', '', $temp);
         $parts = explode($temp, '/', 2);
         $subpathURL = count($parts) > 1 ? $parts[1] : '';
     } else {
         $baseURL = JURI::base();
         $subpathURL = JURI::base(true);
     }
     $baseURL = str_replace('/administrator', '', $baseURL);
     $subpathURL = str_replace('/administrator', '', $subpathURL);
     // -- My Subscriptions URL
     if ($isAdmin || $isCli) {
         $url = 'index.php?option=com_akeebasubs&view=subscriptions&layout=default';
     } else {
         $url = str_replace('&amp;', '&', JRoute::_('index.php?option=com_akeebasubs&view=subscriptions&layout=default'));
     }
     $url = ltrim($url, '/');
     $subpathURL = ltrim($subpathURL, '/');
     if (substr($url, 0, strlen($subpathURL) + 1) == "{$subpathURL}/") {
         $url = substr($url, strlen($subpathURL) + 1);
     }
     $mysubsurl = rtrim($baseURL, '/') . '/' . ltrim($url, '/');
     $currency = '';
     if (!class_exists('AkeebasubsHelperCparams')) {
         @(include_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/cparams.php');
     }
     if (class_exists('AkeebasubsHelperCparams')) {
         $currency = AkeebasubsHelperCparams::getParam('currencysymbol', '€');
     }
     // Dates
     JLoader::import('joomla.utilities.date');
     $jFrom = new JDate($sub->publish_up);
     $jTo = new JDate($sub->publish_down);
     // Download ID
     $dlid = md5($user->id . $user->username . $user->password);
     // User's state, human readable
     $formatted_state = '';
     $state = $kuser->state;
     if (!empty($state)) {
         if (!class_exists('AkeebasubsHelperSelect')) {
             require_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/select.php';
         }
         $formatted_state = AkeebasubsHelperSelect::formatState($state);
     }
     // User's country, human readable
     $formatted_country = '';
     $country = $kuser->country;
     if (!empty($country)) {
         if (!class_exists('AkeebasubsHelperSelect')) {
             require_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/select.php';
         }
         $formatted_country = AkeebasubsHelperSelect::formatCountry($country);
     }
     // -- The actual replacement
     $extras = array_merge(array("\\n" => "\n", '[SITENAME]' => $sitename, '[SITEURL]' => $baseURL, '[FULLNAME]' => $fullname, '[FIRSTNAME]' => $firstname, '[LASTNAME]' => $lastname, '[USERNAME]' => $user->username, '[USEREMAIL]' => $user->email, '[LEVEL]' => $level->title, '[ENABLED]' => JText::_('COM_AKEEBASUBS_SUBSCRIPTION_COMMON_' . ($sub->enabled ? 'ENABLED' : 'DISABLED')), '[PAYSTATE]' => JText::_('COM_AKEEBASUBS_SUBSCRIPTION_STATE_' . $sub->state), '[PUBLISH_UP]' => $jFrom->format(JText::_('DATE_FORMAT_LC2'), true), '[PUBLISH_UP_EU]' => $jFrom->format('d/m/Y H:i:s', true), '[PUBLISH_UP_USA]' => $jFrom->format('m/d/Y h:i:s a', true), '[PUBLISH_UP_JAPAN]' => $jFrom->format('Y/m/d H:i:s', true), '[PUBLISH_DOWN]' => $jTo->format(JText::_('DATE_FORMAT_LC2'), true), '[PUBLISH_DOWN_EU]' => $jTo->format('d/m/Y H:i:s', true), '[PUBLISH_DOWN_USA]' => $jTo->format('m/d/Y h:i:s a', true), '[PUBLISH_DOWN_JAPAN]' => $jTo->format('Y/m/d H:i:s', true), '[MYSUBSURL]' => $mysubsurl, '[URL]' => $mysubsurl, '[CURRENCY]' => $currency, '[$]' => $currency, '[DLID]' => $dlid, '[COUPONCODE]' => $couponcode, '[USER:STATE_FORMATTED]' => $formatted_state, '[USER:COUNTRY_FORMATTED]' => $formatted_country, '[NAME]' => $firstname, '[STATE]' => JText::_('COM_AKEEBASUBS_SUBSCRIPTION_STATE_' . $sub->state), '[FROM]' => $jFrom->format(JText::_('DATE_FORMAT_LC2'), true), '[TO]' => $jTo->format(JText::_('DATE_FORMAT_LC2'), true)), $extras);
     foreach ($extras as $key => $value) {
         $text = str_replace($key, $value, $text);
     }
     return $text;
 }
Exemplo n.º 22
0
 /**
  * This method is called whenever Akeeba Subscriptions is updating the user
  * record with new information, either during sign-up or when you manually
  * update this information in the back-end.
  *
  * In this plugin, it does nothing, but it serves as an example for any
  * developer interested in creating, for example, a "bridge" with a social
  * component like Community Builder or JomSocial.
  *
  * @param AkeebasubsTableUser $userData The user data
  */
 public function onAKUserSaveData($userData)
 {
     // Get the user ID
     $user_id = $userData->user_id;
     // Initialise the data array
     $data = $userData->getData();
     // Remove the params field
     $params = array();
     if (isset($data['params'])) {
         $params = $data['params'];
         if (is_string($params)) {
             $params = json_decode($params, true);
         } elseif (is_object($params)) {
             $params = (array) $params;
         }
         unset($data['params']);
     }
     // Remove some fields which must not be saved
     foreach (array('akeebasubs_user_id', 'user_id', 'notes', 'input') as $key) {
         if (isset($data[$key])) {
             unset($data[$key]);
         }
     }
     // Translate country and state
     if (!class_exists('AkeebasubsHelperSelect')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_akeebasubs/helpers/select.php';
     }
     if (isset($data['state'])) {
         $data['state'] = AkeebasubsHelperSelect::formatState($data['state']);
     }
     if (isset($data['country'])) {
         $data['country'] = AkeebasubsHelperSelect::formatCountry($data['country']);
     }
     // Rename the ZIP field
     if (isset($data['zip'])) {
         $data['postal_code'] = $data['zip'];
         unset($data['zip']);
     }
     // Rename the state field
     if (isset($data['state'])) {
         $data['region'] = $data['state'];
         unset($data['state']);
     }
     // Convert basic data
     foreach (array_keys($data) as $key) {
         $data['profile.' . $key] = json_encode($data[$key]);
         unset($data[$key]);
     }
     // Explode the params field (unless it's an array or object)
     if (!empty($params)) {
         foreach ($params as $k => $v) {
             $data['akeebasubs.' . $k] = json_encode($v);
         }
     }
     $db = JFactory::getDbo();
     $result = true;
     // Loop through all keys, check if they already exist and create/replace them
     if (count($data)) {
         foreach ($data as $k => $v) {
             // Check for an existing record
             $query = $db->getQuery(true)->select('*')->from($db->qn('#__user_profiles'))->where($db->qn('user_id') . '=' . $db->q($user_id))->where($db->qn('profile_key') . '=' . $db->q($k));
             $db->setQuery($query);
             $existing = $db->loadObject();
             if (is_object($existing)) {
                 // The record exists. Delete it.
                 $query = $db->getQuery(true)->delete($db->qn('#__user_profiles'))->where($db->qn('user_id') . '=' . $db->q($user_id))->where($db->qn('profile_key') . '=' . $db->q($k));
                 $db->setQuery($query);
                 $db->execute();
             }
             // Insert the new record
             $o = array('user_id' => $user_id, 'profile_key' => $k, 'profile_value' => $v, 'ordering' => 1);
             $o = (object) $o;
             $result = $result && $db->insertObject('#__user_profiles', $o);
         }
     }
     return $result;
 }