public function actionView($id) { $company = Company::model()->findByPk($id); if (!$company) { throw new CHttpException(404, 'Company not found'); } $usersDataProvider = new CActiveDataProvider(User::class); $usersDataProvider->setData($company->users); $usersDataProvider->sort = false; $this->render('view', ['company' => $company, 'usersDataProvider' => $usersDataProvider]); }
/** * Manages all models. */ public function actionIndex($cat = null) { if (!$cat) { $cat = SnapUtil::config('boxomatic/supplier_product_feature_category'); } $BoxoCart = new BoxoCart(); if (isset($_GET['set-date'])) { $BoxoCart->setDelivery_date_id($_GET['set-date']); } if (isset($_POST['BoxoCart']['location_id'])) { $BoxoCart->location_id = $_POST['BoxoCart']['location_id']; $this->refresh(); } if (isset($_POST['Order']) && isset($_POST['add_to_cart'])) { if ($BoxoCart->addItems($_POST['Order'])) { Yii::app()->user->setFlash('success', 'Item added to cart.'); #redirect to category if ($cat == 'box') { $this->redirect(array('shop/index', 'date' => Yii::app()->request->getParam('date'), 'cat' => SnapUtil::config('boxomatic/redirectBoxCategory'))); } } $this->refresh(); } if (isset($_POST['Order']) && (isset($_POST['update_cart']) || isset($_POST['checkout']))) { if ($BoxoCart->updateItems($_POST['Order'])) { Yii::app()->user->setFlash('success', 'Cart updated.'); } if (isset($_POST['checkout'])) { $this->redirect(array('shop/checkout')); } $this->refresh(); } $userId = Yii::app()->user->id; $User = BoxomaticUser::model()->findByPk($userId); $Category = Category::model()->findByPk($cat); $DeliveryDate = false; $dpProducts = false; $Location = $BoxoCart->Location; if ($Location) { if (!$BoxoCart->DeliveryDate) { $DeliveryDate = $BoxoCart->getNextDeliveryDate(); } else { $DeliveryDate = $BoxoCart->DeliveryDate; } $BoxoCart->setDelivery_date_id($DeliveryDate->id); $products = SupplierProduct::getAvailableItems($DeliveryDate->id, $cat); $dpProducts = new CActiveDataProvider('SupplierProduct'); $dpProducts->setData($products); } $this->render('index', array('dpProducts' => $dpProducts, 'DeliveryDate' => $DeliveryDate, 'Category' => $Category, 'Customer' => $User, 'curCat' => $cat, 'BoxoCart' => $BoxoCart, 'Location' => $Location)); }
public function actionIndex() { $user = User::model()->findByPk(Yii::app()->user->getId()); $topList = $user->topContacts; $pieces = explode(',', $topList); $contacts = array(); foreach ($pieces as $piece) { $contact = Contacts::model()->findByPk($piece); if (isset($contact)) { $contacts[] = $contact; } } $dataProvider = new CActiveDataProvider('Contacts'); $dataProvider->setData($contacts); $this->render('index', array('dataProvider' => $dataProvider)); }
public function actionIndex() { $OrganID = Yii::app()->user->getOrganID(); $criteria = new CDbCriteria(); $arr['LicensePlate'] = Yii::app()->request->getParam("LicensePlate"); $arr['ReserveTime'] = Yii::app()->request->getParam("ReserveTime"); $ReserveTime = strtotime($arr['ReserveTime']); $arr['ReserveNum'] = Yii::app()->request->getParam("ReserveNum"); // $arr['Make'] = Yii::app()->request->getParam("Make"); $arr['Car'] = Yii::app()->request->getParam("Car"); $arr['Code'] = Yii::app()->request->getParam("Code"); // $arr['Engine'] = Yii::app()->request->getParam("Engine"); if (!empty($arr['LicensePlate'])) { // 车牌号 $criteria->addSearchCondition('licenseplate', "{$arr['LicensePlate']}", "AND"); } // if (!empty($arr['Make'])) {// 厂家 // $criteria->addSearchCondition('Make', "{$arr['Make']}", "AND"); // } if (!empty($arr['Code'])) { // 车型编码 $criteria->addCondition("Code = '{$arr['Code']}'", "AND"); } // if (!empty($arr['Engine'])) {// 发动机 // $criteria->addSearchCondition('Engine', "{$arr['Engine']}", "AND"); // } if (!empty($arr['ReserveTime'])) { // 预约时间 $criteria->addSearchCondition('ReserveTime', "{$ReserveTime}", "AND"); } if (!empty($arr['ReserveNum'])) { // 预约号 $criteria->addSearchCondition('ReserveNum', "{$arr['ReserveNum']}", "AND"); } $criteria->order = "t.ID DESC"; //排序条件:t.CreateTime,t.ID倒叙 $criteria->addCondition("t.OrganID = {$OrganID}"); $dataProvider = new CActiveDataProvider('ServiceReserve', array('criteria' => $criteria, 'pagination' => array('pageSize' => '10'))); $data = $dataProvider->getData(); //var_dump($data);die; foreach ($data as $key => $val) { $val['ReserveTime'] = date("Y-m-d", $val['ReserveTime']) . " " . $val['BeginTime'] . ":00-" . $val['EndTime'] . ":00"; } $dataProvider->setData($data); $this->render('index', array('dataProvider' => $dataProvider, 'arr' => $arr)); }
public function actionIndex() { $this->pageTitle = Yii::app()->name . '-订单总览'; $organID = Yii::app()->user->getOrganID(); $criteria = new CDbCriteria(); $criteria->condition = 't.IsDelete=0 and BuyerID=' . $organID; $criteria->with = 'goodsinfo'; $criteria->order = 't.CreateTime DESC'; //搜索条件 $this->search($criteria); //订单数量 $count = OrderService::getordercount($organID); $dataProvider = new CActiveDataProvider('PapOrder', array('criteria' => $criteria, 'pagination' => array('pageSize' => 5))); $datas = $dataProvider->getData(); foreach ($datas as $vv) { foreach ($vv->goodsinfo as $v) { $v = self::getVersionGoods($v); } } $dataProvider->setData($datas); $this->render('index', array('dataProvider' => $dataProvider, 'count' => $count)); }
public static function servicegetmanagelist() { $OrganID = Yii::app()->user->getOrganID(); $criteria = new CDbCriteria(); $criteria->with = array('vehicle' => array('with' => array('owner'))); $criteria->order = "t.UpdateTime DESC,t.ID DESC"; //排序条件:t.CreateTime,t.ID倒叙 $criteria->addCondition("t.OrganID = {$OrganID}", "AND"); $criteria->addCondition("t.Status = 0", "AND"); $dataProvider = new CActiveDataProvider('ServiceRecord', array('criteria' => $criteria, 'pagination' => array('pageSize' => '4'))); // return $dataProvider; $data = $dataProvider->getData(); foreach ($data as $k => $val) { if ($val['ServiceType'] == 2) { $val['ServiceType'] = "配件服务"; } elseif ($val['ServiceType'] == 3) { $val['ServiceType'] = "全部服务"; } else { $val['ServiceType'] = "保养服务"; } } $dataProvider->setData($data); return $dataProvider; }
/** * Attached action to export a data provider into excel or other formats * Usage: * In your controller, create a method * public function behaviours() * { * return array( * 'eexcelview'=>array( * 'class'=>'ext.eexcelview.EExcelBehavior', * ), * ); * } * Then, to use * public function actionToCSV() * { * $model = Sala::model()->findAll(); * * $columns = array( * 'id', * 'nombre', * array( * 'name' => 'relatedModel.name', * 'header' => 'Related Model Name', * 'footer'=>'Total Balance: 10', * ), * ); * * $this->actionExcel($model, $columns, 'MyTitle', array(), 'CSV'); * } * Of course, this is only a wrapper so you can edit in many ways to allow more specialization * @param null string|CDataProvider|array $model the data provider for the grid. * @param null array $columns array with specif columns and its format. Defaults to all attributes. * @param null string $title title for the file * @param null array $documentDetails details of the document * @param null string $exportType format to export (Excel5,Excel2007, PDF, HTML, CSV). Defaults to Excel2007 (xlsx) */ public function toExcel($model = null, $columns = array(), $title = null, $documentDetails = array(), $exportType = 'Excel2007') { // Be sure to be attached to an instance of CController if (!$this->owner instanceof CController) { Yii::log('EExcelBehavior can only be attached to an instance of CControler', 'error', 'system.base.CBehavior'); return; } /** * We need a data provider in order to create a CGridView. Actually we could pass a CActiveDataProvider instance or * a CArrayDataProvider instance, we should be able to handle both cases */ // First, check if is null if (!isset($model)) { // Get the controller name as the model $model = ucfirst($this->owner->id); $dataProvider = new CActiveDataProvider($model); } elseif (is_string($model)) { // We fetch all records $dataProvider = new CActiveDataProvider($model); } elseif (is_array($model)) { // If is an array, we assume is an array of Model instance // so let's add that data to the CDataprovider if (empty($model)) { // If we got an empty array as model... we can't do much with that information Yii::log('Empty array passed as data, nothing to do *here*', 'info', 'system.base.CBehavior'); return; } else { // At this point we should do type checking on every entry of the array againts a model // But as we don't know what model is, we must try and catch an exception // Get model name $className = get_class($model[0]); // get the class from the first element try { // Set an CActiveDataProvider for this model $dataProvider = new CActiveDataProvider($className); // And add the data $dataProvider->setData($model); } catch (Excetion $e) { // Something went wrong Yii::log($e->getMessage(), 'info', 'system.base.CBehavior'); return; } } } elseif (is_subclass_of($model, 'CDataProvider')) { // We use the provided data set $dataProvider = $model; } else { // We have no valid data set Yii::log('Invalid data set provided', 'error', 'system.base.CBehavior'); return; } /** * Next, we need to check if user passed an array for columns, if not, we define an empty one meaning we want * all columns by default */ if (!is_array($columns)) { $columns = array(); } /** * Finally we export the contents specified */ $config = array('title' => $title, 'exportType' => $exportType, 'dataProvider' => $dataProvider, 'columns' => $columns); $arg = CMap::mergeArray($config, $documentDetails); $this->owner->widget('ext.eexcelview.EExcelView', $arg); Yii::app()->end(); }
public static function getOrderlist($params) { $payment = $params['Payment']; $BuyerName = $params['BuyerName']; $Status = $params['Status']; $EvaStatus = $params['EvaStatus']; $OrderSN = $params['search_text']; $starttime = $params['starttime']; $endtime = $params['endtime']; $pageSize = $params['pageSize'] ? $params['pageSize'] : 10; $criteria = new CDbCriteria(); $criteria->order = "t.CreateTime desc"; $criteria->condition = "t.SellerID = {$params['OrganID']} and t.IsDelete=0"; //订单类型 if ($payment && in_array($payment, array(1, 2))) { $criteria->addCondition("t.Payment = {$payment}", "AND"); } //买家查询 if ($BuyerName) { $BuyerName = EvaluateService::checkKey(urldecode($BuyerName)); $model = self::getOrgan(array('OrganName' => $BuyerName)); $idArr = array(); foreach ($model as $v) { $idArr[] = $v->ID; } $criteria->addInCondition("t.BuyerID", $idArr); } //订单状态 if ($Status && in_array($Status, array(1, 2, 3, 5, 9, 10))) { if ($Status == 5) { $criteria->addCondition("t.Status = 3 and t.ReturnStatus!=0", "AND"); } else { if ($Status == 3) { $criteria->addCondition("t.Status = 3 and t.ReturnStatus=0", "AND"); } else { $criteria->addCondition("t.Status = {$Status}", "AND"); } } } else { if ($params['SendStatus']) { $criteria->addCondition("t.Status in(1,2)", "AND"); } } //订单评价 if ($EvaStatus && $EvaStatus == 1) { $criteria->addCondition("t.EvaStatus in(0,15) and t.Status=9", "AND"); } else { if ($EvaStatus == 2) { $criteria->addCondition("t.EvaStatus in(16,20) and t.Status=9", "AND"); } } //订单号 if ($OrderSN) { $OrderSN = EvaluateService::checkKey(urldecode($OrderSN)); $criteria->addCondition("t.OrderSN like '%{$OrderSN}%'"); } //下单时间 if ($starttime && $endtime) { $criteria->addCondition("t.CreateTime > {$starttime} and t.CreateTime < {$endtime}+3600*24", 'AND'); } else { if ($starttime) { $criteria->addCondition("t.CreateTime > {$starttime}", 'AND'); } else { if ($endtime) { $criteria->addCondition("t.CreateTime < {$endtime}+3600*24", 'AND'); } } } $data = new CActiveDataProvider('PapOrder', array('criteria' => $criteria, 'pagination' => array('pageSize' => $pageSize))); $datas = $data->getData(); foreach ($datas as $vv) { foreach ($vv->goodsinfo as $v) { $v = self::getVersionGoods($v); } } $data->setData($datas); return $data; }
/** * @inheritdoc */ public function getDataProvider(SearchForm $searchForm) { $criteria = new CDbCriteria(); $criteria->compare('id', $searchForm->id); $criteria->compare('username', $searchForm->username, true); $criteria->compare('email', $searchForm->email, true); $criteria->compare('firstname', $searchForm->firstName, true); $criteria->compare('lastname', $searchForm->lastName, true); $criteria->compare('created_on', $searchForm->createdOn); $criteria->compare('updated_on', $searchForm->updatedOn); $criteria->compare('last_visit_on', $searchForm->lastVisitOn); $criteria->compare('email_verified', $searchForm->emailVerified); $criteria->compare('is_active', $searchForm->isActive); $criteria->compare('is_disabled', $searchForm->isDisabled); $dataProvider = new CActiveDataProvider('User', array('criteria' => $criteria, 'keyAttribute' => 'id')); $identities = array(); foreach ($dataProvider->getData() as $row) { $identities[] = self::createFromUser($row); } $dataProvider->setData($identities); return $dataProvider; }
public function actionManageDropDowns() { $dataProvider = new CActiveDataProvider('Dropdowns'); $model = new Dropdowns(); $dropdowns = $dataProvider->getData(); foreach ($dropdowns as $dropdown) { $temp = json_decode($dropdown->options); $str = ""; foreach ($temp as $item) { $str .= $item . ", "; } $str = substr($str, 0, -2); $dropdown->options = $str; } $dataProvider->setData($dropdowns); $this->render('manageDropDowns', array('dataProvider' => $dataProvider, 'model' => $model, 'dropdowns' => $dataProvider->getData())); }
public function actionUpdate1() { //SEGUNDA TELA NO UPDATE DE UM TEST CONTEXT //VERIFICA SE EXISTEM ELEMENTOS QUE AINDA NÃO FORAM USADOS. //CASO NÃO EXISTAM MAIS ELEMENTOS DISPONÍVEIS, ELE REDIRECIONA AUTOMATICAMNETE PARA A TERCEIRA TELA. $idTestContext = Yii::app()->user->getState('idTestContext'); $idDevice = Yii::app()->user->getState('idDevice'); //BOTÃO CANCELAR if (isset($_POST['buttonCancel'])) { $this->redirect("/mtcontrool/index.php/testContext/admin"); } $arrayModels = ElementInst::model()->findAll('id_test_context=' . $idTestContext); $arrayTypes = array(); foreach ($arrayModels as $item) { $item->sent = $item->behavior_screen; $arrayTypes[$item->id_element] = $item->element_type; } //FUNÇÃO CALLBACK DE ORDENAÇÃO. function order($a, $b) { $retval = strnatcmp($a['id_element'], $b['id_element']); if (!$retval) { return strnatcmp($b['description'], $a['description']); } return $retval; } //VERIFICA QUAIS ELEMENTOS ESTÃO ASSICIADOS AO DEVIDE. //E CRIA UM NOVO FORM PARA CADA UM DESSES ELEMENTOS //ISSO PERMITIRÁ QUE NOVAS INSTANCIA DE ELEMENTOS SEJAM CRIADAS. $arrayExclude = array(); $flag = 0; $exclude = null; $elements = new Element(); $elements = Element::model()->with('elementDevices')->findAll('ID_DEVICE=' . $idDevice); if (sizeof($arrayModels) > 0) { //$elements=Element::model()->with('elementDevices')->findAll('ID_DEVICE=' . $idDevice); foreach ($elements as $i => $element) { $model = new ElementInst(); $model->id_element = $element->id; $model->id_test_context = $idTestContext; foreach ($arrayTypes as $key => $value) { if ($model->id_element == $key) { $model->element_type = $value; } } if ($model->element_type != '') { array_push($arrayExclude, $element->id); } else { $flag = 1; } array_push($arrayModels, $model); } //ORDENA O ARRAY DE MODELOS DE FORMA QUE OS MODELOS NÃO PREENCHIDOS FIQUEM POR ULTIMO. usort($arrayModels, 'order'); $exclude = json_encode($arrayExclude); if (sizeof($arrayExclude) > 0 and $flag == 1) { //$this->redirect(Yii::app()->createUrl("/elementInst/create", array("idTestContext"=>$idTestContext,"idDevice"=>$idDevice,"exclude"=>$arrayExclude))); } } else { //$this->redirect(Yii::app()->createUrl("/elementInst/create", array("idTestContext"=>$idTestContext,"idDevice"=>$idDevice))); } $arrayExcluded = array(); if ($exclude != null) { $exclude = json_decode($exclude); foreach ($elements as $key => $item) { foreach ($exclude as $value) { if ($item->id == $value) { array_push($arrayExcluded, $elements[$key]); unset($elements[$key]); } } } $elements = array_values($elements); } $listElements = CHtml::listData($elements, 'id', 'description'); $dataProvider = new CActiveDataProvider('Element'); $dataProvider->setData($elements); //ORDENA O ARRAY DE MODELOS DE FORMA QUE OS MODELOS NÃO PREENCHIDOS FIQUEM POR ULTIMO. usort($arrayModels, 'order'); $count_elements = 0; foreach (array_keys($_POST) as $key) { if (strpos($key, "ElementInst") === 0) { //Key matches, test value. $count_elements++; } } //SALVA OS DADOS NO BANCO DE DADOS $count_saved = 0; if ($count_elements > 0) { foreach ($arrayModels as $key => $model) { if (isset($_POST["description" . $key])) { if (trim($_POST["description" . $key]) != "") { $model->description = $_POST["description" . $key]; if ($model->element_type == "interval") { $model->start_param = $_POST["start_param" . $key]; $model->end_param = $_POST["end_param" . $key]; } if ($model->save()) { $count_saved++; } else { print_r($model->getErrors()); } } else { } } } } if (isset($_POST['confirm'])) { $totalElements = $_POST['total_elements']; $flagSelecionados = 0; $i = 0; $typeNull = 0; $arraySelected = null; while ($i < $totalElements) { if (isset($_POST['ID_' . $i])) { if ($_POST['type_' . $i] != "") { $arraySelected[$_POST['ID_' . $i]] = $_POST['type_' . $i]; $flagSelecionados = 1; } else { $flagSelecionados = 1; $typeNull = 1; } } $i = $i + 1; } $json = null; if ($arraySelected != null) { $json = json_encode($arraySelected); } //salva dados para a próxima action //RENDER DA TERCEIRA TELA APÓS SELECIONAR OS ELEMENTOS. Yii::app()->user->setState('json', $json); Yii::app()->user->setState('idTestContext', $idTestContext); Yii::app()->user->setState('idDevice', $idDevice); $this->redirect("/mtcontrool/index.php/elementInst/create2"); } if (sizeof($listElements) == 0) { //SE NÃO EXISTEM MAIS ELEMENTOS DISPONIVEIS, REDIRECIONA PARA A TERCEIRA TELA Yii::app()->user->setState('json', null); Yii::app()->user->setState('idTestContext', $idTestContext); Yii::app()->user->setState('idDevice', $idDevice); $this->redirect("/mtcontrool/index.php/elementInst/create2"); } else { //PRIMEIRO RENDER AO ABRIR A TELA A PRIMEIRA VEZ $this->render('create_pre', array('listElements' => $listElements, 'models' => $elements, 'dataProvider' => $dataProvider, 'arrayExcluded' => $arrayExcluded, 'idTestContext' => $idTestContext)); } }
<?php /* @var $this StatementsController */ /* @var $model Statements */ $this->breadcrumbs = array('Statements' => array('index'), $model->idStatement); $url = "http://skif.znu.edu.ua:8080/request_report-1.0-1.0-SNAPSHOT/statement.jsp?filter=" . $model->number . "&format=6"; $this->menu = array(array('label' => 'Створити', 'url' => array('create'), 'icon' => "icon-plus-sign"), array('label' => 'Змінити', 'url' => array('update', 'id' => $model->idStatement), 'icon' => " icon-pencil"), array('label' => 'Перелік відомостей', 'url' => array('admin'), 'icon' => "icon-list-alt"), array('label' => 'Перелік слухачів', 'url' => array('/preuniversity/person'), 'icon' => " icon-user"), array('label' => 'Друкувати', 'url' => $url, 'icon' => "icon-print")); ?> <h1>Відомість № <?php echo $model->number; ?> </h1> <?php if (isset($model->Subjects1ID)) { $model->Subjects1ID = $model->subj1->SubjectName; } if (isset($model->Subjects2ID)) { $model->Subjects2ID = $model->subj2->SubjectName; } if (isset($model->Subjects3ID)) { $model->Subjects3ID = $model->subj3->SubjectName; } $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'type' => array('bordered', 'condensed', 'striped'), 'attributes' => array('number', 'created', 'specFullName', 'Subjects1ID', 'Subjects2ID', 'Subjects3ID', 'SubjectsDate1', 'SubjectsDate2', 'SubjectsDate3'))); $data = new CActiveDataProvider('Statementpersons'); $data->setData($itemsmodel); $this->widget('bootstrap.widgets.TbGridView', array('type' => 'striped bordered', 'id' => 'speciality-price-grid', 'dataProvider' => $data, 'template' => "{items}", 'columns' => array(array("name" => "Fio", "header" => "ФИО"), array("name" => "Hash", "header" => "Hash"), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'Subject1Val', 'editable' => array('url' => $this->createUrl('statements/editfield', array('field' => 'Subject1Val')), 'mode' => 'inline', 'inputclass' => 'span1', 'type' => 'text', 'title' => 'Введіть оцінку')), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'Subject2Val', 'editable' => array('url' => $this->createUrl('statements/editfield'), 'mode' => 'inline', 'inputclass' => 'span1', 'type' => 'text', 'title' => 'Введіть оцінку')), array('class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'Subject3Val', 'editable' => array('url' => $this->createUrl('statements/editfield'), 'mode' => 'inline', 'inputclass' => 'span1', 'type' => 'text', 'title' => 'Введіть оцінку')))));
public static function getrecords($Item) { $OrganID = Yii::app()->user->getOrganID(); $time = Yii::app()->request->getParam('time'); $criteria = new CDbCriteria(); if ($Item == 1) { $criteria->addCondition("Item = 1 or Item = 3", "AND"); $criteria->addCondition("OrganID=" . $OrganID, "AND"); } elseif ($Item == 0) { $criteria->addCondition("Item = 0 or Item = 2", "AND"); $criteria->addCondition("OrganID =" . $OrganID, "AND"); } if (strtotime(Yii::app()->request->getParam('starttime'))) { $StartTime = Yii::app()->request->getParam('starttime'); } if (strtotime(Yii::app()->request->getParam('endtime'))) { $endtime = Yii::app()->request->getParam('endtime'); } if (Yii::app()->request->getParam('time')) { $Time = Yii::app()->request->getParam('time'); } if ($StartTime && $EndTime) { $StartTime = strtotime($StartTime); $EndTime = (int) (strtotime($EndTime) + 60 * 60 * 24); $criteria->addBetweenCondition('CreateTime', "{$StartTime}", "{$EndTime}", "AND"); } elseif ($StartTime) { $StartTime = strtotime($StartTime); $criteria->addCondition("CreateTime >= " . $StartTime); } elseif ($EndTime) { $EndTime = (int) (strtotime($EndTime) + 60 * 60 * 24); $criteria->addCondition("CreateTime <= " . $EndTime, "AND"); } if ($Time && !$StartTime && !$EndTime) { $newtime = time(); $datetime = strtotime(date("Y-m-d", $newtime)); if ($Time == 1) { $criteria->addBetweenCondition('CreateTime', "{$datetime}", "{$newtime}", "AND"); } elseif ($Time == 2) { $oldtime = (int) ($datetime - 60 * 60 * 24 * 30); $criteria->addBetweenCondition('CreateTime', "{$oldtime}", "{$newtime}", "AND"); } elseif ($Time == 3) { $oldtime = (int) ($datetime - 60 * 60 * 24 * 30 * 3); $criteria->addBetweenCondition('CreateTime', "{$oldtime}", "{$newtime}", "AND"); } } // $criteria->addCondition('OrganID =' . $OrganID, 'AND'); // $criteria->addCondition('Item =' . $Item, 'AND'); // $criteria->order = 'ID desc'; $dataProvider = new CActiveDataProvider('PapTransactionRecords', array('criteria' => $criteria)); $datas = $dataProvider->getData(); foreach ($datas as $v) { if ($v->Item == '2') { $v->Item = '买方退货:' . $v->BusinessNO; $v->OrganID = OrderreturnService::idgetname($v->GetID); $v->view = "<a class='view' href='" . Yii::app()->createUrl('pap/Cashdeposit/info', array('id' => $v->ID)) . "' title='详情'>查看详情</a>"; } if ($v->Item == '0') { $v->Item = '充值'; $v->OrganID = '北京嘉配科技有限公司'; $v->view = ''; } if ($v->Item == '1') { $v->Item = '充值'; $v->OrganID = OrderreturnService::idgetname($v->OrganID); $v->view = ''; } if ($v->Item == '3') { $v->Item = '违规处罚'; $v->OrganID = CashdepositService::idgetunion($v->GetID); $v->view = "<a class='view' href='" . Yii::app()->createUrl('pap/Cashdeposit/infos', array('id' => $v->ID)) . "' title='详情'>查看详情</a>"; } } $dataProvider->setData($datas); return $dataProvider; }
public static function getDelername2($params) { //PapOrder 经销商 $organID = Yii::app()->user->getOrganID(); $criteria = new CDbCriteria(); $criteria->group = 't.SellerID'; $criteria->select = 't.SellerID,t.SellerName '; $criteria->addCondition("t.BuyerID={$organID} and t.SellerID!='' and t.SellerName!=''"); if ($params['SellerName']) { $criteria->addCondition("t.SellerName like '%{$params['SellerName']}%'", "AND"); } $dataProvider = new CActiveDataProvider('PapOrder', array('criteria' => $criteria, 'pagination' => array('pageSize' => 8))); $data = $dataProvider->getData(); foreach ($data as $key => $value) { $data[$key] = $value; $SellerID = $value['SellerID']; $res = F::getOrgan($SellerID); $data[$key]['SellerName'] = $res['OrganName']; } $data = $dataProvider->setData($data); return $dataProvider; }
/** * @inheritdoc */ public function getDataProvider(SearchForm $searchForm) { $criteria = new CDbCriteria(); $criteria->compare('usuario_id', $searchForm->id); $criteria->compare('usuario', $searchForm->username, true); $criteria->compare('codigo_onapre', $searchForm->codigo_onapre, true); $criteria->compare('correo', $searchForm->email, true); //$criteria->compare('firstname', $searchForm->firstName,true); //$criteria->compare('lastname', $searchForm->lastName,true); $criteria->compare('creado_el', $searchForm->createdOn); $criteria->compare('actualizado_el', $searchForm->updatedOn); $criteria->compare('last_visit_on', $searchForm->lastVisitOn); $criteria->compare('correo_verificado', $searchForm->emailVerified); $criteria->compare('esta_activo', $searchForm->isActive); $criteria->compare('esta_deshabilitado', $searchForm->isDisabled); $dataProvider = new CActiveDataProvider('Usuarios', array('criteria' => $criteria, 'keyAttribute' => 'usuario_id')); $identities = array(); foreach ($dataProvider->getData() as $row) { $identities[] = self::createFromUser($row); } $dataProvider->setData($identities); return $dataProvider; }
public function actionDetail() { $OrganID = Yii::app()->user->getOrganID(); $ServiceID = Yii::app()->request->getParam("id"); //$_GET['ID']; //获取服务记录详情 $record = ServiceRecord::model()->findByPK($ServiceID); //获取配件服务记录详情 $criteria = new CDbCriteria(); $criteria->order = "t.UpdateTime DESC,t.ID DESC"; //排序条件:t.CreateTime,t.ID倒叙 $criteria->addCondition("ServiceID = {$ServiceID}", "AND"); $criteria->addCondition("t.Status = 0", "AND"); $dataProvider = new CActiveDataProvider('ServiceParts', array('criteria' => $criteria, 'pagination' => array('pageSize' => '10'))); $data = $dataProvider->getData(); $key = 0; foreach ($data as $val) { $part = explode(",", $val['PartName']); if (empty(array_filter($part))) { array_splice($data, $key, 1); continue; } $key++; $val['PartName'] = ''; foreach ($part as $v) { $name = Gcategory::model()->find(array('select' => 'Name', 'condition' => 'ID= :ID', 'params' => array(':ID' => $v))); $val['PartName'] .= $name['Name'] . ","; } $val['PartName'] = substr($val['PartName'], 0, strlen($val['PartName']) - 1); if ($val['OperateType'] == 2) { $val['OperateType'] = "维修"; } else { $val['OperateType'] = "更换"; } } //var_dump($data);die; $dataProvider->setData($data); //获取车辆详情 //根据服务记录ID获取车辆ID $carID = ServiceRecord::model()->find(array('select' => 'CarID', 'condition' => 'ID= :ID', 'params' => array(':ID' => $ServiceID))); $car = ServiceCar::model()->findByPK($carID['CarID']); if ($car['UseNature'] == 2) { $car['UseNature'] = "公务车"; } elseif ($car['UseNature'] == 3) { $car['UseNature'] = "运营车"; } else { $car['UseNature'] = "私家车"; } $car['Car'] = str_replace(",", " ", $car['Car']); //获取车主详情 $owner = ServiceCarOwner::model()->findByPK($car['OwnerID']); $this->render('detail', array('dataProvider' => $dataProvider, 'car' => $car, 'owner' => $owner, 'record' => $record)); }
/** * Manages all models. */ public function actionOrder($date = null, $cat = null, $show = 5, $location = null) { if (!$cat) { $cat = SnapUtil::config('boxomatic/supplier_product_feature_category'); } $customerId = Yii::app()->user->user_id; $Customer = Customer::model()->findByPk($customerId); $deadlineDays = SnapUtil::config('boxomatic/orderDeadlineDays'); if (!$date) { $date = DeliveryDate::getCurrentDeliveryDateId(); } $updatedExtras = array(); $updatedOrders = array(); $Category = Category::model()->findByPk($cat); $DeliveryDate = DeliveryDate::model()->findByPk($date); $AllDeliveryDates = false; $pastDeadline = false; $CustDeliveryDate = false; if ($Customer) { $CustDeliveryDate = Order::model()->findByAttributes(array('delivery_date_id' => $date, 'user_id' => $customerId)); if (!$CustDeliveryDate) { $CustDeliveryDate = new Order(); $CustDeliveryDate->delivery_date_id = $date; $CustDeliveryDate->user_id = $customerId; $CustDeliveryDate->location_id = $Customer->location_id; $CustDeliveryDate->save(); } $AllDeliveryDates = DeliveryDate::model()->with('Locations')->findAll("Locations.location_id = " . $CustDeliveryDate->location_id); $deadline = strtotime('+' . $deadlineDays . ' days'); $pastDeadline = strtotime($DeliveryDate->date) < $deadline; if ($pastDeadline) { Yii::app()->user->setFlash('warning', 'Order deadline has passed, order cannot be changed.'); } } if (!$Customer && (isset($_POST['supplier_purchases']) || isset($_POST['boxes']))) { Yii::app()->user->setFlash('error', 'You must register to make an order.'); $this->redirect(array('site/register')); } if ($location) { $locationId = $location; $custLocationId = new CDbExpression('NULL'); if (strpos($locationId, '-')) { //has a customer location $parts = explode('-', $locationId); $locationId = $parts[1]; $custLocationId = $parts[0]; } //$Location=Location::model()->findByPk($locationId); $CustDeliveryDate->location_id = $locationId; $CustDeliveryDate->customer_location_id = $custLocationId; $CustDeliveryDate->save(); $CustDeliveryDate->refresh(); } if (isset($_POST['btn_recurring'])) { $monthsAdvance = (int) $_POST['months_advance']; $startingFrom = $_POST['starting_from']; $every = $_POST['every']; $locationId = $_POST['Order']['delivery_location_key']; $custLocationId = new CDbExpression('NULL'); if (strpos($locationId, '-')) { //has a customer location $parts = explode('-', $locationId); $locationId = $parts[1]; $custLocationId = $parts[0]; } $dayOfWeek = date('N', strtotime($CustDeliveryDate->DeliveryDate->date)) + 1; if ($dayOfWeek == 8) { $dayOfWeek = 1; } $orderedExtras = OrderItem::findCustomerExtras($customerId, $date); $orderedBoxes = UserBox::model()->with('Box')->findAllByAttributes(array('user_id' => $Customer->user_id), 'delivery_date_id=' . $date); $DeliveryDates = DeliveryDate::model()->findAll("\n\t\t\t\t\tdate >= '{$startingFrom}' AND\n\t\t\t\t\tdate <= DATE_ADD('{$startingFrom}', interval {$monthsAdvance} MONTH) AND\n\t\t\t\t\tdate_sub(date, interval {$deadlineDays} day) > NOW() AND\n\t\t\t\t\tDAYOFWEEK(date) = '" . $dayOfWeek . "'"); $n = 0; foreach ($DeliveryDates as $DD) { $CustDD = Order::model()->findByAttributes(array('delivery_date_id' => $DD->id, 'user_id' => $customerId)); if (!$CustDD) { $CustDD = new Order(); $CustDD->delivery_date_id = $DD->id; $CustDD->user_id = $customerId; $CustDD->location_id = $CustDeliveryDate->location_id; $CustDD->save(); } //Delete any extras already ordered $TBDExtras = OrderItem::findCustomerExtras($customerId, $DD->id); foreach ($TBDExtras as $TBDExtra) { $TBDExtra->delete(); } //Delete any extras already ordered $TBDBoxes = UserBox::model()->with('Box')->findAllByAttributes(array('user_id' => $Customer->user_id), 'delivery_date_id=' . $CustDD->delivery_date_id); foreach ($TBDBoxes as $TBDBox) { $TBDBox->delete(); } $n++; if ($n % 2 == 0 && $every == 'fortnight') { continue; } //Copy current days order foreach ($orderedExtras as $orderedExt) { $extra = new OrderItem(); //give the customer the extra $extra->quantity = $orderedExt->quantity; $extra->order_id = $CustDD->id; $extra->supplier_purchase_id = $orderedExt->supplier_purchase_id; $extra->price = $orderedExt->price; $extra->packing_station_id = $orderedExt->packing_station_id; $extra->name = $orderedExt->name; $extra->unit = $orderedExt->unit; $extra->save(); } //Copy current days boxxes foreach ($orderedBoxes as $orderedBox) { $EquivBox = Box::model()->findByAttributes(array('size_id' => $orderedBox->Box->size_id, 'delivery_date_id' => $DD->id)); $box = new UserBox(); $box->attributes = $orderedBox->attributes; $box->user_box_id = null; $box->box_id = $EquivBox->box_id; $box->save(); } } Yii::app()->user->setFlash('success', 'Recurring order set.'); } if (isset($_POST['btn_clear_orders'])) { $orderedExtras = OrderItem::model()->with(array('Order' => array('with' => 'DeliveryDate')))->findAll("DATE_SUB(date, INTERVAL {$deadlineDays} DAY) > NOW() AND user_id = " . $Customer->user_id); foreach ($orderedExtras as $ext) { $ext->delete(); } //Get all boxes beyond the deadline date $Boxes = Box::model()->with('DeliveryDate')->findAll("DATE_SUB(date, interval {$deadlineDays} day) > NOW()"); foreach ($Boxes as $Box) { $CustBox = UserBox::model()->findByAttributes(array('user_id' => $Customer->user_id, 'box_id' => $Box->box_id)); if ($CustBox) { $CustBox->delete(); } } } if (isset($_POST['extras'])) { foreach ($_POST['extras'] as $id => $quantity) { $model = $this->loadModel($id); if ($model->Order->user_id == Yii::app()->user->user_id) { if ($quantity == 0) { $model->delete(); } else { $model->quantity = $quantity; $model->save(); $updatedOrders[$model->id] = $model; } } } } if (isset($_POST['supplier_purchases'])) { foreach ($_POST['supplier_purchases'] as $purchaseId => $quantity) { if ($quantity == 0) { continue; } $extra = OrderItem::model()->with('Order')->findByAttributes(array('supplier_purchase_id' => $purchaseId, 'order_id' => $CustDeliveryDate->id)); if (!$extra) { $extra = new OrderItem(); } $Purchase = SupplierPurchase::model()->findByPk($purchaseId); $SupplierProduct = $Purchase->supplierProduct; //give the customer the extra $extra->quantity += $quantity; $extra->order_id = $CustDeliveryDate->id; $extra->supplier_purchase_id = $purchaseId; $extra->price = $Purchase->item_sales_price; $extra->packing_station_id = $SupplierProduct->packing_station_id; $extra->name = $SupplierProduct->name; $extra->unit = $SupplierProduct->unit; $updatedExtras[$extra->supplier_purchase_id] = $extra; $extra->save(); } } if (isset($_POST['boxes'])) { foreach ($_POST['boxes'] as $boxId => $quantity) { $Box = Box::model()->findByPk($boxId); $CustBoxes = UserBox::model()->with('Box')->findAll(array('condition' => 'user_id=:customerId AND size_id=:sizeId AND delivery_date_id=:deliveryDateId', 'params' => array(':customerId' => $customerId, ':sizeId' => $Box->size_id, ':deliveryDateId' => $Box->delivery_date_id))); $curQuantity = count($CustBoxes); $diff = $quantity - $curQuantity; if ($diff > 0) { //Create extra customer box rows for ($i = 0; $i < $diff; $i++) { $CustBox = new UserBox(); $CustBox->user_id = $customerId; $CustBox->box_id = $boxId; $CustBox->quantity = 1; $CustBox->delivery_cost = $Customer->Location->location_delivery_value; $CustBox->save(); } } if ($diff < 0) { //Remove any boxes the customer no longer wants; $diff = abs($diff); for ($i = 0; $i < $diff; $i++) { $CustBoxes[$i]->delete(); } } } } $orderedExtras = OrderItem::findCustomerExtras($customerId, $date); $dpOrderedExtras = new CActiveDataProvider('OrderItem'); $dpOrderedExtras->setData($orderedExtras); $DeliveryDates = DeliveryDate::model()->with('Boxes')->findAll(array('condition' => 'DATE_SUB(date, INTERVAL -1 week) > NOW() AND date < DATE_ADD(NOW(), INTERVAL 1 MONTH)')); $this->render('order', array('pastDeadline' => $pastDeadline, 'orderedExtras' => $dpOrderedExtras, 'updatedExtras' => $updatedExtras, 'updatedOrders' => $updatedOrders, 'DeliveryDate' => $DeliveryDate, 'DeliveryDates' => $DeliveryDates, 'AllDeliveryDates' => $AllDeliveryDates, 'model' => new OrderItem(), 'Category' => $Category, 'Customer' => $Customer, 'CustDeliveryDate' => $CustDeliveryDate, 'curCat' => $cat)); }
/** * Landing page for admin created dropdowns * * This method allows the admin to access the functions related to creating * and editing admin created dropdowns in the app. */ public function actionManageDropDowns() { $dataProvider = new CActiveDataProvider('Dropdowns'); $model = new Dropdowns(); $dropdowns = $dataProvider->getData(); foreach ($dropdowns as $dropdown) { $temp = json_decode($dropdown->options, true); if (is_array($temp)) { $str = implode(", ", $temp); } else { $str = $dropdown->options; } $dropdown->options = $str; } $dataProvider->setData($dropdowns); $this->render('manageDropDowns', array('dataProvider' => $dataProvider, 'model' => $model, 'dropdowns' => Dropdowns::model()->findAll())); }
public function actionLists() { // Yii:app()->params->groups $criteria = new CDbCriteria(array()); $criteria->addCondition('type="static" OR type="dynamic"'); $criteria->addCondition('x2_checkViewPermission(visibility,assignedTo,"' . Yii::app()->user->getName() . '") > 0'); $contactLists = new CActiveDataProvider('X2List', array('sort' => array('defaultOrder' => 'createDate DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria)); $totalContacts = CActiveRecord::model('Contacts')->count(); $totalMyContacts = CActiveRecord::model('Contacts')->count('assignedTo="' . Yii::app()->user->getName() . '"'); $totalNewContacts = CActiveRecord::model('Contacts')->count('assignedTo="' . Yii::app()->user->getName() . '" AND createDate >= ' . mktime(0, 0, 0)); $allContacts = new X2List(); $allContacts->attributes = array('id' => 'all', 'name' => Yii::t('contacts', 'All Contacts'), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalContacts, 'createDate' => 0, 'lastUpdated' => 0); $newContacts = new X2List(); $newContacts->attributes = array('id' => 'new', 'assignedTo' => Yii::app()->user->getName(), 'name' => Yii::t('contacts', 'New Contacts'), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalNewContacts, 'createDate' => 0, 'lastUpdated' => 0); $myContacts = new X2List(); $myContacts->attributes = array('id' => 'my', 'assignedTo' => Yii::app()->user->getName(), 'name' => Yii::t('contacts', 'My Contacts'), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalMyContacts, 'createDate' => 0, 'lastUpdated' => 0); $contactListData = $contactLists->getData(); // $contactListData[] = $allContacts3; $contactListData[] = $newContacts; $contactListData[] = $myContacts; $contactListData[] = $allContacts; $contactLists->setData($contactListData); $this->render('listIndex', array('contactLists' => $contactLists)); }