set_price($id,$value);
$array['id'] = $id;
$data = $actions->getItemNew($id);
$array['text'] = $L->Str('new_price').': '.$data['price_action'];
}
$array['result'] = $result;
if(!$result)
$array['text'] = $L->Str('error');
header("Content-Type: application/json; charset=UTF-8");
echo json_encode ($array);
}
if($task == 'set-date') {
$actions = new Actions();
$id = Tools_Http::Post('id', true);
$value = Tools_Http::Post('value');
$result = $actions->set_date($id,$value);
$array['result'] = $result;
$array['id'] = $id;
if($result)
$array['text'] = $L->Str('Dati saglabāti.');
else
$array['text'] = $L->Str('error');
header("Content-Type: application/json; charset=UTF-8");
echo json_encode ($array);
}
if($task == 'homepage-action') {
$id = Tools_Http::Post('id', true);
$value = Tools_Http::Post('value', true);
$actions = new Actions();
$result = $actions->homepage($id,$value);
$array['result'] = $result;
$array['id'] = $id;
if($result)
$array['text'] = $L->Str('Dati saglabāti.');
else
$array['text'] = $L->Str('error');
header("Content-Type: application/json; charset=UTF-8");
echo json_encode ($array);
}
if($task == 'enable_action') {
$actions = new Actions();
$id = Tools_Http::Post('id', true);
$value = Tools_Http::Post('value', true);
$result = $actions->enable($id,$value);
//$result = 1;
$array['result'] = $result;
$array['id'] = $id;
if($result)
$array['text'] = $L->Str('Dati saglabāti.');
else
$array['text'] = $L->Str('error');
header("Content-Type: application/json; charset=UTF-8");
echo json_encode ($array);
}
if($task == 'searchGood') {
$search = Tools_Http::Get('query');
$actions = new Actions();
$result = $actions->searchGood($search);
echo json_encode($result);
exit;
}
if ($task == 'addAction') {
$actions = new Actions();
$data = array(
'id' => Tools_Http::Post('itemid', true),
'goods_id' => Tools_Http::Post('goods_id', true),
'price' => Tools_Http::Post('price'),
'date_end' => Tools_Http::Post('date_end'),
'published' => Tools_Http::Post('published', true),
'show_on_mainpage' => Tools_Http::Post('show_on_mainpage', true)
);
if(!$data['price']) {
$error = $L->Str('Set goods price');
}
if($actions->isActive()) {
$error = $L->Str('already_active');
}
$dateEndHour = Tools_Http::Post('date_end_hour');
if($dateEndHour) {
$data['date_end'] = $data['date_end'] . ' ' . $dateEndHour . ':00:00';
} else {
$data['date_end'] = $data['date_end'] . ' 00:00:00';
}
if ($error) {
?>
} else {
if($data['id']) {
$actions->editItem($data);
$result = $data['id'];
} else {
$result = $actions->addItem($data);
}
?>
}
exit;
}
if (!empty($errors)) {
echo 'ER|'.$err_msg.'|'.implode(',',$errors);
}