public function actionListcall($company_id = 0)
 {
     if ($company_id == 0) {
         $company_id = Yii::app()->getUser()->getProfile()->company_id;
     }
     Yii::import('market.models.*');
     $criteria = new CDbCriteria();
     $criteria->condition = 't.type_request = "request"';
     $criteria->with = ['user' => ['joinType' => 'INNER JOIN', 'condition' => 'user.company_id = :company_id']];
     $criteria->params = [':company_id' => $company_id];
     $criteria->order = 'special_technique_id DESC';
     $this->render('list', ['spec' => SpecialTechnique::model()->findAll($criteria), 'company_id' => $company_id]);
 }
Beispiel #2
0
 public function actionDeactivate()
 {
     Yii::app()->setImport(['application.modules.cargo.models.*']);
     $condition = new CDbCriteria();
     $condition->addCondition('TO_DAYS(NOW()) - TO_DAYS(`deleted_status_date`) > 15');
     Product::model()->updateAll(['deleted_status' => Product::DEL_SATUS_ARCHIVE], $condition);
     Cargo::model()->updateAll(['deleted_status' => Cargo::DEL_SATUS_ARCHIVE], $condition);
     Reis::model()->updateAll(['deleted_status' => Reis::DEL_SATUS_ARCHIVE], $condition);
     Sklad::model()->updateAll(['deleted_status' => Sklad::DEL_SATUS_ARCHIVE], $condition);
     Custom::model()->updateAll(['deleted_status' => Custom::DEL_SATUS_ARCHIVE], $condition);
     Insurance::model()->updateAll(['deleted_status' => Insurance::DEL_SATUS_ARCHIVE], $condition);
     SpecialTechnique::model()->updateAll(['deleted_status' => SpecialTechnique::DEL_SATUS_ARCHIVE], $condition);
 }
