public function run()
 {
     if (empty($this->model) || empty($this->type)) {
         return;
     }
     // Определяем тип товара для поиска товаров данного типа
     $productType = ProductType::model()->published()->findByAlias($this->type);
     if (!$productType) {
         return;
     }
     // Определяем товар данного типа с таким же названием, как заданный
     $relatedProduct = Stone::model()->published()->type($productType->id)->with('series')->findByAttributes(array('title' => $this->model->title));
     // Получаем список рандомных товаров данного типа, похожих на заданный по цвету и виду камня
     $criteria = new CDbCriteria();
     $criteria->compare('t.series_id', $this->model->series_id);
     $criteria->compare('t.color_id', $this->model->color_id);
     $notSearchIds = array($this->model->id);
     if ($relatedProduct !== null) {
         $notSearchIds[] = $relatedProduct->id;
     }
     $criteria->addNotInCondition('t.id', $notSearchIds);
     $criteria->order = 'RAND()';
     $criteria->limit = 7;
     $models = Stone::model()->published()->type($productType->id)->with('series')->findAll($criteria);
     if ($relatedProduct !== null) {
         $models = array($relatedProduct) + $models;
     }
     $this->render($this->view, array('productType' => $productType, 'models' => $models, 'model' => $this->model));
 }
Ejemplo n.º 2
0
 public function deleteOldItems($model, $itemsPk)
 {
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('coupon_id', $itemsPk);
     $criteria->addCondition("listing_id= {$model->primaryKey}");
     Coupon::model()->deleteAll($criteria);
 }
Ejemplo n.º 3
0
 public function actionIndex()
 {
     Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css');
     $left_news = Post::model()->findAll(array('select' => 'id, title, image, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 3), 'order' => 'id DESC', 'limit' => 3));
     $special_ids = array();
     foreach ($left_news as $row) {
         array_push($special_ids, $row->id);
     }
     $criteria = new CDbCriteria();
     $criteria->select = 'id, title, summary';
     $criteria->order = 'id DESC';
     $criteria->addCondition('catalog_id = 3');
     $criteria->addNotInCondition('id', $special_ids);
     $criteria->limit = 1;
     $top_news = Post::model()->findAll($criteria);
     array_push($special_ids, $top_news[0]->id);
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $criteria->addCondition('catalog_id = 3');
     $criteria->addNotInCondition('id', $special_ids);
     $count = Post::model()->count($criteria);
     $pager = new CPagination($count);
     $pager->pageSize = 30;
     $pager->applyLimit($criteria);
     $more_news = Post::model()->findAll($criteria);
     $data = array('left_news' => $left_news, 'top_news' => $top_news[0], 'more_news' => $more_news, 'pages' => $pager);
     $this->render('index', $data);
 }
 public function actionHideremnants()
 {
     $readableFile = Yii::getPathOfAlias('webroot') . $this->module->folderFiles;
     $content = @file_get_contents($readableFile . '/' . $this->module->readFileProducts);
     $errors = [];
     $productId = [];
     $IdC = [];
     if ($content) {
         foreach (explode("\n", $content) as $id => $string) {
             $attr = explode(";", $string);
             $IdC[] = $attr[2];
         }
         $criteria = new CDbCriteria();
         $criteria->select = 'id';
         $criteria->compare('id_1c', $IdC, true);
         $products = Product::model()->findAll($criteria);
         foreach ($products as $key => $value) {
             $productId[] = $value->id;
         }
         $criteria = new CDbCriteria();
         $criteria->addCondition('status = :status');
         $criteria->params = [':status' => 1];
         $criteria->addNotInCondition('id', $productId);
         $model = Product::model()->findAll($criteria);
         foreach ($model as $key => $value) {
             $value->status = 2;
             $value->save();
         }
     }
 }
 function report($id, $pro_id)
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'code';
     $criteria->compare('department_id', $pro_id);
     $criteria->compare('parent_id', $id);
     //$criteria->compare('amount!',0);
     $criteria->addNotInCondition('id', array(193, 119, 164, 198));
     $models = aBudget::model()->findAll($criteria);
     $this->myheader($id, $pro_id);
     $w = array(47, 23, 23, 10, 23, 10, 23, 10, 23);
     $this->SetFont('Arial', '', 7);
     $_total = 0;
     $_realization = 0;
     $_payment = 0;
     $_unpayment = 0;
     $_balance = 0;
     foreach ($models as $model) {
         $_amount = $model->amount;
         $_real = aBudget::model()->allComponent($model->id, 2012, 1);
         $_realP = $_amount != 0 ? $_real / $_amount * 100 : 0;
         $_paid = aBudget::model()->allComponentPaid($model->id, 2012, 1);
         $_paidP = $_real != 0 ? $_paid / $_real * 100 : 0;
         $_unpaid = $_real - $_paid;
         $_unpaidP = $_real != 0 ? $_unpaid / $_real * 100 : 0;
         $_endBalance = isset($model->end_balance) ? $model->end_balance->balance : $_amount;
         $this->SetFont('Arial', '', 7);
         $this->Cell($w[0], 6, $model->code . ". " . $model->name, 'L');
         $this->Cell($w[1], 6, number_format($_amount, 2, ',', '.'), 'LR', 0, 'R');
         $this->Cell($w[2], 6, number_format($_real, 2, ',', '.'), '', 0, 'R');
         $this->Cell($w[3], 6, round($_realP, 2), 'LR', 0, 'R');
         $this->Cell($w[4], 6, number_format($_paid, 2, ',', '.'), '', 0, 'R');
         $this->Cell($w[5], 6, round($_paidP, 2), 'LR', 0, 'R');
         $this->Cell($w[6], 6, number_format($_unpaid, 2, ',', '.'), '', 0, 'R');
         $this->Cell($w[7], 6, round($_unpaidP, 2), 'LR', 0, 'R');
         $this->Cell($w[8], 6, number_format($_endBalance, 0, ',', '.'), 'LR', 0, 'R');
         $this->Ln();
         $_total = $_total + $_amount;
         $_realization = $_realization + $_real;
         $_payment = $_payment + $_paid;
         $_unpayment = $_unpayment + $_unpaid;
         $_balance = $_balance + $_endBalance;
     }
     $this->Cell(array_sum($w), 4, '', 'T');
     $this->Ln(6);
     $_realizationP = $_total != 0 ? $_realization / $_total * 100 : 0;
     $_paymentP = $_realization != 0 ? $_payment / $_realization * 100 : 0;
     $_unpaymentP = $_realization != 0 ? $_unpayment / $_realization * 100 : 0;
     $this->SetFont('Arial', 'B', 8);
     $this->Cell($w[0], 8, 'T O T A L', 1);
     $this->Cell($w[1], 8, number_format($_total, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[2], 8, number_format($_realization, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[3], 8, round($_realizationP, 2), 1, 0, 'R');
     $this->Cell($w[4], 8, number_format($_payment, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[5], 8, round($_paymentP, 2), 1, 0, 'R');
     $this->Cell($w[6], 8, number_format($_unpayment, 0, ',', '.'), 1, 0, 'R');
     $this->Cell($w[7], 8, round($_unpaymentP, 2), 1, 0, 'R');
     $this->Cell($w[8], 8, number_format($_balance, 0, ',', '.'), 1, 0, 'R');
     $this->Ln();
 }
Ejemplo n.º 6
0
 /**
  * Search the local authorities and return both their address and the address of their social security department
  *
  * @param $term
  */
 public function actionAutoComplete($term)
 {
     $crit = new \CDbCriteria();
     // NOTE: have commented out the address eager loading here due to column ambiguity issues with the relation definitions.
     // need to investigate if this can be solved with the cunning use of scopes on the Contact model or not.
     $crit->with = array('contact' => array('alias' => 'service_contact'), 'commissioning_body', 'commissioning_body.contact', 'type' => array('alias' => 'service_type'), 'commissioning_body.type' => array('alias' => 'body_type'));
     $crit->compare('LOWER(t.name)', strtolower($term), true);
     $crit->compare('LOWER(commissioning_body.name)', strtolower($term), true, 'OR');
     $crit->addColumnCondition(array('service_type.shortname' => 'SSD'));
     $crit->addColumnCondition(array('body_type.shortname' => 'LA'));
     $crit->order = 'commissioning_body.name, t.name';
     $results = array();
     $found_bodies = array();
     foreach (\CommissioningBodyService::model()->findAll($crit) as $cbs) {
         $body = $cbs->commissioning_body;
         $found_bodies[] = $body->id;
         $results[] = array('id' => 'service' . $cbs->id, 'value' => $cbs->name . " ({$body->name})", 'service' => array('id' => $cbs->id, 'name' => $cbs->name, 'address' => $cbs->getLetterAddress(array('delimiter' => ",\n")), 'telephone' => $cbs->contact->primary_phone), 'body' => array('id' => $body->id, 'name' => $body->name, 'address' => $body->getLetterAddress(array('delimiter' => ",\n")), 'telephone' => $body->contact->primary_phone));
     }
     $body_crit = new \CDbCriteria();
     $body_crit->with = array('type', 'contact', 'contact.correspondAddress');
     $body_crit->compare('LOWER(t.name)', strtolower($term), true);
     $body_crit->addNotInCondition('t.id', $found_bodies);
     $body_crit->addColumnCondition(array('type.shortname' => 'LA'));
     foreach (\CommissioningBody::model()->findAll($body_crit) as $body) {
         $results[] = array('id' => 'body' . $body->id, 'value' => $body->name, 'body' => array('id' => $body->id, 'name' => $body->name, 'address' => $body->getLetterAddress(array('delimiter' => ",\n")), 'telephone' => $body->contact->primary_phone));
     }
     echo json_encode($results);
 }
Ejemplo n.º 7
0
 public function actionUser()
 {
     $user = User::model()->findByPk(isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : null);
     if (is_null($user)) {
         $user = new User();
     }
     $criteria = new CDbCriteria();
     $criteria->compare('controller', Yii::app()->params['controllers'][2]);
     $criteria->compare('enable', '1');
     $criteria->addNotInCondition('action', AccessGlobal::getDefaultAction());
     $criteria->order = "action asc";
     $actions = AccessGlobal::model()->findAll($criteria);
     if (Yii::app()->request->isPostRequest && isset($_POST['User'])) {
         $user->attributes = $_POST['User'];
         $user->pass = $_POST['User']['pass'];
         if ($user->save()) {
             AccessUser::model()->deleteAllByAttributes(array('user_id' => $user->user_id));
             $accessForUser = array_merge($_POST['access'] ? $_POST['access'] : array(), AccessGlobal::getIdDefaultAction());
             foreach ($accessForUser as $val) {
                 $access = new AccessUser();
                 $access->user_id = $user->user_id;
                 $access->action_id = $val;
                 $access->save();
             }
             $this->redirect($this->createUrl('superadmin/users'));
         }
     }
     $this->render('user', array('user' => $user, 'actions' => $actions, 'access' => AccessUser::getActionIdFromUser($user->user_id)));
 }
Ejemplo n.º 8
0
 public function getSimilarPosts(Post $post, $limit = 10)
 {
     $criteria = new CDbCriteria();
     $criteria->limit = $limit;
     $criteria->order = 'publish_time DESC';
     $criteria->addNotInCondition('t.id', [$post->id]);
     $criteria->mergeWith(Post::model()->public()->published()->getFindByTagsCriteria($post->getTags()));
     return Post::model()->findAll($criteria);
 }
Ejemplo n.º 9
0
 /**
  * @param Patient $patient
  * @param array   $exclude
  *
  * @return array|CActiveRecord[]|mixed|null
  */
 public function getPrescriptionItemsForPatient(Patient $patient, $exclude = array())
 {
     $prescriptionCriteria = new CDbCriteria(array('order' => 'event_date DESC'));
     $prescriptionCriteria->addCondition('episode.patient_id = :id');
     $prescriptionCriteria->addNotInCondition('t.id', $exclude);
     $prescriptionCriteria->params = array_merge($prescriptionCriteria->params, array(':id' => $patient->id));
     $prescriptionItems = OphDrPrescription_Item::model()->with('prescription', 'drug', 'duration', 'prescription.event', 'prescription.event.episode')->findAll($prescriptionCriteria);
     return $prescriptionItems;
 }
Ejemplo n.º 10
0
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = $this->limit;
     $criteria->order = 'publish_date DESC';
     $criteria->addNotInCondition('t.id', array($this->post->id));
     $criteria->mergeWith(Post::model()->public()->published()->getFindByTagsCriteria($this->post->getTags()));
     $posts = Post::model()->findAll($criteria);
     $this->render($this->view, array('posts' => $posts));
 }
Ejemplo n.º 11
0
 public function searchNotFor($id)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('name', $this->name, true);
     $criteria->compare('price', $this->price);
     $criteria->compare('sku', $this->sku, true);
     $criteria->compare('category_id', $this->category_id);
     $criteria->addNotInCondition('id', [$id]);
     return new CActiveDataProvider(get_class($this), ['criteria' => $criteria, 'sort' => ['defaultOrder' => 't.position']]);
 }
Ejemplo n.º 12
0
 public function getOrganizationsForTaskCreate()
 {
     $criteria = new CDbCriteria();
     if ($this->so_ids) {
         $criteria->addNotInCondition('id', explode(',', $this->so_ids), true);
     }
     $criteria->compare('name', $this->name, true);
     $criteria->compare('type', $this->type, true);
     $criteria->compare('region_id', $this->region_id, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'name', 'route' => 'task/organizations/'), 'pagination' => array('pageSize' => 1000, 'route' => 'task/organizations/')));
 }
