/** * Настройки поиска * @return \CActiveDataProvider */ public function search() { $criteria = new CDbCriteria(); $criteria->compare('bhid', $this->bhid); $criteria->addSearchCondition('player_ip', $this->player_ip); $criteria->addSearchCondition('player_id', $this->player_id); $criteria->addSearchCondition('player_nick', $this->player_nick); $criteria->compare('admin_ip', $this->admin_ip, true); $criteria->compare('admin_id', $this->admin_id, true); if ($this->admin_nick) { $criteria->compare('admin_nick', $this->admin_nick, true); } $criteria->compare('ban_type', $this->ban_type, true); $criteria->addSearchCondition('ban_reason', $this->ban_reason, true); if ($this->ban_created) { $start = strtotime("{$this->ban_created} 00:00:00"); $end = strtotime("{$this->ban_created} 23:59:59"); $criteria->addBetweenCondition('ban_created', $start, $end); } $criteria->compare('ban_length', $this->ban_length); $criteria->compare('server_ip', $this->server_ip, true); $criteria->compare('server_name', $this->server_name, true); if ($this->unban_created) { $start = strtotime("{$this->unban_created} 00:00:00"); $end = strtotime("{$this->unban_created} 23:59:59"); $criteria->addBetweenCondition('unban_created', $start, $end); } $criteria->compare('unban_reason', $this->unban_reason, true); $criteria->compare('unban_admin_nick', $this->unban_admin_nick, true); $criteria->compare('map_name', $this->map_name, true); $criteria->order = '`bhid` DESC'; return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->config->bans_per_page))); }
/** * Retrieves a list of models based on the current search/filter conditions. * * Typical usecase: * - Initialize the model fields with values from filter form. * - Execute this method to get CActiveDataProvider instance which will filter * models according to data in model fields. * - Pass data provider to CGridView, CListView or any similar widget. * * @return CActiveDataProvider the data provider that can return the models * based on the search/filter conditions. */ public function search($patientId = null) { // @todo Please modify the following code to remove attributes that should not be searched. $criteria = new CDbCriteria(); if (isset($patientId)) { $criteria->addSearchCondition('patient_id', $patientId, true, 'AND'); } // 搜尋就醫時間 if (!empty($this->searchByDateFrom) && !empty($this->searchByDateTo)) { $criteria->addBetweenCondition('date', $this->searchByDateFrom, $this->searchByDateTo); } // 搜尋回診時間 if (!empty($this->searchByNextBackDateFrom) && !empty($this->searchByNextBackDateTo)) { $criteria->addBetweenCondition('next_back_to_clinic_date', $this->searchByNextBackDateFrom, $this->searchByNextBackDateTo); } if (is_null($patientId)) { $criteria->with = array('patient'); } $criteria->compare('patient.name', $this->searchByPatient, true); $criteria->compare('t.id', $this->id, true); $criteria->compare('date', $this->date, true); $criteria->compare('purpose', $this->purpose, true); $criteria->compare('plan', $this->plan, true); $criteria->compare('result', $this->result, true); $criteria->compare('next_back_to_clinic_date', $this->next_back_to_clinic_date, true); $criteria->compare('next_back_to_clinic_notes', $this->next_back_to_clinic_notes, true); $criteria->order = 'next_back_to_clinic_date DESC, date DESC'; return new CActiveDataProvider($this, array('criteria' => $criteria)); }
/** * Retrieves a list of models based on the current search/filter conditions. * * Typical usecase: * - Initialize the model fields with values from filter form. * - Execute this method to get CActiveDataProvider instance which will filter * models according to data in model fields. * - Pass data provider to CGridView, CListView or any similar widget. * * @return CActiveDataProvider the data provider that can return the models * based on the search/filter conditions. */ public function search() { // @todo Please modify the following code to remove attributes that should not be searched. $criteria = new CDbCriteria(); $aJoin = array(); $criteria->compare('id', $this->id); $criteria->compare('quantidade', $this->quantidade); $criteria->compare('observacao', $this->observacao, true); $criteria->compare('data_hora', $this->data_hora, true); $criteria->compare('ordem_servico_id', $this->ordem_servico_id); $criteria->compare('excluido', $this->excluido); if (!empty($this->data_hora_inicial) && !empty($this->data_hora_final)) { $this->data_hora_inicial_grid = $this->data_hora_inicial; $this->data_hora_final_grid = $this->data_hora_final; $criteria->addBetweenCondition('date(data_hora)', $this->data_hora_inicial, $this->data_hora_final); } else { if (!empty($this->data_hora_inicial_grid) && !empty($this->data_hora_final_grid)) { $this->data_hora_inicial = $this->data_hora_inicial_grid; $this->data_hora_final = $this->data_hora_final_grid; $criteria->addBetweenCondition('date(data_hora)', $this->data_hora_inicial, $this->data_hora_final); } } if (!empty($this->produto_id)) { $criteria->addCondition("produto.titulo like '%" . $this->produto_id . "%'"); } if (!empty($this->usuario_id)) { $criteria->addCondition("usuario.nome like '%" . $this->usuario_id . "%'"); } if (!empty($aJoin)) { $criteria->join = implode(' ', $aJoin); } $criteria->with = array('produto', 'usuario'); return new CActiveDataProvider($this, array('criteria' => $criteria)); }
public function actionSearch() { $model = new SearchMonth('search'); $paper = new PaperApproval('search'); $criteria = new CDbCriteria(); $criteria->with = array('member', 'place'); $criteria->scopes = array('desc', 'notAccept'); if (isset($_POST['SearchMonth'])) { $model->attributes = $_POST['SearchMonth']; if ($model->validate()) { if ($model->validate()) { if ($model->month != null) { $dateStart = 1; $dateEnd = cal_days_in_month(CAL_GREGORIAN, $model->month, $model->year); // จำนวนวันของเดือน นั้นของปี $timeStart = '00:00:00'; $timeEnd = '23:59:59'; $start = "{$model->year}-{$model->month}-{$dateStart} {$timeStart}"; $end = "{$model->year}-{$model->month}-{$dateEnd} {$timeEnd}"; Yii::app()->user->setState('start', $start); Yii::app()->user->setState('end', $end); $criteria->addBetweenCondition('t.create_at', $start, $end); } else { $timeStart = '00:00:00'; $timeEnd = '23:59:59'; $start = "{$model->year}-1-1 {$timeStart}"; $end = "{$model->year}-12-31} {$timeEnd}"; Yii::app()->user->setState('start', $start); Yii::app()->user->setState('end', $end); $criteria->addBetweenCondition('t.create_at', $start, $end); } } } else { $this->renderPartial('/error/_error', array('models' => array($model))); Yii::app()->end(); } } else { $start = Yii::app()->user->getState('start'); $end = Yii::app()->user->getState('end'); $criteria->addBetweenCondition('t.create_at', $start, $end); } if (isset($_GET['PaperApproval'])) { $paper->attributes = $_GET['PaperApproval']; $criteria->compare('paper_no', $paper->paper_no, true); $criteria->compare('member.name', $paper->member_id, true); $criteria->compare('go', $paper->go, true); $criteria->compare('request', $paper->request, true); $criteria->compare('responsible', $paper->responsible); $criteria->compare('place.name', $paper->place_id, true); $criteria->compare('t.status', $paper->status); } $dataProvider = new CActiveDataProvider($paper, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->params['pageSize']))); $this->renderPartial('_list', array('model' => $paper, 'dataProvider' => $dataProvider), false, true); }
public function run() { $this->controller->_seoTitle = '交易记录 - ' . $this->controller->_setting['site_name']; $this->controller->loadModel(); $model = new UserTrade(); $criteria = new CDbCriteria(); //查询条件 $create_time_start = Yii::app()->request->getParam('create_time_start'); $create_time_end = Yii::app()->request->getParam('create_time_end'); $trade_type = Yii::app()->request->getParam('trade_type'); $trade_status = Yii::app()->request->getParam('trade_status'); $create_time_start && $criteria->addBetweenCondition('time_create', strtotime($create_time_start), strtotime($create_time_end)); if ($trade_type && $trade_type != 'all') { $criteria->addColumnCondition(['type' => $trade_type]); } if ($trade_status && $trade_status != 'all') { $criteria->addColumnCondition(['status' => $trade_status]); } $criteria->addColumnCondition(array('user_id' => Yii::app()->user->id)); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $pages->applyLimit($criteria); $lists = $model->findAll($criteria); //加载css js Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/jquery/jquery.js"); Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/My97DatePicker/WdatePicker.js", CClientScript::POS_END); $this->controller->render('list_trade', array('lists' => $lists, 'pages' => $pages, 'create_time_start' => $create_time_start, 'create_time_end' => $create_time_end, 'trade_type' => $trade_type, 'trade_status' => $trade_status)); }
public function actionEvents() { /** * @var $task Task * @var $cmd CDbCommand */ $result = array('success' => 1); if (isset($_GET['from']) && isset($_GET['to'])) { $start = date(Task::DF_INTER, intval($_GET['from']) / 1000); $end = date(Task::DF_INTER, intval($_GET['to']) / 1000); //echo $start."\n".$end; $criteria = new CDbCriteria(); $criteria->addBetweenCondition('start_date', $start, $end); if ($this->_user()->role == User::ROLE_USER) { $cmd = Yii::app()->db->createCommand(); $taskIds = $cmd->select('task_id')->from(Job::model()->tableName())->where('organization_id = :id AND (updated_at BETWEEN :start AND :end)', array(':id' => $this->_user()->organization_id, ':start' => $start, ':end' => $end))->queryColumn(); $criteria->addInCondition('id', $taskIds); } $tasks = Task::model()->findAll($criteria, array('order' => array('priority' => 'DESC'))); $data = array(); foreach ($tasks as $task) { $data[] = array('id' => $task->id, 'title' => $task->name, 'url' => Yii::app()->createUrl('task/view', array('id' => $task->id)), 'start' => strtotime($task->created_at) . '000', 'end' => strtotime($task->created_at) + 1800 . '000', 'class' => 'priority-' . $task->priority); } $result['result'] = $data; } $this->renderJSON($result); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionExportar() { $clave = Configuraciones::model()->findByPk(1); if ($_POST['clave'] == $clave->super_usuario) { if ($_POST['filtro'] == 1) { $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_desde']); $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_hasta']); $attribs = array('estado' => 'Activo'); $criteria = new CDbCriteria(array('order' => 'id DESC')); $criteria->addBetweenCondition('fecha', $laFechaDesde, $laFechaHasta); $rows = Ventas::model()->findAllByAttributes($attribs, $criteria); } else { $rows = Ventas::model()->findAll("estado = 'Activo'"); } // Export it $this->toExcel($rows, array('id::ID', 'paciente.nombreCompleto::Paciente', 'paciente.n_identificacion', 'descripcion', 'forma_pago', 'total1', 'forma_pago2', 'total2', 'tarjeta_tipo', 'tarjeta_aprobacion', 'tarjetaCuentaBanco.numero::Tarjeta Cuenta', 'tarjeta_tipo2', 'tarjeta_aprobacion2', 'tarjetaCuentaBanco2.numero::Tarjeta Cuenta 2', 'sub_total', 'total_iva', 'descuento', 'descuento_valor::Valor con Descuento', 'descuento_total::Total de Descuento', 'total_venta::Total de Venta', 'personal0.nombreCompleto::Realizado por', 'fecha::Fecha')); } else { Yii::app()->user->setFlash('error', "Clave incorrecta para realizar la exportación."); $model = new Ventas('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Ventas'])) { $model->attributes = $_GET['Ventas']; } $this->layout = 'main'; $lasVentas = Ventas::model()->count(); if ($lasVentas == 0) { $this->render('vacio', array('model' => $model)); } else { $this->render('admin', array('model' => $model)); } } }
public function searchTotal() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); //$criteria->compare('date',$this->date,true); $criteria->compare('total_sub', $this->total_sub); $criteria->compare('total_unsub', $this->total_unsub); $criteria->compare('access_event', $this->access_event); $criteria->compare('access_play', $this->access_play); $criteria->compare('total_play_all', $this->total_play_all); $criteria->compare('total_msisdn_valid', $this->total_msisdn_valid); $criteria->compare('listen_music', $this->listen_music); $criteria->compare('download_music', $this->download_music); $criteria->compare('play_video', $this->play_video); $criteria->compare('download_video', $this->download_video); $criteria->compare('have_transaction', $this->have_transaction); if (is_array($this->date)) { $criteria->addBetweenCondition('date', $this->date[0], $this->date[1]); } else { $criteria->compare('date', $this->date, true); } $data = GameEventReportAllModel::model()->findAll($criteria); return $data; }
/** * 操作日志列表 */ public function ActionOperationLogList() { $criteria = new CDbCriteria(); // 判断查询类型 (分页查询 / 条件查询) $searchType = Yii::app()->request->getParam('searchType'); if ($searchType === 'page') { $search_condition = unserialize(base64_decode(Yii::app()->request->getParam('search_condition'))); // 对分布传来的数据进行还原 } else { // 如有搜索条件 则获取条件并过滤条件数组中的空格与空值 if (!empty($_POST['search'])) { foreach ($_POST['search'] as $key => $val) { $search_condition[$key] = trim($val); } $search_condition = array_filter($search_condition); } else { $search_condition = ''; } } // 增加搜索条件 [S] // 搜索条件中包含时间 则添加时间查询条件 if (!empty($search_condition['start_time']) || !empty($search_condition['end_time'])) { // 如起始时间与结束时间一致 则查询同一个时间点的数据 if (!empty($search_condition['start_time']) && !empty($search_condition['end_time']) && $search_condition['start_time'] == $search_condition['end_time']) { $criteria->addSearchCondition('CreationDate', $search_condition['start_time']); } else { // 1.只按起始时间查询 2.只按结束时间查询 3.按起始+结束时间段查询 if (!empty($search_condition['start_time']) && empty($search_condition['end_time'])) { $criteria->addCondition('CreationDate >= :start_time'); $criteria->params[':start_time'] = $search_condition['start_time'] . ' 23:59:59'; } else { if (empty($search_condition['start_time']) && !empty($search_condition['end_time'])) { $criteria->addCondition('CreationDate <= :end_time'); $criteria->params[':end_time'] = $search_condition['end_time'] . ' 23:59:59'; } else { $criteria->addBetweenCondition('CreationDate', $search_condition['start_time'], $search_condition['end_time']); } } } } // 搜索条件中包含真实姓名 则添加关联查询及条件 if (!empty($search_condition['real_name'])) { $criteria->with = array('account' => array('joinType' => 'INNER JOIN', 'condition' => 'account.RealName="' . $search_condition['real_name'] . '"')); } //增加搜索条件 [E] // 分页配置 $criteria->order = 't.ID DESC'; $count = OperationLog::model()->count($criteria); $pager = new CPagination($count); if (!empty($search_condition)) { //判断是否存在搜索条件,并对搜索条件进行数据处理(便于url传输) $pager->params = array('search_condition' => base64_encode(serialize($search_condition)), 'searchType' => 'page'); } $pager->pageSize = 20; $pager->applyLimit($criteria); // 获取日志列表 $operation_log_list = OperationLog::model()->findAll($criteria); // 跳转至用户操作日志页面 $this->render('list_operation_log', array('operation_log_list' => $operation_log_list, 'pages' => $pager, 'search_condition' => $search_condition)); }
public function actionExportar() { $clave = Configuraciones::model()->findByPk(1); if ($_POST['clave'] == $clave->super_usuario) { if ($_POST['filtro'] == 1) { $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_desde']); $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_hasta']); $attribs = array(); $criteria = new CDbCriteria(array('order' => 'id DESC')); $criteria->addBetweenCondition('fecha_sola', $laFechaDesde, $laFechaHasta); $rows = MedicamentosBiologicos::model()->findAllByAttributes($attribs, $criteria); } else { $rows = MedicamentosBiologicos::model()->findAll(); } // Export it $this->toExcel($rows, array('id::ID', 'medicamento')); } else { Yii::app()->user->setFlash('error', "Clave incorrecta para realizar la exportación."); $model = new MedicamentosBiologicos('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['MedicamentosBiologicos'])) { $model->attributes = $_GET['MedicamentosBiologicos']; } $this->render('admin', array('model' => $model)); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionExportar() { $clave = Configuraciones::model()->findByPk(1); if ($_POST['clave'] == $clave->super_usuario) { if ($_POST['filtro'] == 1) { $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_desde']); $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_hasta']); $attribs = array('estado' => 'Activo'); $criteria = new CDbCriteria(array('order' => 'id DESC')); $criteria->addBetweenCondition('fecha_sola', $laFechaDesde, $laFechaHasta); $rows = Egresos::model()->findAllByAttributes($attribs, $criteria); } else { $rows = Egresos::model()->findAll("estado = 'Activo'"); } // Export it $this->toExcel($rows, array('id::ID', 'proveedor.nombre', 'factura.factura_n', 'forma_pago', 'valor_egreso', 'iva_valor', 'total_egreso', 'centroCosto.nombre', 'personal.nombreCompleto', 'fecha_sola::Fecha')); } else { Yii::app()->user->setFlash('error', "Clave incorrecta para realizar la exportación."); $model = new Egresos('search'); $model->unsetAttributes(); // clear any default values $this->layout = 'main'; if (isset($_GET['Egresos'])) { $model->attributes = $_GET['Egresos']; } $losEgresos = Egresos::model()->count(); if ($losEgresos == 0) { $this->render('vacio', array('model' => $model)); } else { $this->render('admin', array('model' => $model)); } } }
public function actionIndex() { // total semua pemasukan $criteria = new CDbCriteria(); $criteria->addBetweenCondition('TANGGAL_ORDER', date('Y-m-01', strtotime('this month')), date('Y-m-t', strtotime('this month'))); $kredit = Order::model()->findAll($criteria); $total = 0; foreach ($kredit as $k) { $total += $k->TOTAL; } // menghitung total order $order_c = Order::model()->count(); // menghitung total pasien $pelanggan_c = Pasien::model()->count(); // get data order hari ini $criteria2 = new CDbCriteria(); $criteria2->condition = 'date(TANGGAL_ORDER) = date(NOW())'; $hariini = Order::model()->count($criteria2); // get barang yang tanggal expired $expired = Item::getExpired(); // data obat habis $criteria = new CDbCriteria(); $criteria->order = 'TANGGAL_ORDER DESC'; $criteria->limit = '5'; $dataProvider = new CActiveDataProvider('Pasien', array('pagination' => false, 'criteria' => $criteria)); $this->render('index', array('total' => $total, 'order' => $order_c, 'pelanggan' => $pelanggan_c, 'hariini' => $hariini, 'expired' => $expired)); }
public function actionExportar() { $clave = Configuraciones::model()->findByPk(1); if ($_POST['clave'] == $clave->super_usuario) { if ($_POST['filtro'] == 1) { $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_desde']); $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_hasta']); $attribs = array(); $criteria = new CDbCriteria(array('order' => 'id DESC')); $criteria->addBetweenCondition('fecha', $laFechaDesde, $laFechaHasta); $rows = Presupuesto::model()->findAllByAttributes($attribs, $criteria); } else { $rows = Presupuesto::model()->findAll(); } // Export it $this->toExcel($rows, array('id::ID', 'paciente.nombreCompleto', 'paciente.n_identificacion::Cedula', 'estado', 'fecha', 'total', 'vendedor.nombreCompleto::Vendido Por')); } else { Yii::app()->user->setFlash('error', "Clave incorrecta para realizar la exportación."); $model = new Presupuesto('search'); $model->unsetAttributes(); // clear any default values $this->layout = 'main'; if (isset($_GET['Presupuesto'])) { $model->attributes = $_GET['Presupuesto']; } $this->render('admin', array('model' => $model)); } }
public static function getCityInRadius($geonameid, $radKm) { $gradus = $radKm / 111.144; $City = City::model()->findByPk($geonameid); $criteria = new CDbCriteria(); $criteria->addBetweenCondition('latitude', $City->latitude - $gradus, $City->latitude + $gradus); $criteria->addBetweenCondition('longitude', $City->longitude - $gradus, $City->longitude + $gradus); $criteria->select = 'geonameid,latitude,longitude'; $result = City::model()->findAll($criteria); $return = [$geonameid]; foreach ($result as $row) { $dist = self::getDistance($City->latitude, $City->longitude, $row['latitude'], $row['longitude']); if ($dist < $radKm * 1000) { $return[] = $row['geonameid']; } } return $return; }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $user = Yii::app()->user; if (Yii::app()->request->isPostRequest) { $type = $_POST['type']; if ($type == 'login') { $identity = new UserIdentity($_POST['LoginForm']['email'], $_POST['LoginForm']['password']); if ($identity->authenticate()) { $user->login($identity); $this->redirect('/'); } else { } } return; } // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' if ($user->isGuest) { $this->render('login', array('userinput' => Yii::app()->request->isPostRequest ? $_POST['LoginForm'] : array())); } else { $criteria = new CDbCriteria(); if ($user->isChannel()) { if ($user->getChannelId()) { $criteria->compare('channel_id', Yii::app()->user->getChannelId()); } else { echo '此账户尚未开通,请联系管理员'; return; } } else { //管理员 $channel_id = $user->getChannelId(); if ($user->getChannelId()) { $criteria->compare('channel_id', Yii::app()->user->getChannelId()); } } //添加搜索条件 if ($_GET) { $tag = $_GET['tag']; $adv_name = $_GET['adv_name']; $adv_id = ""; if ($adv_name) { $advertise = Advertise::model(); $adv_id = $advertise->getAdvId($adv_name); } $startTime = $_GET['startTime']; $endTime = $_GET['endTime']; $criteria->compare('tag', $tag); $criteria->compare('adv_id', $adv_id); if ($startTime) { $criteria->addBetweenCondition('date', $startTime, $endTime); } } $criteria->order = "date desc"; $dataProvider = new CActiveDataProvider('AdvData', array('criteria' => $criteria, 'pagination' => array('pageSize' => 20, 'pageVar' => 'page'))); $this->render('index', array('attributes' => array('date', 'adv.name', 'tag', 'download_number', 'price', 'total_price', 'star_level'), 'current_channel_id' => $user->getChannelId(), 'channels' => Yii::app()->user->isAdmin() ? Channel::model()->findAll() : array(), 'dataProvider' => $dataProvider)); } }
/** * Retrieves a list of models based on the current search/filter conditions. * * Typical usecase: * - Initialize the model fields with values from filter form. * - Execute this method to get CActiveDataProvider instance which will filter * models according to data in model fields. * - Pass data provider to CGridView, CListView or any similar widget. * * @return CActiveDataProvider the data provider that can return the models * based on the search/filter conditions. */ public function search() { $criteria = new CDbCriteria(); $criteria->compare('card_id', $this->card_id); $criteria->compare('status', $this->status); if (!empty($this->action_date)) { $criteria->addBetweenCondition('action_date', date('Y-m-d H:i:s', strtotime($this->action_date)), date('Y-m-d H:i:s', strtotime('+1 day', strtotime($this->action_date))), 'AND'); } return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'action_date ASC'), 'pagination' => array('pageSize' => 20))); }
/** * Return events as JSON-string for AJAX call * @param <int> $start unix time * @param <int> $end unix time */ public function actionList($start = 0, $end = 0) { if (Yii::app()->request->isAjaxRequest and Yii::app()->user->hasState('calUserId')) { $criteria = new CDbCriteria(array('condition' => 'user_id=:user_id', 'params' => array(':user_id' => Yii::app()->user->getState('calUserId')))); $criteria->addBetweenCondition('start', $start, $end); $events = Event::model()->findAll($criteria); echo CJSON::encode($events); Yii::app()->end(); } }
public function search() { $criteria = new CDbCriteria(); if ($this->timestamp) { $criteria->addBetweenCondition('timestamp', strtotime("{$this->timestamp} 00:00:00"), strtotime("{$this->timestamp} 23:59:59")); } $criteria->compare('username', $this->username, true); $criteria->compare('action', $this->action, true); $criteria->order = 'id DESC'; return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->config->bans_per_page))); }
public function frontendSearch($year) { $criteria = new CDbCriteria(); if ($year) { $criteria->addBetweenCondition('created_at', mktime(0, 0, 0, 1, 1, $year), mktime(0, 0, 0, 12, 31, $year)); } $limit = Yii::app()->request->getParam('items_limit', Yii::app()->params['frontend']['itemsPerPage']); $pagination = array('pageSize' => $limit, 'pageVar' => 'page'); // This column headers for those fields will be active $sort = array('sortVar' => 'sort', 'defaultOrder' => 'created_at DESC'); return new CActiveDataProvider(__CLASS__, array('criteria' => $criteria, 'pagination' => $pagination, 'sort' => $sort)); }
public function reportPembelian() { $dari = date_format(date_create_from_format('d-m-Y', $this->dari), 'Y-m-d'); $sampai = date_format(date_create_from_format('d-m-Y', $this->sampai), 'Y-m-d'); // echo $dari.' sampai '.$sampai; $criteria = new CDbCriteria(); $criteria->addBetweenCondition("date_format(tanggal,'%Y-%m-%d')", $dari, $sampai); // if (!empty($this->profilId)) { // $criteria->addCondition('profil_id=:profilId', array(':profilId' => $this->profilId)); // } $pembelian = Pembelian::model()->findAll($criteria); return $pembelian; }
public function search() { $criteria = new CDbCriteria(); $criteria->compare('numero', $this->numero, true); $criteria->compare('escompra', $this->escompra, true); //$criteria->compare('estado',$this->estado,true); //$criteria->compare('fechaent',$this->fechaent,true); $criteria->compare('tipsolpe', $this->tipsolpe, true); $criteria->compare('centro', $this->centro, true); $criteria->compare('codal', $this->codal, true); $criteria->compare('codart', $this->codart, true); $criteria->compare('imputacion', $this->imputacion, true); $criteria->compare('cant', $this->cant); $criteria->compare('desum', $this->desum, true); //$criteria->compare('txtmaterial',$this->txtmaterial,true); $criteria->compare('cantatendida', $this->cantatendida); $criteria->compare('cant_pendiente', $this->cant_pendiente); $criteria->addcondition(" txtmaterial like '%" . MiFactoria::cleanInput($this->txtmaterial) . "%' "); $criteria->addBetweenCondition('fechaent', '' . $this->fechaent . '', '' . $this->fechaent1 . ''); $criteria->addBetweenCondition('fechacrea', '' . $this->fechacrea . '', '' . $this->fechacrea1 . ''); return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => 100))); }
/** * Retrieves a list of models based on the current search/filter conditions. * * Typical usecase: * - Initialize the model fields with values from filter form. * - Execute this method to get CActiveDataProvider instance which will filter * models according to data in model fields. * - Pass data provider to CGridView, CListView or any similar widget. * * @return CActiveDataProvider the data provider that can return the models * based on the search/filter conditions. */ public function search() { $criteria = new CDbCriteria(); $criteria->compare('series', $this->series); $criteria->compare('number', $this->number, true); if (!empty($this->created_at)) { $criteria->addBetweenCondition('created_at', date('Y-m-d H:i:s', strtotime($this->created_at)), date('Y-m-d H:i:s', strtotime('+1 day', strtotime($this->created_at))), 'AND'); } if (!empty($this->expired_at)) { $criteria->addBetweenCondition('expired_at', strtotime($this->expired_at), strtotime('+1 day', strtotime($this->expired_at)), 'AND'); } if (!empty($this->status)) { if ($this->status == self::STATUS_EXPIRED) { $criteria->addCondition('expired_at <= :time'); $criteria->params = CMap::mergeArray($criteria->params, array(':time' => time())); } else { $criteria->compare('status', $this->status); $criteria->addCondition('expired_at > :time'); $criteria->params = CMap::mergeArray($criteria->params, array(':time' => time())); } } return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => 20))); }
public function actionMaintainlist() { $userID = Commonmodel::getOrganID(); $criteria = new CDbCriteria(); $criteria->with = "owners"; if ($_GET) { if ($_GET['name']) { $remind = $this->getRecord($_GET['name']); $criteria->addInCondition('t.ID', $remind); } if ($_GET['status']) { $criteria->addCondition("t.Status = {$_GET['status']}", "AND"); } if ($_GET['date']) { $starttime = strtotime($_GET['date']); $endtime = (int) (strtotime($_GET['date']) + 60 * 60 * 24); $criteria->addBetweenCondition('t.MaintainDate', $starttime, $endtime, "AND"); } } $criteria->order = "t.MaintainDate DESC,t.UpdateTime DESC"; //排序条件:t.MaintainDate,t.UpdateTime倒叙 $criteria->addCondition("t.OrganID = {$userID}", "AND"); $count = MaintainRemind::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = $_GET['rows']; $pages->applyLimit($criteria); $model = MaintainRemind::model()->findAll($criteria); foreach ($model as $key => $value) { $data[$key]['ID'] = $value['ID']; if ($value['Status'] == '1') { $data[$key]['State'] = '待发送'; } elseif ($value['Status'] == '2') { $data[$key]['State'] = '已发送'; } else { $data[$key]['State'] = '取消发送'; } $data[$key]['Status'] = $value['Status']; $data[$key]['MaintainDate'] = date('Y-m-d', $value['MaintainDate']); $data[$key]['MaintainTime'] = $value['MaintainDate']; $data[$key]['RemindContent'] = $value['RemindContent']; $data[$key]['Content'] = F::msubstr($value['RemindContent']); foreach ($value->owners as $owners_key => $owners_value) { $data[$key]['OldName'] .= $owners_value->Name . ","; $data[$key]['Name'] = F::msubstr(substr($data[$key]['OldName'], 0, -1)); } } $rs = array('total' => $count, 'rows' => $data ? $data : array()); echo json_encode($rs); }
/** * @param array $typeSearchAttributes * @return CDbCriteria */ protected function buildCriteriaForTypeAttributes(array $typeSearchAttributes) { $criteria = new CDbCriteria(); $criteria->params = []; $i = 0; foreach ($typeSearchAttributes as $attribute => $params) { if (empty($params['value'])) { continue; } $alias = "attributes_values_{$i}"; $criteria->join .= " JOIN {{store_product_attribute_value}} {$alias} ON t.id = {$alias}.product_id "; //@TODO подумать как улучшить if (is_array($params['value'])) { if (isset($params['value']['from'], $params['value']['to'])) { $between = new CDbCriteria(); $between->addBetweenCondition("{$alias}." . $params['column'], $params['value']['from'], $params['value']['to']); $between->addCondition("{$alias}.attribute_id = :attributeId_{$i}"); $between->params[":attributeId_{$i}"] = (int) $params['attribute_id']; $criteria->mergeWith($between); } elseif (isset($params['value']['from']) && !isset($params['value']['to'])) { $between = new CDbCriteria(); $between->addCondition("{$alias}.attribute_id = :attributeId_{$i}"); $between->addCondition("{$alias}.{$params['column']} >= :attr_{$i}"); $between->params[":attributeId_{$i}"] = (int) $params['attribute_id']; $between->params[":attr_{$i}"] = $params['value']['from']; $criteria->mergeWith($between); } elseif (isset($params['value']['to']) && !isset($params['value']['from'])) { $between = new CDbCriteria(); $between->addCondition("{$alias}.attribute_id = :attributeId_{$i}"); $between->addCondition("{$alias}.{$params['column']} <= :attr_{$i}"); $between->params[":attributeId_{$i}"] = (int) $params['attribute_id']; $between->params[":attr_{$i}"] = $params['value']['to']; $criteria->mergeWith($between); } else { $in = new CDbCriteria(); $in->addInCondition("{$alias}." . $params['column'], $params['value']); $criteria->mergeWith($in); } } else { $condition = new CDbCriteria(); $condition->addCondition("{$alias}.attribute_id = :attributeId_{$i}"); $condition->params[":attributeId_{$i}"] = (int) $params['attribute_id']; $condition->addColumnCondition(["{$alias}." . $params['column'] => $params['value']]); $criteria->mergeWith($condition); } $i++; } return $criteria; }
public function searchByCondition($attr, $cnt = null, $pagination = 1) { $criteria = new CDbCriteria(); if (!empty($attr['date_start']) && !empty($attr['date_end'])) { $date_start = strtotime($attr['date_start']); $date_end = strtotime($attr['date_end']); $criteria->addBetweenCondition('signed_date', $date_start, $date_end, 'OR'); $criteria->addBetweenCondition('signed_recieve', $date_start, $date_end, 'OR'); } if (!empty($attr['assignee'])) { $assignee = $attr['assignee']; $criteria->addSearchCondition('staff_assigned', $assignee); } if (!empty($attr['keyword'])) { $keyword = $attr['keyword']; $criteria->addSearchCondition('content', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('staff_assigned', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('verification_period', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('decided_assigned', $keyword, true, "OR", "LIKE"); $criteria->addSearchCondition('letter_created', $keyword, true, "OR", "LIKE"); } $count = Letters::model()->count($criteria); if (!empty($cnt)) { return $count; } if ($pagination != 1) { $result = Letters::model()->findAll($criteria); return $result; } $pages = new CPagination($count); // results per page $pages->pageSize = Yii::app()->params['limit']; $pages->applyLimit($criteria); $result = Letters::model()->findAll($criteria); return array('models' => $result, 'pages' => $pages); }
public function actionExportar() { if ($_POST['filtro'] == 1) { $laFechaDesde = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_desde']); $laFechaHasta = Yii::app()->dateformatter->format("yyyy-MM-dd", $_POST['fecha_hasta']); $attribs = array('estado' => 'Activo'); $criteria = new CDbCriteria(array('order' => 'id DESC')); $criteria->addBetweenCondition('fecha', $laFechaDesde, $laFechaHasta); $rows = NotaCredito::model()->findAllByAttributes($attribs, $criteria); } else { $rows = NotaCredito::model()->findAll("id > 0"); } // Export it $this->toExcel($rows, array('id::ID', 'paciente.nombreCompleto', 'n_identificacion', 'valor', 'observaciones', 'personal.nombreCompleto', 'contrato_asociado_id', 'fecha')); }
public function actionGetReport() { if (Yii::app()->request->isAjaxRequest && isset($_GET['field'])) { $criteria = new CDbCriteria(); if (!empty($_GET['customer_id']) && is_numeric($_GET['customer_id'])) { $criteria->compare('customer_id', $_GET['customer_id']); } if (!empty($_GET['start']) && $_GET['start'] != '' && (!empty($_GET['end']) && $_GET['end'] != '')) { $criteria->addBetweenCondition('created', $_GET['start'], $_GET['end']); } $columns = $_GET['field']; $shipment_report = new CActiveDataProvider(ViewReport::model(), array('criteria' => $criteria)); $this->renderPartial('_report', array('shipment_report' => $shipment_report, 'columns' => $columns), FALSE, TRUE); } }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $criteria->compare('id_url', $this->id_url); $criteria->compare('md5_url', $this->md5_url); $criteria->compare('url_url', $this->url_url, true); $criteria->compare('enabled_url', $this->enabled_url); $criteria->compare('added_when_url', $this->added_when_url, true); if (isset($_SESSION['interval_start'])) { $criteria->addBetweenCondition('added_when_url', $_SESSION['interval_start'], $_SESSION['interval_end']); } return new CActiveDataProvider(get_class($this), array('criteria' => $criteria)); }
private function retrieveDataRecords() { $records = null; /*using export type specified above*/ if ($this->exportType === 'all') { $criteria = new CDbCriteria(); $criteria->compare("account_id", $this->model->account_id); $criteria->order = "date_created DESC"; $criteria->distinct = true; $records = Records::model()->findAll($criteria); } else { if ($this->exportType === 'this week') { $criteria = new CDbCriteria(); $criteria->compare("account_id", $this->model->account_id); $startingDate = date("Y-m-d 12:00:00", strtotime('friday last week')); $endDate = date("Y-m-d 23:59:00", strtotime('friday this week')); $criteria->addBetweenCondition("t.date_created", $startingDate, $endDate); $criteria->order = "date_created DESC"; $criteria->distinct = true; $records = Records::model()->findAll($criteria); } else { if ($this->exportType === 'today') { $criteria = new CDbCriteria(); $criteria->compare("account_id", $_REQUEST['accountID']); $criteria->addCondition("date(date_created) = date(now())"); $criteria->order = "date_created DESC"; //$criteria->group = "ip_address"; $criteria->distinct = true; $records = Records::model()->findAll($criteria); } else { if ($this->exportType === 'range') { /*get claims between */ $criteria = new CDbCriteria(); $dateFrom = DateTime::createFromFormat("m/d/Y", $this->configurations['dateFrom']); $dateTo = DateTime::createFromFormat("m/d/Y", $this->configurations['dateTo']); $dateFromStr = $dateFrom->format('Y-m-d'); $dateToStr = $dateTo->format('Y-m-d'); $criteria->compare("account_id", $this->model->account_id); $criteria->addBetweenCondition('date_created', $dateFromStr, $dateToStr); $criteria->order = "date_created DESC"; $criteria->distinct = true; $records = Records::model()->findAll($criteria); } } } } return $records; }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $criteria->compare('id_scl', $this->id_scl); $criteria->compare('md5_scl', $this->md5_scl); $criteria->compare('added_when_scl', $this->added_when_scl); $criteria->compare('type_scl', $this->type_scl); $criteria->compare('enabled_scl', $this->enabled_scl); $criteria->compare('pending_action_scl', $this->pending_action_scl); if (isset($_SESSION['interval_start'])) { $criteria->addBetweenCondition('added_when_scl', $_SESSION['interval_start'], $_SESSION['interval_end']); } return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => VIREX_PAGE_SIZE), 'sort' => array('defaultOrder' => 'id_scl DESC'))); }