<?php
$trosk = $modx->getService('trosk','Trosk',$modx->getOption('doodles.core_path',null,$modx->getOption('core_path').'components/trosk/').'model/trosk/',$scriptProperties);
if (!($trosk instanceof Trosk)) return 'err';


	$projectId = $_REQUEST['proj_id'];
	return ($trosk->lastNSaved($projectId,3));

/*

	$tpl='fem.trosk.savedStavka';
	$criteria=$modx->newQuery('items');
	$criteria->where(array(
		'project_id' => $projectId,
	));
	$criteria->sortBy('id','DESC');
	$criteria->limit(3);
    $stavke=$modx->getCollection('items',$criteria);
	foreach ($stavke as $stavka) {
	    $stavkaArray = $stavka->toArray();
		$output .= $modx->getChunk($tpl,$stavkaArray);
	};
   	return $output;
	$parentId=$_REQUEST['par_id'];
	$childIds=$modx->getChildIds($parentId,1);
	if(empty($childIds)){
		$catId=$modx->getParentIds($parentId,1);
		$parentChildIds=$modx->getChildIds($catId,1);
		$criteria=$modx->newQuery('items');
	    $criteria->where(array(
	         'original_id:IN' => $parentChildIds,
	    ));
		$criteria->sortBy('id','ASC');
    	$stavke=$modx->getCollection('items',$criteria);
	    foreach ($stavke as $stavka) {
	      $stavkaArray = $stavka->toArray();
	      $output .= $modx->getChunk($tpl,$stavkaArray);
	    };
	    return $output;
	}
*/