Ejemplo n.º 13
0
 protected function afterSave()
 {
     if ($this->scenario == 'selectEvaAttributes') {
         $evaAttribsArray = json_decode($this->evaAttributes);
         $assMethodsCriteria = new CDbCriteria();
         $assMethodsCriteria->condition = 'evaluationId=' . $this->evalId;
         $assMethodsCriteria->addNotInCondition('evaAttribute', $evaAttribsArray);
         EvaAssessmentMethods::model()->deleteAll($assMethodsCriteria);
         return parent::afterSave();
     }
 }
Ejemplo n.º 14
0
 public function searchFilter()
 {
     $criteria1 = new CDbCriteria();
     $criteria1->compare('receiver_id', Yii::app()->user->id, false, 'OR');
     $criteria1->compare('sender_id', Yii::app()->user->id, false, 'OR');
     $criteria = new CDbCriteria();
     $criteria->mergeWith($criteria1);
     $criteria->compare('type_id', 2);
     $criteria->addNotInCondition('read_id', array(6));
     $criteria->order = 'sender_date DESC';
     return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => 5)));
 }
Ejemplo n.º 15
0
 public function getValidParents()
 {
     $result = array();
     $criteria = new CDbCriteria();
     if (!$this->_model->getIsNewRecord()) {
         $criteria->addNotInCondition($this->getPK(), $this->getDescendantsIds($this->_model));
     }
     foreach ($this->_model->findAll($criteria) as $model) {
         $result[$model->{$this->getPK()}] = $model->getCaption();
     }
     return $result;
 }
