예제 #1
0
 public function Create($accountid, $orderid = -1, $amount = 0, $duedate, $status = 'Unpaid', $comment = '', $datecreated = '', $datepaid = '', $transactionid = '-1')
 {
     $time = Time::getInstance();
     if (!is_numeric($accountid) || !is_numeric($transactionid) || !is_numeric($orderid)) {
         throw new Exception("problems with invoice data");
     }
     $amount = floatval($amount);
     if ($datecreated == '') {
         $datecreated = $time->UtoM(time());
     } elseif (!$time->validateTime($datecreated)) {
         throw new Exception("Date of creation in wrong format!");
     }
     if (!$time->validateTime($duedate) && $duedate != '0000-00-00 00:00:00') {
         throw new Exception("Due date in wrong format");
     }
     if (!preg_match('/^(Paid|Unpaid|Cancelled)$/i', $status)) {
         throw new Exception("Invoice status in wrong format");
     }
     if ($datepaid != '' && !$time->validateTime($datepaid)) {
         throw new Exception("Date of payment in wrong format");
     }
     $this->data = array('accountid' => $accountid, 'orderid' => $orderid, 'amount' => $amount, 'status' => $status, 'datecreated' => $datecreated, 'datedue' => $duedate, 'datepaid' => $datepaid, 'comment' => $comment, 'transactionid' => $transactionid);
     $this->raw = $this->db->query_insert('Invoice', $this->data);
     if (is_numeric($this->raw)) {
         $this->invid = $this->raw;
         return $this->raw;
     } else {
         return false;
     }
 }
 public function Create($invoiceid, $gatewayid, $amount, $date = NULL, $comments = '', $userid = NULL)
 {
     if (!is_numeric($invoiceid) && !is_float($amount)) {
         throw new Exception("Invoice ID or amount in wrong format");
     }
     $inv = Invoice::getInstance();
     $invdata = $inv->FetchData($invoiceid);
     $time = Time::getInstance();
     if ($date == NULL) {
         $date = $time->UtoM(time());
     }
     $this->raw = $this->db->query_insert('Transaction', array('invoiceid' => $invoiceid, 'customerid' => $invdata['accountid'], 'date' => $date, 'amount' => $amount, 'gatewayid' => $gatewayid, 'comments' => $comments));
     $inv->Update('status', 'Paid', $invoiceid);
     $inv->Update('transactionid', $this->raw, $invoiceid);
     $inv->Update('datepaid', $date, $invoiceid);
     return $this->raw;
 }
 public function Create($ticketid, $userid, $message, $type = "reply", $date = '')
 {
     $time = Time::getInstance();
     if (!is_numeric($ticketid) || !is_numeric($userid)) {
         throw new Exception("Ticket or User ID is not numeric");
     }
     if (!preg_match('/^(status|reply)$/i', $type)) {
         throw new Exception("change type in wrong format");
     }
     if ($date == '') {
         $date = $time->UtoM(time());
     } elseif (!$time->validateTime($date)) {
         throw new Exception("Date in wrong format");
     }
     $array = array("userid" => $userid, "message" => $message, "type" => $type, "ticketid" => $ticketid, "date" => $date);
     $this->raw = $this->db->query_insert("TicketChange", $array);
     return $this->raw;
 }
예제 #4
0
 public static function properties()
 {
     $time = Time::getInstance();
     return array('required' => array('depid', 'userid', 'subject'), 'values' => array('date' => $time->UtoM(time()), 'status' => 'Support'));
 }
 public static function properties()
 {
     $time = Time::getInstance();
     return array('required' => array('name', 'shortname'));
 }
