public function executeDsrmulti(sfWebRequest $request) { $requestparams = $request->getParameter("invoice"); $day = $requestparams["date"]["day"]; $month = $requestparams["date"]["month"]; $year = $requestparams["date"]["year"]; $invoice = new Invoice(); if (!$day or !$month or !$year) { $invoice->setDate(MyDate::today()); } else { $invoice->setDate($year . "-" . $month . "-" . $day); } $requestparams = $request->getParameter("purchase"); $day = $requestparams["date"]["day"]; $month = $requestparams["date"]["month"]; $year = $requestparams["date"]["year"]; $purchase = new Purchase(); if (!$day or !$month or !$year) { $purchase->setDate(MyDate::today()); } else { $purchase->setDate($year . "-" . $month . "-" . $day); } $this->form = new InvoiceForm($invoice); $this->toform = new PurchaseForm($purchase); $this->invoices = InvoiceTable::fetchByDateRange($invoice->getDate(), $purchase->getDate()); $this->events = EventTable::fetchByDatenParentclass($invoice->getDate(), "Invoice"); $this->cashsales = 0; $this->chequesales = 0; $this->creditsales = 0; $this->cashother = 0; $this->chequeother = 0; $this->creditother = 0; $this->cashtotal = 0; $this->chequetotal = 0; $this->credittotal = 0; $this->deducttotal = 0; $this->templates = Doctrine_Query::create()->from('InvoiceTemplate t')->orderBy('id')->execute(); //calculations start //no tmc so, no lesley, no interoffice foreach ($this->templates as $template) { //end no tmc so, no lesley, no interoffice foreach ($this->invoices as $invoice) { if ($invoice->getIsTemporary() == 0) { if ($invoice->getTemplateId() == $template->getId()) { if ($invoice->getStatus() != "Cancelled") { if ($invoice->getHidden() == 0) { $this->cashsales += $invoice->getCash(); $this->chequesales += $invoice->getChequeamt(); $this->creditsales += $invoice->getCredit(); $this->cashtotal += $invoice->getCash(); $this->chequetotal += $invoice->getChequeamt(); $this->credittotal += $invoice->getCredit(); $this->deducttotal += $invoice->getDsrdeduction(); } } } } } //no tmc so, no lesley, no interoffice } //end no tmc so, no lesley, no interoffice /* //hide events foreach($this->events as $event) { $invoice=$event->getParent(); if($invoice->getStatus()!="Cancelled") { $this->cashother+=$event->getDetail("cashamt"); $this->chequeother+=$event->getDetail("chequeamt"); $this->creditother+=$event->getDetail("creditamt"); $this->cashtotal+=$event->getDetail("cashamt"); $this->chequetotal+=$event->getDetail("chequeamt"); $this->credittotal+=$event->getDetail("creditamt"); $this->deducttotal+=$event->getDetail3(); } } */ $this->total = $this->cashtotal + $this->chequetotal + $this->credittotal; }
public function executeDsrmulti(sfWebRequest $request) { $requestparams = $request->getParameter("invoice"); $day = $requestparams["date"]["day"]; $month = $requestparams["date"]["month"]; $year = $requestparams["date"]["year"]; $invoice = new Invoice(); if (!$day or !$month or !$year) { $invoice->setDate(MyDate::today()); } else { $invoice->setDate($year . "-" . $month . "-" . $day); } $requestparams = $request->getParameter("purchase"); $day = $requestparams["date"]["day"]; $month = $requestparams["date"]["month"]; $year = $requestparams["date"]["year"]; $purchase = new Purchase(); if (!$day or !$month or !$year) { $purchase->setDate(MyDate::today()); } else { $purchase->setDate($year . "-" . $month . "-" . $day); } $this->form = new InvoiceForm($invoice); $this->toform = new PurchaseForm($purchase); $this->purchases = PurchaseTable::fetchByDateRange($invoice->getDate(), $purchase->getDate()); $this->events = EventTable::fetchByDatenParentclass($purchase->getDate(), "Purchase"); $this->cashsales = 0; $this->chequesales = 0; $this->creditsales = 0; $this->cashother = 0; $this->chequeother = 0; $this->creditother = 0; $this->cashtotal = 0; $this->chequetotal = 0; $this->credittotal = 0; $this->deducttotal = 0; foreach ($this->purchases as $purchase) { if ($purchase->getStatus() != "Cancelled") { $this->cashsales += $purchase->getCash(); $this->chequesales += $purchase->getCheque(); $this->creditsales += $purchase->getCredit(); $this->cashtotal += $purchase->getCash(); $this->chequetotal += $purchase->getCheque(); $this->credittotal += $purchase->getCredit(); //$this->deducttotal+=$purchase->getDsrdeduction(); } } foreach ($this->events as $event) { $purchase = $event->getParent(); if ($purchase->getStatus() != "Cancelled") { $this->cashother += $event->getDetail("cashamt"); $this->chequeother += $event->getDetail("chequeamt"); $this->creditother += $event->getDetail("creditamt"); $this->cashtotal += $event->getDetail("cashamt"); $this->chequetotal += $event->getDetail("chequeamt"); $this->credittotal += $event->getDetail("creditamt"); $this->deducttotal += $event->getDetail3(); } } $this->total = $this->cashtotal + $this->chequetotal + $this->credittotal; }