public function create() { $customerId = $this->request_stack["arguments"][0]; $customer = CustomerQuery::create()->findOneById($customerId); $projects = $customer->getProjects(); $invoice = new Invoice(); $invoice->setCreated(time())->setDue(time() + 36000)->setPaid(0)->setCustomer($customer)->save(); foreach ($projects as $project) { $tasks = $project->getTasks(); foreach ($tasks as $task) { $bill = new Bill(); $bill->setTask($task)->setInvoice($invoice)->save(); } } $this->getRequest()->redirect("invoice", "index"); }
public function executeIndex(sfWebRequest $request) { $namespace = $request->getParameter('searchNamespace'); $search = $this->getUser()->getAttribute('search', null, $namespace); $sort = $this->getUser()->getAttribute('sort', array('name', 'desc'), $namespace); $page = $this->getUser()->getAttribute('page', 1, $namespace); $maxResults = $this->getUser()->getPaginationMaxResults(); $q = CustomerQuery::create()->search($search)->orderBy("{$sort['0']} {$sort['1']}, name {$sort['1']}"); $date_range = array(); $date_range['from'] = isset($search['from']) ? $search['from'] : null; $date_range['to'] = isset($search['to']) ? $search['to'] : null; $this->date_range = $date_range; // totals $this->gross = $q->total('gross_amount'); $this->due = $q->total('due_amount'); $this->pager = new sfDoctrinePager('Customer', $maxResults); $this->pager->setQuery($q); $this->pager->setPage($page); $this->pager->init(); $this->getUser()->setAttribute('page', $request->getParameter('page')); $this->sort = $sort; }
public function deleteCustomer($id) { CustomerQuery::create()->findOneById($id)->getPerson()->delete(); CustomerQuery::create()->findOneById($id)->delete(); }