Ejemplo n.º 1
0
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
require_once 'core.php';
$setting = Settings::getInstance();
$order = Order::getInstance();
$nt = Notification::getInstance();
$user = User::getInstance();
if ($setting->Get('system.cron.autosuspend') == '1') {
    echo "Starting autosuspention of overdue orders...\n";
    $suspended = $order->SuspendOverdueOrders();
    echo "Done.\n";
}
if ($setting->Get('system.cron.autoterminate') == '1') {
    echo "Starting autotermination of overdue orders...\n";
    $terminated = $order->TerminateOverdueOrders();
    echo "Done.\n";
}
echo "Generating invoices...";
$order->generateLastInv();
if (is_array($suspended) && count($suspended) > 1) {
    foreach ($suspended as $k => $v) {
Ejemplo n.º 2
0
 public static function ManageNotifies()
 {
     $xtpl = self::$xtpl;
     if (!is_numeric(self::$page)) {
         $page = 1;
     } else {
         $page = self::$page;
     }
     $xtpl->assign('NOTIFYCURR', 'current');
     $xtpl->assign('NOTIFYHISTCURR', 'current');
     $notify = Notification::getInstance();
     $nots = $notify->GetButch(self::$per_page, 1, 'id', 'DESC', self::$per_page * $page - self::$per_page);
     if (count($nots) < 1) {
         $xtpl->parse('main.managenotifies.notfound');
     } else {
         for ($i = 0; $i < count($nots); $i++) {
             $xtpl->assign('NOT', $nots[$i]);
             $xtpl->parse('main.managenotifies.table.row');
         }
         for ($i = 1; $i <= self::count_pages($notify->Calculate()); $i++) {
             if ($page == $i) {
                 $xtpl->assign('CURRENT', 'current');
             } else {
                 $xtpl->assign('CURRENT', '');
             }
             $xtpl->assign('NUM', $i);
             if (preg_match('/page=[0-9]+/', self::$request_uri)) {
                 $link = preg_replace('/page=[0-9]+/', 'page=' . $i, self::$request_uri);
             } else {
                 $link = self::$request_uri . '&page=' . $i;
             }
             $xtpl->assign('LINK', $link);
             $xtpl->parse('main.managenotifies.table.page');
         }
         $xtpl->parse('main.managenotifies.table');
     }
     $xtpl->parse('main.managenotifies');
     $xtpl->parse('main');
     $xtpl->out('main');
 }
Ejemplo n.º 3
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!");
     }
 }