예제 #6
0
 public static function EditInvoice($invid)
 {
     $xtpl = self::$xtpl;
     $xtpl->assign('FINCURR', 'current');
     $xtpl->assign('MANAGEINVCURR', 'current');
     $order = Order::getInstance();
     $invoice = Invoice::getInstance();
     $user = User::getInstance();
     $time = Time::getInstance();
     $gm = GatewayModule::getInstance();
     $gmodules = $gm->GetButch();
     $setting = Settings::getInstance();
     $defgw = $setting->Get('system.paygateway.default');
     $invdata = $invoice->FetchData($invid);
     for ($i = 0; $i < count($gmodules); $i++) {
         $prov = call_user_func(array($gmodules[$i]['modulename'] . "PaymentGateway", 'getInstance'));
         if ($defgw == $gmodules[$i]['id']) {
             $xtpl->assign('DEFAULT', 'selected="selected"');
         } else {
             $xtpl->assign('DEFAULT', '');
         }
         $xtpl->assign('GM', $gmodules[$i]);
         $ginfo = $prov->Info();
         $xtpl->assign('GNAME', $ginfo['name']);
         $xtpl->parse('main.editinv.paygw');
     }
     if ($invdata['status'] == 'Paid' && $invdata['transactionid'] != '-1') {
         $trans = Transaction::getInstance();
         $xtpl->assign('TRANS', $trans->FetchData($invdata['transactionid']));
         $xtpl->parse('main.editinv.invoice.transaction');
     }
     $xtpl->assign('CURRDATE', $time->UtoM(time()));
     $xtpl->assign('Status' . $invdata['status'], 'selected="selected"');
     $xtpl->assign('USER', $user->FetchData($invdata['accountid']));
     $xtpl->assign('ORDER', $order->FetchData($invdata['orderid']));
     $xtpl->assign('INV', $invdata);
     $xtpl->parse('main.editinv.invoice');
     $xtpl->parse('main.editinv');
     $xtpl->parse('main');
     $xtpl->out('main');
 }
예제 #7
0
 public static function properties()
 {
     $time = Time::getInstance();
     return array('required' => array('username', 'password', 'email'), 'values' => array('opentime' => $time->UtoM(time()), 'status' => 'Active'));
 }
예제 #8
0
 public function generateLastInv($orderid = '')
 {
     $time = Time::getInstance();
     $inv = Invoice::getInstance();
     $pkg = Package::getInstance();
     $setting = Settings::getInstance();
     if (!is_numeric($orderid) && !is_numeric($this->orderid)) {
         $result = array();
         $days = $time->add_date($time->UtoM(time()), $setting->Get('system.cron.daystonewinv'));
         $this->raw = $this->db->fetch_all_array('SELECT * FROM `Order` WHERE `status` = "Active" AND `nextdue` < "' . $days . '" AND `cycle` > 0');
         for ($i = 0; $i < count($this->raw); $i++) {
             $invdata = $inv->FetchData($this->raw[$i]['lastinv']);
             if ($time->MtoU($invdata['datedue']) < $time->MtoU($this->raw[$i]['nextdue'])) {
                 //new invoice should be generated
                 $pkgdata = $pkg->FetchData($this->raw[$i]['productid']);
                 $nextdue = $time->add_date($this->raw[$i]['nextdue'], '', $this->raw[$i]['cycle']);
                 $comment = "Order for package " . $pkgdata['name'] . " (" . $this->raw[$i]['nextdue'] . " - " . $nextdue . ")";
                 $lastinv = $inv->Create($this->raw[$i]['accountid'], $this->raw[$i]['id'], $this->raw[$i]['recuramount'], $this->raw[$i]['nextdue'], 'Unpaid', $comment);
                 $result[] = array('invoice' => $lastinv, 'order' => $this->raw[$i]['id']);
                 $this->Update('lastinv', $lastinv, $this->raw[$i]['id']);
             }
         }
         return $result;
     } else {
         if (!is_numeric($orderid)) {
             $orderid = $this->orderid;
         }
         $orderdata = $this->FetchData($orderid);
         $lastinvdata = $inv->FetchData($orderdata['lastinv']);
         if ($orderdata['status'] == 'Active' && $orderdata['cycle'] > 0 && $time->MtoU($orderdata['nextdue']) > $time->MtoU($lastinvdata['datedue'])) {
             $pkgdata = $pkg->FetchData($orderdata['productid']);
             $nextdue = $time->add_date($orderdata['nextdue'], '', $orderdata['cycle']);
             $comment = "Order for package " . $pkgdata['name'] . " (" . $orderdata['nextdue'] . " - " . $nextdue . ")";
             $lastinv = $inv->Create($orderdata['accountid'], $orderdata['id'], $orderdata['recuramount'], $orderdata['nextdue'], '', $comment);
             $this->Update($orderdata['id'], 'lastinv', $lastinv);
         }
     }
 }
