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


PHP Invoice::model方法代码示例

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


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

示例1: init

 public function init()
 {
     parent::init();
     // Create new field in your users table for store dashboard preference
     // Set table name, user ID field name, user preference field name
     $this->setTableParams('dashboard_page', 'user_id', 'title');
     // set array of portlets
     $this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
     //set content BEFORE dashboard
     $this->setContentBefore();
     // uncomment the following to apply jQuery UI theme
     // from protected/components/assets/themes folder
     $this->applyTheme('ui-lightness');
     // uncomment the following to change columns count
     //$this->setColumns(4);
     // uncomment the following to enable autosave
     $this->setAutosave(true);
     // uncomment the following to disable dashboard header
     $this->setShowHeaders(false);
     // uncomment the following to enable context menu and add needed items
     /*
     $this->menu = array(
         array('label' => 'Index', 'url' => array('index')),
     );
     */
 }
开发者ID:FranHurtado,项目名称:hotels,代码行数:26,代码来源:DashController.php

示例2: actionInvoiceList

 public function actionInvoiceList()
 {
     if ($_POST["start"]) {
         $criteria = new CDbCriteria();
         $criteria->condition = "Date BETWEEN :start AND :finish AND UserID = :userid";
         $criteria->params = array(':start' => date("Y-m-d", strtotime($_POST["start"])), ':finish' => date("Y-m-d", strtotime($_POST["fin"])), ':userid' => Yii::app()->user->ID);
         $model = Invoice::model()->findAll($criteria);
         set_time_limit(600);
         # mPDF
         $pdf = Yii::app()->ePdf->mpdf('', 'A4', '', '', '', '', '', '', '', '', 'P');
         $pdf->writeHTMLfooter = false;
         $pdf->writeHTMLheader = false;
         $pdf->DeflMargin = 15;
         $pdf->DefrMargin = 15;
         $pdf->tMargin = 15;
         $pdf->bMargin = 15;
         $pdf->w = 297;
         //manually set width
         $pdf->h = 209.8;
         //manually set height
         # render (full page)
         $pdf->WriteHTML($this->renderPartial('_invoicelist', array('model' => $model), true));
         # Outputs ready PDF
         $pdf->Output('ListaFacturas_' . date("d/m/Y") . '.pdf', 'D');
     } else {
         $this->render('selector');
     }
 }
开发者ID:FranHurtado,项目名称:hotels,代码行数:28,代码来源:DefaultController.php

示例3: loadModel

 /**
  * 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 $id the ID of the model to be loaded
  * @return Zal the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Invoice::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:Aplay,项目名称:anetika_site,代码行数:15,代码来源:InvoiceController.php

示例4: getPaymentUrl

 public function getPaymentUrl($invoice_id, $options = array())
 {
     $invoice = Invoice::model()->findByPk($invoice_id);
     if ($invoice == null) {
         return false;
     }
     if ($invoice->customer_id != Yii::app()->user->getId()) {
         return false;
     }
     $amount = $invoice->amount;
     $amount = $amount * 100;
     $merchantSession = urlencode(time() . '-' . $this->makePaystationSessionID(8, 8));
     $this->setSessionId($merchantSession);
     $this->merchantRef = Yii::app()->user->getId();
     $paystationUrl = "https://www.paystation.co.nz/direct/paystation.dll";
     $paystationParameters = "paystation=_empty&pstn_pi=" . $this->paystationId . "&pstn_gi=" . $this->gatewayId . "&pstn_ms=" . $merchantSession . "&pstn_mr=" . $this->merchantRef . "&pstn_am=" . $amount . "&pstn_nr=t";
     if ($this->testMode == 'true') {
         $paystationParameters = $paystationParameters . "&pstn_tm=t";
     }
     foreach ($options as $key => $value) {
         $paystationParameters .= "&" . $key . "=" . $value;
     }
     $result = $this->doPostRequest($paystationUrl, $paystationParameters);
     // handle result
     $xmlData = new SimpleXMLElement($result);
     $digitalOrder = $xmlData->DigitalOrder;
     // The URL that we re-direct the customer too.
     $transactionID = $xmlData->PaystationTransactionID;
     //The transaction ID Paystation has just created.
     $PaymentRequestTime = $xmlData->PaymentRequestTime;
     // The time that the transaction was initiated
     $DigitalOrderTime = $xmlData->DigitalOrderTime;
     //The time Paystation responds
     // redirect
     if ($digitalOrder) {
         $payment = new Payment();
         $payment->transaction_id = $transactionID;
         $payment->session_id = $merchantSession;
         $payment->order_time = $DigitalOrderTime;
         $payment->merchant_ref = $this->merchantRef;
         $payment->customer_id = Yii::app()->user->getId();
         $payment->invoice_id = $invoice_id;
         $payment->save(false);
         return $digitalOrder;
     } else {
         //echo "<pre>".htmlentities($result)."</pre>"; //no digitalorder variable, so initiation must have failed.  Print out xml packet for debugging purposes
         return false;
     }
     return false;
 }
开发者ID:huynt57,项目名称:vs,代码行数:50,代码来源:PayStation.php

示例5: Top

 public function Top($num)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "UserID = :userid";
     $criteria->params = array(':userid' => Yii::app()->user->ID);
     $criteria->limit = $num;
     $model = Invoice::model()->findAll($criteria);
     $result = "";
     $result .= "<table cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse;'>";
     $result .= "<tr><td><b>Serie</b></td><td><b>Numero</b></td><td><b>Cliente</b></td></tr>";
     foreach ($model as $customer) {
         $result .= "<tr>";
         $result .= "<td><a href='" . Yii::app()->createURL('/invoice/invoice/update/', array('id' => $customer->ID)) . "'>" . $customer->serie->Serie . "</td>";
         $result .= "<td><a href='" . Yii::app()->createURL('/invoice/invoice/update/', array('id' => $customer->ID)) . "'>" . $customer->Number . "</td>";
         $result .= "<td><a href='" . Yii::app()->createURL('/invoice/invoice/update/', array('id' => $customer->ID)) . "'>" . Functions::stringCut($customer->customer->FullName, 20) . "</td>";
         $result .= "</tr>";
     }
     $result .= "</table>";
     return $result;
 }
开发者ID:FranHurtado,项目名称:hotels,代码行数:20,代码来源:Invoice.php

示例6: array

		<?php 
echo $form->dropDownList($model, 'SerieID', CHtml::listData(Serie::model()->findAll($criteria), 'ID', 'Serie'), array('style' => 'width: 100%;'));
?>
		<?php 
echo $form->error($model, 'SerieID');
?>
	</div>
	
	<?php 
// If it is a new record. We calculate the next invoice number
if ($model->isNewRecord) {
    $criteriaNextNumber = new CDbCriteria();
    $criteriaNextNumber->condition = 'UserID = :userid';
    $criteriaNextNumber->params = array(':userid' => Yii::app()->user->ID);
    $criteriaNextNumber->order = 'Number Desc';
    $model->Number = Invoice::model()->find($criteriaNextNumber)->ID + 1;
}
?>
	
	<div class="row" style="width: 15%; float: left; margin-left: 5%;">
		<?php 
echo $form->labelEx($model, 'Number');
?>
		<?php 
echo $form->textField($model, 'Number', array('style' => 'width: 100%;', 'maxlength' => 25));
?>
		<?php 
echo $form->error($model, 'Number');
?>
	</div>
开发者ID:FranHurtado,项目名称:hotels,代码行数:30,代码来源:_form.php

示例7: actionShow

 /**
  * Shows a particular model.
  */
 public function actionShow()
 {
     if (!User::isClient() && !User::isManager() && !User::isAdministrator()) {
         // not enough rights
         MUserFlash::setTopError(Yii::t('hint', 'We are sorry, but you don\'t have enough rights to browse companies.'));
         $this->redirect($this->getGotoUrl());
     }
     if (isset($_GET['my'])) {
         // show client's company
         if (Yii::app()->user->isGuest) {
             // guest may not have any company
             MUserFlash::setTopError(Yii::t('hint', 'Please authorize to view your company.'));
             $this->redirect($this->getGotoUrl());
         }
         if (($user2Company = User2Company::model()->findByAttributes(array('userId' => Yii::app()->user->id, 'position' => Company::OWNER), array('order' => "`companyPriority` ASC"))) !== null) {
             $id = $user2Company->companyId;
         } else {
             // user is not an owner yet
             MUserFlash::setTopError(Yii::t('hint', 'We are sorry, but you are not the owner of any company yet.'));
             $this->redirect($this->getGotoUrl());
         }
     } else {
         // get id from the url
         $id = isset($_GET['id']) ? $_GET['id'] : 0;
     }
     // load model
     $with = array('allUser');
     /*if(User::isClient())
       $with[]='allUser2Company';*/
     $model = $this->loadModel(array('id' => $id, 'with' => $with));
     // may member view this record?
     if (User::isClient()) {
         /*$allOwner=array();
           foreach($model->allUser2Company as $user2Company)
           {
               if($user2Company->position===Company::OWNER)
                   $allOwner[]=$user2Company->userId;
           }
           if(!in_array(Yii::app()->user->id,$allOwner))*/
         if (!$model->isOwner()) {
             MUserFlash::setTopError(Yii::t('hint', 'We are sorry, but you don\'t have enough rights to view the company record number {id}.', array('{id}' => MHtml::wrapInTag($model->id, 'strong'))));
             $this->redirect($this->getGotoUrl());
         }
     }
     // FIXME: check is owner or manager or admin
     // transaction's payments
     $companyPayments = CompanyPayment::model()->findAllByAttributes(array('companyId' => $model->id), new CDbCriteria(array('order' => "`t`.`paymentDate` ASC, `t`.`id` ASC")));
     // transaction's invoices
     $invoices = Invoice::model()->findAllByAttributes(array('companyId' => $model->id), new CDbCriteria(array('order' => "`t`.`invoiceDate` ASC, `t`.`id` ASC")));
     // construct tmp array of all transactions. use time as index
     $array = array();
     foreach ($companyPayments as $companyPayment) {
         $time = strtotime($companyPayment->paymentDate);
         while (array_key_exists($time, $array)) {
             $time++;
         }
         $array[$time] = array('date' => $companyPayment->paymentDate, 'credit' => $companyPayment->amount, 'number' => $companyPayment->paymentNumber, 'method' => $companyPayment->getAttributeView('paymentMethod'), 'id' => $companyPayment->id, 'controllerId' => 'companyPayment');
     }
     foreach ($invoices as $invoice) {
         $time = strtotime($invoice->invoiceDate);
         while (array_key_exists($time, $array)) {
             $time++;
         }
         $array[$time] = array('date' => $invoice->invoiceDate, 'debit' => $invoice->amountTotal, 'id' => $invoice->id, 'controllerId' => 'invoice');
     }
     // sort by index
     ksort($array);
     // construct transaction history array
     $transactions = array();
     $balance = $debit = $credit = 0;
     foreach ($array as $row) {
         $d = isset($row['debit']) ? $row['debit'] : 0;
         $c = isset($row['credit']) ? $row['credit'] : 0;
         $balance = $balance - $d + $c;
         $debit += $d;
         $credit += $c;
         $transactions[] = array('date' => $row['date'], 'debit' => isset($row['debit']) ? $row['debit'] : null, 'credit' => isset($row['credit']) ? $row['credit'] : null, 'number' => isset($row['number']) ? $row['number'] : null, 'method' => isset($row['method']) ? $row['method'] : null, 'balance' => $balance, 'id' => $row['id'], 'controllerId' => $row['controllerId']);
     }
     // rows for the static grid
     $gridRows = array();
     foreach ($transactions as $transaction) {
         $gridRows[] = array(array('align' => 'right', 'content' => CHtml::encode(MDate::format($transaction['date'], 'long', null)), 'title' => CHtml::encode(MDate::format($transaction['date'], 'full', null))), array('content' => CHtml::link($transaction['controllerId'] === 'invoice' ? Yii::t('link', 'Invoice {number}', array('{number}' => $transaction['number'] === null ? $transaction['id'] : $transaction['number'])) : Yii::t('link', 'Payment {number} ({method})', array('{number}' => $transaction['number'] === null ? $transaction['id'] : $transaction['number'], '{method}' => $transaction['method'])), array($transaction['controllerId'] . '/show', 'id' => $transaction['id']))), array('align' => 'right', 'content' => is_numeric($transaction['debit']) ? CHtml::encode(MCurrency::format($transaction['debit'])) : ''), array('align' => 'right', 'content' => is_numeric($transaction['credit']) ? CHtml::encode(MCurrency::format($transaction['credit'])) : ''), array('align' => 'right', 'content' => CHtml::encode(MCurrency::format($transaction['balance']))));
     }
     // render the view file
     $this->render($this->action->id, array('model' => $model, 'debit' => $debit, 'credit' => $credit, 'balance' => $credit - $debit, 'gridRows' => $gridRows));
 }
