当前位置: 首页>>代码示例>>PHP>>正文


PHP Invoice::create方法代码示例

本文整理汇总了PHP中Invoice::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::create方法的具体用法?PHP Invoice::create怎么用?PHP Invoice::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Invoice的用法示例。


在下文中一共展示了Invoice::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 function create()
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         unset($_POST['files']);
         $_POST['estimate'] = 1;
         $_POST['estimate_status'] = "Open";
         $estimate = Invoice::create($_POST);
         $new_estimate_reference = $_POST['reference'] + 1;
         $estimate_reference = Setting::first();
         $estimate_reference->update_attributes(array('invoice_reference' => $new_estimate_reference));
         if (!$estimate) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_estimate_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_estimate_success'));
         }
         redirect('estimates');
     } else {
         $this->view_data['estimates'] = Invoice::all();
         $this->view_data['next_reference'] = Invoice::last();
         $this->view_data['projects'] = Project::all();
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_estimate');
         $this->view_data['form_action'] = 'estimates/create';
         $this->content_view = 'estimates/_estimate';
     }
 }
开发者ID:timclifford,项目名称:freelance-manager,代码行数:29,代码来源:estimates.php

示例2: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Invoice::create([]);
     }
 }
开发者ID:mladjom,项目名称:smartinvoice,代码行数:7,代码来源:InvoicesTableSeeder.php

示例3: store

 /**
  * Store a newly created invoice in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Invoice::create($data);
     return Redirect::route('invoices.index');
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:14,代码来源:InvoicesController.php

示例4: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         $status = Status::orderByRaw("RAND()")->first();
         $user = User::orderByRaw("RAND()")->first();
         Invoice::create(['due' => $faker->date(), 'status_id' => $status->id, 'amount' => $faker->randomFloat($nbMaxDecimals = 2), 'owner_id' => $user->id]);
     }
 }
开发者ID:terrygl,项目名称:SimpleLance,代码行数:9,代码来源:InvoicesTableSeeder.php

示例5: store

 /**
  * Store a newly created product in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Invoice::$rules);
     if ($validator->passes()) {
         $invoice = Invoice::create(Input::all());
         return Response::json(array('success' => true, "invoice_id" => $invoice->id));
     } else {
         return Response::json(array('success' => false, 'errors' => $validator->errors()));
     }
 }
开发者ID:jimmyhien,项目名称:dailyhuuhoc,代码行数:15,代码来源:InvoicesController.php

示例6: 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|max:50|', 'invoicedate' => 'required', 'duedate' => 'required'));
     if ($v->passes()) {
         Invoice::create($input);
         return Redirect::intended('invoice');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
开发者ID:jeremiteki,项目名称:mteja-laravel,代码行数:16,代码来源:InvoiceController.php

示例7: run

 public function run()
 {
     Eloquent::unguard();
     DB::table('invoices')->truncate();
     DB::table('invoice_items')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 30; $i++) {
         $invoice = Invoice::create(array('user_id' => $faker->randomNumber(1, 20), 'due_date' => $faker->dateTimeThisYear, 'status' => $faker->randomElement(array('Draft', 'Unpaid', 'Paid'))));
         InvoiceItem::create(array('invoice_id' => $invoice->id, 'description' => $faker->sentence, 'unit_price' => $faker->randomNumber(1, 200), 'quantity' => $faker->randomNumber(1, 2)));
     }
 }
开发者ID:carriercomm,项目名称:saaspanel,代码行数:11,代码来源:InvoicesTableSeeder.php

示例8: 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;
 }
开发者ID:khaled-saiful-islam,项目名称:zen_v1.0,代码行数:59,代码来源:InvoiceItemComponent.php

示例9: store

 /**
  * Store a newly created quote in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $validator = Validator::make($data = Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['event_date'] = strtotime($data['event_date']);
     Invoice::create($data);
     return Redirect::route('finances.index');
 }
开发者ID:dynamicsystems,项目名称:TechTracker,代码行数:18,代码来源:InvoicesController.php

示例10: amendInvoice

 public static function amendInvoice($booking)
 {
     $total = Booking::getTotalBookingAmount($booking);
     $invoice = Invoice::where('booking_id', $booking->id)->first();
     if ($invoice) {
         $invoice->count = ++$invoice->count;
         $invoice->amount = $total;
         $invoice->save();
         return true;
     } else {
         $invoiceData = array('amount' => $total, 'booking_id' => $booking->id);
         Invoice::create($invoiceData);
         return false;
     }
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:15,代码来源:Invoice.php

示例11: testGenerate

 /**
  * Test the generate method
  */
 public function testGenerate()
 {
     $invoice = $this->_getNewRecord();
     $client = $invoice['Invoice'];
     unset($client['prefix']);
     $invoiceLine = $invoice['InvoiceLine'];
     $result = $this->Invoice->generate($client, $invoiceLine);
     $resultInvoice = $this->Invoice->read();
     $this->assertTrue($result);
     $this->assertWithinMargin($resultInvoice['Invoice']['global_price'], 119.6, 0.0001);
     $this->Invoice->setInvoiceNumberGenerator('TestInvoiceNumberGenerator');
     $this->Invoice->create($invoice);
     $this->expectError('PHPUnit_Framework_Error');
     $result = $this->Invoice->generate($client, $invoiceLine);
     $resultInvoice = $this->Invoice->read();
     $this->assertTrue($this->__isUuid($resultInvoice['Invoice']['id']));
 }
开发者ID:occitech,项目名称:invoices,代码行数:20,代码来源:InvoiceTest.php

示例12: run

 public function run()
 {
     DB::table('DEMO_Invoice')->delete();
     Invoice::create(array('client' => 'Client A', 'number' => 1, 'date' => date('2014-01-10'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client B', 'number' => 2, 'date' => date('2014-01-11'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client C', 'number' => 3, 'date' => date('2014-01-12'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client D', 'number' => 4, 'date' => date('2014-01-13'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client E', 'number' => 5, 'date' => date('2014-01-14'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client F', 'number' => 6, 'date' => date('2014-01-15'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client G', 'number' => 7, 'date' => date('2014-01-16'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client H', 'number' => 8, 'date' => date('2014-01-17'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client I', 'number' => 9, 'date' => date('2014-01-18'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client J', 'number' => 10, 'date' => date('2014-01-19'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client K', 'number' => 11, 'date' => date('2014-01-20'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client L', 'number' => 12, 'date' => date('2014-01-21'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client M', 'number' => 13, 'date' => date('2014-01-22'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client N', 'number' => 14, 'date' => date('2014-01-23'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client O', 'number' => 15, 'date' => date('2014-01-24'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client P', 'number' => 16, 'date' => date('2014-01-25'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client Q', 'number' => 17, 'date' => date('2014-01-26'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client R', 'number' => 18, 'date' => date('2014-01-27'), 'country' => 'USA'));
     Invoice::create(array('client' => 'Client S', 'number' => 19, 'date' => date('2014-01-29'), 'country' => 'Canada'));
     Invoice::create(array('client' => 'Client T', 'number' => 20, 'date' => date('2014-01-29'), 'country' => 'USA'));
 }
开发者ID:chappyhome,项目名称:laravel-jqgrid-tutorial,代码行数:24,代码来源:InvoiceTableSeeder.php

示例13: planOrder

 function planOrder($id = FALSE, $condition = FALSE, $plan_id = FALSE)
 {
     $this->load->helper('notification');
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'cprojects', $this->lang->line('application_overview') => 'cprojects/view/' . $id, $this->lang->line('application_tasks') => 'cprojects/tasks/' . $id, $this->lang->line('application_media') => 'cprojects/media/' . $id);
     switch ($condition) {
         case 'create':
             $plan = ProjectHasItem::find($plan_id);
             $current_inventory = $plan->shipping_available_inventory;
             if ($_POST) {
                 if (!isset($plan_id) || empty($plan_id)) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_project_make_plan_item_empty'));
                     redirect('cprojects/view/' . $id);
                 }
                 if (!$current_inventory) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_project_make_plan_inventory_empty'));
                     redirect('cprojects/view/' . $id);
                 }
                 $quantity = $_POST['amount'];
                 $current_inventory_available = $current_inventory - $quantity;
                 if (!$quantity) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_project_make_plan_qty_empty'));
                     redirect('cprojects/view/' . $id);
                 }
                 if ($current_inventory_available < 0) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_project_make_plan_qty_empty'));
                     redirect('cprojects/view/' . $id);
                 }
                 unset($_POST['send']);
                 unset($_POST['files']);
                 unset($_POST['amount']);
                 $_POST['shipping_lebel'] = '';
                 $config['upload_path'] = './files/media';
                 $config['encrypt_name'] = TRUE;
                 $config['allowed_types'] = '*';
                 $this->load->library('upload', $config);
                 if ($this->upload->do_upload()) {
                     $data = array('upload_data' => $this->upload->data());
                     $_POST['shipping_lebel'] = $data['upload_data']['file_name'];
                 }
                 unset($_POST['userfile']);
                 unset($_POST['dummy']);
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $shipping_address = array('shipping_name' => $_POST['shipping_name'], 'shipping_company' => $_POST['shipping_company'], 'shipping_address' => $_POST['shipping_address'], 'shipping_city' => $_POST['shipping_city'], 'shipping_state' => $_POST['shipping_state'], 'shipping_zip' => $_POST['shipping_zip'], 'shipping_country' => $_POST['shipping_country'], 'shipping_phone' => $_POST['shipping_phone'], 'shipping_email' => $_POST['shipping_email'], 'shipping_website' => $_POST['shipping_website']);
                 unset($_POST['shipping_name']);
                 unset($_POST['shipping_company']);
                 unset($_POST['shipping_address']);
                 unset($_POST['shipping_city']);
                 unset($_POST['shipping_state']);
                 unset($_POST['shipping_zip']);
                 unset($_POST['shipping_country']);
                 unset($_POST['shipping_phone']);
                 unset($_POST['shipping_email']);
                 unset($_POST['shipping_website']);
                 $core_settings = Setting::first();
                 $_POST['reference'] = $core_settings->invoice_reference;
                 $_POST['project_id'] = $id;
                 $_POST['company_id'] = $this->client->company->id;
                 $_POST['status'] = 'Sent';
                 $_POST['issue_date'] = date('Y-m-d');
                 $_POST['due_date'] = date('Y-m-d', strtotime('+1 day'));
                 $_POST['currency'] = $core_settings->currency;
                 $_POST['terms'] = $core_settings->invoice_terms;
                 $_POST['invoice_type'] = $this->invoice_shipment_type;
                 $invoice = Invoice::create($_POST);
                 $new_invoice_reference = $_POST['reference'] + 1;
                 $invoice_id = $invoice->id;
                 $this->projectlib->addInvoiceAddress($invoice_id, true, $shipping_address);
                 $invoice_reference = Setting::first();
                 $invoice_reference->update_attributes(array('invoice_reference' => $new_invoice_reference));
                 $invoice_item_data = array('invoice_id' => $invoice_id, 'item_id' => $plan->item_id, 'project_item_id' => $plan->id, 'photo' => $plan->photo, 'photo_type' => $plan->photo_type, 'photo_original_name' => $plan->photo_original_name, 'name' => $plan->name, 'amount' => $quantity, 'type' => $plan->type, 'description' => $plan->description, 'sku' => $plan->sku, 'value' => $plan->cost, 'original_cost' => $plan->original_cost, 'shipping_item' => '1', 'shipping_method' => $plan->shipping_method, 'shipping_box_size_length' => $plan->shipping_box_size_length, 'shipping_box_size_width' => $plan->shipping_box_size_width, 'shipping_box_size_height' => $plan->shipping_box_size_height, 'shipping_box_size_weight' => $plan->shipping_box_size_weight, 'shipping_pcs_in_carton' => $plan->shipping_pcs_in_carton);
                 $item_add = InvoiceHasItem::create($invoice_item_data);
                 $plan->shipping_available_inventory = $current_inventory_available;
                 if (!$current_inventory_available) {
                     $plan->payment_status = 'invoiced';
                 }
                 $plan->save();
                 $this->projectlib->updateInvoiceTotal($invoice);
                 $this->projectlib->sendInvoice($invoice_id, false);
                 if (!$invoice) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_invoice_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_invoice_success'));
                 }
                 redirect('cinvoices/view/' . $invoice_id);
             } else {
                 $this->load->library('geolib');
                 $this->view_data['geolib'] = $this->geolib;
                 $this->view_data['max_qty'] = $plan->shipping_available_inventory;
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_create_shipping_plan');
                 $this->view_data['form_action'] = 'cprojects/planOrder/' . $id . '/create/' . $plan_id;
                 $this->content_view = 'projects/client_views/_create_plan';
             }
             break;
         default:
             $this->view_data['project'] = Project::find($id);
             $this->content_view = 'cprojects/view/' . $id;
             break;
     }
 }
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:100,代码来源:cprojects.php

示例14: storeAllData

 public function storeAllData()
 {
     $data = Session::pull('MyBookingData');
     if (Session::has('rate_box_details') || Session::has('transport_cart_box') || Session::has('predefined_transport') || Session::has('excursion_cart_details')) {
         if ($booking = Booking::create($data)) {
             $ehi_users = User::getEhiUsers();
             if (Auth::check()) {
                 //DB::table('booking_user')->insert(array('booking_id' => $booking->id, 'user_id' => $user->id));
                 if (Session::has('client-list')) {
                     $clients = Session::pull('client-list');
                     foreach ($clients as $client) {
                         $client['booking_id'] = $booking->id;
                         $client['gender'] === 'male' ? $client['gender'] = 1 : ($client['gender'] = 0);
                         Client::create($client);
                     }
                 }
                 $flight_data = [];
                 $flight_data['booking_id'] = $booking->id;
                 $flight_data['date'] = $data['date_arrival'];
                 $flight_data['time'] = $data['arrival_time'];
                 $flight_data['flight'] = $data['arrival_flight'];
                 $flight_data['flight_type'] = 1;
                 FlightDetail::create($flight_data);
                 //departure flight data
                 $flight_data['date'] = $data['date_departure'];
                 $flight_data['time'] = $data['departure_time'];
                 $flight_data['flight'] = $data['departure_flight'];
                 $flight_data['flight_type'] = 0;
                 FlightDetail::create($flight_data);
             }
             /**
              *  transport - custom trips
              */
             $a = 0;
             if (Session::has('transport_cart_box')) {
                 $custom_trips = Session::pull('transport_cart_box');
                 $a++;
                 $x = 1;
                 foreach ($custom_trips as $custom_trip) {
                     $custom_trip['from'] = date('Y-m-d H:i', strtotime($custom_trip['pick_up_date'] . ' ' . $custom_trip['pick_up_time_hour'] . ':' . $custom_trip['pick_up_time_minutes']));
                     $custom_trip['to'] = date('Y-m-d H:i', strtotime($custom_trip['drop_off_date'] . ' ' . $custom_trip['drop_off_time_hour'] . ':' . $custom_trip['drop_off_time_minutes']));
                     $custom_trip['reference_number'] = 'TR' . ($booking->reference_number * 1000 + $x++);
                     $custom_trip['booking_id'] = $booking->id;
                     $custom_trip['locations'] = $custom_trip['destination_1'] . ',' . $custom_trip['destination_2'] or '' . ',' . $custom_trip['destination_3'];
                     $custom_trip['amount'] = rand(100, 200);
                     CustomTrip::create($custom_trip);
                 }
             }
             /**
              *  predefined package bookings
              */
             if (Session::has('predefined_transport')) {
                 $a++;
                 $predefined_packages = Session::pull('predefined_transport');
                 foreach ($predefined_packages as $predefined_package) {
                     $package = [];
                     $package['transport_package_id'] = $predefined_package['predefine_id'];
                     $package['booking_id'] = $booking->id;
                     $package['pick_up_date_time'] = $predefined_package['check_in_date'];
                     $package['amount'] = TransportPackage::find($predefined_package['predefine_id'])->rate;
                     PredefinedTrip::create($package);
                 }
             }
             /**
              * Send Transportation Email to All EHI users
              */
             $pdf = PDF::loadView('emails/transport', array('booking' => $booking));
             $pdf->save('public/temp-files/transport' . $booking->id . '.pdf');
             //                if ($a > 0) {
             //                    Mail::send('emails/transport-mail', array(
             //                        'booking' => Booking::find($booking->id)
             //                    ), function ($message) use ($booking, $ehi_users) {
             //                        $message->attach('public/temp-files/transport.pdf')
             //                            ->subject('New Transfer : ' . $booking->reference_number)
             //                            ->from('transport@srilankahotels.travel', 'SriLankaHotels.Travel')
             //                            ->bcc('admin@srilankahotels.travel');
             //                        if (!empty($ehi_users))
             //                            foreach ($ehi_users as $ehi_user) {
             //                                $message->to($ehi_user->email, $ehi_user->first_name);
             //                            }
             //                    });
             //                }
             /**
              * Excursions
              */
             if (Session::has('excursion_cart_details')) {
                 $excursions = Session::pull('excursion_cart_details');
                 $x = 1;
                 foreach ($excursions as $excursion) {
                     $excursionBooking = ExcursionRate::with(array('city', 'excursion', 'excursionTransportType'))->where('city_id', $excursion['city_id'])->where('excursion_transport_type_id', $excursion['excursion_transport_type'])->where('excursion_id', $excursion['excursion'])->first();
                     $excursionBookingData = array('booking_id' => $booking->id, 'city_id' => $excursionBooking->city_id, 'excursion_transport_type_id' => $excursionBooking->excursion_transport_type_id, 'excursion_id' => $excursionBooking->excursion_id, 'unit_price' => $excursionBooking->rate, 'pax' => $excursion['excursion_pax'], 'date' => $excursion['excursion_date'], 'reference_number' => 'EX' . ($booking->reference_number * 1000 + $x++));
                     ExcursionBooking::create($excursionBookingData);
                 }
                 $pdf = PDF::loadView('emails/excursion', array('booking' => $booking));
                 $pdf->save('public/temp-files/excursions.pdf');
                 //                    Mail::send('emails/excursion-mail', array(
                 //                        'booking' => $booking
                 //                    ), function ($message) use ($booking, $ehi_users) {
                 //                        $message->attach('public/temp-files/excursions.pdf')
                 //                            ->subject('New Excursions : ' . $booking->reference_number)
//.........这里部分代码省略.........
开发者ID:tharindarodrigo,项目名称:agent,代码行数:101,代码来源:BookingsController.php

示例15: import

 public function import($options = array())
 {
     $db = JFactory::getDBO();
     $stdfields = array('id', 'name', 'username', 'email', 'password', 'plan_id', 'invoice_number', 'expiration');
     foreach ($this->rows as $k => $row) {
         // Skip first line, if desired
         if ($k === 0 && !empty($options['skip_first'])) {
             continue;
         }
         $userid = null;
         $user = $this->convertRow($row);
         if (empty($user['username']) && empty($user['id'])) {
             continue;
         }
         if (!empty($user['id'])) {
             $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `id` = \'' . $user['id'] . '\'';
             $db->setQuery($query);
             $userid = $db->loadResult();
         }
         if (empty($userid)) {
             $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $user['username'] . '\'';
             $db->setQuery($query);
             $userid = $db->loadResult();
         }
         if (!$userid) {
             // We cannot find any user by this id or name, create one
             if (!empty($user['email']) && !empty($user['username'])) {
                 if (empty($user['password'])) {
                     $user['password'] = AECToolbox::randomstring(8, true);
                 }
                 if (empty($user['name'])) {
                     $user['name'] = $user['username'];
                 }
                 if (!empty($user['password'])) {
                     $user['password2'] = $user['password'];
                 }
                 $fields = $user;
                 $excludefields = array('plan_id', 'invoice_number', 'expiration');
                 foreach ($excludefields as $field) {
                     if (isset($fields[$field])) {
                         unset($fields[$field]);
                     }
                 }
                 $userid = $this->createUser($fields);
             } else {
                 continue;
             }
         }
         if (empty($userid)) {
             $this->errors++;
         }
         $metaUser = new metaUser($userid);
         $custom_params = array();
         foreach ($user as $i => $v) {
             if (!in_array($i, $stdfields)) {
                 $custom_params[$i] = $v;
             }
         }
         if (!empty($custom_params)) {
             $metaUser->meta->addCustomParams($custom_params);
             $metaUser->meta->storeload();
         }
         if (!empty($user['plan_id'])) {
             $pid = $user['plan_id'];
         } else {
             $pid = $this->options['assign_plan'];
         }
         $subscr_action = false;
         if (!empty($pid)) {
             $plan = new SubscriptionPlan();
             $plan->load($pid);
             $metaUser->establishFocus($plan, 'none', true);
             $metaUser->focusSubscription->applyUsage($pid, 'none', 1);
             $subscr_action = true;
         }
         if (!empty($user['expiration']) && !empty($metaUser->focusSubscription->id)) {
             $metaUser->focusSubscription->expiration = date('Y-m-d H:i:s', strtotime($user['expiration']));
             if ($metaUser->focusSubscription->status == 'Trial') {
                 $metaUser->focusSubscription->status = 'Trial';
             } else {
                 $metaUser->focusSubscription->status = 'Active';
             }
             $metaUser->focusSubscription->lifetime = 0;
             $metaUser->focusSubscription->storeload();
             $subscr_action = true;
         }
         if (!empty($user['invoice_number']) && !empty($pid)) {
             // Create Invoice
             $invoice = new Invoice();
             $invoice->create($userid, $pid, 'none', $user['invoice_number']);
             if ($subscr_action) {
                 $invoice->subscr_id = $metaUser->focusSubscription->id;
             }
             $invoice->setTransactionDate();
         }
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:97,代码来源:admin.acctexp.class.php


注:本文中的Invoice::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。