public function executeNew(sfWebRequest $request)
 {
     $this->event = new Event();
     //set Default Data
     $this->event->setParentClass($request->getParameter("parent_class"));
     $this->event->setParentId($request->getParameter("parent_id"));
     $parent = $this->event->getParent();
     //validate parent is not cancelled, do nothing
     if ($parent->isCancelled()) {
         $this->redirect("home/error?msg='Cannot create event. This transaction has been cancelled.'");
     }
     //validate parent is not fully paid
     if ($this->event->getParentClass() == "Invoice") {
         $invoice = $this->event->getParent();
         if ($invoice->getStatus() == "Paid") {
             //new invno not unique: error msg and quit
             $message = "Invoice is fully paid";
             $this->getUser()->setFlash('error', $message);
             return $this->redirect($request->getReferer());
         }
     }
     $this->event->setParentName($parent->getName());
     $this->event->setType($request->getParameter("type"));
     $this->event->setDate(MyDate::today());
     if ($request->getParameter("type") == "stockin" or $request->getParameter("type") == "stockout" or $request->getParameter("type") == "stocktrans") {
         EventTable::generate($this->event);
         $this->redirect($request->getReferer());
     }
     $this->form = $this->configuration->getForm($this->event);
 }
 public function executeListcheckedout(sfWebRequest $request)
 {
     $this->invoices = Doctrine_Query::create()->from('Invoice i')->where('date="' . MyDate::today() . '"')->orWhere('is_temporary=1')->execute();
 }
 public function executeNew(sfWebRequest $request)
 {
     $this->stock = new stock();
     $this->stock->setDate(MyDate::today());
     $this->form = $this->configuration->getForm($this->stock);
 }
 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;
 }
 public function executeNew(sfWebRequest $request)
 {
     $this->account = new account();
     $this->account->setDate(MyDate::today());
     $this->form = $this->configuration->getForm($this->account);
 }