Ejemplo n.º 16
0
 /**
  * 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->addNotInCondition('t.id', Roles::$aRoleRestrict);
     $criteria->compare('id', $this->id);
     $criteria->compare('role_name', $this->role_name, true);
     $criteria->compare('role_short_name', $this->role_short_name, true);
     $criteria->compare('application_id', $this->application_id);
     $criteria->order = "id DESC";
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
Ejemplo n.º 17
0
 public function uniqueCombination($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $criteria = new CDbCriteria();
         if (!$this->isNewRecord) {
             $criteria->addNotInCondition('id', array($this->id), 'AND');
         }
         $not_unique = self::model()->findByAttributes(array('service_id' => $this->service_id, 'weight' => $this->weight, 'type' => $this->type), $criteria);
         if ($not_unique instanceof RateInternational) {
             $message = 'Rate price ini sudah ada, silahkan masukan service, berat atau type paket yang lain';
             $this->addErrors(array('service_id' => $message, 'type' => $message, 'weight' => $message));
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * @param $id
  * @throws CHttpException
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         if ($model->save() && $model->storeTypeAttributes(Yii::app()->getRequest()->getPost('attributes', []))) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.store', 'Product type is updated'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $availableAttributes = Attribute::model()->findAll($criteria);
     $this->render('update', ['model' => $model, 'availableAttributes' => $availableAttributes]);
 }
 /**
  * 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.
     $acdm_terms = AcademicTerm::model()->findAll('current_sem=1');
     $data = array();
     foreach ($acdm_terms as $list) {
         $data[] = $list['academic_term_id'];
     }
     $criteria = new CDbCriteria();
     $criteria->with = array('Rel_Stud_Info', 'Rel_Status', 'Rel_Division', 'Rel_language', 'Rel_user');
     $criteria->addInCondition('student_academic_term_name_id', $data, 'OR');
     $criteria->addNotInCondition('student_transaction_detain_student_flag', array('1', '2'));
     $criteria->compare('student_transaction_id', $this->student_transaction_id);
     $criteria->compare('student_transaction_detain_student_flag', $this->student_transaction_detain_student_flag);
     $criteria->compare('student_transaction_user_id', $this->student_transaction_user_id);
     $criteria->compare('student_transaction_student_id', $this->student_transaction_student_id);
     $criteria->compare('student_transaction_branch_id', $this->student_transaction_branch_id, true);
     $criteria->compare('student_transaction_category_id', $this->student_transaction_category_id);
     $criteria->compare('student_transaction_organization_id', $this->student_transaction_organization_id);
     $criteria->compare('student_transaction_student_address_id', $this->student_transaction_student_address_id);
     $criteria->compare('student_transaction_nationality_id', $this->student_transaction_nationality_id);
     $criteria->compare('student_transaction_quota_id', $this->student_transaction_quota_id);
     $criteria->compare('student_transaction_religion_id', $this->student_transaction_religion_id);
     $criteria->compare('student_transaction_shift_id', $this->student_transaction_shift_id);
     $criteria->compare('student_transaction_languages_known_id', $this->student_transaction_languages_known_id);
     $criteria->compare('student_transaction_student_photos_id', $this->student_transaction_student_photos_id);
     $criteria->compare('student_transaction_division_id', $this->student_transaction_division_id);
     $criteria->compare('student_transaction_batch_id', $this->student_transaction_batch_id);
     $criteria->compare('student_academic_term_period_tran_id', $this->student_academic_term_period_tran_id);
     $criteria->compare('student_academic_term_name_id', $this->student_academic_term_name_id);
     $criteria->compare('Rel_user.user_organization_email_id', $this->user_organization_email_id, true);
     //$criteria->compare('Rel_Branch.branch_name',$this->branch_name,true);
     $criteria->compare('Rel_Stud_Info.student_first_name', $this->student_first_name, true);
     $criteria->compare('Rel_Stud_Info.student_living_status', $this->student_living_status, true);
     $criteria->compare('Rel_Stud_Info.student_enroll_no', $this->student_enroll_no, true);
     $criteria->compare('Rel_Stud_Info.student_roll_no', $this->student_roll_no, true);
     $criteria->compare('Rel_Stud_Info.student_middle_name', $this->student_middle_name, true);
     $criteria->compare('Rel_Stud_Info.student_last_name', $this->student_last_name, true);
     $criteria->compare('Rel_Stud_Info.student_dtod_regular_status', $this->student_dtod_regular_status, true);
     $criteria->compare('Rel_Division.division_name', $this->division_name, true);
     $criteria->compare('Rel_Status.status_name', $this->status_name, true);
     $criteria->compare('Rel_Stud_Info.student_mobile_no', $this->student_mobile_no, true);
     $criteria->compare('Rel_Stud_Info.student_email_id_1', $this->student_email_id_1, true);
     $stud_data = new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'student_transaction_id DESC')));
     $_SESSION['Student_records'] = $stud_data;
     return $stud_data;
 }
Ejemplo n.º 20
0
 public function setPhoto($photos)
 {
     $curModel = get_class($this);
     $curPrimaryKeyValue = $this->{$this->tableSchema->primaryKey};
     $contition = new CDbCriteria();
     $contition->addCondition('record_id=:record_id');
     $contition->addNotInCondition('id', $photos);
     $contition->addCondition('model=:model');
     $contition->params[':record_id'] = $curPrimaryKeyValue;
     $contition->params[':model'] = $curModel;
     File::model()->updateAll(['record_id' => '0'], $contition);
     $condition = new CDbCriteria();
     $condition->addCondition('model=:model');
     $condition->params[':model'] = $curModel;
     File::model()->updateByPk($photos, ['record_id' => $curPrimaryKeyValue], $condition);
 }
 public function actionGetList()
 {
     header("Content-Type: application/json");
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition("username", array("lj2016888"));
     $allAccts = FreeVoipAccounts::model()->findAll($criteria);
     $finalArr = array();
     foreach ($allAccts as $key => $value) {
         if ($value->username == "Prion1967") {
             $value->username = "******";
         }
         $rawDateUpdated = strtotime($value->date_updated);
         $finalArr[] = array("id" => $value->id, "username" => $value->username, "password" => $value->password, "credits" => $value->credits, "last_updated" => VoipTransDateHelper::timeAgo($rawDateUpdated), "date_created" => $value->date_created, "date_updated" => $value->date_updated);
     }
     echo CJSON::encode($finalArr);
 }
 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->writeLine('Initializing');
     $criteria = new CDbCriteria();
     $criteria->alias = 'keyword';
     $criteria->addCondition('keyword.period > 0');
     $criteria->addNotInCondition('keyword.status', array(Keyword::STATUS_PENDING, Keyword::STATUS_TAKEN, Keyword::STATUS_IN_PROGRESS));
     $keyword = Keyword::model()->findAll($criteria);
     $console->progressStart('Updating keywords', count($keyword));
     foreach ($keyword as $k) {
         $console->progressStep();
         if (time() > strtotime($k->checked_at) + $k->period) {
             $k->setStatus(Keyword::STATUS_PENDING);
         }
     }
     $console->progressEnd();
 }
Ejemplo n.º 23
0
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         $model->categories = serialize(Yii::app()->getRequest()->getPost('categories'));
         if ($model->save()) {
             $model->setTypeAttributes(Yii::app()->getRequest()->getPost('attributes'));
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.type', 'Тип обновлен.'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $availableAttributes = Attribute::model()->findAll($criteria);
     $this->render('update', ['model' => $model, 'availableAttributes' => $availableAttributes]);
 }
Ejemplo n.º 24
0
 /**
  * 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($question = "", $type = "show")
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $quetModel = Question::model()->findByPk($question);
     $answerArray = $quetModel->hide_answer_id == "" ? array() : explode(",", trim($quetModel->hide_answer_id, ","));
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('content', $this->content, true);
     if ($question != "") {
         $criteria->addCondition('question_id=' . $question);
     }
     if ($type == "show") {
         $criteria->addNotInCondition('id', $answerArray);
     } else {
         $criteria->addInCondition('id', $answerArray);
     }
     $criteria->compare('create_user', $this->create_user);
     $criteria->compare('create_time', $this->create_time);
     $criteria->compare('is_anonymous', $this->is_anonymous, true);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
Ejemplo n.º 25
0
 /**
  * Update product type
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     if ($new === true) {
         $model = new StoreProductType();
     } else {
         $model = StoreProductType::model()->findByPk($_GET['id']);
     }
     if (!$model) {
         throw new CHttpException(404, Yii::t('StoreModule.admin', 'Тип продукта не найден.'));
     }
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['StoreProductType'];
         if (isset($_POST['categories']) && !empty($_POST['categories'])) {
             $model->categories_preset = serialize($_POST['categories']);
             $model->main_category = $_POST['main_category'];
         } else {
             //return defaults when all checkboxes were checked off
             $model->categories_preset = null;
             $model->main_category = 0;
         }
         if ($model->validate()) {
             $model->save();
             // Set type attributes
             $model->useAttributes(Yii::app()->request->getPost('attributes', array()));
             $this->setFlashMessage(Yii::t('StoreModule.admin', 'Изменения успешно сохранены'));
             if (isset($_POST['REDIRECT'])) {
                 $this->smartRedirect($model);
             } else {
                 $this->redirect('create');
             }
         }
     }
     // Select available(not used) attributes
     $cr = new CDbCriteria();
     $cr->addNotInCondition('StoreAttribute.id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $allAttributes = StoreAttribute::model()->findAll($cr);
     $this->render('update', array('model' => $model, 'attributes' => $allAttributes));
 }
Ejemplo n.º 26
0
 /**
  * Update product type
  * @param bool $new
  * @throws CHttpException
  */
 public function actionUpdate($new = false)
 {
     if ($new === true) {
         $model = new ShopProductType();
     } else {
         $model = ShopProductType::model()->findByPk($_GET['id']);
     }
     if (!$model) {
         throw new CHttpException(404, Yii::t('ShopModule.admin', 'NO_FOUND_TYPEPRODUCT'));
     }
     Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/admin/productType.update.js', CClientScript::POS_END);
     $this->pageName = $model->isNewRecord ? Yii::t('ShopModule.admin', 'Создание нового типа продукта') : Yii::t('ShopModule.admin', 'Редактирование типа продукта');
     $this->breadcrumbs = array(Yii::t('ShopModule.default', 'MODULE_NAME') => array('/admin/shop'), Yii::t('ShopModule.admin', 'TYPE_PRODUCTS') => $this->createUrl('index'), $this->pageName);
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['ShopProductType'];
         if (isset($_POST['categories']) && !empty($_POST['categories'])) {
             $model->categories_preset = serialize($_POST['categories']);
             $model->main_category = $_POST['main_category'];
         } else {
             //return defaults when all checkboxes were checked off
             $model->categories_preset = null;
             $model->main_category = 0;
         }
         if ($model->validate()) {
             $model->save();
             // Set type attributes
             $model->useAttributes(Yii::app()->request->getPost('attributes', array()));
             $this->redirect('index');
         }
     }
     // Select available(not used) attributes
     //die(print_r(Html::listData($model->attributeRelation, 'attribute_id', 'attribute_id')));
     $cr = new CDbCriteria();
     $cr->addNotInCondition('t.id', Html::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     //ShopAttribute.id
     $allAttributes = ShopAttribute::model()->findAll($cr);
     $this->render('update', array('model' => $model, 'attributes' => $allAttributes));
 }
