public function actionInvoice() { $model = new Invoice(); if ($model->load(Yii::$app->request->post()) && $model->save()) { /** @var \robokassa\Merchant $merchant */ $merchant = Yii::$app->get('robokassa'); return $merchant->payment($model->sum, $model->id, \skeeks\cms\shop\Module::t('app', 'Refill'), null, Yii::$app->user->identity->email); } else { return $this->render('invoice', ['model' => $model]); } }
SchemaDB\Database::getDefault()->drop('confirm'); // class Invoice extends SchemaDB\Storable { // public $code = ''; // public $product = '<<Product>>'; } // class Product extends SchemaDB\Storable { // public $id = self::PRIMARY_KEY; // public $name = ''; // public $price = 0.0; } // $Invoice0 = new Invoice(array('code' => 'FAT1', 'product' => array('name' => 'Product No 1', 'price' => 1.3))); // $Invoice0->store(); // Invoice::dump(); // Product::dump(); // $Invoice1 = Invoice::load('FAT1'); // SchemaDB\Debug::varDump($Invoice1);
public function Action() { if (empty($_POST['edit'])) { return null; } $db = JFactory::getDBO(); switch ($_POST['type']) { case 'metauser': $object = new metaUserDB(); break; case 'processor': $object = new processor(); break; case 'invoice': $object = new Invoice(); break; } $object->load($_POST['id']); if ($object->id != $_POST['id']) { return "<h3>Error - could not find item.</h3>"; } $vars = get_object_vars($object); $encoded = $object->declareParamFields(); foreach ($vars as $k => $v) { if (in_array($k, $encoded)) { if (get_magic_quotes_gpc()) { $object->{$k} = jsoonHandler::decode(stripslashes($_POST[$k])); } else { $object->{$k} = jsoonHandler::decode($_POST[$k]); } } elseif (strpos($k, '_') !== 0) { $object->{$k} = $_POST[$k]; } } $object->check(); if ($object->store()) { return "<h3>Success! Item updated.</h3>"; } else { return "<h3>Error - could not store item.</h3>"; } }
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 cancelEntity($invoice_number, $task) { $invoiceid = aecInvoiceHelper::InvoiceIDfromNumber($invoice_number, 0, true); $userid = ''; if ($invoiceid) { $objInvoice = new Invoice(); $objInvoice->load($invoiceid); $objInvoice->delete(); if (strcmp($task, 'editMembership') == 0) { $userid = '&userid=' . $objInvoice->userid; } } aecRedirect('index.php?option=com_acctexp&task=' . $task . $userid, JText::_('REMOVED')); }
} } } } $pagesize = 15; if (empty($page)) { $page = 0; } $invoiceList = aecInvoiceHelper::InvoiceIdList($metaUser->userid, $page * $pagesize, $pagesize); $properties['invoice_pages'] = (int) ($invoiceno / $pagesize); $properties['invoice_page'] = $page; $invoices = array(); foreach ($invoiceList as $invoiceid) { $invoices[$invoiceid] = array(); $invoice = new Invoice(); $invoice->load($invoiceid); $rowstyle = ''; $actionsarray = array(); if (!in_array($invoice->method, $excludedprocs)) { $actionsarray[] = array('task' => 'invoicePrint', 'add' => 'invoice=' . $invoice->invoice_number . '&tmpl=component', 'text' => JText::_('HISTORY_ACTION_PRINT'), 'insert' => ' target="_blank" ', 'class' => 'btn'); $actionsarray[] = array('task' => 'invoicePDF', 'add' => 'invoice=' . $invoice->invoice_number, 'text' => 'PDF', 'insert' => '', 'class' => 'btn'); } if ($invoice->transaction_date == '0000-00-00 00:00:00' || $invoice->subscr_id) { if ($invoice->transaction_date == '0000-00-00 00:00:00') { $actionsarray[] = array('task' => 'repeatPayment', 'add' => 'invoice=' . $invoice->invoice_number . '&' . xJ::token() . '=1', 'text' => JText::_('HISTORY_ACTION_REPEAT'), 'class' => 'btn btn-success'); if (is_null($invoice->fixed) || !$invoice->fixed) { $actionsarray[] = array('task' => 'cancelPayment', 'add' => 'invoice=' . $invoice->invoice_number, 'text' => JText::_('HISTORY_ACTION_CANCEL'), 'class' => 'btn btn-danger'); } } $rowstyle = 'invoice-unpaid'; }
public function exportMembers() { $db = JFactory::getDBO(); foreach ($this->filter as $k => $v) { if (empty($v)) { $this->filter[$k] = array(); } } // Assemble Database call if (!in_array('notconfig', $this->filter['status'])) { $where = array(); if (!empty($this->filter['planid'])) { $where[] = '`plan` IN (' . implode(',', $this->filter['planid']) . ')'; } $query = 'SELECT a.id, a.userid' . ' FROM #__acctexp_subscr AS a' . ' INNER JOIN #__users AS b ON a.userid = b.id'; if (!empty($where)) { $query .= ' WHERE ( ' . implode(' OR ', $where) . ' )'; } if (!empty($this->filter['status'])) { $stati = array(); foreach ($this->filter['status'] as $status) { $stati[] = 'LOWER( `status` ) = \'' . strtolower($status) . '\''; } if (!empty($where)) { $query .= ' AND (' . implode(' OR ', $stati) . ')'; } else { $query .= ' WHERE (' . implode(' OR ', $stati) . ')'; } } if (!empty($this->filter['orderby'])) { $query .= ' ORDER BY ' . $this->filter['orderby'] . ''; } } else { $query = 'SELECT DISTINCT b.id AS `userid`' . ' FROM #__users as b' . ' WHERE b.id NOT IN (' . ' SELECT a.userid' . ' FROM #__acctexp_subscr as a);'; } $db->setQuery($query); $descriptions = AECToolbox::rewriteEngineExplain($this->options['rewrite_rule']); $descarray = explode(';', $descriptions); $this->exphandler->putDescription($descarray); // Fetch Userlist $userlist = $db->loadObjectList(); // Plans Array $plans = array(); // Iterate through userlist if (!empty($userlist)) { foreach ($userlist as $entry) { $metaUser = new metaUser($entry->userid); if (!empty($entry->id)) { $metaUser->moveFocus($entry->id); } if ($metaUser->hasSubscription) { $planid = $metaUser->focusSubscription->plan; if (!isset($plans[$planid])) { $plans[$planid] = new SubscriptionPlan(); $plans[$planid]->load($planid); } $invoiceid = aecInvoiceHelper::lastClearedInvoiceIDbyUserID($metaUser->userid, $planid); if ($invoiceid) { $invoice = new Invoice(); $invoice->load($invoiceid); $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser, $plans[$planid], $invoice); } else { $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser, $plans[$planid]); } } else { $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser); } $larray = explode(';', $line); // Remove whitespaces and newlines foreach ($larray as $larrid => $larrval) { $larray[$descarray[$larrid]] = trim($larrval); unset($larray[$larrid]); } $this->exphandler->putln($larray); } } }
function cancelInvoice($option, $invoice_number, $pending = 0, $userid, $return = null) { $user = JFactory::getUser(); if (empty($user->id)) { if ($userid) { if (AECToolbox::quickVerifyUserID($userid) === true) { // This user is not expired, so he could log in... return getView('access_denied'); } } else { return getView('access_denied'); } } else { $userid = $user->id; } $invoiceid = aecInvoiceHelper::InvoiceIDfromNumber($invoice_number, $userid); // Only allow a user to access existing and own invoices if ($invoiceid) { $objInvoice = new Invoice(); $objInvoice->load($invoiceid); $objInvoice->cancel(); } else { return getView('access_denied'); } if ($pending) { getView('pending'); } else { if (!empty($return)) { aecRedirect(base64_decode($return)); } else { getView('subscriptiondetails', array('sub' => 'invoices')); } } }