コード例 #1
0
ファイル: Vzaar.php プロジェクト: reuf/laravel-vzaar
 /**
  * This API call returns the details and rights for each vzaar account
  * type along with it's relevant metadata
  * http://vzaar.com/api/accounts/{account}.json
  * @static
  * @param integer $account is the vzaar account type. This is an integer.
  * @return AccountType
  */
 public static function getAccountDetails($account)
 {
     $_url = self::$url;
     $c = new HttpRequest($_url . 'api/accounts/' . $account . '.json');
     $c->verbose = Vzaar::$enableHttpVerbose;
     return AccountType::fromJson($c->send());
 }
コード例 #2
0
ファイル: DatabaseSeeder.php プロジェクト: yeyande/CS499
 public function run()
 {
     DB::table('AccountTypes')->delete();
     AccountType::create(array('name' => 'checking', 'interest' => 0.0));
     AccountType::create(array('name' => 'savings', 'interest' => 0.25));
     AccountType::create(array('name' => 'money_market', 'interest' => 0.25));
     AccountType::create(array('name' => 'mortgage', 'interest' => -0.75));
     AccountType::create(array('name' => 'credit', 'interest' => -0.99));
 }
コード例 #3
0
ファイル: AccountController.php プロジェクト: yeyande/CS499
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $account = Account::where('id', '=', $id)->first();
     if (Request::get('customer_id')) {
         $account->customer_id = Input::get('customer_id');
     }
     if (Request::get('type')) {
         try {
             $type = AccountType::where('name', '=', Input::get('type'))->firstOrFail();
         } catch (ModelNotFoundException $e) {
             return $this->handleInvalidType(Input::get('type'));
         }
         $account->type()->associate($type);
     }
     if (Request::get('balance')) {
         $account->balance = Input::get('balance');
     }
     $account->save();
     return Response::json(array('message' => 'account updated'), 200);
 }
