本文整理汇总了PHP中UserAction::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAction::execute方法的具体用法?PHP UserAction::execute怎么用?PHP UserAction::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAction
的用法示例。
在下文中一共展示了UserAction::execute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$em = $this->em();
$form = $this->prepareForm(new \ru\nazarov\crm\forms\OfferForm('offer-form', 'Add offer', '/?action=add_offer', \ru\nazarov\crm\forms\Form::METHOD_POST, 'multipart/form-data'));
if (!$form->isEmpty() && $form->validate()) {
//$offerId = $em->getRepository('\ru\nazarov\crm\entities\OfferId')->findOneBy(array());
$offer = new \ru\nazarov\crm\entities\Offer();
$offer->setOrg($em->find('\\ru\\nazarov\\crm\\entities\\Organization', $form->get('org')));
$offer->setApp($em->find('\\ru\\nazarov\\crm\\entities\\Application', $form->get('app')));
$offer->setDate(new \DateTime($form->get('date')));
$offer->setComment($form->get('comment'));
$offer->setLegalEntity($_SESSION['le']);
$offer->setOfferId($form->get('offer_id'));
//$offer->setOfferId($offerId->getPrefix() . str_pad($offerId->getNextId(), 4, '0', STR_PAD_LEFT));
$em->persist($offer);
//$offerId->setNextId($offerId->getNextId() + 1);
$em->flush();
if (($attachments = $form->get(AddAppAction::ATTACHMENT_KEY)) != null) {
\ru\nazarov\sitebase\Facade::saveAttachments($offer->getId(), 'offer', $attachments);
$em->flush();
}
$form->clean();
}
if ($form->get('org') == null) {
$form->set('org', 'undef');
}
$form->setFieldVals('org', \ru\nazarov\sitebase\Facade::getPersonFormOrgsSelectDp());
$this->view()->set('form', $form)->set('apps', \ru\nazarov\sitebase\Facade::getAppsSelectDp());
parent::execute();
}
示例2: execute
public function execute()
{
$em = $this->em();
$form = $this->prepareForm(new \ru\nazarov\crm\forms\AppForm('app-form', 'Add request', '/?action=add_app', \ru\nazarov\crm\forms\Form::METHOD_POST, 'multipart/form-data'));
if (!$form->isEmpty() && $form->validate()) {
$app = new \ru\nazarov\crm\entities\Application();
$app->setClient($em->find('\\ru\\nazarov\\crm\\entities\\Organization', $form->get('client')));
$app->setSupplier($em->find('\\ru\\nazarov\\crm\\entities\\Organization', $form->get('supplier')));
$app->setDate(new \DateTime($form->get('date')));
$app->setComment($form->get('comment'));
$app->setLegalEntity($_SESSION['le']);
$em->persist($app);
$em->flush();
\ru\nazarov\sitebase\Facade::notifyHeads('New request.', 'New request added.', '/?action=edit_app&id=' . $app->getId());
if (($attachments = $form->get(self::ATTACHMENT_KEY)) != null) {
\ru\nazarov\sitebase\Facade::saveAttachments($app->getId(), 'application', $attachments);
$em->flush();
}
$form->clean();
}
$form->setFieldVals('supplier', array_map(function ($org) {
return (object) array('label' => htmlspecialchars($org->getName()), 'val' => $org->getId());
}, $em->getRepository('\\ru\\nazarov\\crm\\entities\\Organization')->findBy(array('type' => 1), array('name' => 'ASC'))))->setFieldVals('client', array_map(function ($org) {
return (object) array('label' => htmlspecialchars($org->getName()), 'val' => $org->getId());
}, $em->getRepository('\\ru\\nazarov\\crm\\entities\\Organization')->findBy(array('type' => 2), array('name' => 'ASC'))));
$view = $this->view();
$view->set('form', $form);
parent::execute();
}
示例3: execute
public function execute()
{
try {
$req = $this->request();
$id = $req->get('id');
if ($id === null || ($this->_item = $this->em()->find($this->_entityCls, $id)) == null) {
$this->error($this->_invalidIdMsg);
return;
}
if ($req->get('submit') !== null) {
$this->_form = $form = $this->prepareForm(new $this->_formCls($this->_formId, $this->_formName, $this->_formAct . "&id=" . $this->_item->getId(), $this->_formMethod, $this->_formEnctype, 'save'));
if ($this->_form->validate()) {
$em = $this->em();
$this->_item = $em->find($this->_entityCls, $id);
$this->setItemFields();
$em->flush();
Application::instance()->redirect($this->_redirectUrl);
return;
}
}
parent::execute();
} catch (\ru\nazarov\crm\exceptions\ErrorException $e) {
$this->error($e->mes, $e->back);
}
}
示例4: execute
public function execute()
{
$em = $this->em();
$form = $form = $this->prepareForm(new \ru\nazarov\crm\forms\StoreItemForm('store-item-form', 'Add store item', '/?action=add_store_item', \ru\nazarov\crm\forms\Form::METHOD_POST));
if (!$form->isEmpty() && $form->validate()) {
$item = new \ru\nazarov\crm\entities\StoreItem();
$item->setAmount($form->get('amount'));
$item->setCode($form->get('code'));
$item->setComment($form->get('comment'));
$item->setDescription($form->get('desc'));
$item->setManufacturerCode($form->get('mancode'));
$item->setMinAmount($form->get('minamount'));
$item->setSupplierCode($form->get('supcode'));
$em->persist($item);
$em->flush();
$form->clean();
}
$this->view()->set('form', $form);
parent::execute();
}
示例5: execute
public function execute()
{
$em = $this->em();
$form = $this->prepareForm(new \ru\nazarov\crm\forms\PersonForm('person-form', 'Add person', '/?action=add_person', \ru\nazarov\crm\forms\Form::METHOD_POST));
if (!$form->isEmpty() && $form->validate()) {
$p = new \ru\nazarov\crm\entities\Person();
$p->setName($form->get('name'));
$p->setOrganization($em->find('\\ru\\nazarov\\crm\\entities\\Organization', $form->get('org')));
$p->setPosition($form->get('pos'));
$p->setComment($form->get('comment'));
$p->setLegalEntity($_SESSION['le']);
$em->persist($p);
$contacts = $form->get(self::CONTACT_VALUES_KEY);
if ($contacts != null) {
foreach ($form->get(self::CONTACT_TYPES_KEY) as $i => $type) {
$c = new \ru\nazarov\crm\entities\Contact();
$c->setPerson($p);
$c->setType($em->find('\\ru\\nazarov\\crm\\entities\\ContactType', $type));
$c->setValue($contacts[$i]);
$em->persist($c);
}
}
$em->flush();
$form->clean();
}
$view = $this->view();
$view->set('form', $form)->set('contact_types_key', self::CONTACT_TYPES_KEY)->set('contact_ids_key', self::CONTACT_ID_KEY)->set('contact_values_key', self::CONTACT_VALUES_KEY);
$form->setFieldVals('org', \ru\nazarov\sitebase\Facade::getPersonFormOrgsSelectDp());
if ($form->get('org') == null) {
$form->set('org', 'undef');
}
if (count($types = $form->get(self::CONTACT_TYPES_KEY)) > 0) {
$view->set('contacts', array_map(function ($type, $val) {
return (object) array('type' => $type, 'val' => $val);
}, $types, $form->get(self::CONTACT_VALUES_KEY)));
}
parent::execute();
}
示例6: execute
public function execute()
{
$em = $this->em();
$form = $this->prepareForm(new \ru\nazarov\crm\forms\ReportForm('report-form', 'Add report', '/?action=add_report', \ru\nazarov\crm\forms\Form::METHOD_POST));
if (!$form->isEmpty() && $form->validate()) {
$r = new \ru\nazarov\crm\entities\Report();
$r->setComment($form->get('comment'));
$r->setContact($em->find('\\ru\\nazarov\\crm\\entities\\Contact', $form->get('contact')));
$r->setDate(new \DateTime($form->get('date')));
$r->setLegalEntity($_SESSION['le']);
$r->setApp($em->find('\\ru\\nazarov\\crm\\entities\\Application', $form->get('app')));
$em->persist($r);
$em->flush();
\ru\nazarov\sitebase\Facade::notifyHeads('New report.', 'New report added.', '/?action=edit_report&id=' . $r->getId());
$form->clean();
}
$types = array_map(function ($type) {
return (object) array('label' => $type->getCode(), 'val' => $type->getId());
}, $em->getRepository('\\ru\\nazarov\\crm\\entities\\OrganizationType')->findAll());
//$form->setFieldVals('type', $types);
$this->view()->set('form', $form)->set('types', $types);
parent::execute();
}
示例7: execute
public function execute()
{
$em = $this->em();
$form = $this->prepareForm(new \ru\nazarov\crm\forms\AddOrgForm('org-form', 'Add organization', '/?action=add_org', \ru\nazarov\crm\forms\Form::METHOD_POST));
if (!$form->isEmpty() && $form->validate()) {
$org = new \ru\nazarov\crm\entities\Organization();
$org->setName($form->get('name'));
$org->setType($em->find('\\ru\\nazarov\\crm\\entities\\OrganizationType', $form->get('type')));
$org->setAddress($form->get('address'));
$org->setCountry($form->get('country'));
$org->setPhone($form->get('phone'));
$org->setSite($form->get('site'));
$org->setLegalEntity($_SESSION['le']);
$em->persist($org);
$em->flush();
$form->clean();
}
$types = array_map(function ($t) {
return (object) array('label' => $t->getCode(), 'val' => $t->getId());
}, $em->getRepository('\\ru\\nazarov\\crm\\entities\\OrganizationType')->findAll());
$form->setFieldVals('type', $types);
$this->view()->set('form', $form);
parent::execute();
}