开发者ID:megabr,项目名称:web3cms,代码行数:89,代码来源:CompanyController.php

示例8: gridOutstandingColumn

 protected function gridOutstandingColumn($data, $row)
 {
     $outstanding = Invoice::model()->getOutstanding($data->id);
     foreach ($outstanding as $data) {
         $outstanding_balance = $data['outstanding_balance'];
     }
     print_r(Yii::app()->numberFormatter->formatDecimal($outstanding_balance));
 }
开发者ID:noonnightcoder,项目名称:bakou-pos-apsara,代码行数:8,代码来源:InvoiceController.php

示例9: actionGeneratePrint

 /**
  *	Billing and Print
  */
 public function actionGeneratePrint()
 {
     $model = Book::model()->findByPK($_GET["id"]);
     // Change Book status
     $model->Type = 1;
     $model->save();
     $items = array();
     $startDate = strtotime($model->Start);
     $finishDate = strtotime($model->Finish);
     $roomID = $model->RoomID;
     $Pax = $model->Pax;
     // Create Invoice
     $modelInvoice = new Invoice();
     $modelInvoice->UserID = Yii::app()->user->ID;
     $modelInvoice->CustomerID = $model->CustomerID;
     $modelInvoice->Date = date("Y-m-d");
     $criteriaNextNumber = new CDbCriteria();
     $criteriaNextNumber->condition = 'UserID = :userid';
     $criteriaNextNumber->params = array(':userid' => Yii::app()->user->ID);
     $criteriaNextNumber->order = 'Number Desc';
     $modelInvoice->Number = Invoice::model()->find($criteriaNextNumber)->ID + 1;
     $modelInvoice->SerieID = Serie::model()->findByAttributes(array('Pred' => '1'))->ID;
     $modelInvoice->BookID = $model->ID;
     $modelInvoice->save();
     $days = round(($finishDate - $startDate) / 86400);
     $price = 0;
     // Calculate Room price
     if (Room::model()->findByPK($roomID)->Type == 0) {
         for ($i = 0; $i < $days; $i++) {
             $date = $startDate + $i * 86400;
             $season = Book::model()->getSeason(date("Y-m-d", $date));
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
             $modelCharge->InvoiceID = $modelInvoice->ID;
             $modelCharge->IVA = User::model()->findByPK(Yii::app()->user->ID)->IVA;
             switch ($season) {
                 case 0:
                     $items[] = array($model->room->PriceLow, $model->room->Name . " (Temporada Baja).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceLow;
                     $modelCharge->Text = $model->room->Name . " (Temporada Baja).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceLow;
                     break;
                 case 1:
                     $items[] = array($model->room->PriceMed, $model->room->Name . " (Temporada Media).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceMed;
                     $modelCharge->Text = $model->room->Name . " (Temporada Media).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceMed;
                     break;
                 case 2:
                     $items[] = array($model->room->PriceBig, $model->room->Name . " (Temporada Alta).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceBig;
                     $modelCharge->Text = $model->room->Name . " (Temporada Alta).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceBig;
                     break;
             }
             $modelCharge->save();
         }
     } else {
         for ($i = 0; $i < $days; $i++) {
             $date = $startDate + $i * 86400;
             $season = Book::model()->getSeason(date("Y-m-d", $date));
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
             $modelCharge->InvoiceID = $modelInvoice->ID;
             $modelCharge->IVA = User::model()->findByPK(Yii::app()->user->ID)->IVA;
             switch ($season) {
                 case 0:
                     $items[] = array(Room::model()->findByPK($roomID)->PriceLow * $Pax, $model->room->Name . " (" . $Pax . " personas Temporada Baja).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceLow * $Pax;
                     $modelCharge->Text = $model->room->Name . " (" . $Pax . " personas Temporada Baja).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceLow * $Pax;
                     break;
                 case 1:
                     $items[] = array(Room::model()->findByPK($roomID)->PriceMed * $Pax, $model->room->Name . " (" . $Pax . " personas Temporada Media).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceMed * $Pax;
                     $modelCharge->Text = $model->room->Name . " (" . $Pax . " personas Temporada Media).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceMed * $Pax;
                     break;
                 case 2:
                     $items[] = array(Room::model()->findByPK($roomID)->PriceBig * $Pax, $model->room->Name . " (" . $Pax . " personas Temporada Alta).");
                     $price = $price + Room::model()->findByPK($roomID)->PriceBig * $Pax;
                     $modelCharge->Text = $model->room->Name . " (" . $Pax . " personas Temporada Alta).";
                     $modelCharge->Price = Room::model()->findByPK($roomID)->PriceBig * $Pax;
                     break;
             }
             $modelCharge->save();
         }
     }
     // Add extras to price
     if ($model->ID > 0) {
         $criteria = new CDbCriteria();
         $criteria->condition = "UserID = :userid AND BookID = :bookid";
         $criteria->params = array(':userid' => Yii::app()->user->ID, ':bookid' => $model->ID);
         $modelExtra = Extra::model()->findAll($criteria);
         foreach ($modelExtra as $extra) {
             $modelCharge = new Charge();
             $modelCharge->UserID = Yii::app()->user->ID;
//.........这里部分代码省略.........
开发者ID:FranHurtado,项目名称:hotels,代码行数:101,代码来源:BookController.php

示例10: actionIndex

 /**
  * Migrate from old project management system.
  */
 public function actionIndex()
 {
     // check rights
     if (!Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
         throw new CHttpException(403, Yii::t('Yii', 'You are not authorized to perform this action.'));
     }
     // models to migrate
     $migrate = array('User' => false, 'Company' => false, 'CompanyPayment' => false, 'Project' => false, 'Task' => false, 'Time' => true, 'Invoice' => false, 'Expense' => false);
     // start
     $message = '';
     // we won't migrate unless form is submitted
     if (Yii::app()->request->isPostRequest) {
         // default criteria
         $findAllCriteria = new CDbCriteria();
         $findAllCriteria->order = "`id` ASC";
         if ($migrate['User']) {
             // user
             $mUsers = MUser::model()->findAll($findAllCriteria);
             if (is_array($mUsers)) {
                 $i = $j = $c = 0;
                 $accessType = array('customer' => 'client', 'consultant' => 'consultant', 'manager' => 'manager', 'admin' => 'administrator');
                 $accessLevel = array('customer' => 2, 'consultant' => 3, 'manager' => 4, 'admin' => 5);
                 foreach ($mUsers as $oldModel) {
                     if (($model = User::model()->findByPk($oldModel->id)) !== null) {
                         $model->delete();
                     }
                     // old model validation
                     if (User::model()->findByAttributes(array('email' => $oldModel->email))) {
                         $oldModel->email = rand(10, 99) . $oldModel->email;
                     }
                     $closeTime = strtotime($oldModel->close_date);
                     $isActive = empty($oldModel->close_date) || $oldModel->close_date === '0000-00-00' || $closeTime === false;
                     // new model
                     $model = new User('migrate');
                     $model->username = $oldModel->email;
                     $model->password = md5($oldModel->password);
                     $model->email = $oldModel->email;
                     $model->screenName = $oldModel->name;
                     $model->accessType = isset($accessType[$oldModel->class]) ? $accessType[$oldModel->class] : 'member';
                     $model->accessLevel = isset($accessLevel[$oldModel->class]) ? $accessLevel[$oldModel->class] : 1;
                     $model->isActive = $isActive ? '1' : '0';
                     $model->createTime = strtotime($oldModel->last);
                     $model->id = $oldModel->id;
                     if ($model->save()) {
                         $i++;
                         if (($userDetails = UserDetails::model()->findByPk($model->id)) !== null) {
                             $userDetails->delete();
                         }
                         $userDetails = new UserDetails('migrate');
                         $userDetails->emailConfirmationKey = md5(uniqid(rand(), true));
                         $userDetails->initials = $oldModel->inits;
                         $userDetails->occupation = $oldModel->title;
                         $userDetails->deactivationTime = $isActive ? null : $closeTime;
                         $userDetails->administratorNote = '[from migration]';
                         $userDetails->userId = $model->id;
                         $userDetails->save();
                         // relation between user and company
                         if ($oldModel->customer_id >= 1) {
                             $user2Company = new User2Company('migrate');
                             $user2Company->userId = $model->id;
                             $user2Company->companyId = $oldModel->customer_id;
                             $user2Company->position = 'owner';
                             //$oldModel->title
                             if ($user2Company->save()) {
                                 $c++;
                             }
                         }
                     }
                     $j++;
                 }
                 $message .= $i . ' of ' . $j . ' users' . ($i === $c ? '' : ' with ' . $c . ' company (relations)') . ' have been migrated.<br/>';
             }
         }
         if ($migrate['Company']) {
             // company
             $mCustomers = MCustomer::model()->findAll($findAllCriteria);
             if (is_array($mCustomers)) {
                 $i = $j = $l = 0;
                 foreach ($mCustomers as $oldModel) {
                     if (($model = Company::model()->findByPk($oldModel->id)) !== null) {
                         $model->delete();
                     }
                     $closeTime = strtotime($oldModel->close_date);
                     $isActive = empty($oldModel->close_date) || $oldModel->close_date === '0000-00-00' || $closeTime === false;
                     $model = new Company('migrate');
                     $model->title = $oldModel->name;
                     $model->titleAbbr = $oldModel->inits;
                     $model->contactName = $oldModel->contact;
                     $model->contactEmail = $oldModel->contact_email;
                     $model->content = '[from migration]';
                     $model->contentMarkup = 'text';
                     $model->invoiceDueDay = $oldModel->terms_days;
                     $model->isActive = $isActive ? '1' : '0';
                     $model->deactivationTime = $isActive ? null : $closeTime;
                     $model->createTime = strtotime($oldModel->last);
                     $model->id = $oldModel->id;
                     if ($model->save()) {
//.........这里部分代码省略.........
开发者ID:megabr,项目名称:web3cms,代码行数:101,代码来源:MigrateController.php

示例11: actionGridData

 /**
  * Print out array of models for the jqGrid rows.
  */
 public function actionGridData()
 {
     if (!Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, Yii::t('http', 'Invalid request. Please do not repeat this request again.'));
         exit;
     }
     // specify request details
     $jqGrid = $this->processJqGridRequest();
     // specify filter parameters
     $company = isset($_GET['company']) ? $_GET['company'] : null;
     if ($company !== 'all' && !ctype_digit($company)) {
         $company = 'all';
     }
     // criteria
     $criteria = new CDbCriteria();
     $criteria->group = "`t`.`id`";
     // required by together()
     $criteria->select = "`t`.amountTotal, `t`.createTime, `t`.id";
     //$criteria->select="`t`.`amountTotal`, `t`.`createTime`, `t`.`id`"; // uncomment in yii-1.1.2
     if ($jqGrid['searchField'] !== null && $jqGrid['searchString'] !== null && $jqGrid['searchOper'] !== null) {
         $field = array('amountTotal' => "`t`.`amountTotal`", 'createTime' => "`t`.`createTime`", 'id' => "`t`.`id`", 'company' => "`Invoice_Company`.`title`");
         $operation = $this->getJqGridOperationArray();
         $keywordFormula = $this->getJqGridKeywordFormulaArray();
         if (isset($field[$jqGrid['searchField']]) && isset($operation[$jqGrid['searchOper']])) {
             $criteria->condition = '(' . $field[$jqGrid['searchField']] . ' ' . $operation[$jqGrid['searchOper']] . ' :keyword)';
             $criteria->params = array(':keyword' => str_replace('keyword', $jqGrid['searchString'], $keywordFormula[$jqGrid['searchOper']]));
             // search by special field types
             if ($jqGrid['searchField'] === 'createTime' && ($keyword = strtotime($jqGrid['searchString'])) !== false) {
                 $criteria->params = array(':keyword' => str_replace('keyword', $keyword, $keywordFormula[$jqGrid['searchOper']]));
                 if (date('H:i:s', $keyword) === '00:00:00') {
                     // visitor is looking for a precision by day, not by second
                     $criteria->condition = '(TO_DAYS(FROM_UNIXTIME(' . $field[$jqGrid['searchField']] . ',"%Y-%m-%d")) ' . $operation[$jqGrid['searchOper']] . ' TO_DAYS(FROM_UNIXTIME(:keyword,"%Y-%m-%d")))';
                 }
             }
         }
     }
     if ($company !== 'all') {
         $criteria->addCondition("`Invoice_Company`.`id`=:companyId");
         $criteria->params[':companyId'] = $company;
     }
     if (User::isClient()) {
         $criteria->addCondition("`Company_User2Company`.`userId`=:clientId AND `Company_User2Company`.`position`=:clientPosition");
         $criteria->params[':clientId'] = Yii::app()->user->id;
         $criteria->params[':clientPosition'] = Company::OWNER;
     }
     // pagination
     $with = array();
     if (strpos($criteria->condition, 'Invoice_Company') !== false) {
         $with[] = 'company';
     }
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with[] = 'company.allUser2Company';
     }
     if (count($with) >= 1) {
         $pages = new CPagination(Invoice::model()->with($with)->count($criteria));
     } else {
         $pages = new CPagination(Invoice::model()->count($criteria));
     }
     $pages->pageSize = $jqGrid['pageSize'] !== null ? $jqGrid['pageSize'] : self::GRID_PAGE_SIZE;
     $pages->applyLimit($criteria);
     // sort
     $sort = new CSort('Invoice');
     $sort->attributes = array('amountTotal' => array('asc' => "`t`.`amountTotal`", 'desc' => "`t`.`amountTotal` desc", 'label' => Invoice::model()->getAttributeLabel('Total')), 'createTime' => array('asc' => "`t`.`createTime`", 'desc' => "`t`.`createTime` desc", 'label' => Invoice::model()->getAttributeLabel('Date')), 'id' => array('asc' => "`t`.`id`", 'desc' => "`t`.`id` desc", 'label' => Invoice::model()->getAttributeLabel('id')), 'company' => array('asc' => "`Invoice_Company`.`title`", 'desc' => "`Invoice_Company`.`title` desc", 'label' => Invoice::model()->getAttributeLabel('companyId')));
     $sort->defaultOrder = "`t`.`createTime` DESC";
     $sort->applyOrder($criteria);
     // find all
     $with = array('company' => array('select' => 'title'));
     if (strpos($criteria->condition, 'Company_User2Company') !== false) {
         $with['company.allUser2Company'] = array('select' => 'id');
     }
     $together = strpos($criteria->condition, 'Company_User2Company') !== false;
     if ($together) {
         $models = Invoice::model()->with($with)->together()->findAll($criteria);
     } else {
         $models = Invoice::model()->with($with)->findAll($criteria);
     }
     // create resulting data array
     $data = array('page' => $pages->getCurrentPage() + 1, 'total' => $pages->getPageCount(), 'records' => $pages->getItemCount(), 'rows' => array());
     foreach ($models as $model) {
         $data['rows'][] = array('id' => $model->id, 'cell' => array(CHtml::encode($model->id), CHtml::encode(MDate::format($model->createTime, 'medium', null)), isset($model->company->id) ? CHtml::link(CHtml::encode($model->company->title), array('company/show', 'id' => $model->company->id)) : '', CHtml::encode($model->amountTotal), CHtml::link('<span class="ui-icon ui-icon-zoomin"></span>', array('show', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-first ui-corner-all', 'title' => Yii::t('link', 'Show'))) . CHtml::link('<span class="ui-icon ui-icon-pencil"></span>', array('update', 'id' => $model->id), array('class' => 'w3-ig w3-link-icon w3-border-1px-transparent w3-last ui-corner-all', 'title' => Yii::t('link', 'Edit')))));
     }
     $this->printJson($data);
 }
开发者ID:megabr,项目名称:web3cms,代码行数:86,代码来源:InvoiceController.php


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