コード例 #1
0
 public function actionList($company_id = 0)
 {
     if ($company_id == 0) {
         $company_id = Yii::app()->getUser()->getProfile()->company_id;
     }
     Yii::import('reis.models.*');
     $criteria = new CDbCriteria();
     $criteria->with = ['user' => ['joinType' => 'INNER JOIN', 'condition' => 'user.company_id = :company_id']];
     $criteria->addCondition('deleted_status != :deleted_status');
     $criteria->params = [':company_id' => $company_id, ':deleted_status' => Reis::DEL_SATUS_DELETED];
     $criteria->order = 'reis_id DESC';
     $this->render('list', ['reis' => Reis::model()->findAll($criteria), 'company_id' => $company_id]);
 }
コード例 #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);
 }
コード例 #3
0
ファイル: add_old.php プロジェクト: alexanderkuz/test-yii2
        </section>
    </div>
    <div class="row show-green">
        <section class="col-sm-3">
        <?php 
echo $form->checkboxListGroup($Reis, 'body', ['widgetOptions' => ['data' => Reis::getBodyType()]]);
?>
        </section>
        <section class="col-sm-3">
        <?php 
echo $form->checkboxListGroup($Reis, 'load_type', ['widgetOptions' => ['data' => Reis::getTypeLoadUnload()]]);
?>
        </section>
        <section class="col-sm-3">
        <?php 
echo $form->checkboxListGroup($Reis, 'unload_type', ['widgetOptions' => ['data' => Reis::getTypeLoadUnload()]]);
?>
        </section>
    </div>
    <h3 class="show-green"><?php 
echo Yii::t('ReisModule.default', 'Оплата');
?>
</h3>
    <div class="row show-green">
        <section class="col-sm-3">
            <?php 
echo $form->textFieldGroup($Reis, 'cost_value_bn_nds');
?>
        </section>
        <section class="col-sm-3">
            <?php 
コード例 #4
0
ファイル: _reis-form.php プロジェクト: alexanderkuz/test-yii2
						});
					});
				</script>
			</section>
			<section class="col-md-4 show-green">
<?php 
echo $form->textFieldGroup($ReisSearchForm, 'weight_to');
?>
				<div class="input-group-btn radius weight-unit">
					<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php 
echo Reis::enumWeight($ReisSearchForm->weight_to_unit);
?>
 <span class="caret"></span></button>
					<ul id="weight_to_unit_ul" class="dropdown-menu dropdown-menu-right">
<?php 
foreach (Reis::enumWeight() as $value => $text) {
    ?>
							<li>
								<a data-value="<?php 
    echo $value;
    ?>
"><?php 
    echo $text;
    ?>
 </a>
							</li>
				<?php 
}
?>
					</ul>
				</div>
コード例 #5
0
 /**
  * Запуск виджета
  */
 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;
     }
 }
コード例 #6
0
 public function actionActivate($id)
 {
     $model = Reis::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->transport != '1' || $model->user_id != Yii::app()->user->id)) {
         throw new CHttpException(403);
     }
     if ($model === null) {
         throw new CHttpException(404, 'Указанная запись не найдена');
     }
     $model->deleted_status = Reis::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/transport');
 }
コード例 #7
0
 /**
  * Удаляем из раздела Reis model - modules/reis/model/Reis, controller modules/reis/controllers/DefaultController
  *
  * @param User $user
  */
 private function deleteReis(\User $user)
 {
     $data = 'user_id = :user_id';
     $param = array(':user_id' => $user->id);
     $count = Reis::model()->count($data, $param);
     $reiss = Reis::model()->findAll($data, $param);
     foreach ($reiss as $reis) {
         /*    $adreses =  Yii::app()->db->createCommand('select address_id from site_reis_address WHERE reis_id = '.$reis->reis_id)->queryAll();
               foreach ($adreses as $adres) {
                   $this->deleteAddress($adres['address_id']);
               }*/
         $this->deleteRelationsAll($reis->reis_id, 'reis_id', 'site_reis_address', 'address_id', 'site_address');
         //$this->deleteRelation($reis->reis_id,'reis_id','site_reis_address');
         $this->deleteRelationsAll($reis->reis_id, 'reis_id', 'site_reis_cost', 'cost_id', 'site_cost');
     }
     if ($this->debug) {
         echo "    ... Reis  del " . $count . " \n";
     } else {
         Reis::model()->deleteAll($data, $param);
     }
 }
コード例 #8
0
ファイル: _cart.php プロジェクト: alexanderkuz/test-yii2
                            <b><?php 
echo Yii::t('ReisModule.default', 'Опасный груз');
?>
:</b>
                        </section>
                        <section class="col-sm-6">
                            <?php 
echo $Reis->dangerous ? Yii::t('ReisModule.default', 'да') : Yii::t('ReisModule.default', 'нет');
?>
                        </section>
                        <?php 
if ($Reis->dangerous) {
    ?>
                        <section class="col-sm-6">
                            <b><?php 
    echo Reis::getSomeOptsByTransportType($Reis->transport_type_id, "ADR_name", "Need translate for=[ADR_name],id=[{$Reis->transport_type_id}]");
    ?>
:</b>
                        </section>
                        <section class="col-sm-6">
                            <?php 
    echo $Reis->ADR ? $Reis->ADR : '---';
    ?>
                        </section>
                        <?php 
}
?>
                    </div>
                </section>
                <section class="col-sm-6">
                    <div class="row">
コード例 #9
0
 public function getCriteria()
 {
     $criteria = new CDbCriteria();
     $params = $with = $condition = $arr = [];
     if (!empty($this->from_shapes)) {
         $from_shapes = json_decode($this->from_shapes);
         foreach ($from_shapes as $shape) {
             switch ($shape->type) {
                 case 'circle':
                     $radius = $shape->radius / 111144;
                     $lat = (double) $shape->center->lat;
                     $lng = (double) $shape->center->lng;
                     $condition[] = "(address_from.lat BETWEEN '" . ($lat - $radius) . "' AND '" . ($lat + $radius) . "') \r\n                          AND (address_from.long BETWEEN '" . ($lng - $radius) . "' AND '" . ($lng + $radius) . "')\r\n                          AND SQRT(POW(" . $lat . "-address_from.lat,2)+POW(" . $lng . "-address_from.long,2)) <" . $radius;
                     break;
                 case 'rectangle':
                     $condition[] = "(address_from.lat BETWEEN '" . (double) $shape->SW->lat . "' AND '" . (double) $shape->NE->lat . "') \r\n                          AND (address_from.long BETWEEN '" . (double) $shape->SW->lng . "' AND '" . (double) $shape->NE->lng . "')";
                     break;
                 case 'polygon':
                     $triangle = $this->_getTriangle($shape);
                     foreach ($triangle as $tr) {
                         $condition[] = "IN_TRIANGLE(" . $tr[0]->lat . "," . $tr[0]->lng . "," . $tr[1]->lat . "," . $tr[1]->lng . "," . $tr[2]->lat . "," . $tr[2]->lng . ",address_from.lat,address_from.long)";
                     }
                     break;
             }
         }
     }
     //		CVarDumper::dump($this,10,10);exit;
     if (!empty($this->from_name)) {
         $arr[] = "address_from.name = " . Yii::app()->db->quoteValue($this->from_name) . "";
         if (!empty($this->from_radius)) {
             $arr[] = "address_from.radius = '" . $this->from_radius . "'";
         }
         if (!empty($this->from_address_lat) && !empty($this->from_address_long)) {
             $from_radius = (int) $this->from_radius;
             $radius = ($from_radius < 25 ? 25 : $from_radius) / 111.144;
             $lat = (double) $this->from_address_lat;
             $lng = (double) $this->from_address_long;
             $condition[] = "(address_from.lat BETWEEN '" . ($lat - $radius) . "' AND '" . ($lat + $radius) . "') \r\n\t\t\t\t  AND (address_from.long BETWEEN '" . ($lng - $radius) . "' AND '" . ($lng + $radius) . "')\r\n\t\t\t\t  AND SQRT(POW(" . $lat . "-address_from.lat,2)+POW(" . $lng . "-address_from.long,2)) <" . $radius;
         }
         if (!empty($arr)) {
             $condition[] = implode(' AND ', $arr);
         }
     }
     if (!empty($condition)) {
         $with['address_from'] = ['joinType' => 'INNER JOIN', 'condition' => implode(' OR ', $condition)];
     }
     $condition = $arr = [];
     if (!empty($this->to_shapes)) {
         $to_shapes = json_decode($this->to_shapes);
         foreach ($to_shapes as $shape) {
             switch ($shape->type) {
                 case 'circle':
                     $radius = $shape->radius / 111144;
                     $lat = (double) $shape->center->lat;
                     $lng = (double) $shape->center->lng;
                     $condition[] = "(address_to.lat BETWEEN '" . ($lat - $radius) . "' AND '" . ($lat + $radius) . "') \r\n                          AND (address_to.long BETWEEN '" . ($lng - $radius) . "' AND '" . ($lng + $radius) . "')\r\n                          AND SQRT(POW(" . $lat . "-address_to.lat,2)+POW(" . $lng . "-address_to.long,2)) <" . $radius;
                     break;
                 case 'rectangle':
                     $condition[] = "(address_to.lat BETWEEN '" . (double) $shape->SW->lat . "' AND '" . (double) $shape->NE->lat . "') \r\n                          AND (address_to.long BETWEEN '" . (double) $shape->SW->lng . "' AND '" . (double) $shape->NE->lng . "')";
                     break;
                 case 'polygon':
                     $triangle = $this->_getTriangle($shape);
                     foreach ($triangle as $tr) {
                         $condition[] = "IN_TRIANGLE(" . $tr[0]->lat . "," . $tr[0]->lng . "," . $tr[1]->lat . "," . $tr[1]->lng . "," . $tr[2]->lat . "," . $tr[2]->lng . ",address_from.lat,address_from.long)";
                     }
                     break;
             }
         }
     }
     if (!empty($this->to_name)) {
         $arr[] = "address_to.name = " . Yii::app()->db->quoteValue($this->to_name) . "";
         if (!empty($this->to_radius)) {
             $arr[] = "address_to.radius = '" . $this->to_radius . "'";
         }
         if (!empty($this->to_address_lat) && !empty($this->to_address_long)) {
             $to_radius = (int) $this->to_radius;
             $radius = ($to_radius < 25 ? 25 : $to_radius) / 111.144;
             $lat = (double) $this->to_address_lat;
             $lng = (double) $this->to_address_long;
             $condition[] = "(address_to.lat BETWEEN '" . ($lat - $radius) . "' AND '" . ($lat + $radius) . "') \r\n\t\t\t\t  AND (address_to.long BETWEEN '" . ($lng - $radius) . "' AND '" . ($lng + $radius) . "')\r\n\t\t\t\t  AND SQRT(POW(" . $lat . "-address_to.lat,2)+POW(" . $lng . "-address_to.long,2)) <" . $radius;
         }
         if (!empty($arr)) {
             $condition[] = implode(' AND ', $arr);
         }
     }
     if (!empty($condition)) {
         $with['address_to'] = ['joinType' => 'INNER JOIN', 'condition' => implode(' OR ', $condition)];
     }
     $condition = [];
     if (!empty($this->when_from) || !empty($this->when_to)) {
         $when_from = date('Y-m-d', strtotime($this->when_from));
         $when_to = date('Y-m-d', strtotime($this->when_to));
         if (!empty($this->when_from) && !empty($this->when_to)) {
             $condition = ':when_from <= t.when_from AND :when_to >= t.when_from ';
             $criteria->addCondition($condition);
             $params[':when_from'] = $when_from;
             $params[':when_to'] = $when_to;
         } elseif (!empty($this->when_from)) {
             $criteria->addCondition(':when_from <= t.when_from');
             $params[':when_from'] = $when_from;
         } elseif (!empty($this->when_to)) {
             $criteria->addCondition(':when_to >= t.when_from');
             $params[':when_to'] = $when_to;
         }
     }
     if (!empty($this->volume_from)) {
         $criteria->addCondition(':volume_from <= t.volume_from');
         $params[':volume_from'] = $this->volume_from;
     }
     if (!empty($this->volume_to)) {
         $criteria->addCondition(':volume_to >= t.volume_to');
         $params[':volume_to'] = $this->volume_to;
     }
     if (!empty($this->weight_from)) {
         $criteria->addCondition(':weight_from <= t.weight_from');
         $params[':weight_from'] = $this->weight_from;
     }
     if (!empty($this->weight_from_unit)) {
         $criteria->addCondition(':weight_from_unit = t.weight_from_unit');
         $params[':weight_from_unit'] = $this->weight_from_unit;
     }
     if (!empty($this->weight_to)) {
         $criteria->addCondition(':weight_to >= t.weight_to');
         $params[':weight_to'] = $this->weight_to;
     }
     if (!empty($this->weight_to_unit)) {
         $criteria->addCondition(':weight_to_unit = t.weight_to_unit');
         $params[':weight_to_unit'] = $this->weight_to_unit;
     }
     if (!empty($this->length_from)) {
         $criteria->addCondition(':length_from <= t.length_from');
         $params[':length_from'] = $this->length_from;
     }
     if (!empty($this->length_to)) {
         $criteria->addCondition(':length_to >= t.length_to');
         $params[':length_to'] = $this->length_to;
     }
     if (!empty($this->height_from)) {
         $criteria->addCondition(':height_from <= t.height_from');
         $params[':height_from'] = $this->height_from;
     }
     if (!empty($this->height_to)) {
         $criteria->addCondition(':height_to >= t.height_to');
         $params[':height_to'] = $this->height_to;
     }
     if (!empty($this->width_from)) {
         $criteria->addCondition(':width_from <= t.width_from');
         $params[':width_from'] = $this->width_from;
     }
     if (!empty($this->width_to)) {
         $criteria->addCondition(':width_to >= t.width_to');
         $params[':width_to'] = $this->width_to;
     }
     //Yii::log("getCriteria this=[".print_r( $this , true )."]","info");
     if (false !== $this->transport_type_id) {
         if (0 == $this->transport_type_id) {
             if (!empty($this->dangerous_ALL)) {
                 $criteria->addCondition(':dangerous = t.dangerous');
                 $params[':dangerous'] = $this->dangerous_ALL;
             }
         } elseif ($this->transport_type_id > 0) {
             $dangerousTmp = Reis::getSomeOptsByTransportType($this->transport_type_id, 'dangerous', null);
             if (!is_null($dangerousTmp) && !empty($this->{$dangerousTmp})) {
                 $criteria->addCondition(':dangerous = t.dangerous');
                 $params[':dangerous'] = $this->{$dangerousTmp};
                 $adrTmp = Reis::getSomeOptsByTransportType($this->transport_type_id, 'ADR', null);
                 if (!is_null($this->{$adrTmp}) && !empty($this->{$adrTmp})) {
                     $criteria->addCondition(':ADR = t.ADR');
                     $params[':ADR'] = $this->{$adrTmp};
                 }
             }
             $criteria->addCondition(':transport_type_id = t.transport_type_id');
             $params[':transport_type_id'] = $this->transport_type_id;
             $arrRel = Reis::getSomeOptsByTransportType($this->transport_type_id, 'relations', []);
             // Yii::log("getCriteria arrRel=[".print_r( $arrRel , true )."],this=[".print_r( $this , true )."]","info");
             foreach ($arrRel as $k => $v) {
                 // k - body , v - body_auto
                 if (!empty($this->{$v})) {
                     // body_list
                     $dataNameRel = Reis::getSomeOptsByTransportType($this->transport_type_id, "{$k}_list", null);
                     if (!is_null($dataNameRel) && method_exists('Reis', $dataNameRel)) {
                         $arrNameRelItems = call_user_func(array('Reis', $dataNameRel));
                         //Yii::log("getCriteria arrNameRelItems=[".print_r( $arrNameRelItems , true )."]","info");
                         $arrIn = [];
                         foreach ($this->{$v} as $v2) {
                             if (isset($arrNameRelItems[$v2])) {
                                 // проверка что в словаре есть такой индекс, защита
                                 $arrIn[] = (int) $v2;
                             }
                         }
                         if (count($arrIn)) {
                             $with[$k] = ['joinType' => 'INNER JOIN', 'condition' => "{$k}.id IN (" . implode(',', $arrIn) . ")"];
                         }
                     }
                 }
             }
         }
     } else {
         Yii::log("getCriteria transport_type_id is false", "info");
     }
     if (false !== $this->price_requested && is_array($this->price_requested)) {
         foreach ($this->price_requested as $v) {
             if (1 == $v) {
                 $criteria->addCondition('t.price_asc = 1');
             } elseif (2 == $v) {
                 $criteria->addCondition('t.price_asc = 0');
             }
         }
     }
     $condition = [];
     if (!empty($this->price_present)) {
         $condition[] = "(cost.value > 0)";
     }
     if (false !== $this->price_methods_of_payment && is_array($this->price_methods_of_payment)) {
         foreach ($this->price_methods_of_payment as $v) {
             if (0 == $v) {
                 $condition[] = "(cost.cash = 0)";
             } elseif (1 == $v) {
                 $condition[] = "(cost.cash = 1)";
             }
         }
     }
     if (false !== $this->price_currency && is_array($this->price_currency)) {
         foreach ($this->price_currency as $v) {
             $condition[] = "(cost.currency_id = {$v})";
         }
     }
     if (!empty($condition)) {
         $with['cost'] = ['joinType' => 'INNER JOIN', 'condition' => implode(' AND ', $condition)];
     }
     $with['user'] = ['with' => ['company']];
     $criteria->addCondition('t.deleted_status=:deleted_status AND company.active = "1"');
     $params[':deleted_status'] = Cargo::DEL_SATUS_ACTIVE;
     $criteria->with = $with;
     $criteria->params = $params;
     $criteria->order = 't.reis_id DESC';
     return $criteria;
 }
コード例 #10
0
 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));
     }
 }