Ejemplo n.º 27
0
 public function search2()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $ugRows = Usergroup::model()->findAll('uid=:uid', array(':uid' => Yii::app()->user->getState("user_id")));
     $grps = [];
     foreach ($ugRows as $ug) {
         $grps[] = $ug['gid'];
     }
     /*Get Blocked Item  Ids*/
     $getRows = Blockeditem::model()->findAllByAttributes(array('blocked_for' => Yii::app()->user->getState("user_id"), 'flag' => 'U', 'unblock_by' => NULL));
     $biU = [];
     foreach ($getRows as $row) {
         $biU[] = $row['item_id'];
     }
     $getRows = Blockeditem::model()->findAllByAttributes(array('blocked_for' => $grps, 'flag' => 'G', 'unblock_by' => NULL));
     $biG = [];
     foreach ($getRows as $row) {
         $biG[] = $row['item_id'];
     }
     ////////////Blocked For All
     $getRows = Blockeditem::model()->findAllByAttributes(array('flag' => 'A', 'unblock_by' => NULL));
     $biA = [];
     foreach ($getRows as $row) {
         $biA[] = $row['item_id'];
     }
     $blockeditemtableIds = array_merge($biU, $biG);
     $blockeditemtableIds = array_unique(array_merge($blockeditemtableIds, $biA));
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('commodity_id', $this->commodity_id);
     $criteria->compare('category_id', $this->category_id, true);
     $criteria->compare('link_to', $this->link_to);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('location_id', $this->location_id);
     $criteria->compare('technical_incharge_id', $this->technical_incharge_id);
     $criteria->compare('size', $this->size);
     $criteria->compare('status_id', $this->status_id);
     $criteria->compare('monitor_type_id', $this->monitor_type_id);
     $criteria->compare('manufacturer_id', $this->manufacturer_id);
     $criteria->compare('serial_number', $this->serial_number);
     $criteria->compare('management_type_id', $this->management_type_id);
     $criteria->compare('comments', $this->comments, true);
     $criteria->compare('document', $this->document, true);
     $criteria->compare('documentFileName', $this->documentFileName, true);
     $criteria->compare('documentFileType', $this->documentFileType, true);
     $criteria->compare('image', $this->image, true);
     $criteria->compare('imageFileName', $this->imageFileName, true);
     $criteria->compare('imageFileType', $this->imageFileType, true);
     $criteria->compare('enable_financial', $this->enable_financial, true);
     $criteria->compare('available_on_loan', $this->available_on_loan, true);
     $criteria->compare('has_microphone', $this->has_microphone, true);
     $criteria->compare('has_speaker', $this->has_speaker, true);
     $criteria->compare('has_subD', $this->has_subD, true);
     $criteria->compare('has_BNC', $this->has_BNC, true);
     $criteria->compare('has_DVI', $this->has_DVI, true);
     $criteria->compare('has_pivot', $this->has_pivot, true);
     $criteria->compare('has_HDMI', $this->has_HDMI, true);
     $criteria->compare('has_displayport', $this->has_displayport, true);
     $criteria->compare('is_deleted', $this->is_deleted);
     $criteria->addCondition("is_deleted = 0");
     $criteria->addNotInCondition('id', $blockeditemtableIds);
     if (isset($_GET['category_id'])) {
         $a = $_GET['category_id'];
         $criteria->addCondition("category_id = '{$a}'");
     }
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => false));
 }
