X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=controllers%2FItemsController.php;h=17f37b3724085bc70ae2609be7ee0fcbffdbbe3d;hb=fdecb86935b63355c9d7258dd25aa5fa63f2e6b6;hp=95f3fb043826e1a7d830a76e25bcfe8c418c0a28;hpb=d3c6abcb39904ddb59c08542669524f6f445259e;p=invent%2Finvent.git
diff --git a/controllers/ItemsController.php b/controllers/ItemsController.php
index 95f3fb0..17f37b3 100644
--- a/controllers/ItemsController.php
+++ b/controllers/ItemsController.php
@@ -61,7 +61,7 @@ class ItemsController extends Controller
{
$result = [
'id' => FALSE,
- 'error' => Yii::t('items', 'Items: Key field missing "invent", "serial", "model"') . print_r($options, TRUE),
+ 'error' => Yii::t('items', 'Items: Key field missing "invent" :') . print_r($options, TRUE),
];
// ÐÑли Ñказан инвенÑаÑнÑй номеÑ
if (is_array($options) && isset($options[ 'invent' ]))
@@ -87,29 +87,31 @@ class ItemsController extends Controller
$model = ModelsController::addIfNeed($options);
if ($model[ 'id' ] === FALSE)
{
- $result[ 'error' ] .= $model[ 'error' ] . '
';
- }
- // СоздаÑм новÑÑ Ð·Ð°Ð¿Ð¸ÑÑ Ð¿ÑедмеÑа/обоÑÑдованиÑ
- $item = new Items();
- $item->name = isset($options[ 'netName' ]) ? $options[ 'netName' ] : NULL; // СеÑевое имÑ
-
- $item->model_id = $model[ 'id' ]; // иденÑиÑикаÑÐ¾Ñ Ð¼Ð¾Ð´ÐµÐ»Ð¸ (ÐодгоÑовлено Ð´Ð»Ñ Ð¿ÑеобÑазованиÑ)
-
- $item->invent = isset($options[ 'invent' ]) ? $options[ 'invent' ] : NULL; // ÐнвенÑаÑнÑй номеÑ
- $item->comment = isset($options[ 'comment' ]) ? $options[ 'comment' ] : NULL; // ÐоменÑаÑий
- $item->os = isset($options[ 'os' ]) ? $options[ 'os' ] : NULL; // ÐпеÑаÑÐ¸Ð¾Ð½Ð½Ð°Ñ ÑиÑÑема
- $item->mac = isset($options[ 'mac' ]) ? $options[ 'mac' ] : NULL; // MAC-адÑеÑ
- $item->serial = isset($options[ 'serial' ]) ? $options[ 'serial' ] : NULL; // СеÑийнÑй номеÑ
- $item->checked = false; // Ðе инвенÑÑизиÑован (ÑÑебÑÐµÑ Ð²Ð½Ð¸Ð¼Ð°Ð½Ð¸Ñ Ð¿Ð¾Ñле импоÑÑа)
- // СоÑ
ÑанÑем запиÑÑ
- if ($item->validate() && $item->save())
- {
- $result[ 'id' ] = $item->id; // ÐозвÑаÑаем иденÑиÑикаÑÐ¾Ñ Ð·Ð°Ð¿Ð¸Ñанного обоÑÑдованиÑ
- $result[ 'error' ] = '';
+ $result[ 'error' ] .= '
' . $model[ 'error' ];
}
else
{
- $result[ 'error' ] .= Yii::t('items', 'Items: Failed to add entry') . print_r($item->errors(), TRUE);
+ // СоздаÑм новÑÑ Ð·Ð°Ð¿Ð¸ÑÑ Ð¿ÑедмеÑа/обоÑÑдованиÑ
+ $item = new Items();
+ $item->name = isset($options[ 'netName' ]) ? $options[ 'netName' ] : NULL; // СеÑевое имÑ
+
+ $item->model_id = $model[ 'id' ]; // иденÑиÑикаÑÐ¾Ñ Ð¼Ð¾Ð´ÐµÐ»Ð¸ (ÐодгоÑовлено Ð´Ð»Ñ Ð¿ÑеобÑазованиÑ)
+ $item->invent = isset($options[ 'invent' ]) ? $options[ 'invent' ] : NULL; // ÐнвенÑаÑнÑй номеÑ
+ $item->comment = isset($options[ 'comment' ]) ? $options[ 'comment' ] : NULL; // ÐоменÑаÑий
+ $item->os = isset($options[ 'os' ]) ? $options[ 'os' ] : NULL; // ÐпеÑаÑÐ¸Ð¾Ð½Ð½Ð°Ñ ÑиÑÑема
+ $item->mac = isset($options[ 'mac' ]) ? $options[ 'mac' ] : NULL; // MAC-адÑеÑ
+ $item->serial = isset($options[ 'serial' ]) ? $options[ 'serial' ] : NULL; // СеÑийнÑй номеÑ
+ $item->checked = false; // Ðе инвенÑÑизиÑован (ÑÑебÑÐµÑ Ð²Ð½Ð¸Ð¼Ð°Ð½Ð¸Ñ Ð¿Ð¾Ñле импоÑÑа)
+ // СоÑ
ÑанÑем запиÑÑ
+ if ($item->validate() && $item->save())
+ {
+ $result[ 'id' ] = $item->id; // ÐозвÑаÑаем иденÑиÑикаÑÐ¾Ñ Ð·Ð°Ð¿Ð¸Ñанного обоÑÑдованиÑ
+ $result[ 'error' ] = '';
+ }
+ else
+ {
+ $result[ 'error' ] .= Yii::t('items', 'Items: Failed to add entry: ') . print_r($item->errors, TRUE) . '
';
+ }
}
}
}
@@ -215,7 +217,7 @@ class ItemsController extends Controller
//$message = '[0] = "' . $keys[0] . '", [1] = "' . $keys[1] . '"
';
foreach ($items as $row)
{
- $message .= $row->model . ' (' . $row->id . ')';
+ $message .= $row->modelName . ' (' . $row->id . ')';
}
if ($message != '')
$message = Yii::t('items', 'Checked item(s): ') . $message;
@@ -287,6 +289,7 @@ class ItemsController extends Controller
// ÐÑовеÑка налиÑÐ¸Ñ ÐºÐ»ÑÑевÑÑ
полей
if ((!isset($arrayRows[ 0 ][ 'model' ]))
+ || (!isset($arrayRows[ 0 ][ 'type' ]))
|| (!isset($arrayRows[ 0 ][ 'invent' ]))
|| (!isset($arrayRows[ 0 ][ 'location' ]))
|| (!isset($arrayRows[ 0 ][ 'region' ]))
@@ -295,7 +298,7 @@ class ItemsController extends Controller
{
// СообÑение об оÑибке
$arrayReturn[ 'countErrors' ] = count($arrayRows);
- $arrayReturn[ 'errors' ] .= '
' . Yii::t('import', 'Skip all. Key column not found: ') . print_r($arrayRows[0], TRUE);
+ $arrayReturn[ 'errors' ] .= '
' . Yii::t('import', 'Skip all. Key column(s) "model", "type", "invent", "location", "region", "date" not found: ') . print_r($arrayRows[0], TRUE);
}
else
{
@@ -308,7 +311,7 @@ class ItemsController extends Controller
{
// СообÑим об оÑибке
$arrayReturn[ 'countErrors' ]++;
- $arrayReturn[ 'errors' ] .= '
' . Yii::t('import', 'Location: {location} ({region})', $row) . ' :: ' . $location[ 'error' ];
+ $arrayReturn[ 'errors' ] .= '
' . $location[ 'error' ];
}
else
{
@@ -354,7 +357,7 @@ class ItemsController extends Controller
else
{
// ÐапиÑÑ Ð½Ðµ ÑдалаÑÑ, пÑобÑем ÑдалиÑÑ Ð¿ÑедмеÑ/обоÑÑдование
- Items::find()->where([ 'id' => $item_id, 'checked' => FALSE ])->one()->delete();
+ Items::find()->where([ 'id' => $item[ 'id' ], 'checked' => FALSE ])->one()->delete();
// СообÑим об оÑибке
$arrayReturn[ 'countErrors' ]++;
$arrayReturn[ 'errors' ] .= '
' . Yii::t('import', 'Moving: {date} (') . $moving->errors['date'][0]. Yii::t('import', '), Inventory number:{invent}, model: {model}, location: {location} ( {region} )' , $row);
@@ -423,13 +426,13 @@ class ItemsController extends Controller
if (count($columns) == 0)
{
// ÐÑем ÑÑÑÐ¾ÐºÑ Ñ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ¾Ð¼ ÑаблиÑÑ
- if ( stripos($row[0], $columnNames[ 'npp' ]) !== FALSE )
+ if ( stripos($row[0], $columnsNames[ 'npp' ]) !== FALSE )
{
// ÐеÑебиÑаем вÑе колонки
foreach ($row as $key => $item)
{
// ÐеÑебиÑаем вÑе Ð½Ð°Ð·Ð²Ð°Ð½Ð¸Ñ Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ¾Ð² колонок
- foreach($columnNamses as $name => $text)
+ foreach($columnsNames as $name => $text)
{
// ÐÑли название Ñовпало,
if (stripos($item, $text) !== FALSE)