if (isset($nameFilter) && $nameFilter != "") {
if (!empty($nameFilter)) {
- $query->andFilterWhere(['like', '`matrix_erp`.`name`', $nameFilter]);;
+ $query->andFilterWhere(['like', 'matrix_erp.name', $nameFilter]);;
}
}
$test = 1;
$isSetModelsMatrixErpMedia = true;
}
- if ($this->request->isPost && $modelMatrixErp->load($this->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->id]);
+ if ($this->request->isPost && $modelMatrixErp->load($this->request->post()) && $modelMatrixErp->save()) {
+ return $this->redirect(['view', 'id' => $modelMatrixErp->id]);
}
$filterModel = DynamicModel::validateData([
$loadMediaIds = ArrayHelper::getColumn($modelsMatrixErpMedia, 'id');
+ if (!empty(array_filter($loadMediaIds))) {
$MatrixErpMediaOld = MatrixErpMedia::find()->andWhere(['guid' => $modelEdit->guid])->andWhere(['NOT IN','id', $loadMediaIds])->all();
+ }
+ if (!empty($MatrixErpMediaOld)) {
foreach ($MatrixErpMediaOld as $item) {
/** @var MatrixErpMedia $item */
if (!empty($item->file_id)) {
}
$item->delete();
}
+ }
echo $form->field($filterModel, 'groupNameFilter')->dropDownList(array_merge(['' => 'Все'], ArrayHelper::map(
\yii_app\records\MatrixErp::find()
- ->select(['group_name' => new \yii\db\Expression("DISTINCT(`group_name`)")])
+ ->select(['group_name' => new \yii\db\Expression("DISTINCT(group_name)")])
->orderBy(['group_name' => SORT_ASC])
->asArray()
->all(),
}
if (!empty($item->matrixProperty)) {
$matrixPropertyRow = $item->matrixProperty;
- $imageIdRow = $matrixPropertyRow->image_id ?? '-';
+ $imageIdRow = $matrixPropertyRow->image_id;
}
$matrixMediaRow = null;
if (!empty($item->matrixMedia)) {
'type' => BaseColumn::TYPE_STATIC,
'value' => function($data) {
// $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp);
- if (!empty($data)) {
+ if (!empty($data['id'])) {
$query = WriteOffsProductsErp::find()
->andWhere([
'write_offs_products_erp.id' => $data['id'],