protected function prepareData() { parent::prepareData(); $em = $this->em(); $attachmentOwnerType = $em->getRepository('\\ru\\nazarov\\crm\\entities\\AttachmentType')->findOneBy(array('code' => 'application')); $attachments = array(); foreach ($em->getRepository('\\ru\\nazarov\\crm\\entities\\Attachment')->findBy(array('type' => $attachmentOwnerType)) as $attachment) { $ownerId = $attachment->getOwner(); if (!array_key_exists($ownerId, $attachments)) { $attachments[$ownerId] = array(); } $attachments[$ownerId][] = $attachment; } $orgs = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Organization')->findBy(array(), array('typeId' => 'ASC', 'name' => 'ASC')); $orgId = $this->request()->get('org'); foreach ($orgs as $org) { if ($org->getId() == $orgId) { break; } } if (isset($org) && $org->getId() != $orgId) { $org = null; } $repo = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Application'); $this->view()->set('content', 'apps_list.tpl')->set('apps', isset($org) ? $repo->findBy(array($org->getType()->getCode() => $org->getId()), array('id' => 'DESC')) : $repo->findBy(array(), array('id' => 'DESC')))->set('attachments', $attachments)->set('orgId', isset($org) ? $org->getId() : null)->set('orgs', $orgs); }
protected function prepareData() { parent::prepareData(); $em = $this->em(); $attachmentOwnerType = $em->getRepository('\\ru\\nazarov\\crm\\entities\\AttachmentType')->findOneBy(array('code' => 'offer')); $attachments = array(); foreach ($em->getRepository('\\ru\\nazarov\\crm\\entities\\Attachment')->findBy(array('type' => $attachmentOwnerType)) as $attachment) { $ownerId = $attachment->getOwner(); if (!array_key_exists($ownerId, $attachments)) { $attachments[$ownerId] = array(); } $attachments[$ownerId][] = $attachment; } $type = $this->request()->get('type'); $types = $em->getRepository('\\ru\\nazarov\\crm\\entities\\OrganizationType')->findAll(); $correctType = false; foreach ($types as $orgType) { if ($orgType->getId() == $type) { $correctType = true; break; } } $em = $this->em(); if ($correctType) { $offersQuery = $em->createQuery('SELECT off FROM \\ru\\nazarov\\crm\\entities\\Offer off JOIN off.org org WHERE org.type=:type ORDER BY off.offerId desc'); $offersQuery->setParameters(array('type' => $type)); $offers = $offersQuery->getResult(); } else { $offers = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Offer')->findBy(array(), array('offerId' => 'DESC')); } $this->view()->set('content', 'offers_list.tpl')->set('attachments', $attachments)->set('offers', $offers)->set('types', $types)->set('filter', $type); }
protected function prepareData() { parent::prepareData(); $this->view()->set('content', 'person_form.tpl')->set('types', array_map(function ($ct) { return (object) array('val' => $ct->getId(), 'lbl' => $ct->getCode()); }, $this->em()->getRepository('\\ru\\nazarov\\crm\\entities\\ContactType')->findAll())); }
protected function prepareData() { parent::prepareData(); $em = $this->em(); $selectsDp = \ru\nazarov\sitebase\Facade::getReportSelectsDps(); $this->view()->set('content', 'report_form.tpl')->set('orgs', $selectsDp->orgs)->set('persons', $selectsDp->persons)->set('contacts', $selectsDp->contacts)->set('apps', $selectsDp->apps)->set('supplierTypeId', $em->getRepository('\\ru\\nazarov\\crm\\entities\\OrganizationType')->findOneBy(array('code' => 'supplier'))->getId())->set('clientTypeId', $em->getRepository('\\ru\\nazarov\\crm\\entities\\OrganizationType')->findOneBy(array('code' => 'client'))->getId()); //->set('apps', array_map(function ($app) { return (object) array('id' => $app->getId()); 'client' => }, )); }
protected function prepareData() { parent::prepareData(); if ($this->_form == null) { $this->_form = $this->prepareForm(new $this->_formCls($this->_formId, $this->_formName, $this->_formAct . "&id=" . $this->_item->getId(), $this->_formMethod, $this->_formEnctype, 'save')); $this->setFormFields(); } $this->fillSelects(); $this->view()->set('content', $this->_tpl)->set('form', $this->_form); }
protected function prepareData() { parent::prepareData(); $em = $this->em(); $orgId = $this->request()->get('org'); $orgs = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Organization')->findBy(array(), array('typeId' => 'ASC', 'name' => 'ASC')); $orgIdCorrect = false; foreach ($orgs as $org) { if ($org->getId() == $orgId) { $orgIdCorrect = true; break; } } $repo = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Person'); $this->view()->set('content', 'persons_list.tpl')->set('orgId', $orgId)->set('orgs', $orgs)->set('persons', $orgIdCorrect ? $repo->findBy(array('organization' => $orgId)) : $repo->findAll()); }
protected function prepareData() { parent::prepareData(); $em = $this->em(); $type = $this->request()->get('type'); $types = $em->getRepository('\\ru\\nazarov\\crm\\entities\\OrganizationType')->findAll(); $correctType = false; foreach ($types as $orgType) { if ($orgType->getId() == $type) { $correctType = true; break; } } $repo = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Organization'); $this->view()->set('content', 'orgs_list.tpl')->set('orgs', $correctType ? $repo->findBy(array('type' => $type), array('name' => 'ASC')) : $repo->findBy(array(), array('name' => 'ASC')))->set('types', $types)->set('filter', $type); }
protected function prepareData() { parent::prepareData(); $em = $this->em(); $storeItem = new \ru\nazarov\crm\entities\StoreItem(); $storeItem->setCode('code' . rand(0, 100)); $storeItem->setDescription(md5(rand(0, 1000))); $storeItem->setAmount(rand(100, 10000)); $storeItem->setComment(md5(rand(100, 2355))); $storeItem->setMinAmount(rand(10, 100)); $storeItem->setManufacturerCode(substr(md5(rand(0, 1000)), 10, 5)); $storeItem->setSupplierCode(substr(md5(rand(0, 1000)), 10, 5)); //$em->persist($storeItem); //$em->flush(); $items = array_map(function ($item) { return $item->getJsonable(); }, $em->getRepository('ru\\nazarov\\crm\\entities\\StoreItem')->findAll()); $this->view()->set('content', 'store.tpl')->set('items', $items); }
protected function prepareData() { parent::prepareData(); $em = $this->em(); $orgs = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Organization')->findBy(array(), array('typeId' => 'ASC', 'name' => 'ASC')); $orgId = $this->request()->get('org'); foreach ($orgs as $org) { if ($org->getId() == $orgId) { break; } } $reports = array(); if (isset($org)) { if ($org->getId() != $orgId) { $reports = $em->getRepository('\\ru\\nazarov\\crm\\entities\\Report')->findBy(array(), array('id' => 'DESC')); $org = null; } else { $query = $em->createQuery('SELECT r FROM \\ru\\nazarov\\crm\\entities\\Report r JOIN r.contact c JOIN c.person p JOIN p.organization o WHERE o=:org ORDER BY r.id DESC'); $query->setParameter('org', $org->getId()); $reports = $query->getResult(); } } $this->view()->set('content', 'reports_list.tpl')->set('reports', $reports)->set('orgId', isset($org) ? $org->getId() : null)->set('orgs', $orgs); }
protected function prepareData() { parent::prepareData(); $this->view()->set('content', 'form.tpl'); }
protected function prepareData() { parent::prepareData(); $r = $this->request(); $this->view()->set('content', 'error.tpl')->set('mes', $r->get('mes'))->set('back', $r->get('back')); }
protected function prepareData() { parent::prepareData(); $this->view()->set('content', 'offer_form.tpl')->set('attachment_key', AddAppAction::ATTACHMENT_KEY); }
protected function prepareData() { parent::prepareData(); $this->view()->set('content', 'app_form.tpl')->set('attachment_key', self::ATTACHMENT_KEY); }
protected function prepareData() { parent::prepareData(); $this->em()->find('\\ru\\nazarov\\crm\\entities\\Organization', 1); $this->view()->set('content', 'welcome.tpl'); }