Пример #1
0
 public function run()
 {
     $iAccountID = $this->get('id');
     $oAccount = new m\Account();
     $aDetail = $oAccount->getAccountDetail($iAccountID);
     if (empty($aDetail)) {
         c\Router::redirect(c\Router::genURL('Home'));
     }
     $aFields = $oAccount->getAccountFields($iAccountID);
     $oUser = new m\User();
     $aDefaultPassword = $oUser->getDefaultPassword();
     $aEmails = $oUser->getEmails();
     foreach ($aFields as $k => $v) {
         $aFields[$k]['display'] = u\Str::partCover($v['value'], 2, 1);
     }
     sort($aFields);
     $aFieldNames = array_map(function ($v) {
         foreach ($v as $key => $value) {
             if ($key !== 'name') {
                 unset($v[$key]);
             }
         }
         return $v;
     }, $aFields);
     $aAccountAll = $oAccount->getAllAccount();
     $aSiteList = [];
     foreach ($aAccountAll as $aAccountDetail) {
         $aSiteList[] = ['name' => 'link:' . $aAccountDetail['name']];
     }
     $aData = ['page_title' => 'Open Sesame - ' . $aDetail['name'], 'app' => $aDetail, 'fields' => $aFields, 'form_action_add' => c\Router::genURL('AddField'), 'form_action_del' => c\Router::genURL('DeleteField'), 'form_action_updatefield' => c\Router::genURL('UpdateField'), 'form_action_updateaccount' => c\Router::genURL('UpdateAccount'), 'site_list' => json_encode($aSiteList), 'field_names' => json_encode($aFieldNames), 'default_password' => $aDefaultPassword['data'], 'emails' => $aEmails['data']];
     return $aData;
 }
Пример #2
0
 public function run()
 {
     $oAccount = new m\Account();
     $iTotal = $oAccount->getTotal();
     if ($iTotal === false) {
         $oAccount->createTable();
     }
     $aData = ['page_title' => 'Open Sesame', 'form_action_add' => c\Router::genURL('AddAccount'), 'site_total' => $iTotal, 'recomm' => (new m\Recommand())->get(4)];
     return $aData;
 }
Пример #3
0
 public function run()
 {
     global $argv;
     if (!isset($argv[2])) {
         c\cecho('搜索词呢?', 'error');
         return false;
     }
     $aConfig = c\Config::get('dsn');
     u\DB::connect($aConfig['data']);
     $sKeyword = $argv[2];
     $aList = (new m\Search())->handle($sKeyword);
     $aNumberMapping = [];
     foreach ($aList as $iIndex => $aAccount) {
         $iIndexNumber = $iIndex + 1;
         $sAccountInfo = ' (' . $aAccount['rowid'] . ') ' . $aAccount['name'] . ' - http://' . $aAccount['value'];
         $sMsg = str_pad($iIndexNumber, 4) . $sAccountInfo;
         $aNumberMapping[$iIndexNumber] = $aAccount['rowid'];
         c\cecho($sMsg, 'notice');
     }
     c\cecho("你要搜索啥?(请输入行首序号)");
     $iNumber = trim(fread(STDIN, 5));
     if (empty($iNumber)) {
         return false;
     }
     while (!empty($iNumber) && !is_numeric($iNumber)) {
         c\cecho('What are you 弄啥累', 'error');
         c\cecho("你要搜索啥?(请输入行首序号)");
         $iNumber = trim(fread(STDIN, 5));
     }
     $iNumber = (int) $iNumber;
     if ($iNumber > 0 && isset($aNumberMapping[$iNumber])) {
         $iAccountID = $aNumberMapping[$iNumber];
         $oAccount = new m\Account();
         $aDetail = $oAccount->getAccountDetail($iAccountID);
         $aFields = $oAccount->getAccountFields($iAccountID);
         c\cecho($aDetail['name'], 'error');
         foreach ($aFields as $aField) {
             $sMsg = $aField['name'] . ' ---- ' . $aField['value'];
             c\cecho($sMsg, 'notice');
         }
     }
 }
Пример #4
0
 public function testCRUD()
 {
     $entity = new Account();
     $entity->setName(self::NAME);
     $entity->setOwnerId(1);
     $this->dao->persist($entity);
     $this->assertEquals(self::ID, $entity->getId());
     $this->assertEquals(self::NAME, $entity->getName());
     $entity = $this->dao->findById(self::ID);
     $this->assertEquals(self::ID, $entity->getId());
     $this->assertEquals(self::NAME, $entity->getName());
     $entity->setName(self::NAME_ANOTHER);
     $entity = $this->dao->flush($entity);
     $entity = $this->dao->findById(self::ID);
     $this->assertEquals(self::ID, $entity->getId());
     $this->assertEquals(self::NAME_ANOTHER, $entity->getName());
     $this->dao->remove($entity);
     $this->assertNull($entity->getId());
     $this->assertNull($entity->getName());
 }
Пример #5
0
function findSavingsAccountObs($userId)
{
    return Observable::just($userId)->skipWhile(function ($input) {
        return empty($input);
    })->map(function ($userId) {
        return User::find($userId);
    })->flatMap(function (User $user) {
        return Observable::fromArray(Account::query('user_id', $user->getId()));
    })->takeWhile(function (Account $account) {
        return $account->getType() === 'SAVINGS';
    });
}
Пример #6
0
 public function run()
 {
     global $argv;
     if (!isset($argv[2])) {
         c\cecho('帐号ID是多少?', 'error');
         return false;
     }
     $aConfig = c\Config::get('dsn');
     u\DB::connect($aConfig['data']);
     $iAccountID = $argv[2];
     $oAccount = new m\Account();
     $aDetail = $oAccount->getAccountDetail($iAccountID);
     if (empty($aDetail)) {
         c\cecho('非法ID', 'error');
         return false;
     }
     $aFields = $oAccount->getAccountFields($iAccountID);
     c\cecho($aDetail['name'], 'error');
     foreach ($aFields as $aField) {
         $sMsg = $aField['name'] . ' ---- ' . $aField['value'];
         c\cecho($sMsg, 'notice');
     }
 }
Пример #7
0
 public function entity(AccountDTO $dto, Account $entity)
 {
     $entity->setOwnerId($dto->getOwnerId());
     $entity->setIdParent($dto->getIdParent());
     $entity->setName($dto->getName());
 }
Пример #8
0
 /**
  * Shows module content
  *
  * @param \phpOMS\Message\RequestAbstract  $request  Request
  * @param \phpOMS\Message\ResponseAbstract $response Response
  *
  * @since  1.0.0
  * @author Dennis Eichhorn <*****@*****.**>
  */
 public function showBackendAccountSingle($request, $response)
 {
     switch ($request->getPath(5)) {
         case 'front':
             $accountView = new \phpOMS\Views\View($this->app, $request, $response);
             $accountView->setTemplate('/Modules/Admin/Theme/Backend/accounts-single');
             $navigation = \Modules\Navigation\Models\Navigation::getInstance($request->getHash(), $this->app->dbPool);
             $accountView->addData('nav', $navigation->nav);
             $account = \Model\Account::getInstance((int) $request->getData('id'), $this->app->dbPool->get(), $this->app->sessionManager, $this->app->cache);
             $accountView->addData('account', $account);
             echo $accountView->render();
             break;
         default:
             $response->setHeader('HTTP', 'HTTP/1.0 404 Not Found');
             $response->setHeader('Status', 'Status: 404 Not Found');
             include __DIR__ . '/../../Web/Backend/404.tpl.php';
             return;
     }
 }
Пример #9
0
println('Example 3 - Just and Map');
\Rx\Observable::just(\Model\User::all())->map(function ($results) {
    return count($results);
})->subscribe($stdoutObserver());
println('Example 4 - Get all accounts of type SAVING');
\Rx\Observable::fromArray(\Model\Account::all())->filter(function (Account $account) {
    return $account->getType() === 'SAVINGS';
})->map(function (Account $savingsAccount) {
    return $savingsAccount->getBalance();
})->subscribe($stdoutObserver());
println('Withdraw 1000 from Luis SAVINGS account');
$id = 1;
Observable::just($id)->map(function ($userId) {
    return User::find($userId);
})->doOnNext(function (User $user) {
    printf("Found user: %s \n", $user->getEmail());
})->flatMap(function (User $user) {
    return Observable::fromArray(Account::query('user_id', $user->getId()));
})->takeWhile(function (Account $account) {
    return $account->getType() === 'SAVINGS';
})->doOnNext(function (Account $account) {
    printf("Found savings account. Current balance: %d \n", $account->getBalance());
})->map(function (Account $account) {
    return $account->withdraw(1000)->save();
})->subscribe(new Observer\CallbackObserver(function ($account) {
    printf("New account balance: %d \n", $account->getBalance());
}, function (Exception $ex) {
    print 'Error: ' . $ex->getMessage();
}, function () {
    print 'Completed!';
}));
Пример #10
0
            echo '{"code":"1","msg":"数据没有更改"}';
            exit(0);
        }
        Account::update($data, $eid);
    } else {
        Account::insert($data);
    }
    echo '{"code":"0","msg":"数据更新成功"}';
    exit(0);
}
$buttonTitle = $eid > 0 ? '编辑' : '添加';
if ($eid > 0) {
    $accountData = Account::getAccountById($eid, '*');
    $accountData['account_content'] = $encrypt->decode($accountData['account_content']);
} else {
    $accountData = Account::getTableAttribute();
    $accountData['cat_title'] = '请选择一个分类';
}
?>
<form id="account_form" method="post" action="<?php 
echo WEB_URL . '/index.php?d=account&f=add&act=save&eid=' . $eid;
?>
">
<div id="form_wrap">
    <div class="field_line">
        <label>分类</label>
        <input id="account_cat_id" name="account[cat_id]" readonly="readonly" style="width:50px;text-align:center;" value="<?php 
echo $accountData['account_cat'];
?>
" />
        <input style="width:500px;text-align:center;" value="<?php 
Пример #11
0
use Model\Account;
$act = isset($_GET['act']) ? $_GET['act'] : '';
if ($act == 'data') {
    $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $limit = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
    if ($page < 1) {
        $page = 1;
    }
    if ($limit < 10) {
        $limit = 10;
    }
    if ($limit > 50) {
        $limit = 50;
    }
    $accountData = Account::getList($page, $limit);
    echo json_encode($accountData);
    exit(0);
}
?>
<div id="account_tb">
    <a href="#" onclick="add_account();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
    <a href="#" onclick="edit_account();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">编辑</a>
    <a href="#" onclick="del_account();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
</div>
<div id="module-wrap">
    <h2>账户管理</h2>
    <table id="account_grid" style="width: 100%; height: auto;"></table>
</div>
<div id="account_dialog"></div>
<div id="select_dialog"></div>