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); }
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; } }
function addEntry($date, $qty, $ref_class = null, $ref_id = null, $type = null, $description = null) { $entry = new Stockentry(); $entry->setDate($date); $entry->setQty($qty); $entry->setRefClass($ref_class); $entry->setRefId($ref_id); //add custom fields here $entry->setType($type); $entry->setDescription($description); $entry->setStockId($this->getId()); //get last entry at the point of date given $previous = $this->getLastEntryForDate($date); if ($previous) { //echo "gotchaa"; $entry->setBalance($previous->getBalance() + $qty); //if the same date as previous, if (MyDateTime::frommysql($entry->getDate())->isequalto(MyDateTime::frommysql($previous->getDate()))) { $entry->setPriority($previous->getPriority() + 1); } else { $entry->setPriority(1); } $entry->save(); } else { //echo "gotchab"; //add as first entry $entry->setPriority(1); $entry->setBalance($qty); $entry->save(); } $this->calcFromStockEntry($entry); return $entry; }
<?php echo link_to("Add Quote", "quote/new?vendor_id=" . $vendor->getId()); ?> <table border=1> <tr> <td>Date</td> <td>Product</td> <td>Description</td> <td>Price</td> </tr> <?php foreach ($vendor->getQuote() as $detail) { ?> <tr> <td><?php echo MyDateTime::frommysql($detail->getDate())->toshortdate(); ?> </td> <td><?php echo link_to($detail->getProduct(), "product/view?id=" . $detail->getProductId()); ?> </td> <td><?php echo $detail->getProduct()->getDescription(); ?> </td> <td><?php echo $detail->getPrice(); ?> </td> <td><?php
} else { $pdf->Cell($w, 0, '', 0, 0); } $pdf->ln(); if (array_key_exists(0, $line) and $line[0] >= 0) { $pdf->Cell($w, 0, MyTMC::encode($details[$line[0]]->getUnittotal()) . ' ' . MyDateTime::frommysql($purchase->getDate())->toshortdate(), 0, 0); } else { $pdf->Cell($w, 0, '', 0, 0); } if (array_key_exists(1, $line) and $line[1] >= 0) { $pdf->Cell($w, 0, MyTMC::encode($details[$line[1]]->getUnittotal()) . ' ' . MyDateTime::frommysql($purchase->getDate())->toshortdate(), 0, 0); } else { $pdf->Cell($w, 0, '', 0, 0); } if (array_key_exists(2, $line) and $line[2] >= 0) { $pdf->Cell($w, 0, MyTMC::encode($details[$line[2]]->getUnittotal()) . ' ' . MyDateTime::frommysql($purchase->getDate())->toshortdate(), 0, 0); } else { $pdf->Cell($w, 0, '', 0, 0); } $pdf->ln(); $pdf->SetFont('dejavusans', '', 2, '', true); $pdf->ln(); $pdf->SetFont('dejavusans', '', 8, '', true); } // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output('example_001.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+
<?php class MyDateTime extends DateTime { public function __construct() { } } class MyDateTimeZone extends DateTimeZone { public function __construct() { } } $o = new MyDateTime(); var_dump($o->format("d")); $x = clone $o; var_dump($x->format("d")); clone $o; var_dump(timezone_location_get(clone new MyDateTimezone()));
$pdf->MultiCell($widths[7], $height, $content[7], 1, 'C', 0, 0, '', '', true,0,true); $pdf->MultiCell($widths[8], $height, $content[8], 1, 'C', 0, 1, '', '', true,0,true); } } */ foreach ($invoices as $invoice) { if ($invoice->getIsTemporary() == 0) { if ($invoice->getTemplateId() == $template->getId()) { if ($invoice->getHidden() == 0) { $particularsstring = $invoice->getParticularsString() ? $invoice->getParticularsString() : " "; if ($invoice->getCheque()) { $particularsstring = implode("; ", array($particularsstring, "Cheque no.: " . $invoice->getCheque() . ", " . MyDateTime::frommysql($invoice->getChequeDate())->toshortdate())); } $chequestring = $invoice->getChequeamt() > 0 ? $invoice->getChequeamt() : " "; //if($invoice->getCheque())$chequestring=implode("; ",array($chequestring,"Cheque no.: ".$invoice->getCheque().", ".MyDateTime::frommysql($invoice->getChequeDate())->toshortdate())); $content = array(MyDateTime::frommysql($invoice->getDate())->toshortdate(), $invoice->getCustomer() . " " . $invoice->getCustomerName(), $invoice->getInvno() ? $invoice->getInvno() : " ", $particularsstring, ($invoice->getCash() > 0 and $invoice->getStatus() != "Cancelled") ? $invoice->getCash() : " ", $invoice->getStatus() != "Cancelled" ? $chequestring : " ", ($invoice->getCredit() > 0 and $invoice->getStatus() != "Cancelled") ? $invoice->getCredit() : " ", $invoice->getDiscamt() == 0 ? "" : $invoice->getDiscamt(), $invoice->getEmployee() ? $invoice->getEmployee() : " ", $invoice->getStatus() == "Paid Check" ? $invoice->getCheque() : ($invoice->getStatus() ? $invoice->getStatus() : " ")); $height = 1; foreach ($content as $index => $txt) { $numlines = $pdf->getNumLines($txt, $widths[$index], false, true, '', ''); if ($height < $numlines) { $height = $numlines; } } $height *= 4.5; $pdf->MultiCell($widths[0], $height, $content[0], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[1], $height, $content[1], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[2], $height, $content[2], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[3], $height, $content[3], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[4], $height, $content[4], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[5], $height, $content[5], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[6], $height, $content[6], 1, 'C', 0, 0, '', '', true, 0, true);
<?php use_helper('I18N', 'Date'); echo form_tag_for(new purchaseForm(), "purchase/dsr"); $today = MyDateTime::frommysql($form->getObject()->getDate()); $yesterday = MyDateTime::frommysql($form->getObject()->getDate()); $yesterday->adddays(-1); $tomorrow = MyDateTime::frommysql($form->getObject()->getDate()); $tomorrow->adddays(1); ?> <table> <tr> <td>Date</td> <td><?php echo $form["date"]; ?> </td> <td><input type=submit value=View ></td> </tr> </table> <?php echo link_to("Yesterday", "purchase/dsr?purchase[date][day]=" . $yesterday->getDay() . "&purchase[date][month]=" . $yesterday->getMonth() . "&purchase[date][year]=" . $yesterday->getYear()); ?> <?php echo link_to("Tomorrow", "purchase/dsr?purchase[date][day]=" . $tomorrow->getDay() . "&purchase[date][month]=" . $tomorrow->getMonth() . "&purchase[date][year]=" . $tomorrow->getYear()); ?> <?php echo link_to("Go to DSR Multi Date", "purchase/dsrmulti?invoice[date][day]=" . $today->getDay() . "&invoice[date][month]=" . $today->getMonth() . "&invoice[date][year]=" . $today->getYear() . "&purchase[date][day]=" . $today->getDay() . "&purchase[date][month]=" . $today->getMonth() . "&purchase[date][year]=" . $today->getYear()); ?> </form><h1>Daily Purchases Report </h1>
$height *= 4.5; $pdf->MultiCell($widths[0], $height, $content[0], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[1], $height, $content[1], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[2], $height, $content[2], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[3], $height, $content[3], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[4], $height, $content[4], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[5], $height, $content[5], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[6], $height, $content[6], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[7], $height, $content[7], 1, 'C', 0, 1, '', '', true, 0, true); } } foreach ($purchases as $purchase) { if ($purchase->getTemplateId() == $template_id) { $particularsstring = $purchase->getParticularsString() ? $purchase->getParticularsString() : " "; if ($purchase->getCheque()) { $particularsstring = implode("; ", array($particularsstring, "Cheque no.: " . $purchase->getCheque() . ", " . MyDateTime::frommysql($purchase->getChequeDate())->toshortdate())); } $chequestring = $purchase->getCheque() > 0 ? $purchase->getCheque() : " "; //if($purchase->getCheque())$chequestring=implode("; ",array($chequestring,"Cheque no.: ".$purchase->getCheque().", ".MyDateTime::frommysql($purchase->getChequeDate())->toshortdate())); $content = array($purchase->getVendor(), $purchase->getInvno() ? $purchase->getInvno() : " ", $particularsstring, ($purchase->getCash() > 0 and $invoice->getStatus() != "Cancelled") ? $purchase->getCash() : " ", $purchase->getStatus() != "Cancelled" ? $chequestring : " ", ($purchase->getCredit() > 0 and $purchase->getStatus() != "Cancelled") ? $purchase->getCredit() : " ", $purchase->getEmployee() ? $purchase->getEmployee() : " ", $purchase->getStatus() == "Paid Check" ? $purchase->getCheque() : ($purchase->getStatus() ? $purchase->getStatus() : " ")); $height = 1; foreach ($content as $index => $txt) { $numlines = $pdf->getNumLines($txt, $widths[$index], false, true, '', ''); if ($height < $numlines) { $height = $numlines; } } $height *= 4.5; $pdf->MultiCell($widths[0], $height, $content[0], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[1], $height, $content[1], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[2], $height, $content[2], 1, 'C', 0, 0, '', '', true, 0, true);
$pdf->MultiCell($widths[4], $height, $content[4], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[5], $height, $content[5], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[6], $height, $content[6], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[7], $height, $content[7], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[8], $height, $content[8], 1, 'C', 0, 1, '', '', true, 0, true); } } foreach ($purchases as $purchase) { if ($purchase->getTemplateId() == $template_id) { $particularsstring = $purchase->getParticularsString() ? $purchase->getParticularsString() : " "; if ($purchase->getCheque()) { $particularsstring = implode("; ", array($particularsstring, "Cheque no.: " . $purchase->getCheque() . ", " . MyDateTime::frommysql($purchase->getChequeDate())->toshortdate())); } $chequestring = $purchase->getCheque() > 0 ? $purchase->getCheque() : " "; //if($purchase->getCheque())$chequestring=implode("; ",array($chequestring,"Cheque no.: ".$purchase->getCheque().", ".MyDateTime::frommysql($purchase->getChequeDate())->toshortdate())); $content = array(MyDateTime::frommysql($purchase->getDate())->toshortdate(), $purchase->getVendor() . " " . $purchase->getVendorName(), $purchase->getPono() ? $purchase->getPono() : " ", $particularsstring, ($purchase->getCash() > 0 and $invoice->getStatus() != "Cancelled") ? $purchase->getCash() : " ", $purchase->getStatus() != "Cancelled" ? $chequestring : " ", ($purchase->getCredit() > 0 and $purchase->getStatus() != "Cancelled") ? $purchase->getCredit() : " ", $purchase->getEmployee() ? $purchase->getEmployee() : " ", $purchase->getStatus() == "Paid Check" ? $purchase->getCheque() : ($purchase->getStatus() ? $purchase->getStatus() : " ")); $height = 1; foreach ($content as $index => $txt) { $numlines = $pdf->getNumLines($txt, $widths[$index], false, true, '', ''); if ($height < $numlines) { $height = $numlines; } } $height *= 4.5; $pdf->MultiCell($widths[0], $height, $content[0], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[1], $height, $content[1], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[2], $height, $content[2], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[3], $height, $content[3], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[4], $height, $content[4], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[5], $height, $content[5], 1, 'C', 0, 0, '', '', true, 0, true); $pdf->MultiCell($widths[6], $height, $content[6], 1, 'C', 0, 0, '', '', true, 0, true);
WHERE OrderDate >=? And OrderDate <=? GROUP BY YEAR(OrderDate)'; break; case 'months': $startDate = new DateTime($startDate . '-1-1'); $endDate = new DateTime(date_format($startDate, "Y") . '-12-31 23:59:59'); $de->addParameter($startDate); $de->addParameter($endDate); $de->dataFields = 'name=Month,yAxis=TotalOrder'; $de->sqlStatement = 'SELECT YEAR(OrderDate) AS Year, MONTH(OrderDate) AS Month, SUM(Total) AS TotalOrder FROM Orders WHERE OrderDate >=? And OrderDate <=? GROUP BY YEAR(OrderDate), MONTH(OrderDate) ORDER BY YEAR(OrderDate), MONTH(OrderDate);'; $de->dateGrouping = "Year"; //This setting shows all the months in the year regardless of having data on that month or not. break; case 'days': $startDate = MyDateTime::createFromFormat('Y-M-d H:i:s', $startDate . ' 00:00:00'); $endDate = new DateTime(date_format($startDate, "Y") . '-' . date_format($startDate, "m") . '-' . date_format($startDate, "t") . ' 23:59:59'); $de->addParameter($startDate); $de->addParameter($endDate); $de->dataFields = 'name=Day,yAxis=TotalOrder'; $de->sqlStatement = 'SELECT Day(OrderDate) AS Day, SUM(Total) AS TotalOrder FROM Orders WHERE OrderDate >=? And OrderDate <=? GROUP BY Day(OrderDate) ORDER BY Day(OrderDate);'; $de->dateGrouping = "Month"; //This setting shows all the days in the month regardless of having data on that day or not. break; case 'hours': $startDate = new DateTime($startDate); $endDate = new DateTime(date_format($startDate, "Y") . '-' . date_format($startDate, "m") . '-' . date_format($startDate, "d") . ' 23:59:59'); $de->addParameter($startDate); $de->addParameter($endDate); $de->dataFields = 'name=Hour,yAxis=TotalOrder';
</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 //echo $purchase->getChequeno()
<?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");
function updateParent() { if ($this->getParentClass() == "Purchase" or $this->getParentClass() == "Invoice") { $parent = $this->getParent(); $parent->getUpdateChequedata(); //to show status pending in invoice show if checks not yet cleared: //on event update // if invoice.checkcleardate < event.checkcleardate // invoice.checkcleardate = event.checkcleardate if ($this->getParentClass() == "Invoice") { $parentdate = MyDateTime::frommysql($parent->getCheckcleardate()); $date = MyDateTime::frommysql($this->getCheckcleardate()); if ($parentdate->isearlierthan($date)) { $parent->setCheckcleardate($this->getCheckcleardate()); } $parent->calc(); } $parent->save(); } }
$pdf->MultiCell($widths[2], $height, $content[2], 0, 'R', $content[6] == "Cancelled" ? 1 : 0, 0, '', '', true); $pdf->MultiCell($widths[3], $height, $content[3], 0, 'R', $content[6] == "Cancelled" ? 1 : 0, 0, '', '', true); $pdf->MultiCell($widths[4], $height, $content[4], 0, 'R', $content[6] == "Cancelled" ? 1 : 0, 0, '', '', true); $pdf->MultiCell($widths[5], $height, $content[5], 0, 'R', $content[6] == "Cancelled" ? 1 : 0, 0, '', '', true); $pdf->MultiCell($widths[6], $height, $content[6], 0, 'R', $content[6] == "Cancelled" ? 1 : 0, 1, '', '', true); } //pending is lightgreen $pdf->SetFillColor(127, 255, 127); // $pdf->SetTextColor(128,0,0); // $pdf->SetDrawColor(128, 0, 0); //display pending $contents = array(); foreach ($employeedata as $invoice) { if ($invoice->getStatus() == "Pending") { $count++; $contents[] = array($count, MyDateTime::frommysql($invoice->getDate())->toshortdate(), $invoice, MyDecimal::format($invoice->getTotal()), MyDecimal::format($invoice->getCommissionTotal($employees[$empid])), MyDecimal::format($invoice->getCommission($employees[$empid])), $invoice->getStatus()); } } $widths = array(10, 30, 35, 30, 30, 20, 20); $height = 1; foreach ($contents as $content) { $pdf->MultiCell($widths[0], $height, $content[0], 0, 'R', 1, 0, '', '', true); $pdf->MultiCell($widths[1], $height, $content[1], 0, 'R', 1, 0, '', '', true); $pdf->MultiCell($widths[2], $height, $content[2], 0, 'R', 1, 0, '', '', true); $pdf->MultiCell($widths[3], $height, $content[3], 0, 'R', 1, 0, '', '', true); $pdf->MultiCell($widths[4], $height, $content[4], 0, 'R', 1, 0, '', '', true); $pdf->MultiCell($widths[5], $height, $content[5], 0, 'R', 1, 0, '', '', true); $pdf->MultiCell($widths[6], $height, $content[6], 0, 'R', 1, 1, '', '', true); } } /*