@ 2014-04-03T19:21:27Z <?php
namespace AdminModule;
use Nette\Application\UI;
/**
* Description of InvoiceDateForm
*
* @author Richard Kapička, http://richard.kapicka.cz
* @copyright 2014
*/
class InvoiceDateForm extends UI\Form
{
/**
* @var \AdminModule\Models\InvoiceModel
*/
private $invoiceModel;
/**
* @var \AdminModule\Models\ProjectModel(
*/
private $projectModel;
/**
* @var \Xprom\FlexiBee
*/
private $flexiBee;
/**
* @param \AdminModule\Models\InvoiceModel
* @param \AdminModule\Models\ProjectModel
* @param \Xprom\FlexiBee
*/
public function __construct(\AdminModule\Models\InvoiceModel $im, \AdminModule\Models\ProjectModel $pm, \Xprom\FlexiBee $fb)
{
parent::__construct();
$this->invoiceModel = $im;
$this->projectModel = $pm;
$this->flexiBee = $fb;
}
/**
* @return \Nette\Forms\Form
*/
public function builForm()
{
$form = $this->form;
$_this = $this;
$form->addDynamic('projects', function(\Nette\Forms\Container $container) use($_this) {
$container->addHidden('id');
$container->addHidden('phaseId');
$container->addDatePicker('date_transfer')
->controlPrototype->class('input-small no-margin');
$container->addSubmit('submit', 'Převést')
->onClick[] = $_this->formSuccess;
$container['submit']->controlPrototype->class('btn btn-success');
}, 1);
return $form;
}
/**
* @param \Nette\Forms\Controls\SubmitButton
*/
public function formSuccess(\Nette\Forms\Controls\SubmitButton $button)
{
$values = $button->form->getValues();
$errors = array();
if (isset($values->projects->{$button->parent->name}) && !empty($values->projects->{$button->parent->name}->date_transfer)) {
$section = $values->projects->{$button->parent->name};
$pr = $this->projectModel->getProjectByPhaseId($section->phaseId);
$phase = $this->projectModel->getPhaseById($section->phaseId);
if (!is_null($phase->date_invoice_transfer) && $phase->date_invoice_transfer->format('Y-m-d') >= $section->date_transfer->format('Y-m-d')) {
$errors[] = 'Datum převodu musí být větší než datum posledního převodu!';
} else {
// This is first invoice for this phase
if (is_null($phase->date_invoice_transfer)) { // Only on firt invoice set SDZ && VDZ (signs pay by amount)
// Create FlexiBee record
$fbResult = $this->flexiBee->addOrder(
$phase->id,
$pr->number,
$pr->name,
$pr->place,
$pr->note,
$pr->bil_name,
$pr->bil_street,
$pr->bil_city,
$pr->bil_postcode,
$pr->bil_cin,
$pr->bil_tin,
array('pdz', 'sdz', 'vdz'),
NULL,
$section->date_transfer
);
} else {
// Create FlexiBee record
$fbResult = $this->flexiBee->addOrder(
$phase->id,
$pr->number,
$pr->name,
$pr->place,
$pr->note,
$pr->bil_name,
$pr->bil_street,
$pr->bil_city,
$pr->bil_postcode,
$pr->bil_cin,
$pr->bil_tin,
array('pdz'),
$phase->date_invoice_transfer,
$section->date_transfer
);
}
if ($fbResult === TRUE) {
$this->invoiceModel->setDateInvoiceTransferBy($section->date_transfer, array('id_project' => $pr->id, 'id' => $phase->id));
} else {
$errors[] = 'FlexiBee převod nebyl uskutečněn, jelikož dané období neobsahuje žádná data.';
}
}
}
if (count($errors)) {
foreach ($errors as $error) {
$button->form->addError((string) $error);
}
} else {
$this->presenter->redirect('this');
}
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught Error: Class "Nette\Application\UI\Form" not found in /in/QdOOu:13
Stack trace:
#0 {main}
thrown in /in/QdOOu on line 13
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
47.8 ms | 401 KiB | 8 Q