/** * @param Invoice $objInvoice */ public function entryFromInvoice($objInvoice, $response, $pp) { $user = new cmsUser(); $user->load($objInvoice->userid); $plan = new SubscriptionPlan(); $plan->load($objInvoice->usage); if ($pp->id) { $this->proc_id = $pp->id; $this->proc_name = $pp->processor_name; } $this->user_id = $user->id; $this->user_name = $user->username; if ($plan->id) { $this->plan_id = $plan->id; $this->plan_name = $plan->name; } $this->transaction_date = date('Y-m-d H:i:s', (int) gmdate('U')); $this->amount = $objInvoice->amount; $this->invoice_number = $objInvoice->invoice_number; $this->response = $response; $this->cleanup(); $short = 'history entry'; $event = 'Processor (' . $pp->processor_name . ') notification for ' . $objInvoice->invoice_number; $tags = 'history,processor,payment'; $params = array('invoice_number' => $objInvoice->invoice_number); $eventlog = new eventLog(); $eventlog->issue($short, $tags, $event, 2, $params); $this->check(); $this->store(); }
public function Action() { $db = JFactory::getDBO(); $entries = 0; $planlist = array(); $pplist = array(); $processors = array('authorize_arb', 'google_checkout', 'hsbc', 'iats', 'paypal_wpp', 'sparkassen_internetkasse', 'usaepay'); $query = 'SELECT `id`' . ' FROM #__acctexp_invoices' . ' WHERE `method` IN (' . implode(',', $processors) . ')'; $db->setQuery($query); $invoices = xJ::getDBArray($db); foreach ($invoices as $id) { $invoice = new Invoice(); $invoice->load($id); // Skip non-rebilled if (count($invoice->transactions) < 2) { continue; } foreach ($invoice->transactions as $tid => $transaction) { if (!$tid) { // Skip first entry continue; } if (!empty($_POST['safe'])) { $query = 'SELECT `id`' . ' FROM #__acctexp_log_history' . ' WHERE transaction_date = \'' . $transaction->timestamp . '\'' . ' AND proc_name = \'' . $transaction->processor . '\'' . ' AND invoice_number = \'' . $invoice->invoice_number . '\''; $db->setQuery($query); $hasentry = $db->loadResult(); if ($hasentry) { continue; } } $entries++; if (!empty($_POST['create'])) { $entry = new logHistory(); $user = new cmsUser(); $user->load($invoice->userid); if (!isset($planlist[$invoice->usage])) { $plan = new SubscriptionPlan(); $plan->load($invoice->usage); $planlist[$invoice->usage] = $plan; } if (!isset($pplist[$invoice->method])) { $pp = new SubscriptionPlan(); $pp->load($invoice->method); $pplist[$invoice->method] = $pp; } if ($pplist[$invoice->method]->id) { $entry->proc_id = $pplist[$invoice->method]->id; $entry->proc_name = $pplist[$invoice->method]->processor_name; } $entry->user_id = $user->id; $entry->user_name = $user->username; if ($planlist[$invoice->usage]->id) { $entry->plan_id = $planlist[$invoice->usage]->id; $entry->plan_name = $planlist[$invoice->usage]->name; } $entry->transaction_date = $transaction->timestamp; $entry->amount = $transaction->amount; $entry->invoice_number = $invoice->invoice_number; $entry->response = 'Created by the Rebuild Rebills Tool'; $entry->cleanup(); $entry->check(); $entry->store(); } } } if (empty($entries)) { if ($_POST['create']) { return "No Invoices found to create History Entries from."; } else { return "No Invoices with data found."; } } else { if ($_POST['create']) { return $entries . " History Entries created."; } else { return "No History Entries created, found " . $entries . " that can be converted (select 'Create' from the settings above and carry out the query again)"; } } }
public function userchange($row, $post, $trace = '') { $db = JFactory::getDBO(); $mi_list = $this->getUserChangeIntegrations(); if (is_int($row)) { $userid = $row; } elseif (is_string($row)) { $query = 'SELECT id' . ' FROM #__users' . ' WHERE username = \'' . $row . '\''; $db->setQuery($query); $userid = $db->loadResult(); } elseif (is_array($row)) { $userid = $row['id']; } elseif (!is_object($row)) { $userid = $row; } if (!is_object($row)) { $row = new cmsUser(); $row->load($userid); } if (!empty($mi_list)) { foreach ($mi_list as $mi_id) { if (!is_null($mi_id) && $mi_id != '' && $mi_id) { $mi = new microIntegration(); $mi->load($mi_id); if ($mi->callIntegration()) { $mi->on_userchange_action($row, $post, $trace); } } } } }
function quicklookup() { $searcc = trim(aecGetParam('search', 0)); if (empty($searcc)) { return false; } $search = xJ::escape(JFactory::getDBO(), strtolower($searcc)); $s = AECToolbox::searchUser($search); if (empty($s) || !is_array($s)) { return false; } $return = array(); foreach ($s as $user) { $JTableUser = new cmsUser(); $JTableUser->load($user); $userlink = '<div class="lookupresult">'; $userlink .= '<a href="'; $userlink .= JURI::base() . 'index.php?option=com_acctexp&task=edit&entity=Membership&userid=' . $JTableUser->id; $userlink .= '">'; $userlink .= str_replace($search, '<span class="search-match">' . $search . '</span>', $JTableUser->name) . ' (' . str_replace($search, '<span class="search-match">' . $search . '</span>', $JTableUser->username) . ')'; $userlink .= '</a>'; $userlink .= '</div>'; $return[] = $userlink; } return '<div class="lookupresults">' . implode($return) . '</div>'; }
public function sendEmailRegistered($renew, $adminonly = false, $invoice = null) { global $aecConfig; $app = JFactory::getApplication(); $free = strcmp(strtolower($this->type), 'none') == 0 || strcmp(strtolower($this->type), 'free') == 0; $urow = new cmsUser(); $urow->load($this->userid); $plan = new SubscriptionPlan(); $plan->load($this->plan); $name = $urow->name; $email = $urow->email; $username = $urow->username; $pwd = $urow->password; $activationcode = $urow->activation; $message = sprintf(JText::_('ACCTEXP_MAILPARTICLE_GREETING'), $name); // Assemble E-Mail Subject & Message if ($renew) { $subject = sprintf(JText::_('ACCTEXP_SEND_MSG_RENEW'), $name, $app->getCfg('sitename')); $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_THANKSREN'), $app->getCfg('sitename')); if ($plan->email_desc) { $message .= "\n\n" . $plan->email_desc . "\n\n"; } else { $message .= " "; } if ($free) { $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root()); } else { $message .= JText::_('ACCTEXP_MAILPARTICLE_PAYREC') . " " . sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root()); } } else { $subject = sprintf(JText::_('ACCTEXP_SEND_MSG'), $name, $app->getCfg('sitename')); $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_THANKSREG'), $app->getCfg('sitename')); if ($plan->email_desc) { $message .= "\n\n" . $plan->email_desc . "\n\n"; } else { $message .= " "; } if ($free) { $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root()); } else { $message .= JText::_('ACCTEXP_MAILPARTICLE_PAYREC') . " " . sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root()); } } $message .= JText::_('ACCTEXP_MAILPARTICLE_FOOTER'); $subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8'); $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); // Send email to user if ($app->getCfg('mailfrom') != '' && $app->getCfg('fromname') != '') { $adminName2 = $app->getCfg('fromname'); $adminEmail2 = $app->getCfg('mailfrom'); } else { $rows = xJACLhandler::getSuperAdmins(); $row2 = $rows[0]; $adminName2 = $row2->name; $adminEmail2 = $row2->email; } if (!$adminonly) { xJ::sendMail($adminEmail2, $adminEmail2, $email, $subject, $message); } $aecUser = array(); if (is_object($invoice)) { if (!empty($invoice->params['creator_ip'])) { $aecUser['ip'] = $invoice->params['creator_ip']; // user Hostname (if not deactivated) if ($aecConfig->cfg['gethostbyaddr']) { $aecUser['isp'] = gethostbyaddr($invoice->params['creator_ip']); } else { $aecUser['isp'] = 'deactivated'; } } } if (empty($aecUser)) { $aecUser = AECToolbox::aecIP(); } // Send notification to all administrators if ($renew) { $subject2 = sprintf(JText::_('ACCTEXP_SEND_MSG_RENEW'), $name, $app->getCfg('sitename')); $message2 = sprintf(JText::_('ACCTEXP_ASEND_MSG_RENEW'), $adminName2, $app->getCfg('sitename'), $name, $email, $username, $plan->id, $plan->name, $aecUser['ip'], $aecUser['isp']); } else { $subject2 = sprintf(JText::_('ACCTEXP_SEND_MSG'), $name, $app->getCfg('sitename')); $message2 = sprintf(JText::_('ACCTEXP_ASEND_MSG'), $adminName2, $app->getCfg('sitename'), $name, $email, $username, $plan->id, $plan->name, $aecUser['ip'], $aecUser['isp']); } $subject2 = html_entity_decode($subject2, ENT_QUOTES, 'UTF-8'); $message2 = html_entity_decode($message2, ENT_QUOTES, 'UTF-8'); $admins = AECToolbox::getAdminEmailList(); foreach ($admins as $adminemail) { if (!empty($adminemail)) { xJ::sendMail($adminEmail2, $adminEmail2, $adminemail, $subject2, $message2); } } }