本文整理汇总了PHP中Invoice::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::fromArray方法的具体用法?PHP Invoice::fromArray怎么用?PHP Invoice::fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice::fromArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeNew
public function executeNew(sfWebRequest $request)
{
$i18n = $this->getContext()->getI18N();
$invoice = new Invoice();
$invoice->fromArray(array('customer_name' => $i18n->__('Client Name'), 'customer_identification' => $i18n->__('Client Legal Id'), 'contact_person' => $i18n->__('Contact Person'), 'invoicing_address' => $i18n->__('Invoicing Address'), 'shipping_address' => $i18n->__('Shipping Address'), 'customer_email' => $i18n->__('Client Email Address')));
$this->invoiceForm = new InvoiceForm($invoice, array('culture' => $this->culture));
$this->title = $i18n->__('New Invoice');
$this->action = 'create';
$this->setTemplate('edit');
}
示例2: generateInvoice
/**
* Generates and saves an invoice based on this recurring
*
* @return Invoice
**/
public function generateInvoice()
{
$i = new Invoice();
// Get Invoice column mapping and intersect with Recurring one
// to remove non common columns. Unset id and type columns.
$iKeys = array_flip(array_keys($i->getTable()->getColumns()));
$data = $this->toArray(false);
unset($data['id'], $data['type'], $data['must_occurrences'], $data['created_at'], $data['last_execution_date'], $data['occurrences']);
$data = array_intersect_key($data, $iKeys);
// Add specific fields for Invoice and hydrate.
$data = array_merge($data, array('recurring_invoice_id' => $this->getId(), 'issue_date' => sfDate::getInstance()->format('Y-m-d'), 'due_date' => sfDate::getInstance()->addDay($this->getDaysToDue())->format('Y-m-d'), 'draft' => false));
$i->fromArray($data);
// Copy Items and taxes
foreach ($this->Items as $item) {
$iTmp = $item->copy(false);
foreach ($item->Taxes as $tax) {
$iTmp->Taxes[] = $tax;
}
$i->Items[] = $iTmp;
}
// copy tags
foreach ($this->getTags() as $tag) {
$i->addTag($tag);
}
if ($i->trySave()) {
$this->setLastExecutionDate(sfDate::getInstance()->format('Y-m-d'));
$this->save();
}
return $i;
}
示例3: dirname
<?php
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../testTools.php';
$browser = new SiwappTestBrowser();
$browser->signin()->info('Test the send email action')->post('/invoices/batch', array('ids' => array(23, 21), 'batch_action' => 'email'))->with('mailer')->begin()->hasSent(2)->checkHeader('Subject', '/Invoicer LTD \\[Invoice: ASET-8\\]/')->checkBody('/\\.*Invoicer LTD/')->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'invoices')->isParameter('action', 'index')->end();
// create to fake invoices to delete them
$inv1 = new Invoice();
$inv2 = new Invoice();
$inv1->fromArray($fake_invoice_array);
$inv2->fromArray($fake_invoice_array);
$inv1->save();
$inv2->save();
$browser->info('Test the batch delete action')->post('/invoices/batch', array('ids' => array($inv1->id, $inv2->id), 'batch_action' => 'delete'))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('doctrine')->begin()->check('Invoice', array('id' => $inv1->id), false)->check('Invoice', array('id' => $inv2->id), false)->end();
示例4: generateInvoice
public function generateInvoice()
{
$invoice = new Invoice();
// Get Invoice column mapping and intersect with Estimate columns
// to remove non common columns. Unset id and type columns.
$iKeys = array_flip(array_keys($invoice->getTable()->getColumns()));
$data = $this->toArray(false);
unset($data['id'], $data['type'], $data['created_at'], $data['updated_at'], $data['draft'], $data['number'], $data['sent_by_email']);
$data = array_intersect_key($data, $iKeys);
$invoice->fromArray($data);
// $invoice->setDraft(true);
$invoice->setIssueDate(sfDate::getInstance()->format('Y-m-d'));
$invoice->setDueDate(sfDate::getInstance()->addMonth()->format('Y-m-d'));
// Copy Items and taxes
foreach ($this->Items as $item) {
$iTmp = $item->copy(false);
foreach ($item->Taxes as $tax) {
$iTmp->Taxes[] = $tax;
}
$invoice->Items[] = $iTmp;
}
// copy tags
foreach ($this->getTags() as $tag) {
$invoice->addTag($tag);
}
if ($invoice->trySave()) {
$invoice->refresh(true)->setAmounts()->save();
return $invoice;
}
return false;
}