Ejemplo n.º 28
0
 public function actionContact()
 {
     $OrganID = Commonmodel::getOrganID();
     //获取共享关系表中机构ID
     $ids = $this->getShareids();
     //获取用户表中所有经销商ID
     $users = User::getDealerID();
     foreach ($users as $user) {
         $identity[] = $user['id'];
     }
     //获取不在共享关系表中的机构信息
     $criteria = new CDbCriteria();
     $criteria->addInCondition('t.contact_user_id', $identity);
     //业务联系人属于经销商
     $criteria->addCondition("t.user_id = {$OrganID}", "AND");
     //当前机构下
     $criteria->addCondition("t.Status = 0", "AND");
     //未删除
     $criteria->addNotInCondition('t.contact_user_id', $ids);
     //业务联系人不在确定共享关系中
     $criteria->order = "t.create_time desc";
     //以添加时间倒序
     //通过机构名称模糊检索
     if ($_GET['name']) {
         $criteria->addSearchCondition('t.companyname', $_GET['name'], "AND");
     }
     //分页
     $count = BusinessContacts::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = $_GET['rows'];
     $pages->applyLimit($criteria);
     $model = BusinessContacts::model()->findAll($criteria);
     foreach ($model as $key => $value) {
         $data[$key]['id'] = $value['id'];
         $data[$key]['name'] = F::msubstr($value['name']);
         $data[$key]['sex'] = $value['sex'];
         $data[$key]['jiapart_ID'] = $value['jiapart_ID'];
         $data[$key]['companyname'] = F::msubstr($value['companyname']);
         $data[$key]['phone'] = F::msubstr($value['phone']);
         $data[$key]['address'] = F::msubstr(Area::getCity($value['province']) . Area::getCity($value['city']) . Area::getCity($value['area']));
     }
     $rs = array('total' => $count, 'rows' => $data ? $data : array());
     echo json_encode($rs);
 }
	public function transportsearch()
   	{
        $criteria=new CDbCriteria;

        $criteria->with = array('Rel_Stud_Info','Rel_user');       

        $transportregisterstudent = TransportStudentRegistration::model()->findAll();

        $data = array();
        foreach($transportregisterstudent as $list)
        {
            $data[] = $list['transport_student_transaction_id'];
        }
   	
        $criteria->addNotInCondition('student_transaction_id',$data);       
        $criteria->compare('student_transaction_batch_id',$this->student_transaction_batch_id);
        $criteria->compare('Rel_Stud_Info.student_first_name',$this->student_first_name,true);
        $criteria->compare('Rel_Stud_Info.student_roll_no',$this->student_roll_no,true);
        $criteria->compare('Rel_Stud_Info.student_middle_name',$this->student_middle_name,true);
        $criteria->compare('Rel_Stud_Info.student_last_name',$this->student_last_name,true);

        $transportstud_data = new CActiveDataProvider($this, array(
            'criteria'=>$criteria,
        ));
        $_SESSION['transportStudent_records']=$transportstud_data;
        return $transportstud_data;
    }
Ejemplo n.º 30
0
 /**
  * 计算经销商推荐收益
  * 每个月1号执行一次, 或者每隔1个月执行一次
  * @param unknown $args
  */
 public function run($args)
 {
     Yii::app()->getComponent('log');
     Yii::log(date('Y-m-d H:i:s') . " [RecommendIncome] start", 'info', 'command');
     echo date('Y-m-d H:i:s') . " [RecommendIncome] start \n";
     $beginmoth = strtotime('-1 month');
     $year = date('Y', $beginmoth);
     $month = date('m', $beginmoth);
     $beginmoth = date('Y-m', $beginmoth);
     $beginmoth = strtotime($beginmoth);
     $endmoth = date('Y-m');
     $endmoth = strtotime($endmoth);
     $Time = date('Y-m', time());
     $Time = strtotime($Time);
     Yii::log('beginmoth:' . $beginmoth, 'info', 'command');
     Yii::log('beginyear:' . $year, 'info', 'command');
     Yii::log('beginmoth:' . $beginmoth, 'info', 'command');
     Yii::log('endmoth:' . $endmoth, 'info', 'command');
     Yii::log('time:' . $Time, 'info', 'command');
     $discountRate = Settings::getValue("discountRate");
     //获取推荐收益参数
     $criteria = new CDbCriteria();
     $criteria->select = 'userID';
     $criteria->distinct = true;
     $criteria->order = 'userID desc';
     $sql_find = 'select ID from jpd_organ where Identity=2';
     $dealers = Yii::app()->jpdb->createcommand($sql_find)->queryAll();
     if (!empty($dealers)) {
         foreach ($dealers as $deakey => $deaval) {
             $IncomeID = '';
             $exit = RecommendIncome::model()->find('OrganID=:OrganID and Month=:Month and Year=:Year', array(':OrganID' => $deaval['ID'], ':Month' => $month, ':Year' => $year));
             if ($exit) {
                 $IncomeID = $exit->ID;
             } else {
                 $model = new RecommendIncome();
                 $model->EffectTime = time();
                 $model->OrganID = $deaval['ID'];
                 $model->IsAccount = 0;
                 $model->Month = $month;
                 $model->Year = $year;
                 $model->save();
                 $IncomeID = Yii::app()->jpdb->getLastInsertID();
             }
             $serviceID = '';
             $lastmonthtotal = 0;
             $Record_all = RecommendRecord::model()->findAll('DealerID=:OrganID ', array(':OrganID' => $deaval['ID']));
             if ($Record_all) {
                 foreach ($Record_all as $app2) {
                     if (!empty($app2)) {
                         if ($app2->ServiceID) {
                             $serviceID[] = $app2->ServiceID;
                             $app4 = PapOrder::model()->findAll('BuyerID=:BuyerID and Status=:Status and SellerID!=:SellerID and ReceiptTime<:endmoth and ReceiptTime>=:beginmoth', array(':BuyerID' => $app2->ServiceID, ':Status' => 9, ':SellerID' => $deaval['ID'], ':endmoth' => $endmoth, ':beginmoth' => $beginmoth));
                             if (!empty($app4)) {
                                 $month1 = 0;
                                 foreach ($app4 as $ke => $valu) {
                                     $discountAmount = $valu['RealPrice'] * $discountRate;
                                     //                                        $payAmount = is_float($discountAmount) ? substr_replace($discountAmount, '', strpos($discountAmount, '.') + 3) : $discountAmount . '.00';
                                     $payAmount = round($discountAmount, 2);
                                     $month1 += $payAmount;
                                     $lastmonthtotal += $payAmount;
                                 }
                                 $detail = RecommendIncomeDetail::model()->find("OrganID=:OrganID and ServiceID=:ServiceID and incomeID=:incomeID", array(':OrganID' => $deaval['ID'], ":ServiceID" => $app2->ServiceID, ':incomeID' => $IncomeID));
                                 if (!empty($detail)) {
                                     RecommendIncomeDetail::model()->updateByPK($detail->ID, array('income' => $month1));
                                 } else {
                                     $income = new RecommendIncomeDetail();
                                     $income->RecomID = $app2->RecomID;
                                     $income->RecomTime = time();
                                     //                                        $income->IncomeAccount = 0;
                                     $income->IncomeTime = time();
                                     $income->isAccount = 0;
                                     $income->BeFormalTime = 0;
                                     $income->income = $month1;
                                     $income->OrganID = $deaval['ID'];
                                     $income->ServiceID = $app2->ServiceID;
                                     $income->incomeID = $IncomeID;
                                     $income->save();
                                 }
                             }
                         }
                     }
                 }
             }
             $criteria = new CDbCriteria();
             $criteria->select = 'BuyerID';
             $criteria->distinct = true;
             $criteria->addCondition('Status=9');
             $criteria->addCondition("ReceiptTime<" . $endmoth);
             $criteria->addCondition("ReceiptTime>=" . $beginmoth);
             $criteria->addCondition("SellerID=" . $deaval['ID']);
             if (!empty($serviceID)) {
                 $criteria->addNotInCondition('BuyerID', $serviceID);
             }
             $criteria->order = 'BuyerID desc';
             $payservicers = PapOrder::model()->findAll($criteria);
             if (!empty($payservicers)) {
                 foreach ($payservicers as $paykey => $payval) {
                     $record = RecommendRecord::model()->find('ServiceID=:ServiceID', array(":ServiceID" => $payval->BuyerID));
                     if (!empty($record)) {
                         $month2 = 0;
                         $paysers = PapOrder::model()->findAll('BuyerID=:BuyerID and Status=:Status and SellerID=:SellerID and ReceiptTime<:endmoth and ReceiptTime>=:beginmonth', array(':BuyerID' => $payval->BuyerID, ':Status' => 9, ':SellerID' => $deaval['ID'], ':endmoth' => $endmoth, ':beginmonth' => $beginmoth));
                         foreach ($paysers as $Skey => $Sval) {
                             $discountAmount = $Sval['RealPrice'] * $discountRate;
                             //                                $payAmount = is_float($discountAmount) ? substr_replace($discountAmount, '', strpos($discountAmount, '.') + 3) : $discountAmount . '.00';
                             $payAmount = round($discountAmount, 2);
                             $month2 -= $payAmount;
                             $lastmonthtotal -= $payAmount;
                         }
                         $detail = RecommendIncomeDetail::model()->find("OrganID=:OrganID and ServiceID=:ServiceID and incomeID=:incomeID", array(':OrganID' => $deaval['ID'], ":ServiceID" => $payval->BuyerID, ':incomeID' => $IncomeID));
                         if (!empty($detail)) {
                             RecommendIncomeDetail::model()->updateByPK($detail->ID, array('income' => $month2));
                         } else {
                             $income = new RecommendIncomeDetail();
                             $income->RecomID = $record->RecomID;
                             $income->RecomTime = time();
                             $income->IncomeTime = time();
                             $income->isAccount = 0;
                             $income->BeFormalTime = 0;
                             $income->income = $month2;
                             $income->OrganID = $deaval['ID'];
                             $income->ServiceID = $payval->BuyerID;
                             $income->incomeID = $IncomeID;
                             $income->save();
                         }
                     }
                 }
             }
             RecommendIncome::model()->updateByPK($IncomeID, array('MonthIncome' => $lastmonthtotal));
         }
     }
     Yii::log(date('Y-m-d H:i:s') . " [RecommendIncome] end \n", 'info', 'command');
     echo date('Y-m-d H:i:s') . " [RecommendIncome] end \n";
 }