コード例 #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable
  */
 public function loadAccountType($id = null)
 {
     if ($this->_model === null) {
         if ($id !== null || isset($_GET['id'])) {
             $this->_model = AccountType::model()->findbyPk($id !== null ? $id : $_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
コード例 #5
0
<!-- <div id="legend">
	<strong>Report Type Legend </strong><br />
    Account Balance = 17 <br />
    Project Expense = 16 <br />
	Account Summary (default) = 3<br />
	Account Summary (reconciled) = 14 <br />
</div> -->
<?php 
}
?>


<div class="simple">
<?php 
echo CHtml::activeLabelEx($model, 'accountTypeId', array('class' => 'help', 'title' => Yii::t('lazy8', 'contexthelp.accountTypeId'), 'onclick' => 'alert(this.title)'));
echo CHtml::activeDropDownList($model, 'accountTypeId', CHtml::listData(AccountType::model()->findAll(array('order' => 'isInBalance DESC, sortOrder', 'condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'))), 'id', 'name'), array('onchange' => 'check(\'AccountEmail\');'));
?>
</div>

<?php 
if ($update) {
    ?>
	<center>
		<div class="selectTag" style="width: 90%;margin: 1em;">

			<div style="font-weight: bold;text-align: center;margin-bottom: 1em;">Add a tag to this account: </div>

			<div class="tagList" style="float: left;margin-bottom: 1em;">
				<?php 
    echo CHtml::dropDownList('AddTagToAccount', 'customerId', CHtml::encodeArray(CHtml::listData(Customer::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'), 'select' => 'id, CAST(CONCAT(code, ": " ,name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name')));
    ?>
コード例 #6
0
 /**
  * @return array Errors Export Account information
  */
 public static function ExportAccounts()
 {
     $comp = Company::model()->findbyPk(Yii::app()->user->getState('selectedCompanyId'));
     // set headers
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Content-Description: File Transfer");
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"lazy8web.accounts." . CompanyController::replace_bad_filename_chars($comp->name) . "." . date('Y-m-d_H.i.s') . ".xml\"");
     header("Content-Transfer-Encoding: binary");
     //header("Content-Length: " );
     $writer = new XMLWriter();
     // Output directly to the user
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'utf-8');
     $writer->setIndent(4);
     $writer->startElement('lazy8webportaccount');
     $writer->writeAttribute('version', '1.00');
     $accountTypes = AccountType::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId')));
     foreach ($accountTypes as $accountType) {
         $writer->startElement('accounttype');
         $writer->writeAttribute("code", $accountType->code);
         $writer->writeAttribute("name", $accountType->name);
         $writer->writeAttribute("sortorder", $accountType->sortOrder);
         $writer->writeAttribute("isinbalance", $accountType->isInBalance);
         $accounts = Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId') . ' AND accountTypeId=' . $accountType->id));
         foreach ($accounts as $account) {
             $allAccounts[$account->id] = $account->code;
             $writer->startElement('account');
             $writer->writeAttribute("code", $account->code);
             $writer->writeAttribute("name", $account->name);
             $writer->writeAttribute("email", $account->email);
             $writer->writeAttribute("balance_threshold", $account->balance_threshold);
             $writer->writeAttribute("days", $account->days);
             $writer->writeAttribute("report_id", $account->report_id);
             $writer->endElement();
         }
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
     return;
     //we may not send any more to the screen or it will mess up the file we just sent!
 }
コード例 #7
0
ファイル: AccountTest.php プロジェクト: yeyande/CS499
 protected function createAccount($type = null)
 {
     if (is_null($type)) {
         $type = $this->validTypes[array_rand($this->validTypes)];
     }
     $type = AccountType::where('name', '=', $type)->firstOrFail();
     $account = new Account();
     $account->type()->associate($type);
     $account->user()->associate($this->user);
     $account->balance = round(mt_rand() / mt_getrandmax() * 1000, 2);
     $account->save();
     return $account;
 }
コード例 #8
0
 private function exportCompany($companyId = null)
 {
     $compName = "AllCompanies";
     if ($companyId != null) {
         $compName = CompanyController::replace_bad_filename_chars(Company::model()->findbyPk($companyId)->name);
     }
     // set headers
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Content-Description: File Transfer");
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"lazy8webExport.Company." . $compName . "." . date('Y-m-d_H.i.s') . ".xml\"");
     header("Content-Transfer-Encoding: binary");
     //safari can't deal with this header length zero
     //		header("Content-Length: " );
     $writer = new XMLWriter();
     // Output directly to the user
     //dirname(__FILE__).DIRECTORY_SEPARATOR.'../..'.'/assets/upload.sql'
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'utf-8');
     $writer->setIndent(4);
     $writer->startElement('lazy8webport');
     $writer->writeAttribute('version', '1.00');
     $companies = array();
     if (isset($companyId)) {
         $companies[] = Company::model()->findbyPk($companyId);
     } else {
         $companies = Company::model()->findAll(array('order' => 'code'));
     }
     foreach ($companies as $company) {
         ChangeLog::addLog('OTHER', 'Company', 'Exported company ' . $company->toString());
         $writer->startElement('company');
         $writer->writeAttribute("code", $company->code);
         $writer->writeAttribute("name", $company->name);
         $writer->writeAttribute("lastAbsTransNum", $company->lastAbsTransNum);
         $allAccounts = array();
         $accountTypes = AccountType::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'code'));
         foreach ($accountTypes as $accountType) {
             $writer->startElement('accounttype');
             $writer->writeAttribute("code", $accountType->code);
             $writer->writeAttribute("name", $accountType->name);
             $writer->writeAttribute("sortorder", $accountType->sortOrder);
             $writer->writeAttribute("isinbalance", $accountType->isInBalance);
             $accounts = Account::model()->findAll(array('condition' => 'companyId=' . $company->id . ' AND accountTypeId=' . $accountType->id, 'order' => 'code'));
             foreach ($accounts as $account) {
                 $allAccounts[$account->id] = $account->code;
                 $writer->startElement('account');
                 $writer->writeAttribute("code", $account->code);
                 $writer->writeAttribute("name", $account->name);
                 $writer->endElement();
             }
             $writer->endElement();
         }
         $customers = Customer::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'code'));
         $allCustomers = array();
         foreach ($customers as $customer) {
             $writer->startElement('customer');
             $allCustomers[$customer->id] = $customer->code;
             $writer->writeAttribute("code", $customer->code);
             $writer->writeAttribute("name", $customer->name);
             $writer->writeAttribute("desc", $customer->desc);
             if (isset($allAccounts[$customer->accountId])) {
                 $writer->writeAttribute("accountcode", $allAccounts[$customer->accountId]);
             } else {
                 $writer->writeAttribute("accountcode", 0);
             }
             $writer->endElement();
         }
         $periods = Period::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'dateStart'));
         foreach ($periods as $period) {
             $writer->startElement('period');
             $writer->writeAttribute("datestart", $period->dateStart);
             $writer->writeAttribute("dateend", $period->dateEnd);
             $writer->writeAttribute("lastperiodtransnum", $period->lastPeriodTransNum);
             $transactions = Trans::model()->findAll(array('condition' => 'companyId=' . $company->id . ' AND periodId=' . $period->id, 'order' => 'companyNum'));
             foreach ($transactions as $transaction) {
                 $writer->startElement('transaction');
                 $writer->writeAttribute("code", $transaction->companyNum);
                 $writer->writeAttribute("periodnum", $transaction->periodNum);
                 $writer->writeAttribute("regdate", $transaction->regDate);
                 $writer->writeAttribute("invdate", $transaction->invDate);
                 $writer->writeAttribute("notes", $transaction->notes);
                 $writer->writeAttribute("fileinfo", $transaction->fileInfo);
                 $transrows = TransRow::model()->findAll(array('condition' => 'transId=' . $transaction->id, 'order' => 'amount DESC'));
                 foreach ($transrows as $transrow) {
                     $writer->startElement('amount');
                     $writer->writeAttribute("accountcode", isset($allAccounts[$transrow->accountId]) ? $allAccounts[$transrow->accountId] : 0);
                     $writer->writeAttribute("customercode", isset($allCustomers[$transrow->customerId]) ? $allCustomers[$transrow->customerId] : 0);
                     $writer->writeAttribute("notes", $transrow->notes);
                     $writer->writeAttribute("amount", $transrow->amount);
                     $writer->endElement();
                 }
                 $writer->endElement();
             }
             $writer->endElement();
         }
         yii::app()->onExport(new Lazy8Event(array('exportobject' => 'Company', 'writer' => $writer), $company->id));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
     return;
     //we may not send any more to the screen or it will mess up the file we just sent!
 }