当前位置: 首页>>代码示例>>PHP>>正文


PHP Statement::save方法代码示例

本文整理汇总了PHP中Statement::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Statement::save方法的具体用法?PHP Statement::save怎么用?PHP Statement::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statement的用法示例。


在下文中一共展示了Statement::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createStatement

 protected function createStatement(\Lrs $lrs, \Client $client, array $statement)
 {
     $model = new \Statement(['lrs_id' => new \MongoId($lrs->_id), 'client_id' => $client->_id, 'statement' => $statement, 'active' => true, 'voided' => false, 'refs' => []]);
     $model->timestamp = new \MongoDate(strtotime($model->statement['timestamp']));
     $model->save();
     return $model;
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:7,代码来源:StatementsTestCase.php

示例2: gerenateMonthly

 public function gerenateMonthly()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'propertyid' => 'required', 'agent_id' => 'required'));
     if ($v->passes()) {
         $propertyidan = Input::get('propertyid');
         $houseID = Input::get('houseID');
         $startDate = time();
         $lastmonth = date('Y-m-d', strtotime('+5 day', $startDate));
         $ddate = date('d');
         $agent_id = Input::get('agent_id');
         $billedusr = User::find($agent_id);
         $hisBalance = $billedusr->credit_balance;
         $newBalance = $hisBalance - 3;
         $billedusr->credit_balance = $newBalance;
         $billedusr->save();
         $billstatement = new Statement();
         $billstatement->type = "Generating Invoice";
         $billstatement->amount = 3;
         $billstatement->save();
         if ($houseID === "All") {
             $houses = House::where('status', '=', 'booked')->where('frequency', '=', 1)->where('propertyID', $propertyidan)->get();
             foreach ($houses as $house) {
                 $hid = $house->id;
                 $houseName = $house->name;
                 $propid = $house->propertyID;
                 $propname = Property::where('id', $propid)->pluck('name');
                 $rent = $house->rent;
                 $water = $house->water;
                 $garbage = $house->garbage;
                 $electricity = $house->electricity;
                 $security = $house->security;
                 $frequency = $house->frequency;
                 $tenant_id = $house->tenant;
                 $tenantnames = strtok($tenant_id, " ");
                 $tenant = Tenant::where('name', $tenantnames)->first();
                 $t_name = $tenant->name;
                 $to = $tenant->phone;
                 $t_agent = $tenant->agent_id;
                 $balance = $rent + $water + $garbage + $electricity + $security;
                 $invoice = new Invoice();
                 $invoice->type = 'to tenant';
                 $invoice->houseID = $houseName;
                 $invoice->recipient = $t_name;
                 $invoice->agent_id = $t_agent;
                 $invoice->balance = $balance;
                 $invoice->propertyid = $propid;
                 $invoice->duedate = $lastmonth;
                 $invoice->save();
                 $invoicedetail = new Invoicedetail();
                 $invoicedetail->rent = $rent;
                 $invoicedetail->water = $water;
                 $invoicedetail->garbage = $garbage;
                 $invoicedetail->electricity = $electricity;
                 $invoicedetail->security = $security;
                 $invoice->invoicedetail()->save($invoicedetail);
                 $message = 'Dear ' . $t_name . ', your rent for this month of Ksh ' . number_format($balance, 2) . '  is due for payment. For inquiries contact 0700548168 Rehema House Ngong';
                 Queue::push('SendSMS', array('message' => $message, 'number' => $to));
             }
             $noteSuccesGen = array('error' => false, 'message' => "Monthly invoice(s) generated successfully");
             return $noteSuccesGen;
         } else {
             $house = House::where('name', '=', $houseID)->where('frequency', '=', 1)->first();
             $hid = $house->id;
             $houseName = $house->name;
             $propid = $house->propertyID;
             $propname = Property::where('id', $propid)->pluck('name');
             $rent = $house->rent;
             $water = $house->water;
             $garbage = $house->garbage;
             $electricity = $house->electricity;
             $security = $house->security;
             $frequency = $house->frequency;
             $tenant_id = $house->tenant;
             $tenantnames = strtok($tenant_id, " ");
             $tenant = Tenant::where('name', $tenantnames)->first();
             $t_name = $tenant->name;
             $to = $tenant->phone;
             $t_agent = $tenant->agent_id;
             $balance = $rent + $water + $garbage + $electricity + $security;
             $invoice = new Invoice();
             $invoice->type = 'to tenant';
             $invoice->houseID = $houseName;
             $invoice->recipient = $t_name;
             $invoice->agent_id = $t_agent;
             $invoice->balance = $balance;
             $invoice->propertyid = $propid;
             $invoice->duedate = $lastmonth;
             $invoice->save();
             $invoicedetail = new Invoicedetail();
             $invoicedetail->rent = $rent;
             $invoicedetail->water = $water;
             $invoicedetail->garbage = $garbage;
             $invoicedetail->electricity = $electricity;
             $invoicedetail->security = $security;
             $invoice->invoicedetail()->save($invoicedetail);
             $message = 'Dear ' . $t_name . ', your rent for this month of Ksh ' . number_format($balance, 2) . '  is due for payment.For inquiries contact 0700548168 Rehema House Ngong';
             Queue::push('SendSMS', array('message' => $message, 'number' => $to));
             $noteSuccesGen = array('error' => false, 'message' => "Monthly invoice(s) generated successfully");
             return $noteSuccesGen;
//.........这里部分代码省略.........
开发者ID:jeremiteki,项目名称:mteja-laravel,代码行数:101,代码来源:AndroidController.php

示例3: updateDBByData

 protected static function updateDBByData(&$arrData)
 {
     $arrLog = [];
     Yii::log("updateDBByData start", "info");
     foreach ($arrData as $k => $v) {
         // найти запись в {{company}}
         // блокировка её FOR UPDATE
         $Company = Company::model()->findByAttributes(['INN' => $v['inn']]);
         if (!is_null($Company)) {
             $transaction = Yii::app()->getDb()->beginTransaction();
             try {
                 C2goActiveRecord::logStart();
                 $sqlCompanyBlock = 'SELECT * FROM ' . $Company->tableName() . ' WHERE `id`=:id  FOR UPDATE';
                 $CompanyById = Company::model()->findBySql($sqlCompanyBlock, ['id' => $Company->id]);
                 //$sqlCheckStatementExist = 'SELECT * FROM {{statement}} WHERE `tnd`=:tnd AND `sum`=:sum AND `inn`=:inn AND `date`=:date';
                 $arrParams = ['tnd' => $v['tnd'], 'sum' => $v['sum'], 'date' => static::convertXMLDate($v['date']), 'inn' => $v['inn']];
                 $StatementCheck = Statement::model()->findByAttributes($arrParams);
                 if (is_null($StatementCheck)) {
                     // добавить
                     $Statement = new Statement();
                     $Statement->tnd = $v['tnd'];
                     $Statement->sum = $v['sum'];
                     $Statement->date = static::convertXMLDate($v['date']);
                     $Statement->inn = $v['inn'];
                     $Statement->name = $v['name'];
                     if (!$Statement->save()) {
                         throw new CException(Yii::t('StatementModule.default', 'Не могу сохранить запись в Statement,errors', ['errors' => print_r($Statement->getErrors(), true)]));
                     }
                     Yii::log("updateDBByData p3 ", "info");
                     //@todo: log.processed
                     static::addToStatementLog($Statement, StatementLog::PROCESSED, $CompanyById);
                     Yii::log("updateDBByData p4 ", "info");
                     // verify
                     if (!$CompanyById->verify || !$CompanyById->validate) {
                         $CompanyById->verify = 1;
                         $CompanyById->validate = 1;
                         if ($CompanyById->save()) {
                             //@todo: log.verified
                             static::addToStatementLog($Statement, StatementLog::VERIFIED, $CompanyById);
                         } else {
                             throw new CException(Yii::t('StatementModule.default', 'Не могу в Company сделать verify=1,validate=1 ,errors', ['errors' => print_r($CompanyById->getErrors(), true)]));
                         }
                     }
                     // company.balance
                     $CompanyById->balance += $v['sum'];
                     if ($CompanyById->save()) {
                         $AccountMotion = new AccountMotion();
                         $AccountMotion->company_id = $CompanyById->id;
                         $AccountMotion->price = $v['sum'];
                         $AccountMotion->notice = "import statement Statement.id=[{$Statement->id}]";
                         if ($AccountMotion->save()) {
                             //@todo: log.enrolled
                             static::addToStatementLog($Statement, StatementLog::ENROLLED, $CompanyById);
                             //sleep(5);
                             $transaction->commit();
                             $arrLog[] = ['success'];
                             C2goActiveRecord::logEndAndWrite();
                         } else {
                             throw new CException(Yii::t('StatementModule.default', 'Не могу добавить в AccountMotion ,errors', ['errors' => print_r($AccountMotion->getErrors(), true)]));
                         }
                     } else {
                         throw new CException(Yii::t('StatementModule.default', 'Не могу в Company изменить balance ,errors', ['errors' => print_r($CompanyById->getErrors(), true)]));
                     }
                 } else {
                     throw new CException(Yii::t('StatementModule.default', 'Statement запись уже есть'));
                 }
             } catch (Exception $e) {
                 $transaction->rollback();
                 $strException = $e->__toString();
                 Yii::log("updateDBByData exception [{$strException}]", "error");
                 $arrLog[] = ['error', $e->getMessage()];
                 C2goActiveRecord::logEmptyMessages();
             } finally {
                 C2goActiveRecord::logEnd();
             }
         } else {
             $arrLog[] = ['error', Yii::t('StatementModule.default', 'Не найдена компания по INN, inn_value', ['inn_value' => $v['inn']])];
         }
         //@todo: delete
         //break;
     }
     Yii::log("updateDBByData end", "info");
     return $arrLog;
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:84,代码来源:Statement.php

示例4: loopStatements

 public function loopStatements($statements)
 {
     //build new statements
     foreach ($statements as $s) {
         if (isset($s->context['extensions']['http://learninglocker&46;net/extensions/lrs'][1])) {
             $setlrs = $s->context['extensions']['http://learninglocker&46;net/extensions/lrs'][1];
         } elseif (isset($s->context['extensions']['http://learninglocker&46;net/extensions/lrs'][0])) {
             $setlrs = $s->context['extensions']['http://learninglocker&46;net/extensions/lrs'][0];
         } elseif (isset($s->context['extensions']['http://learninglocker&46;net/extensions/lrs'])) {
             $setlrs = $s->context['extensions']['http://learninglocker&46;net/extensions/lrs'];
         } else {
             $setlrs = $s->context['extensions']['http://learninglocker.net/extensions/lrs'];
         }
         //set statement
         if (isset($s->id)) {
             $set_statement['id'] = $s->id;
         }
         if (isset($s->actor)) {
             $set_statement['actor'] = $s->actor;
         }
         if (isset($s->verb)) {
             $set_statement['verb'] = $s->verb;
         }
         if (isset($s->object)) {
             $set_statement['object'] = $s->object;
         }
         if (isset($s->stored)) {
             $set_statement['stored'] = $s->stored;
         }
         if (isset($s->context)) {
             $context = $s->context;
             unset($context['extensions']['http://learninglocker&46;net/extensions/lrs']);
             unset($context['extensions']['http://learninglocker&46;net/extensions/category']);
             if (empty($context['extensions'])) {
                 unset($context['extensions']);
             }
             if (!empty($context)) {
                 $set_statement['context'] = $context;
             }
         }
         if (isset($s->result)) {
             $set_statement['result'] = $s->result;
         }
         if (isset($s->timestamp)) {
             $set_statement['timestamp'] = $s->timestamp;
         } else {
             $set_statement['timestamp'] = $s->stored;
         }
         if (isset($s->version)) {
             $set_statement['version'] = $s->version;
         }
         if (isset($s->attachments)) {
             $set_statement['attachments'] = $s->attachments;
         }
         //insert record to our new collection
         $statement = new Statement();
         $statement->lrs = (object) $setlrs;
         $statement->statement = $set_statement;
         $statement->created_at = $s->created_at;
         $statement->updated_at = $s->updated_at;
         $statement->save();
     }
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:63,代码来源:MigrateController.php


注:本文中的Statement::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。