コード例 #1
0
ファイル: admin.acctexp.php プロジェクト: Ibrahim1/aec
 public function save()
 {
     $row = new Invoice();
     $row->load($_POST['id']);
     $returnTask = $_POST['returnTask'];
     unset($_POST['id']);
     unset($_POST['returnTask']);
     if (empty($_POST['coupons'])) {
         $_POST['coupons'] = array();
     }
     $previous = array();
     if (!empty($row->coupons)) {
         foreach ($row->coupons as $coupon_code) {
             $id = couponHandler::idFromCode($coupon_code);
             $previous[] = $id['id'];
         }
     }
     $added = array();
     foreach ($_POST['coupons'] as $coupon_id) {
         if (!in_array($coupon_id, $previous)) {
             $added[] = $coupon_id;
         } else {
             unset($previous[array_search($coupon_id, $previous)]);
         }
     }
     if (!empty($added)) {
         foreach ($added as $coupon_id) {
             $row->addCoupon((int) $coupon_id, true);
         }
     }
     if (!empty($previous)) {
         foreach ($previous as $coupon_id) {
             $row->removeCoupon((int) $coupon_id, true);
         }
     }
     unset($_POST['coupons']);
     $row->savePOSTsettings($_POST);
     $row->storeload();
     $this->setMessage(JText::_('AEC_CONFIG_SAVED'));
 }
コード例 #2
0
ファイル: acctexp.php プロジェクト: Ibrahim1/aec
function InvoiceAddCoupon($option)
{
    $invoice = aecGetParam('invoice', 0, true, array('word', 'string', 'clear_nonalnum'));
    $coupon_code = aecGetParam('coupon_code', 0, true, array('word', 'string', 'clear_nonalnum'));
    $objinvoice = new Invoice();
    $objinvoice->loadInvoiceNumber($invoice);
    $objinvoice->addCoupon($coupon_code);
    $objinvoice->storeload();
    repeatInvoice($option, $invoice, null, $objinvoice->userid);
}
コード例 #3
0
ファイル: tool_pretend.php プロジェクト: Ibrahim1/aec
 public function createPayments()
 {
     if (!$_POST['create_payments']) {
         return;
     }
     $db = JFactory::getDBO();
     $amountlist = array();
     for ($i = $this->range['plans']['start']; $i <= $this->range['plans']['end']; $i++) {
         $amountlist[$i] = array();
         $modlist[$i]['sin'] = rand(0, 360);
         $modlist[$i]['speed'] = rand(0, 1000) / 100;
         $modlist[$i]['multi'] = rand(0, 100) / 50;
     }
     $start_date = strtotime($_POST['start'] . '-01-01 00:00:00');
     $years = (int) date('Y') - $_POST['start'];
     $days = $years * 365 + date('z') + 1;
     $saleslist = $this->stream_layers($amountlist, $days + 2, 1);
     $plandetails = array();
     $query = 'SELECT MIN(id)' . ' FROM #__acctexp_log_history';
     $db->setQuery($query);
     $this->range['payments']['start'] = $db->loadResult() + 1;
     for ($i = 1; $i <= $days; $i++) {
         $dtime = strtotime("+" . $i . " days", $start_date);
         foreach ($modlist as $k => $v) {
             $modlist[$k]['sin'] += $modlist[$k]['speed'];
             $modlist[$k]['sin'] = $modlist[$k] % 360;
         }
         foreach ($saleslist as $plan => $dayslist) {
             if (!isset($plandetails[$plan])) {
                 $splan = new SubscriptionPlan();
                 $splan->load($plan);
                 $plandetails[$plan] = array('name' => $splan->name, 'cost' => $splan->params['full_amount']);
             }
             // Add some sine modification
             $dsales = (int) ($dayslist[$i] * ((1 + sin($modlist[$plan]['sin'])) * $modlist[$plan]['multi']));
             // Less sales on the weekends
             if (date('N', $dtime) > 5) {
                 $dsales = (int) ($dsales / rand(1, 4));
             }
             for ($j = 0; $j < $dsales; $j++) {
                 $found = false;
                 while (!$found) {
                     $userid = rand($this->range['users']['start'], $this->range['users']['end']);
                     $db->setQuery('SELECT id FROM #__users WHERE `id` = \'' . $userid . '\'');
                     $check = $db->loadResult();
                     $found = !empty($check);
                 }
                 $invoice = new Invoice();
                 $invoice->userid = $userid;
                 $invoice->usage = $plan;
                 $invoice->method = 'none';
                 $invoice->invoice_number = $invoice->generateInvoiceNumber();
                 $invoice->storeload();
                 $invoice->computeAmount();
                 $invoice->pay();
                 $invoice->transaction_date = date('Y-m-d H:i:s', $dtime + rand(0, 86400));
                 $invoice->check();
                 $invoice->store();
                 $pp = new stdClass();
                 $pp->id = 0;
                 $pp->processor_name = 'none';
                 $history = new logHistory();
                 $history->entryFromInvoice($invoice, array("dummy" => "data"), $pp);
                 $history->transaction_date = date('Y-m-d H:i:s', $dtime + rand(0, 86400));
                 $history->check();
                 $history->store();
             }
         }
     }
     $query = 'SELECT MAX(id)' . ' FROM #__acctexp_log_history';
     $db->setQuery($query);
     $this->range['payments']['end'] = $db->loadResult();
 }
コード例 #4
0
 public function parseNotification($post)
 {
     if (empty($this->settings)) {
         $this->getSettings();
     }
     $return = $this->processor->parseNotification($post);
     // Check whether this is an ad-hoc notification
     if (!empty($return['_aec_createuser']) && empty($return['invoice'])) {
         // Identify usage
         $usage = 1;
         // Create new user account and fetch id
         $userid = aecRegistration::saveUserRegistration($return['_aec_createuser'], true, true, false);
         // Create Invoice
         $invoice = new Invoice();
         $invoice->create($userid, $usage, $this->processor_name);
         $invoice->computeAmount();
         // Set new return variable - we now know what invoice this is
         $return['invoice'] = $invoice->invoice_number;
     }
     // Always amend secondary ident codes
     if (!empty($return['secondary_ident']) && !empty($return['invoice'])) {
         $invoice = new Invoice();
         $invoice->loadInvoiceNumber($return['invoice']);
         $invoice->secondary_ident = $return['secondary_ident'];
         $invoice->storeload();
     }
     if (!empty($return['_aec_createuser'])) {
         unset($return['_aec_createuser']);
     }
     return $return;
 }