本文整理汇总了PHP中Invoice::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::save方法的具体用法?PHP Invoice::save怎么用?PHP Invoice::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* This function is likely never returns
* but anyway handle result and exceptions
* @return Am_Paysystem_Result
*/
function process()
{
$err = $this->invoice->validate();
if ($err) {
throw new Am_Exception_InputError($err[0]);
}
$this->invoice->save();
$plugin = Am_Di::getInstance()->plugins_payment->loadGet($this->invoice->paysys_id);
$this->result = new Am_Paysystem_Result();
$plugin->processInvoice($this->invoice, $this->controller->getRequest(), $this->result);
if ($this->result->isSuccess() || $this->result->isFailure()) {
if ($transaction = $this->result->getTransaction()) {
$transaction->setInvoice($this->invoice);
$transaction->process();
}
}
if ($this->result->isSuccess()) {
$url = REL_ROOT_URL . "/thanks?id=" . $this->invoice->getSecureId('THANKS');
$this->callback($this->onSuccess);
$this->controller->redirectLocation($url, ___("Invoice processed"), ___("Invoice processed successfully"));
// no return Am_Exception_Redirect
} elseif ($this->result->isAction()) {
$this->callback($this->onAction);
$this->result->getAction()->process($this->controller);
// no return Am_Exception_Redirect
} else {
// ($result->isFailure()) {
$this->callback($this->onFailure);
}
return $this->result;
}
示例2: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$houses = House::where('status', '=', 'booked')->where('frequency', '=', 4)->get();
foreach ($houses as $house) {
$hid = $house->id;
$rent = $house->rent;
$water = $house->water;
$garbage = $house->garbage;
$frequency = $house->frequency;
$tenant_id = $house->tenant;
$tenant = Tenant::find($tenant_id);
$t_name = $tenant->name;
$t_agent = $tenant->agent_id;
$balance = $rent + $water + $garbage;
$invoice = new Invoice();
$invoice->type = 'to tenant';
$invoice->houseID = $hid;
$invoice->recipient = $t_name;
$invoice->agent_id = $t_agent;
$invoice->balance = $balance;
$invoice->duedate = '2015/03/21';
$invoice->save();
$invoicedetail = new Invoicedetail();
$invoicedetail->rent = $rent;
$invoicedetail->water = $water;
$invoicedetail->garbage = $garbage;
$invoice->invoicedetail()->save($invoicedetail);
}
}
示例3: store
/**
* Store a newly created resource in storage.
* POST /invoice
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Invoice::$rules);
if ($validator->fails()) {
return Redirect::to('invoice')->withErrors($validator)->withInput(Input::all());
} else {
$invoice = new Invoice();
$invoice->no_inv = Input::get('no_inv');
$invoice->tgl_inv = Input::get('tgl_inv');
$invoice->no_PO = Input::get('no_PO');
$invoice->ship_by = Input::get('ship_by');
$invoice->pay_method = Input::get('pay_method');
$invoice->no_rek = Input::get('no_rek');
$invoice->pelabuhan = Input::get('pelabuhan');
$invoice->carrier = Input::get('carrier');
$invoice->save();
$SPPB = Barang::join('detil_SPPB', 'barang.kode_barang', '=', 'detil_SPPB.kode_barang')->join('SPPB', 'detil_SPPB.no_SPPB', '=', 'SPPB.no_SPPB')->join('PO', 'SPPB.no_SPPB', '=', 'PO.no_SPPB')->where('no_PO', Input::get('no_PO'))->selectRaw('barang.kode_barang as barang, jml_pesan as pesan')->get();
foreach ($SPPB as $key => $value) {
$barang = Barang::find($value->barang);
$barang->jml_barang = $barang->jml_barang - $value->pesan;
$barang->save();
}
Session::flash('message', 'Successfully created invoice!');
return Redirect::to('invoice');
}
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Invoice();
$modelCustomer = new Customer();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Invoice'])) {
$model->attributes = $_POST['Invoice'];
// Si creamos un nuevo Customer hay que guardarlo
if (strlen($model->CustomerID) == 0) {
$modelCustomer->attributes = $_POST['Customer'];
if ($modelCustomer->save()) {
$model->CustomerID = $modelCustomer->ID;
}
} else {
$modelCustomer = Customer::model()->findByPK($model->CustomerID);
$modelCustomer->attributes = $_POST['Customer'];
$modelCustomer->save();
}
if ($model->save()) {
$this->redirect(array('admin'));
}
}
$this->render('create', array('model' => $model, 'modelCustomer' => $modelCustomer));
}
示例5: edit
/**
* Update existing payment
*
* @param void
* @return null
*/
function edit()
{
if ($this->active_payment->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$payment_data = $this->request->post('payment');
if (!is_array($payment_data)) {
$payment_data = array('invoice_id' => $this->active_payment->getInvoiceId(), 'amount' => $this->active_payment->getAmount(), 'comment' => $this->active_payment->getComment());
}
// if
$this->smarty->assign('payment_data', $payment_data);
if ($this->request->isSubmitted()) {
$this->active_invoice->setAttributes($payment_data);
$save = $this->active_payment->save();
if ($save && !is_error($save)) {
flash_success('Payment has been updated');
$this->redirectTo('invoices');
} else {
$this->smarty->assign('errors', $save);
}
// if
}
// if
}
示例6: refundStore
public function refundStore()
{
$input = Input::all();
$v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rentD' => 'required', 'waterD' => 'required', 'electricityD' => 'required', 'grepairs' => 'required', 'Obills' => 'required', 'Tcost' => 'required', 'Sfees' => 'required', 'duedate' => 'required'));
if ($v->passes()) {
$balance = Input::get('rentD') + Input::get('waterD') + Input::get('grepairs') + Input::get('Obills') + Input::get('Tcost') + Input::get('Sfees') + Input::get('electricityD');
$invoice = new Invoice();
$invoice->type = Input::get('type');
$invoice->houseID = Input::get('houseID');
$invoice->recipient = Input::get('tenant');
$invoice->balance = $balance;
$invoice->duedate = Input::get('duedate');
$invoice->save();
$invoicedetail = new Invoicedetail();
$invoicedetail->rentD = Input::get('rentD');
$invoicedetail->waterD = Input::get('waterD');
$invoicedetail->g_repairs = Input::get('grepairs');
$invoicedetail->o_bills = Input::get('Obills');
$invoicedetail->transport_cost = Input::get('Tcost');
$invoicedetail->storage_fees = Input::get('Sfees');
$invoicedetail->electricityD = Input::get('electricityD');
$invoice->invoicedetail()->save($invoicedetail);
return Redirect::intended('admin/invoice');
}
return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
}
示例7: createInvoice
/**
*
* @param type $data
*
* $data = array(
* 'header' => 'Header Text',
* 'invoice_no' => 'Invoice number auto generate',
* 'invoice_of' => 'Invoice type. e.g. quote, po',
* 'ref_id' => 'id of the invoice_of',
* 'ref_number' => 'number the invoice_of',
* 'gst' => 'GST',
* 'items' => array(
* [] => array(
* 'id' => 'db row id of the item',
* 'number' => 'Unique Number of the item',
* 'desc' => 'Description',
* 'qty' => 'Quantity',
* 'price' => 'Each Price',
* 'total' => 'Total', // NULL in case of autocalculate
* ),
* ),
* 'customer' => array( // null to empty
* 'id' => 'Customer ID',
* 'name' => 'Name',
* 'address' => 'Address',
* 'city' => 'City',
* 'postal-code' => 'Postal Code',
* 'province' => 'Province',
* 'country' => 'Country',
* 'email' => 'Email',
* 'phone' => 'Phone',
* ),
* 'supplier' => array( // null to empty
* 'id' => 'Customer ID',
* 'name' => 'Name',
* 'address' => 'Address',
* 'city' => 'City',
* 'postal-code' => 'Postal Code',
* 'province' => 'Province',
* 'country' => 'Country',
* 'email' => 'Email',
* 'phone' => 'Phone',
* ),
* 'total' => 'GST',
* 'sales-person' => 'Sales Person',
* 'ship-date' => 'Ship Date',
* );
*/
function createInvoice($data)
{
App::import('Model', 'InvoiceManager.Invoice');
$invoice = new Invoice();
$data_json = json_encode($data);
$invoice_data['Invoice'] = array('invoice_no' => $data['invoice_no'], 'invoice_of' => $data['invoice_of'], 'ref_id' => $data['ref_id'], 'data_set' => $data_json, 'total' => $data['total'], 'invoice_status_id' => $data['invoice_status_id']);
$invoice_data['InvoiceLog'] = array('invoice_status_id' => $data['invoice_status_id']);
$invoice->create();
$flag = $invoice->save($invoice_data);
return $flag;
}
示例8: actionInvoice
public function actionInvoice()
{
$model = new Invoice();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
/** @var \robokassa\Merchant $merchant */
$merchant = Yii::$app->get('robokassa');
return $merchant->payment($model->sum, $model->id, \skeeks\cms\shop\Module::t('app', 'Refill'), null, Yii::$app->user->identity->email);
} else {
return $this->render('invoice', ['model' => $model]);
}
}
示例9: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$a = new Am_Paysystem_Action_Form(self::URL);
$params = array('jp_item_type' => 'cart', 'jp_item_name' => $invoice->getLineDescription(), 'order_id' => $invoice->public_id, 'jp_business' => $this->getConfig('business'), 'jp_payee' => $invoice->getEmail(), 'jp_shipping' => '', 'jp_amount_1' => $invoice->currency == 'KES' ? $invoice->first_total : $this->exchange($invoice->first_total), 'jp_amount_2' => 0, 'jp_amount_5' => $invoice->currency == 'USD' ? $invoice->first_total : 0, 'jp_rurl' => $this->getPluginUrl('thanks'), 'jp_furl' => $this->getCancelUrl(), 'jp_curl' => $this->getCancelUrl());
$invoice->data()->set('jambopay-terms-KES', $params['jp_amount_1']);
$invoice->data()->set('jambopay-terms-USD', $params['jp_amount_5']);
$invoice->save();
foreach ($params as $k => $v) {
$a->addParam($k, $v);
}
$result->setAction($a);
}
示例10: refundStore
public function refundStore()
{
$input = Input::all();
$ed = Input::get('electricityD');
$rd = Input::get('rentD');
$wd = Input::get('waterD');
$v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rentD' => 'required|numeric|max:' . $rd, 'waterD' => 'required|numeric|max:' . $wd, 'electricityD' => 'required|numeric|max:' . $ed, 'grepairs' => 'required|numeric', 'Obills' => 'required|numeric', 'Tcost' => 'required|numeric', 'Sfees' => 'required|numeric'));
if ($v->passes()) {
$agent_id = Sentry::getUser()->id;
$deposits = Input::get('rentD') + Input::get('waterD') + Input::get('electricityD');
$others = Input::get('grepairs') + Input::get('Obills') + Input::get('Tcost') + Input::get('Sfees');
$amountpaid = $deposits - $others;
$Idate = date('Y-m-d H:i:s');
$balance = 0;
$hid = Input::get('houseID');
$house = House::find($hid);
$houseOccupaied = $house->name;
$totalTo = $house->rentd + $house->waterd + $house->electricityd;
if ($amountpaid > $totalTo) {
return Redirect::back()->withFlashMessage('Sorry the Total Refund has exceeded the deposits, Please try again');
} elseif ($amountpaid < 0) {
return Redirect::back()->withFlashMessage('Sorry check on the Total Deductions not to exceed the deposits');
} else {
$invoice = new Invoice();
$invoice->type = Input::get('type');
$invoice->houseID = $houseOccupaied;
$invoice->recipient = Input::get('tenant');
$invoice->agent_id = $agent_id;
$invoice->amountpaid = 0;
$invoice->balance = $amountpaid;
$invoice->duedate = $Idate;
$invoice->save();
$invoicedetail = new Invoicedetail();
$invoicedetail->rentD = Input::get('rentD');
$invoicedetail->waterD = Input::get('waterD');
$invoicedetail->g_repairs = Input::get('grepairs');
$invoicedetail->o_bills = Input::get('Obills');
$invoicedetail->transport_cost = Input::get('Tcost');
$invoicedetail->storage_fees = Input::get('Sfees');
$invoicedetail->electricityD = Input::get('electricityD');
$invoice->invoicedetail()->save($invoicedetail);
$properties = Property::where('agent_id', '=', Sentry::getUser()->id)->get();
return Redirect::route('refunds', compact('amountpaid', 'properties'))->withFlashMessage('Refund processed successfully');
}
}
return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
}
示例11: store
/**
* Store a newly created resource in storage.
* POST /invoices
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Invoice::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$user = Auth::user();
$this->invoice->biller_id = Input::get('biller_id');
$this->invoice->client_id = Input::get('client_id');
$this->invoice->currency_id = Input::get('currency_id');
$this->invoice->number = Input::get('number');
$this->invoice->subtotal = floatval(Input::get('subtotal'));
$this->invoice->tax_rate_id = Input::get('tax_rate');
$this->invoice->tax_total = floatval(Input::get('invoice_total_tax'));
$this->invoice->total = floatval(Input::get('total'));
$this->invoice->paid = floatval(Input::get('invoice_total_paid'));
$total = floatval(Input::get('total'));
$paid = floatval(Input::get('invoice_total_paid'));
$this->invoice->balance = $total - $paid;
$this->invoice->user_id = $user->id;
$this->note = Input::get('note');
if (Input::has('date')) {
$this->invoice->date = Input::get('date');
}
if (Input::has('due_date')) {
$this->invoice->due_date = Input::get('due_date');
}
if ($this->invoice->save()) {
$item_id = Input::get('item_id');
$name = Input::get('item_name');
$description = Input::get('item_description');
$price = Input::get('item_price');
$quantity = Input::get('item_qty');
$keys = array('item_id', 'name', 'description', 'price', 'quantity');
$items = array();
foreach (array_map(null, $item_id, $name, $description, $price, $quantity) as $key => $value) {
$items[] = array_combine($keys, $value);
}
foreach ($items as $item) {
$itemRecord = array('invoice_id' => $this->invoice->id, 'name' => $item['name'], 'description' => $item['description'], 'price' => floatval($item['price']), 'quantity' => floatval($item['quantity']), 'total' => floatval($item['price']) * floatval($item['quantity']));
Item::create($itemRecord);
}
return Redirect::to('invoices/' . $this->invoice->id . '/edit')->with('success', Lang::get('invoices.message.success.create'));
}
}
示例12: testGetSyncList
/**
* @covers Moneybird\Invoice_Service::getSyncList
*/
public function testGetSyncList()
{
$revision = $this->object->revision;
$this->assertNotNull($revision, 'Invoice ' . self::$invoiceId . ' not in synclist');
$this->object->setData(array('firstname' => 'Test' . time()));
$this->object->save($this->service);
sleep(1);
$newRevision = null;
$syncList = $this->service->getSyncList();
$this->assertInstanceOf('Moneybird\\Invoice_Array', $syncList);
foreach ($syncList as $sync) {
if ($sync->id == self::$invoiceId) {
$newRevision = $sync->revision;
}
}
$this->assertNotNull($newRevision, 'Invoice ' . self::$invoiceId . ' not in synclist');
$this->assertGreaterThan($revision, $newRevision);
}
示例13: store
/**
* Store a newly created resource in storage.
* POST /invoices
*
* @return Response
*/
public function store()
{
$input = Input::all();
$v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rent' => 'required', 'service' => 'required', 'garbage' => 'required', 'water' => 'required', 'security' => 'required', 'electricity' => 'required', 'duedate' => 'required'));
//if validation passes create an invoice
if ($v->passes()) {
$balance = Input::get('rent') + Input::get('water') + Input::get('service') + Input::get('garbage') + Input::get('electricity') + Input::get('security');
$agent_id = Sentry::getUser()->id;
$hid = Input::get('houseID');
$house = House::find($hid);
$houseOccupaied = $house->name;
$htenant = Input::get('tenant');
$tenant_details = Tenant::where('name', $htenant)->get();
foreach ($tenant_details as $tenant_detail) {
$number = $tenant_detail->phone;
$lname = $tenant_detail->lname;
}
$nams = $htenant . ' ' . $lname;
$invoice = new Invoice();
$invoice->type = Input::get('type');
$invoice->houseID = $houseOccupaied;
$invoice->recipient = $nams;
$invoice->agent_id = $agent_id;
$invoice->balance = $balance;
$invoice->duedate = Input::get('duedate');
$invoice->save();
$invoicedetail = new Invoicedetail();
$invoicedetail->rent = Input::get('rent');
$invoicedetail->water = Input::get('water');
$invoicedetail->service = Input::get('service');
$invoicedetail->garbage = Input::get('garbage');
$invoicedetail->electricity = Input::get('electricity');
$invoicedetail->security = Input::get('security');
$invoice->invoicedetail()->save($invoicedetail);
#send an sms to the tenant
$to = $number;
$message = ' Hi ' . $htenant . 'Your invoivce for this month of amount: Ksh. ' . number_format($balance, 2) . ' is due, Please for detailed information login at real-estate.kenya.com';
Queue::push('SendSMS', array('message' => $message, 'number' => $to));
return Redirect::intended('admin/invoice');
}
return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
}
示例14: testSendEmail
function testSendEmail()
{
$company = new Company();
$company->set(array('name' => 'Test Company'));
$company->save();
$contact = new Contact();
$contact->set(array('first_name' => 'Testy', 'last_name' => 'test', 'email' => 'ted@radicaldesigns.org', 'is_billing_contact' => true, 'company_id' => $company->id));
$contact->save();
$i = new Invoice();
$i->set(array('company_id' => $company->id, 'start_date' => '2010-01-01', 'end_date' => '2010-03-31'));
$i->execute();
$i->save();
# here i test sending my invoice
require_once 'controller/InvoiceController.php';
$invoice_controller = new InvoiceController();
$invoice_controller->disableRedirect();
$invoice_controller->execute('email', array('id' => $i->id));
$msg = Render::_dumpMessages();
$this->assertPattern('/Email Sent/', $msg);
}
示例15: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'show' page.
*/
public function actionCreate()
{
$model = new Invoice($this->action->id);
if (isset($_POST['Invoice'])) {
// collect user input data
$model->attributes = $_POST['Invoice'];
// validate with the current action as scenario and save without validation
if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
// set success message
MUserFlash::setTopSuccess(Yii::t('hint', 'The new invoice record number "{invoiceNumber}" has been successfully created.', array('{invoiceNumber}' => MHtml::wrapInTag($model->id, 'strong'))));
// go to the 'show' page
$this->redirect(array('show', 'id' => $model->id));
}
} else {
// pre-assigned attributes (default values for a new record)
if (isset($_GET['companyId'])) {
// company is known
$model->companyId = $_GET['companyId'];
}
}
$this->render($this->action->id, array('model' => $model));
}