<?php

require_once dirname(__FILE__) . '/../lib/product_propGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/product_propGeneratorHelper.class.php';

/**
 * product_prop actions.
 *
 * @package    sf
 * @subpackage product_prop
 * @author     Atma
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class product_propActions extends autoProduct_propActions
{
    protected function buildQuery()
    {
        $query = parent::buildQuery();
        $query->leftJoin("r.Translation t");
        return $query;
    }

    public function executeAjax_delete(sfWebRequest $request)
    {
        if ($request->hasParameter('id')) {
            $id = $request->getParameter('id');
            $elem = Doctrine::getTable("ProductPropList")->find($id);
            if ($elem) {
                $elem->delete();
                $response['status'] = 'success';
            } else {
                $response['status'] = 'error';
                $response['errorText'] = 'Не удалось удалить обьект';
            }

        } else {
            $response['status'] = 'error';
            $response['errorText'] = 'Не переданы необходимые параметры';
        }

        echo json_encode($response);

        return sfView::NONE;
    }
}
