<?php
namespace Modules\Partners\DueDatesManagement;

class View_Index extends \App\Mvc\View_Popup_FormAbstract
{
	public function renderDueDatesRow($matrix, $index, $counter)
	{

		// we need to do this because the standard Smarty template is not implicitly called (JS error when adding new elements);
		$CSS = \Engine\Theme\CSSLoader\CSSLoader::getInstance();
		$JS = \Engine\Theme\JSLoader\JSLoader::getInstance();
		$CSS->initializeRequestKeyFromMvcView($this);
		$CSS->preload();
		$JS->preload();

		// the smarty manipulation is an ugly fix to make sure the module $lang is assigned to $smarty, instead of makinmg the input load its own lang file
		\Theme::getInstance()->stdModuleSmartyAssign($this);
		$this->render_prepare(\Engine\Smarty\SmartyMultiton::getInstance());

		$responseRow = '';
		for ($i = $index; $i < ($index+$counter); $i++) {
			$responseRow.= $matrix->getRow('Engine\Form\Input\Matrix\Row')
				->setIndex($i)
				->setValue([])
				->setStyle('class_body', 'clone')
				->render();
		}

		return $responseRow;
	}
}