public function actionType($id) { $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->condition = 'status = 1 AND doc_type_id =' . $id; $criteria->order = 'sort_order ASC ,last_update DESC'; $model = Document::model()->findAll($criteria); $type = DocumentType::model()->findByPK($id); $this->render('index', array('model' => $model, 'type' => $type)); }
public function actionView() { $tid = isset($_GET['tid']) ? $_GET['tid'] : NULL; $lay = isset($_GET['topid']) ? $_GET['topid'] : NULL; $did = isset($_GET['did']) ? $_GET['did'] : NULL; $title = isset($_GET['title']) ? $_GET['title'] : NULL; $id = isset($tid) ? $tid : $did; $islink = isset($_GET['islink']) ? TRUE : FALSE; if ($islink) { $dataProvider = Document::model()->findByPk($id); } else { $dataProvider = Document::model()->findByAttributes(array('did' => $id)); } $this->render('view', array('model' => $dataProvider, 'lay' => $lay)); }
public function loadModel() { $tid = $_GET['tid']; $this->islink = $_GET['islink']; $criteria = new CDbCriteria(array('order' => 'did DESC')); if ($this->islink) { $this->_model = DocumentContent::model()->findByAttributes(array('did' => $_GET['tid'])); if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } else { $this->_model = Document::model()->findAllByAttributes(array('tid' => $_GET['tid']), $criteria); } return $this->_model; }
public function actionIndex($alias = NULL) { if ($alias != NULL) { $cdbDocument = new CDbCriteria(); $cdbDocument->condition = 'alias = "' . $alias . '"'; $modelDocument = Document::model()->find($cdbDocument); if ($modelDocument === NULL) { throw new CHttpException(404, 'Trang bạn yêu cầu không tồn tại'); } //cac tin khac de hien thi phan tin tuc $detail_more = new CDbCriteria(); $detail_more->order = 'id DESC'; $detail_more_num = $modelDocument->id; $detail_more->condition = 'id NOT IN (' . $detail_more_num . ') '; $dataProviderMore = new CActiveDataProvider('Document', array('criteria' => $detail_more, 'pagination' => array('pageSize' => 4))); $this->render('detail', array('model' => $modelDocument, 'dataProviderMore' => $dataProviderMore)); } else { $dataProvider = new CActiveDataProvider('Document', array('criteria' => array('order' => 'datecreate DESC'), 'pagination' => array('pageSize' => 3))); $this->render('index', array('dataProvider' => $dataProvider)); } }
public function searchByCondition($txt, $cnt = NULL, $pagination = 1) { $criteria = new CDbCriteria(); if (!empty($txt)) { $criteria->addSearchCondition('t.name', $txt, true, 'OR', 'LIKE'); $criteria->addSearchCondition('t.description', $txt, true, 'OR', 'LIKE'); } $count = Document::model()->count($criteria); if (!empty($cnt)) { return $count; } if ($pagination != 1) { $result = Document::model()->findAll($criteria); return $result; } $pages = new CPagination($count); // results per page $pages->pageSize = Yii::app()->params['limit']; $pages->applyLimit($criteria); $result = Document::model()->findAll($criteria); return array('models' => $result, 'pages' => $pages); }
/** * Calculates pending order qty to count against available * inventory by searching for Requested or Awaiting Processing orders * Because we have our cart table and our documents table, we have to get both numbers */ public function CalculateReservedInventory() { //Pending orders not yet converted to Invoice $intReservedA = $this->getDbConnection()->createCommand("SELECT SUM(qty) FROM " . CartItem::model()->tableName() . " AS a\n\t\t\t\t\tLEFT JOIN " . Cart::model()->tableName() . " AS b ON a.cart_id=b.id\n\t\t\t\t\tLEFT JOIN " . Document::model()->tableName() . " AS c ON b.document_id=c.id\n\t\t\t\t\tWHERE\n\t\t\t\t\ta.product_id=" . $this->id . " AND b.cart_type=" . CartType::order . "\n\t\t\t\t\tAND (b.status='" . OrderStatus::Requested . "' OR b.status='" . OrderStatus::AwaitingProcessing . "'\n\t\t\t\t\t\tOR b.status='" . OrderStatus::Downloaded . "')\n\t\t\t\t\tAND (c.status IS NULL OR c.status='" . OrderStatus::Requested . "');")->queryScalar(); if (empty($intReservedA)) { $intReservedA = 0; } //Unattached orders (made independently in Lightspeed) $intReservedB = $this->getDbConnection()->createCommand("SELECT SUM(qty) from " . DocumentItem::model()->tableName() . " AS a\n\t\t\t\t\tLEFT JOIN " . Document::model()->tableName() . " AS b ON a.document_id=b.id\n\t\t\t\t\tWHERE\n\t\t\t\t\ta.product_id=" . $this->id . " AND b.order_type=" . CartType::order . "\n\t\t\t\t\tAND cart_id IS NULL AND left(order_str,3)='WO-' AND (b.status='" . OrderStatus::Requested . "');")->queryScalar(); if (empty($intReservedB)) { $intReservedB = 0; } return $intReservedA + $intReservedB; }
public static function getN() { return Document::model()->count(); }
public function actionView() { $tid = isset($_GET['tid']) ? $_GET['tid'] : NULL; $did = isset($_GET['did']) ? $_GET['did'] : NULL; $title = isset($_GET['title']) ? $_GET['title'] : NULL; $id = isset($tid) ? $tid : $did; $model = new Document(); $criteria = new CDbCriteria(); $criteria->condition = 'tid=:id'; $criteria->params = array(':id' => $id); $criteria->order = 'addtime DESC'; $total = $model->count($criteria); $pages = new CPagination($total); $pages->pageSize = 5; $pages->applyLimit($criteria); $list = $model->with('hm_dc_did')->findAll($criteria); $dataProvider = Document::model()->findByAttributes(array('did' => $id)); $this->render('view', array('list' => $list, 'pages' => $pages, 'model' => $dataProvider)); }
/** * Document Flush * * @param string $passkey * @return string */ public function document_flush($passkey) { if (!$this->check_passkey($passkey)) { return self::FAIL_AUTH; } if (_xls_get_conf('DEBUG_RESET', 0) == 1) { Yii::log('Skipped document flush operation due to DEBUG mode', CLogger::LEVEL_WARNING, 'application.' . __CLASS__ . "." . __FUNCTION__); return self::OK; } try { SroRepair::model()->deleteAll(); SroItem::model()->deleteAll(); Sro::model()->deleteAll(); Cart::model()->updateAll(array('document_id' => null)); //We need to make Document items for anything not Invoiced manual to roll back $objCarts = Document::model()->findAll("order_type = :type AND (status=:status1 OR status=:status2 OR status=:status3)", array(':type' => CartType::order, ':status1' => OrderStatus::Requested, ':status2' => OrderStatus::Processed, ':status3' => OrderStatus::PartiallyReceived)); foreach ($objCarts as $objCart) { foreach ($objCart->documentItems as $item) { $item->qty = 0; $item->save(); $item->product->SetAvailableInventory(); $item->delete(); } $objCart->delete(); } //Then delete everytihing else DocumentItem::model()->deleteAll(); Document::model()->deleteAll(); Yii::app()->db->createCommand("alter table " . Document::model()->tableName() . " auto_increment=1;")->execute(); Yii::app()->db->createCommand("alter table " . DocumentItem::model()->tableName() . " auto_increment=1;")->execute(); Yii::app()->db->createCommand("alter table " . Sro::model()->tableName() . " auto_increment=1;")->execute(); Yii::app()->db->createCommand("alter table " . SroItem::model()->tableName() . " auto_increment=1;")->execute(); Yii::app()->db->createCommand("alter table " . SroRepair::model()->tableName() . " auto_increment=1;")->execute(); //We shouldn't have anything in the cart table that's not an original order, so remove the following if they exist //ToDo: this shouldn't be in production because we will have removed Quote lines from _cart during install $objCarts = Cart::model()->findAllByAttributes(array('cart_type' => CartType::quote)); foreach ($objCarts as $objCart) { foreach ($objCart->cartItems as $item) { $item->delete(); } $objCart->delete(); } //ToDo: this shouldn't be in production because we will have removed SRO lines from _cart during install $objCarts = Cart::model()->findAllByAttributes(array('cart_type' => CartType::sro)); foreach ($objCarts as $objCart) { foreach ($objCart->cartItems as $item) { $item->delete(); } $objCart->delete(); } //ToDo: this shouldn't be in production because we will have removed O- from _cart during install //Delete anything here that's just a pure Order from LS from our Cart Table $objCarts = Cart::model()->findAll("cart_type = :type and id_str LIKE 'O-%'", array(':type' => CartType::order)); foreach ($objCarts as $objCart) { foreach ($objCart->cartItems as $item) { $item->delete(); } $objCart->delete(); } //Delete any Web Orders that have been reuploaded from Lightspeed already $objCarts = Cart::model()->findAll("cart_type = :type AND status<>:status1 AND status<>:status2 AND status<>:status3", array(':type' => CartType::order, ':status1' => OrderStatus::AwaitingPayment, ':status2' => OrderStatus::AwaitingProcessing, ':status3' => OrderStatus::Downloaded)); foreach ($objCarts as $objCart) { foreach ($objCart->cartItems as $item) { $item->delete(); } $objCart->delete(); } //Delete any carts older than our timeout that don't have a customer ID attached (since those can always be restored) Cart::GarbageCollect(); } catch (Exception $e) { Yii::log('SOAP ERROR : In flushing document tables ' . $e, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); return self::UNKNOWN_ERROR; } return self::OK; }
/** * Load a Session */ public function actionLoad($sessionHash, $documentID = null) { $session = Session::model()->find('hash=:signature', [':signature' => $sessionHash]); /* @var $session Session */ $documents = []; if ($session) { if ($documentID) { $document = Document::model()->findByAttributes(['sessionID' => $session->ID, 'ID' => $documentID]); if ($document) { $documents[] = $document; } } else { $documents = $session->documents; } } $this->sendResponse(200, CJSON::encode(['sessionID' => $session->ID, 'documents' => $documents]), 'application/json'); }
if ($addQuestion) { $url = $app->createUrl('question/answer', ['id' => $addQuestion->q_id]); } ?> <style> .newSearch { right: -150px; } </style> <ul class="newMenu registered"> <li class=""><a href="/site/jurist/">Наши юристы</a></li> <li class=""> <a href="/document/MyDocument/">Мои документы в работе( <?php echo count(Document::model()->findAllByAttributes(['status' => 1, 'user_id' => $jurist->id])); ?> ) </a> </li> <!--<li class=""> <a href="/requestCall/myPhones/">Мои звонки в работе( <? /*= count(RequestCall::model()->findAllByAttributes(['status' => 1, 'jurist_id' => $jurist->id])) */ ?> ) </a> </li>--> <li class=""> <a style="<?php echo $addQuestion ? 'background-color: rgba(163, 9, 15, 0.79)' : null; ?> "
/** * 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 ID of the model to be loaded */ public function loadModel($id) { $model = Document::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Returns the static model of the specified AR class. * @return User the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * Load Cart by the Id String (i.e. WO- number) * @param $strIdStr * @return array|CActiveRecord|mixed|null */ public static function LoadByIdStr($strIdStr) { return Document::model()->findByAttributes(array('order_str' => $strIdStr)); }
public function actionView($id) { $model = Document::model()->findByPk($id); $this->render('view', ['model' => $model]); }
public function actionSearch() { $keyword = trim($_GET['q']); if (isset($keyword)) { $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%' OR desc_th LIKE '%{$keyword}%' OR desc_en LIKE '%{$keyword}%'"; $condition->order = "create_date desc"; $condition->offset = 0; $condition->limit = 20; $model_news = News::model()->findAll($condition); $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%'"; $condition->order = "last_update desc"; $condition->offset = 0; $condition->limit = 20; $model_document = Document::model()->findAll($condition); $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%'"; $condition->order = "know_id desc"; $condition->offset = 0; $condition->limit = 20; $model_knowledge = Knowledge::model()->findAll($condition); $condition = new CDbCriteria(); $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%' OR desc_th LIKE '%{$keyword}%' OR desc_en LIKE '%{$keyword}%'"; $condition->order = "last_update desc"; $condition->offset = 0; $condition->limit = 20; $model_student = StudentService::model()->findAll($condition); //print_r($model); $this->render('search', array('model_news' => $model_news, 'model_document' => $model_document, 'model_knowledge' => $model_knowledge, 'model_student' => $model_student)); } }
<?php /** * @var TransModel $billing * @var UserModel $model */ $flashes = Yii::app()->user->getFlashes(); $document = Document::model()->findByPk(Yii::app()->user->getState('document_id')); $cost = 0; if ($document->type_cost == Document::TYPE_INDIVIDUAL) { $cost = 1200; } if ($document->type_cost == Document::TYPE_CLASSIC) { $cost = 300; } if ($document->consultation == 1) { $cost += 300; } if ($document->fast_document == 1) { $cost += 300; } ?> <div id="middle"> <?php if (!empty($flashes)) { if (isset($flashes['error'])) { ?> <div class="info"> <?php echo $flashes['error']; ?>
} } ?> </div> </div> <?php $user = UserModel::model()->jurist()->findByPk(Yii::app()->user->id); if (!$user) { echo CHtml::linkButton('Создать документ', ['href' => $this->createUrl('add'), 'style' => 'margin-bottom: 15px; display: block;'], 'Создать документ'); } echo '<br>'; $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'columns' => [['name' => 'category', 'value' => function ($data) { return Document::model()->arr_type[$data->category]; }], ['name' => 'type_cost', 'value' => function ($data) { return Document::model()->type_costs[$data->type_cost]; }], ['name' => 'file', 'type' => 'html', 'value' => function ($data) { if ($data->file) { return CHtml::image('/uploads/document/images/' . $data->file, '', ['style' => 'width:140px; height:140px;']); } }], 'text', ['name' => 'cost', 'value' => function ($data) { if ($data->cost) { return $data->cost . ' руб'; } return 'Нет данных'; }], ['class' => 'CButtonColumn', 'template' => '{view} ' . ($user ? '{update}' : null), 'viewButtonOptions' => ['title' => 'Просмотреть данные о документе'], 'updateButtonOptions' => ['title' => 'Взять документ в работу'], 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view",array("id"=>$data->id))', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("workDocument",array("id"=>$data->id))']])); ?> <script type="text/javascript"> $(function () { var content = $('.items'), ch = content.height() + content.offset().top;
<?php /** * @var Document $model */ $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'category', 'value' => Document::model()->arr_type[$model->category]), ['name' => 'type_cost', 'value' => Document::model()->type_costs[$model->type_cost]], 'text', ['name' => 'consultation', 'value' => $model->consultation == 1 ? 'Да' : 'Нет'], ['name' => 'fast_document', 'value' => $model->fast_document == 1 ? 'Да' : 'Нет']))); $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(['name' => '', 'type' => 'html', 'value' => '<h1 style="margin-right: 50%; font-size: 20px;">Данные о заказчике</h1>'], ['name' => 'document_user.name', 'value' => $model->document_user->name], ['name' => 'document_user.phone', 'value' => $model->document_user->phone], ['name' => 'document_user.email', 'value' => $model->document_user->email]))); ?> <script type="text/javascript"> $(function () { var content = $('#yw1'), ch = content.height() + content.offset().top; if (ch < $(window).height()) { content.height($(window).height() - content.offset().top - 94) } }) </script>
public function run() { $model = Document::model()->findAll('id != 0 LIMIT 10'); $this->render('document', array('model' => $model)); }
public function actionDoIndex() { $document = Document::model()->findAll(); Yii::import('application.vendor.*'); require_once 'Zend/Search/Lucene.php'; $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.index'), true); try { foreach ($document as $doc) { $indexDoc = new Zend_Search_Lucene_Document(); $indexDoc->addField(Zend_Search_Lucene_Field::text("title", CHtml::encode($doc->title), 'utf-8')); $indexDoc->addField(Zend_Search_Lucene_Field::text("content", CHtml::encode($doc->content), 'utf-8')); $indexDoc->addField(Zend_Search_Lucene_Field::text("author", CHtml::encode($doc->author), 'utf-8')); $indexDoc->addField(Zend_Search_Lucene_Field::unIndexed("id", CHtml::encode($doc->id), 'utf-8')); $indexDoc->addField(Zend_Search_Lucene_Field::keyword("url", CHtml::encode($doc->url), 'utf-8')); $index->addDocument($indexDoc); } $index->commit(); Yii::app()->user->setFlash('success', 'Indexing success!'); } catch (Exception $e) { Yii::app()->user->setFlash('error', 'Indexing fail, try again!'); } $this->redirect(array('document/admin')); }
/** * Open a quoted cart based on a link. This will bring in any items into your existing cart */ public function actionQuote() { $strLink = Yii::app()->getRequest()->getQuery('code'); if (empty($strLink)) { Yii::app()->controller->redirect(Yii::app()->createUrl('site/index')); } if (Yii::app()->shoppingcart->totalItemCount > 0) { Yii::app()->user->setFlash('error', Yii::t('cart', 'You have items in your cart already. A quote cannot be merged with an existing shopping cart. Please complete your checkout or clear your cart and try again.')); Yii::app()->controller->redirect(Yii::app()->createUrl('site/index')); return; } //Use our class variable which is accessible from the view $objDocument = Document::model()->findByAttributes(array('linkid' => $strLink)); //We can only perform this on a cart that has not completed if ($objDocument instanceof Document && $objDocument->order_type == CartType::quote) { //Use the same mechanism as we use when logging in and finding an old cart, since we merge items anyway $retVal = Yii::app()->shoppingcart->loginQuote($objDocument); if (strlen($retVal) > 5) { Yii::app()->user->setFlash('error', Yii::t('cart', 'An error occured while loading quote {quoteno}: {errstring}', array('{quoteno}' => $objDocument->order_str, '{errstring}' => $retVal))); } else { Yii::app()->user->setFlash('success', Yii::t('cart', 'The quoted items from Quote {quoteno} have been added to your cart.', array('{quoteno}' => $objDocument->order_str))); } // Since the email link generated by OnSite references the CartController // and this action, we must redirect to the proper cart view if the Web // Store is using a theme on Advanced Checkout. if (Yii::app()->theme->info->advancedCheckout === true) { Yii::app()->controller->redirect(Yii::app()->createUrl('/editcart')); } // And go to cart view Yii::app()->controller->redirect(Yii::app()->createUrl('cart')); } else { Yii::app()->user->setFlash('error', Yii::t('cart', 'Quote not found.')); //Go to home page Yii::app()->controller->redirect(Yii::app()->createUrl('site/index')); } }
public function actionSearchByCondition() { try { $txt = StringHelper::filterString(Yii::app()->request->getQuery('txt')); $result = Document::model()->searchByCondition($txt); } catch (Exception $ex) { var_dump($ex->getMessage()); } $this->render('result', $result); }