Skip to content

Instantly share code, notes, and snippets.

@delbono
Created October 8, 2010 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delbono/616897 to your computer and use it in GitHub Desktop.
Save delbono/616897 to your computer and use it in GitHub Desktop.
<?php
/**
* orderitem actions.
*
* @package ordinativi
* @subpackage orderitem
* @author KEY5
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class orderitemActions extends sfActions
{
public function executeIndex(sfWebRequest $request)
{
$this->ordinativi_order_items = Doctrine::getTable('OrdinativiOrderItem')
->createQuery('a')
->execute();
}
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
die("BATCH CREATE PROCESS VALID");
$ordinativi_order_item = $form->save(); // un metodo save modificato.
} else {
$errors = $form->getErrorSchema()->getErrors();
if (count($errors) > 0)
{
echo 'List of Errors:' . '<br>';
foreach ($errors as $name => $error)
{
echo $name . ': ' . $error . '<BR>';
}
}
die();
}
$request_data = $request->getParameter('ordinativi_order_item');
$this->redirect('orderitem/editPasti/?order='.$request_data['order']);
die("BATCH CREATE PROCESS NOT VALID");
}
public function executeEditPasti(sfWebRequest $request)
{
$this->forward404Unless($order = Doctrine::getTable('OrdinativiOrder')->find(array($request->getParameter('order'))), sprintf('L\'ordine selezionato non esiste (%s).', $request->getParameter('order')));
$this->order = $order;
$this->forward404Unless($this->order);
$ordinativi_items = new OrdinativiOrderItem();
$this->ordered_items = $ordinativi_items->getOrderedItems( $this->order->getId() );
$this->menu = Doctrine::getTable('OrdinativiMenu')->find( $order->getMenuId() );
$ordinativi_weeks = new OrdinativiMenuItemDay();
$this->week = $this->order->getWeekId();
$this->foods = $ordinativi_weeks->getWeekMenus( $order->getMenuId() );
// array('food_choices' => $food_choices , 'food_defaults' => $food_defaults, 'menu' => $this->getRoute()->getObject()->getId(), 'week' => $request->getParameter('week'), 'day' => $request->getParameter('day') )
$this->form = new OrdinativiOrderItemFoodForm(new OrdinativiOrderItem(), array('foods'=>$this->foods, 'ordered_items'=>$this->ordered_items, 'order'=> $this->order->getId() ) );
}
public function executeBatch_create(sfWebRequest $request)
{
$ordinativi_order_item = $request->getParameter('ordinativi_order_item');
$order = Doctrine::getTable('OrdinativiOrder')->find(array((int)$ordinativi_order_item['order']));
$ordinativi_weeks = new OrdinativiMenuItemDay();
$this->foods = $ordinativi_weeks->getWeekMenus( $order->getMenuId() );
$this->form = new OrdinativiOrderItemFoodForm(new OrdinativiOrderItem(), array('foods'=>$this->foods));
$this->processForm($request, $this->form);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment