/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { parent::configureFormFields($formMapper); $id = $this->getRequest()->get($this->getIdParameter()); $doctrine = \AppKernel::getStaticContainer()->get('doctrine'); /* @var $em \Doctrine\ORM\EntityManager */ $em = $doctrine->getManager(); if ($id && ($garantie = $em->getRepository('ApplicationSonataClientBundle:Garantie')->find($id))) { //$typeDocumentId = $document->getTypeDocument()->getId(); $formMapper->with(' ')->add('nom_de_la_banques_id_old', 'hidden', array('data' => $garantie->getNomDeLaBanquesId(), 'mapped' => false)); } $formMapper->with($this->getFieldLabel('title'))->add('type_garantie', null, array('label' => $this->getFieldLabel('type_garantie'), 'disabled' => !!$id))->add('montant', new AmountType(), array('data_class' => 'Application\\Sonata\\ClientBundle\\Entity\\Garantie', 'label' => $this->getFieldLabel('montant')))->add('nom_de_lemeteur', null, array('label' => $this->getFieldLabel('nom_de_lemeteur')))->add('nom_de_la_banques_id', 'choice', array('label' => $this->getFieldLabel('nom_de_la_banques_id'), 'data' => $id ? null : 1, 'choices' => Garantie::getNomDeLaBanques()))->add('num_de_ganrantie', null, array('label' => $this->getFieldLabel('num_de_ganrantie'), 'data' => $id ? null : 'sans référence'))->add('date_demission', null, array('label' => $this->getFieldLabel('date_demission'), 'attr' => array('class' => 'datepicker'), 'widget' => 'single_text', 'input' => 'datetime', 'format' => $this->date_format_datetime))->add('date_decheance', null, array('label' => $this->getFieldLabel('date_decheance'), 'attr' => array('class' => 'datepicker'), 'widget' => 'single_text', 'input' => 'datetime', 'format' => $this->date_format_datetime))->add('expire', null, array('label' => $this->getFieldLabel('expire')))->add('note', null, array('label' => $this->getFieldLabel('note'))); }
/** * @return array */ protected function makeExportData() { $rows = array(); $rows[] = $this->excelHeader(); /** @var $em \Doctrine\ORM\EntityManager */ $em = \AppKernel::getStaticContainer()->get('doctrine'); /** @var $query \Doctrine\ORM\QueryBuilder */ $object = $em->getRepository('ApplicationSonataClientBundle:Garantie')->createQueryBuilder('g')->orderBy('g.date_decheance', 'ASC')->getQuery()->execute(); $nom_de_la_banques = Garantie::getNomDeLaBanques(); foreach ($object as $key => $row) { $date_decheance = $row->getDateDecheance() ? \PHPExcel_Shared_Date::PHPToExcel($row->getDateDecheance()) : ''; /** @var $row Garantie */ $cell = array('client' => (string) $row->getClient(), 'date_decheance' => $date_decheance, 'montant' => $row->getMontant(), 'nom_de_la_banques_id' => isset($nom_de_la_banques[$row->getNomDeLaBanquesId()]) ? $nom_de_la_banques[$row->getNomDeLaBanquesId()] : '', 'num_de_ganrantie' => $row->getNumDeGanrantie(), 'note' => $row->getNote(), 'client_date_fin_mission' => $row->getClient()->getDateFinMission() ? \PHPExcel_Shared_Date::PHPToExcel($row->getClient()->getDateFinMission()) : '', 'calc_day_date_decheance' => $date_decheance ? '=B' . ($key + 2) . '-TODAY()' : ''); //format $this->excelCellFormat($key + 2, $row); $rows[] = $cell; } return $rows; }
/** *statut | nom_de_la_banques_id */ protected function _getNomDeLaBanquesId($value) { //return $this->_getStatutDocument($value); $choices = array_flip(\Application\Sonata\ClientBundle\Entity\Garantie::getNomDeLaBanques()); if (isset($choices[$value])) { return $choices[$value]; } if ('obtenu' == strtolower($value)) { return 0; } return $value; }