public function executeNew(sfWebRequest $request)
 {
     $this->quote = new Quote();
     $this->quote->setDate(MyDateTime::today()->tomysql());
     $this->quote->setPrice(0);
     $this->quote->setVendorId($request->getParameter("vendor_id"));
     $this->form = $this->configuration->getForm($this->quote);
 }
 public function executeNew(sfWebRequest $request)
 {
     $this->pettycash = new Pettycash();
     $this->pettycash->setDate(MyDateTime::today()->tomysql());
     if ($request->getParameter("pettycashno")) {
         $this->pettycash->setPettycashno($request->getParameter("pettycashno"));
     }
     $this->form = $this->configuration->getForm($this->pettycash);
 }
 public function executeView(sfWebRequest $request)
 {
     $this->account = $this->getRoute()->getObject();
     $this->form = $this->configuration->getForm($this->account);
     $this->startdate = $request->getParameter("startdate") ? $request->getParameter("startdate") : MyDateTime::today()->getstartofmonth()->tomysql();
     $this->enddate = $request->getParameter("enddate") ? $request->getParameter("enddate") : MyDateTime::today()->getendofmonth()->tomysql();
     $startentry = new AccountEntry();
     $startentry->setDate($this->startdate);
     $this->startdateform = new AccountentryForm($startentry);
     $endentry = new AccountEntry();
     $endentry->setDate($this->enddate);
     $this->enddateform = new AccountentryForm($endentry);
     //$accountentries=$account->getAccountEntriesDesc();
     $this->accountentries = $this->account->getAccountEntriesDescByDate($this->startdate, $this->enddate);
 }
      </table>
    </td>
    <td>
			<table>
				<tr>
					<td>Status</td>
					<td><?php 
/*
  if status=paid,
    if checkcleardate > today, 
      status = pending. 
    else 
      status = paid
*/
if ($invoice->getStatus() == "Paid") {
    $today = MyDateTime::today();
    $checkcleardate = MyDateTime::frommysql($invoice->getCheckcleardate());
    $status = "Paid";
    if ($checkcleardate->islaterthan($today)) {
        $status = "Check to clear on " . $checkcleardate->toshortdate();
    }
    echo $status;
} else {
    echo $invoice->getStatus();
}
?>
</td>
				</tr>
				<!--tr>
					<td>Cheque No</td>
					<td><?php 
 public function executeCommission(sfWebRequest $request)
 {
     $requestparams = $request->getParameter("invoice");
     $day = $requestparams["date"]["day"];
     $month = $requestparams["date"]["month"];
     $year = $requestparams["date"]["year"];
     //if no date, date is today. else date is date given
     if (!$year or !$month or !$day) {
         $date = MyDateTime::today();
     } else {
         $date = new MyDateTime($year, $month, $day, 0, 0, 0);
     }
     $invoice = new Invoice();
     $invoice->setDate($date->getstartofmonth()->tomysql());
     $purchase = new Purchase();
     $purchase->setDate($date->getendofmonth()->tomysql());
     $this->date = $date;
     $this->form = new InvoiceForm($invoice);
     $this->toform = new PurchaseForm($purchase);
     //set up an array of employees indexed by employee id
     $this->rawemployees = Doctrine_Query::create()->from('Employee e')->where('e.commission > 0 ')->execute();
     $this->employees = array();
     foreach ($this->rawemployees as $employee) {
         $this->employees[$employee->getId()] = $employee;
     }
     $this->empinvoices = array();
     foreach ($this->employees as $employee) {
         $this->empinvoices[$employee->getId()] = Doctrine_Query::create()->from('Invoice i, i.Employee e, i.Invoicedetail id, id.Product p')->where('i.salesman_id=' . $employee->getId())->andwhere('i.date >= "' . $invoice->getDate() . '"')->andwhere('i.date <=  "' . $purchase->getDate() . '"')->orWhere('i.technician_id=' . $employee->getId())->andwhere('i.date >= "' . $invoice->getDate() . '"')->andwhere('i.date <=  "' . $purchase->getDate() . '"')->orderBy('i.invno')->execute();
     }
     $commissiontotals = array();
     foreach ($this->empinvoices as $empid => $employeedata) {
         $totalcommission = 0;
         foreach ($employeedata as $invoice) {
             if ($invoice->getStatus() == "Paid") {
                 $totalcommission += $invoice->getCommissionTotal($this->employees[$empid]);
             }
         }
         $commissiontotals[$empid] = $totalcommission;
     }
     $this->commissiontotals = $commissiontotals;
     $this->grandtotalcommission = 0;
     foreach ($commissiontotals as $total) {
         $this->grandtotalcommission += $total;
     }
 }
<?php

//include(dirname(__FILE__).'/../bootstrap/unit.php');
//include(dirname(__FILE__).'/../../config/config.php');
//require_once($sf_symfony_lib_dir.'/util/sfCore.class.php');
//sfCore::initSimpleAutoload($sf_symfony_lib_dir.'/util');
//sfCore::initSimpleAutoload(array(
//SF_ROOT_DIR.'/lib/model',
//$sf_symfony_lib_dir.'/vendor/propel'
//));
//set_include_path($sf_symfony_lib_dir.'/vendor'.PATH_SEPARATOR.SF_ROOT_DIR.PATH_SEPARATOR.get_include_path()
// Stub objects and functions for test purposes
class producttypeDataGroupTest
{
    public function myMethod()
    {
    }
}
function throw_an_exception()
{
    throw new Exception('exception thrown');
}
// Initialize the test object
$t = new lime_test(2, new lime_output_color());
$t->diag('Tests for MyDateTime');
$t->isa_ok(MyDateTime::today(), "MyDateTime", "MyDateTime::today() returns a MyDateTime object");
$t->is(MyDateTime::today()->toprettydate(), "November 16, 2010", "MyDateTime::today() returns current date in format of November 16, 2010");