Beispiel #3
0
 public static function getHumanNameByResponseItem($model, $external_id)
 {
     $ret = '';
     switch ($model) {
         case 'Cargo':
             $ret = Yii::t('default', 'Грузы');
             break;
         case 'Reis':
             $ret = Yii::t('default', 'Транспорт');
             break;
         case 'Sklad':
             $ret = Yii::t('default', 'Склад');
             break;
         case 'SkladCall':
             $ret = Yii::t('default', 'Запрос на склад');
             break;
         case 'Custom':
             $ret = Yii::t('default', 'Таможня');
             break;
         case 'Insurance':
             $ret = Yii::t('default', 'Страховка');
             break;
         case 'SpecialTechnique':
         case 'SpecialTechniqueCall':
             $SpecialTechnique = SpecialTechnique::model()->findByPk($external_id);
             if ('offer' == $SpecialTechnique->type_request) {
                 $ret = Yii::t('default', 'Спецтехника');
             } else {
                 if ('request' == $SpecialTechnique->type_request) {
                     $ret = Yii::t('default', 'Спецтехника запрос');
                 }
             }
             break;
         case 'StoreCall':
             $ret = Yii::t('default', 'Запрос товаров/услуг');
             break;
         case 'Product':
             $ret = Yii::t('default', 'Товары/услуги');
             break;
         default:
             Yii::t("getHumanNameByResponseItem undefinite model=[{$model}]", "info");
     }
     return $ret;
 }
 public function actionActivate($id)
 {
     $model = SpecialTechnique::model()->findByPk($id);
     if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $model->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->specialtech != '1' || $model->user_id != Yii::app()->user->id)) {
         throw new CHttpException(403);
     }
     if ($model === null) {
         throw new CHttpException(404, 'Указанная запись не найдена');
     }
     $model->deleted_status = SpecialTechnique::DEL_SATUS_ACTIVE;
     $model->deleted_status_date = date('Y-m-d H:i:s');
     $model->update();
     Yii::app()->user->setFlash('success', Yii::t('CabinetModule.default', 'Предложение успешно активированно.'));
     $this->redirect('/cabinet/specialtechnique');
 }
 /**
  * Запуск виджета
  */
 public function run()
 {
     switch ($this->type) {
         case 'store_add':
             $product = Product::model()->find('t.slug = "' . $this->record_id . '"');
             $criteria = new CDbCriteria();
             $product->category_id = isset($product->category_id) ? $product->category_id : 1;
             $criteria->condition = 't.category_id = ' . $product->category_id . ' AND t.status ="active"';
             $criteria->limit = 5;
             $storecalls = StoreCall::model()->findAll($criteria);
             $this->render('store_add', ['storecalls' => $storecalls]);
             break;
         case 'store_call_add':
             $storecall = StoreCall::model()->findByPk($this->record_id);
             $criteria = new CDbCriteria();
             $storecall->category_id = isset($storecall->category_id) ? $storecall->category_id : 1;
             $criteria->condition = 't.category_id =' . $storecall->category_id . ' AND t.status ="1"';
             $criteria->limit = 5;
             $products = Product::model()->findAll($criteria);
             $this->render('store_call_add', ['products' => $products]);
             break;
         case 'cargo_add':
             $cargo = Cargo::model()->with('address_from', 'address_to')->findByPk($this->record_id);
             $reissearchform = new ReisSearchForm();
             $reissearchform->from_name = $cargo->address_from[0]->name;
             $reissearchform->from_address_lat = $cargo->address_from[0]->lat;
             $reissearchform->from_address_long = $cargo->address_from[0]->long;
             $reissearchform->from_radius = $this->radius;
             $reissearchform->to_name = $cargo->address_to[0]->name;
             $reissearchform->to_address_lat = $cargo->address_to[0]->lat;
             $reissearchform->to_address_long = $cargo->address_to[0]->long;
             $reissearchform->to_radius = $this->radius;
             $reisIds = $reissearchform->relatedReis();
             if (!empty($reisIds)) {
                 $reis = Reis::model()->findAllByAttributes(array('reis_id' => $reisIds), array('order' => 'reis_id desc', 'limit' => 5));
             } else {
                 $reis = array();
             }
             $this->render('cargo_add', ['reis' => $reis]);
             break;
         case 'transport_add':
             $transport = Reis::model()->findByPk($this->record_id);
             $transport->address_from;
             $transport->address_to;
             $cargosearchform = new CargoSearchForm();
             $cargosearchform->from_name = $transport->address_from[0]->name;
             $cargosearchform->from_address_lat = $transport->address_from[0]->lat;
             $cargosearchform->from_address_long = $transport->address_from[0]->long;
             $cargosearchform->from_radius = $this->radius;
             if (!empty($transport->address_to)) {
                 $cargosearchform->to_name = $transport->address_to[0]->name;
                 $cargosearchform->to_address_lat = $transport->address_to[0]->lat;
                 $cargosearchform->to_address_long = $transport->address_to[0]->long;
                 $cargosearchform->to_radius = $this->radius;
             }
             $cargoIds = $cargosearchform->relatedCargo();
             if (!empty($cargoIds)) {
                 $cargo = Cargo::model()->findAllByAttributes(array('cargo_id' => $cargoIds), array('order' => 'cargo_id desc', 'limit' => 5));
             } else {
                 $cargo = array();
             }
             $this->render('transport_add', ['cargo' => $cargo]);
             break;
         case 'sklad_call_add':
             $skladcall = SkladCall::model()->with('address')->findByPk($this->record_id);
             if ($skladcall->address->name && $skladcall->address->lat && $skladcall->address->long) {
                 $skladsearchform = new SkladSearchForm();
                 $skladsearchform->from_name = $skladcall->address->name;
                 $skladsearchform->from_address_lat = $skladcall->address->lat;
                 $skladsearchform->from_address_long = $skladcall->address->long;
                 $skladsearchform->from_radius = $this->radius;
                 $criteria = $skladsearchform->getCriteria();
                 $criteria->limit = 5;
                 $sklads = Sklad::model()->findAll($criteria);
             } else {
                 $sklads = array();
             }
             $this->render('sklad_call', ['sklads' => $sklads]);
             break;
         case 'sklad_add':
             $sklad = Sklad::model()->with('address')->findByPk($this->record_id);
             if ($sklad->address->name && $sklad->address->lat && $sklad->address->long) {
                 $skladcallsearchform = new SkladCallSearchForm();
                 $skladcallsearchform->from_name = $sklad->address->name;
                 $skladcallsearchform->from_address_lat = $sklad->address->lat;
                 $skladcallsearchform->from_address_long = $sklad->address->long;
                 $skladcallsearchform->from_radius = $this->radius;
                 $criteria = $skladcallsearchform->getCriteria();
                 $criteria->limit = 5;
                 $skladcalls = SkladCall::model()->findAll($criteria);
             } else {
                 $skladcalls = array();
             }
             $this->render('sklad_add', ['skladcalls' => $skladcalls]);
             break;
         case 'specialtechnique_call_add':
             $specialTechniqueCall = SpecialTechnique::model()->with('address')->findByPk($this->record_id);
             if ($specialTechniqueCall->address->name && $specialTechniqueCall->address->lat && $specialTechniqueCall->address->long) {
                 $specialtechniqueform = new SpecialTechniqueForm();
                 $specialtechniqueform->from_name = $specialTechniqueCall->address->name;
                 $specialtechniqueform->from_address_lat = $specialTechniqueCall->address->lat;
                 $specialtechniqueform->from_address_long = $specialTechniqueCall->address->long;
                 $specialtechniqueform->from_radius = $this->radius;
                 $specialtechniqueform->type_request = 'offer';
                 $specialtechniqueform->category_id = $specialTechniqueCall->category_id;
                 $criteria = $specialtechniqueform->getCriteria();
                 $criteria->limit = 5;
                 $specialtechnique = SpecialTechnique::model()->findAll($criteria);
             } else {
                 $specialtechnique = array();
             }
             $this->render('specialtechnique_call_add', ['specialtechnique' => $specialtechnique]);
             break;
         case 'specialtechnique_add':
             $specialTechnique = SpecialTechnique::model()->with('address')->findByPk($this->record_id);
             if ($specialTechnique->address->name && $specialTechnique->address->lat && $specialTechnique->address->long) {
                 $specialtechniqueform = new SpecialTechniqueForm();
                 $specialtechniqueform->from_name = $specialTechnique->address->name;
                 $specialtechniqueform->from_address_lat = $specialTechnique->address->lat;
                 $specialtechniqueform->from_address_long = $specialTechnique->address->long;
                 $specialtechniqueform->from_radius = $this->radius;
                 $specialtechniqueform->type_request = 'request';
                 $specialtechniqueform->category_id = $specialTechnique->category_id;
                 $criteria = $specialtechniqueform->getCriteria();
                 $criteria->limit = 5;
                 $specialtechniquecall = SpecialTechnique::model()->findAll($criteria);
             } else {
                 $specialtechniquecall = array();
             }
             $this->render('specialtechnique_add', ['specialtechniquecall' => $specialtechniquecall]);
             break;
         default:
             break;
     }
 }
 /**
  * Удаляем из раздела SpecialTechnique model - modules/market/model/SpecialTechnique, controller modules/cabinet/controllers/SpecialTechniqueController
  *
  * @param User $user
  */
 private function deleteSpecialTechnique(\User $user)
 {
     $data = 'user_id = :user_id';
     $param = array(':user_id' => $user->id);
     $count = SpecialTechnique::model()->count($data, $param);
     $specialtechniques = SpecialTechnique::model()->findAll($data, $param);
     foreach ($specialtechniques as $specialtechnique) {
         $this->deleteFile($specialtechnique->special_technique_id, 'SpecialTechnique');
         $this->deleteRelation($specialtechnique->special_technique_id, 'special_technique_id', 'site_special_technique_relations');
         $this->deleteRelationsAll($specialtechnique->special_technique_id, 'special_technique_id', 'site_special_technique_cost', 'cost_id', 'site_cost');
         $this->deleteAddress($specialtechnique->address_id);
     }
     if ($this->debug) {
         echo "    ... SpesialTechnique  : del " . $count . " \n";
     } else {
         SpecialTechnique::model()->deleteAll($data, $param);
     }
 }
 public function actionDelete($id)
 {
     $user = User::model()->find(array('condition' => 'id = :id', 'params' => array(':id' => $id)));
     if (isset($user)) {
         if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $user->company_id || Yii::app()->user->id == $id)) {
             throw new CHttpException(403);
         }
         $users = User::getUserList($id);
         $model = new ModuleAccess();
         if (isset($_POST['ModuleAccess'])) {
             $userId = $_POST['ModuleAccess']['user'];
             Transport::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             Product::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             Cargo::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             Reis::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             Sklad::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             Custom::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             Insurance::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             SpecialTechnique::model()->updateAll(array('user_id' => $userId), 'user_id=' . $id);
             if ($user->delete()) {
                 $this->redirect('/cabinet/staff/list');
             }
         }
         $this->render('delete', array('model' => $model, 'user' => $user, 'users' => $users));
     }
 }