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(); } }
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; }
</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()
} 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 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
$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);
$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); } } /*