예제 #9
0
 public function newPayment($invid)
 {
     if (!is_numeric($this->invid) && !is_numeric($invid)) {
         throw new Exception("Invoice ID is not set or set incorrectly");
     } elseif (is_numeric($this->invid) && !is_numeric($invid)) {
         $invid = $this->invid;
     }
     $error = 0;
     $sm = ServerModule::getInstance();
     $user = User::getInstance();
     $order = Order::getInstance();
     $invoice = Invoice::getInstance();
     $time = Time::getInstance();
     $nt = Notification::getInstance();
     $invdata = $invoice->FetchData($invid);
     $users = $user->GetButch(1, '`id` = "' . $invdata['accountid'] . '"');
     $orderdata = $order->FetchData($invdata['orderid']);
     $ntarray = array('USER' => $users[0], 'INV' => $invdata, 'ORDER' => $orderdata);
     switch ($orderdata['status']) {
         case 'Active':
             $nt->Send($users, $ntarray, 'usernewpayment');
             $order->Update('nextdue', $time->add_date($orderdata['nextdue'], 0, $orderdata['cycle']), $orderdata['id']);
             break;
         case 'Pending':
             //Making all this shit for creating new account; sendmail email with access data
             try {
                 $this->Create($orderdata['id']);
             } catch (Exception $e) {
                 $admins = $user->GetButch('', '`status` = "Admin"');
                 $nterarray = array('USER' => $users[0], 'INV' => $invdata, 'MESSAGE' => $e->getMessage(), 'DEBUG' => $e);
                 $nt->Send($admins, $nterarray, 'adminservicesetuperror');
                 $error = 1;
             }
             if ($error > 0) {
                 //we need to refetch order data as we updated accessdata when created new service
                 $orderdata = $order->FetchData($invdata['orderid']);
                 $accessdata = unserialize($orderdata['accessdata']);
                 $order->orderid = $invdata['orderid'];
                 $sm->id = $order->FindModuleID();
                 $modulecreatearray = $sm->getArray('Create');
                 $acdata_to_mail = '';
                 for ($i = 0; $i < count($modulecreatearray); $i++) {
                     if (array_key_exists($modulecreatearray[$i]['name'], $accessdata)) {
                         $acdata_to_mail .= $modulecreatearray[$i]['label'] . ": " . $accessdata[$modulecreatearray[$i]['name']] . "\n";
                     }
                 }
                 $ntarray['ACCESSDATA'] = $acdata_to_mail;
                 //there email should me sent
                 $nt->Send($admins, $ntarray, 'usernewservicedetails');
                 $order->Update('status', 'Active', $invdata['orderid']);
             } else {
                 die("Error");
             }
             break;
         case 'Suspended':
             $this->Unsuspend($order->orderid);
             $order->Update('', 'status', 'Active');
             break;
         case 'Terminated':
             //there are should be some notification for admin and user about payment for terminated service or money should be returned back to the balance
             //$this->Create($order->orderid);
             //$order->Update('','status', 'Active');
             break;
         default:
             throw new Exception("Unknown order status!");
     }
 }
 public static function properties()
 {
     $time = Time::getInstance();
     return array('required' => array('text', 'subject', 'moduleid', 'address', 'status'), 'values' => array('date' => $time->UtoM(time())));
 }
예제 #11
0
 public function GetOverdue()
 {
     $time = Time::getInstance();
     $oneday = $time->rem_date($time->UtoM(time()), 1);
     return $this->GetButch('', '`time` < "' . $oneday . '"', 'name');
 }
예제 #12
0
         Page::message('attention', 'Wrong data entered. Try again');
         Page::Database();
     } else {
         $config->set('DATABASE_HOST', $_POST['host']);
         $config->set('DATABASE_USER', $_POST['dbuser']);
         $config->set('DATABASE_PASSWORD', $_POST['dbpassword']);
         $config->set('DATABASE_NAME', $_POST['dbname']);
         Page::PerformDBinstall();
     }
     break;
 case 5:
     Page::AddAdmin();
     break;
 case 6:
     $db = DB::getInstance();
     $time = Time::getInstance();
     if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['username']) || !preg_match('/\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b/i', $_POST['email'])) {
         Page::message('attention', 'Admin username or email in wrong format. Go back and try again');
         Page::AddAdmin();
     } elseif ($_POST['password'] != $_POST['password2']) {
         Page::message('attention', 'Passwords do not match');
         Page::AddAdmin();
     } else {
         if ($db->query_insert('User', array('username' => $_POST['username'], 'password' => md5($_POST['password']), 'email' => $_POST['email'], 'opentime' => $time->UtoM(time()), 'status' => 'Admin'))) {
             Page::message('success', 'Success! Installation completed. We recommend you to remove /install/ folder from the server');
         } else {
             Page::message('attention', 'Error! Installation not completed. Please, try again');
         }
         $config->set('IS_INSTALLED', 1);
         Page::Done();
     }