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


PHP Invoice::find_by_id方法代码示例

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


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

示例1: decline

 function decline($id = FALSE)
 {
     $this->load->helper('notification');
     $data["core_settings"] = Setting::first();
     if ($_POST) {
         $this->view_data['estimate'] = Invoice::find_by_id($_POST['invoice_id']);
         $this->view_data['estimate']->estimate_status = "Declined";
         $this->view_data['estimate']->save();
         send_notification($data["core_settings"]->email, $data["core_settings"]->estimate_prefix . $this->view_data['estimate']->reference . ' - ' . $this->lang->line('application_Declined'), $_POST['reason']);
         redirect('cestimates/view/' . $_POST['invoice_id']);
     } else {
         $this->view_data['estimate'] = Invoice::find($id);
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_Declined');
         $this->view_data['form_action'] = 'cestimates/decline';
         $this->content_view = 'estimates/client_views/_decline';
     }
 }
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:18,代码来源:cestimates.php

示例2: authorizenet

 function authorizenet($id = FALSE)
 {
     if ($_POST) {
         // Authorize.net lib
         $this->load->library('authorize_net');
         $invoice = Invoice::find_by_id($_POST['invoice_id']);
         log_message('error', 'Authorize.net: Payment process started for invoice: #' . $invoice->reference);
         $amount = sprintf("%01.2f", round($invoice->sum - $invoice->paid, 2));
         $auth_net = array('x_card_num' => str_replace(' ', '', $_POST['x_card_num']), 'x_exp_date' => $_POST['x_card_month'] . '/' . $_POST['x_card_year'], 'x_card_code' => $_POST['x_card_code'], 'x_description' => $this->lang->line('application_invoice') . ' #' . $invoice->reference, 'x_amount' => $amount, 'x_first_name' => $invoice->company->client->firstname, 'x_last_name' => $invoice->company->client->lastname, 'x_address' => $invoice->company->address, 'x_city' => $invoice->company->city, 'x_zip' => $invoice->company->zipcode, 'x_phone' => $invoice->company->phone, 'x_email' => $invoice->company->client->email, 'x_customer_ip' => $this->input->ip_address());
         $this->authorize_net->setData($auth_net);
         // Try to AUTH_CAPTURE
         if ($this->authorize_net->authorizeAndCapture()) {
             $this->session->set_flashdata('message', 'success: ' . $this->lang->line('messages_payment_complete'));
             log_message('error', 'Authorize.net: Transaction ID: ' . $this->authorize_net->getTransactionId());
             log_message('error', 'Authorize.net: Approval Code: ' . $this->authorize_net->getApprovalCode());
             log_message('error', 'Authorize.net: Payment completed.');
             $invoice->status = "Paid";
             $invoice->paid_date = date('Y-m-d', time());
             $invoice->save();
             $attributes = array('invoice_id' => $invoice->id, 'reference' => $this->authorize_net->getTransactionId(), 'amount' => $amount, 'date' => date('Y-m-d', time()), 'type' => 'credit_card', 'notes' => $this->authorize_net->getApprovalCode());
             $invoiceHasPayment = InvoiceHasPayment::create($attributes);
             redirect('cinvoices/view/' . $invoice->id);
         } else {
             log_message('error', 'Authorize.net: Payment failed.');
             log_message('error', 'Authorize.net: ' . $this->authorize_net->getError());
             $this->view_data['return_link'] = "invoices/view/" . $invoice->id;
             $this->view_data['message'] = $this->authorize_net->getError();
             //$this->authorize_net->debug();
             $this->content_view = 'error/error';
         }
     } else {
         $this->view_data['invoices'] = Invoice::find_by_id($id);
         $this->view_data["settings"] = Setting::first();
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_pay_with_credit_card');
         $this->view_data['form_action'] = 'cinvoices/authorizenet';
         $this->content_view = 'invoices/_authorizenet';
     }
 }
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:39,代码来源:cinvoices.php

示例3: is_finished

 public function is_finished($id = 0)
 {
     if (!($id && ($invoice = Invoice::find_by_id($id, array('select' => 'id, is_finished, updated_at'))))) {
         return $this->output_json(array('status' => false, 'message' => '當案不存在,或者您的權限不夠喔!'));
     }
     $posts = OAInput::post();
     if ($msg = $this->_validation_is_finished_posts($posts)) {
         return $this->output_json(array('status' => false, 'message' => $msg, 'content' => Invoice::$finishNames[$invoice->is_finished]));
     }
     if ($columns = array_intersect_key($posts, $invoice->table()->columns)) {
         foreach ($columns as $column => $value) {
             $invoice->{$column} = $value;
         }
     }
     $update = Invoice::transaction(function () use($invoice) {
         return $invoice->save();
     });
     if ($update) {
         return $this->output_json(array('status' => true, 'message' => '更新成功!', 'content' => Invoice::$finishNames[$invoice->is_finished]));
     } else {
         return $this->output_json(array('status' => false, 'message' => '更新失敗!', 'content' => Invoice::$finishNames[$invoice->is_finished]));
     }
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:23,代码来源:invoices.php

示例4: stripepay

 function stripepay($id = FALSE, $sum = FALSE)
 {
     $data["core_settings"] = Setting::first();
     $stripe_keys = array("secret_key" => $data["core_settings"]->stripe_p_key, "publishable_key" => $data["core_settings"]->stripe_key);
     if ($_POST) {
         unset($_POST['send']);
         $invoice = Invoice::find($_POST['id']);
         // Stores errors:
         $errors = array();
         // Need a payment token:
         if (isset($_POST['stripeToken'])) {
             $token = $_POST['stripeToken'];
             // Check for a duplicate submission, just in case:
             // Uses sessions, you could use a cookie instead.
             if (isset($_SESSION['token']) && $_SESSION['token'] == $token) {
                 $errors['token'] = 'You have apparently resubmitted the form. Please do not do that.';
                 $this->session->set_flashdata('message', 'error: You have apparently resubmitted the form. Please do not do that.');
             } else {
                 // New submission.
                 $_SESSION['token'] = $token;
             }
         } else {
             $this->session->set_flashdata('message', 'error: The order cannot be processed. Please make sure you have JavaScript enabled and try again.');
             $errors['token'] = 'The order cannot be processed. Please make sure you have JavaScript enabled and try again.';
             log_message('error', 'Stripe: ERROR - Payment canceled for invoice #' . $invoice->reference . '.');
         }
         // Set the order amount somehow:
         $sum_exp = explode('.', $_POST['sum']);
         $amount = $sum_exp[0] * 100 + $sum_exp[1];
         // in cents
         //Get currency
         # PHP ISO currency => name list
         $currency = $invoice->currency;
         $currency_codes = array("AFA" => "Afghani", "AFN" => "Afghani", "ALK" => "Albanian old lek", "ALL" => "Lek", "DZD" => "Algerian Dinar", "USD" => "US Dollar", "ADF" => "Andorran Franc", "ADP" => "Andorran Peseta", "EUR" => "Euro", "AOR" => "Angolan Kwanza Readjustado", "AON" => "Angolan New Kwanza", "AOA" => "Kwanza", "XCD" => "East Caribbean Dollar", "ARA" => "Argentine austral", "ARS" => "Argentine Peso", "ARL" => "Argentine peso ley", "ARM" => "Argentine peso moneda nacional", "ARP" => "Peso argentino", "AMD" => "Armenian Dram", "AWG" => "Aruban Guilder", "AUD" => "Australian Dollar", "ATS" => "Austrian Schilling", "AZM" => "Azerbaijani manat", "AZN" => "Azerbaijanian Manat", "BSD" => "Bahamian Dollar", "BHD" => "Bahraini Dinar", "BDT" => "Taka", "BBD" => "Barbados Dollar", "BYR" => "Belarussian Ruble", "BEC" => "Belgian Franc (convertible)", "BEF" => "Belgian Franc (currency union with LUF)", "BEL" => "Belgian Franc (financial)", "BZD" => "Belize Dollar", "XOF" => "CFA Franc BCEAO", "BMD" => "Bermudian Dollar", "INR" => "Indian Rupee", "BTN" => "Ngultrum", "BOP" => "Bolivian peso", "BOB" => "Boliviano", "BOV" => "Mvdol", "BAM" => "Convertible Marks", "BWP" => "Pula", "NOK" => "Norwegian Krone", "BRC" => "Brazilian cruzado", "BRB" => "Brazilian cruzeiro", "BRL" => "Brazilian Real", "BND" => "Brunei Dollar", "BGN" => "Bulgarian Lev", "BGJ" => "Bulgarian lev A/52", "BGK" => "Bulgarian lev A/62", "BGL" => "Bulgarian lev A/99", "BIF" => "Burundi Franc", "KHR" => "Riel", "XAF" => "CFA Franc BEAC", "CAD" => "Canadian Dollar", "CVE" => "Cape Verde Escudo", "KYD" => "Cayman Islands Dollar", "CLP" => "Chilean Peso", "CLF" => "Unidades de fomento", "CNX" => "Chinese People's Bank dollar", "CNY" => "Yuan Renminbi", "COP" => "Colombian Peso", "COU" => "Unidad de Valor real", "KMF" => "Comoro Franc", "CDF" => "Franc Congolais", "NZD" => "New Zealand Dollar", "CRC" => "Costa Rican Colon", "HRK" => "Croatian Kuna", "CUP" => "Cuban Peso", "CYP" => "Cyprus Pound", "CZK" => "Czech Koruna", "CSK" => "Czechoslovak koruna", "CSJ" => "Czechoslovak koruna A/53", "DKK" => "Danish Krone", "DJF" => "Djibouti Franc", "DOP" => "Dominican Peso", "ECS" => "Ecuador sucre", "EGP" => "Egyptian Pound", "SVC" => "Salvadoran colón", "EQE" => "Equatorial Guinean ekwele", "ERN" => "Nakfa", "EEK" => "Kroon", "ETB" => "Ethiopian Birr", "FKP" => "Falkland Island Pound", "FJD" => "Fiji Dollar", "FIM" => "Finnish Markka", "FRF" => "French Franc", "XFO" => "Gold-Franc", "XPF" => "CFP Franc", "GMD" => "Dalasi", "GEL" => "Lari", "DDM" => "East German Mark of the GDR (East Germany)", "DEM" => "Deutsche Mark", "GHS" => "Ghana Cedi", "GHC" => "Ghanaian cedi", "GIP" => "Gibraltar Pound", "GRD" => "Greek Drachma", "GTQ" => "Quetzal", "GNF" => "Guinea Franc", "GNE" => "Guinean syli", "GWP" => "Guinea-Bissau Peso", "GYD" => "Guyana Dollar", "HTG" => "Gourde", "HNL" => "Lempira", "HKD" => "Hong Kong Dollar", "HUF" => "Forint", "ISK" => "Iceland Krona", "ISJ" => "Icelandic old krona", "IDR" => "Rupiah", "IRR" => "Iranian Rial", "IQD" => "Iraqi Dinar", "IEP" => "Irish Pound (Punt in Irish language)", "ILP" => "Israeli lira", "ILR" => "Israeli old sheqel", "ILS" => "New Israeli Sheqel", "ITL" => "Italian Lira", "JMD" => "Jamaican Dollar", "JPY" => "Yen", "JOD" => "Jordanian Dinar", "KZT" => "Tenge", "KES" => "Kenyan Shilling", "KPW" => "North Korean Won", "KRW" => "Won", "KWD" => "Kuwaiti Dinar", "KGS" => "Som", "LAK" => "Kip", "LAJ" => "Lao kip", "LVL" => "Latvian Lats", "LBP" => "Lebanese Pound", "LSL" => "Loti", "ZAR" => "Rand", "LRD" => "Liberian Dollar", "LYD" => "Libyan Dinar", "CHF" => "Swiss Franc", "LTL" => "Lithuanian Litas", "LUF" => "Luxembourg Franc (currency union with BEF)", "MOP" => "Pataca", "MKD" => "Denar", "MKN" => "Former Yugoslav Republic of Macedonia denar A/93", "MGA" => "Malagasy Ariary", "MGF" => "Malagasy franc", "MWK" => "Kwacha", "MYR" => "Malaysian Ringgit", "MVQ" => "Maldive rupee", "MVR" => "Rufiyaa", "MAF" => "Mali franc", "MTL" => "Maltese Lira", "MRO" => "Ouguiya", "MUR" => "Mauritius Rupee", "MXN" => "Mexican Peso", "MXP" => "Mexican peso", "MXV" => "Mexican Unidad de Inversion (UDI)", "MDL" => "Moldovan Leu", "MCF" => "Monegasque franc (currency union with FRF)", "MNT" => "Tugrik", "MAD" => "Moroccan Dirham", "MZN" => "Metical", "MZM" => "Mozambican metical", "MMK" => "Kyat", "NAD" => "Namibia Dollar", "NPR" => "Nepalese Rupee", "NLG" => "Netherlands Guilder", "ANG" => "Netherlands Antillian Guilder", "NIO" => "Cordoba Oro", "NGN" => "Naira", "OMR" => "Rial Omani", "PKR" => "Pakistan Rupee", "PAB" => "Balboa", "PGK" => "Kina", "PYG" => "Guarani", "YDD" => "South Yemeni dinar", "PEN" => "Nuevo Sol", "PEI" => "Peruvian inti", "PEH" => "Peruvian sol", "PHP" => "Philippine Peso", "PLZ" => "Polish zloty A/94", "PLN" => "Zloty", "PTE" => "Portuguese Escudo", "TPE" => "Portuguese Timorese escudo", "QAR" => "Qatari Rial", "RON" => "New Leu", "ROL" => "Romanian leu A/05", "ROK" => "Romanian leu A/52", "RUB" => "Russian Ruble", "RWF" => "Rwanda Franc", "SHP" => "Saint Helena Pound", "WST" => "Tala", "STD" => "Dobra", "SAR" => "Saudi Riyal", "RSD" => "Serbian Dinar", "CSD" => "Serbian Dinar", "SCR" => "Seychelles Rupee", "SLL" => "Leone", "SGD" => "Singapore Dollar", "SKK" => "Slovak Koruna", "SIT" => "Slovenian Tolar", "SBD" => "Solomon Islands Dollar", "SOS" => "Somali Shilling", "ZAL" => "South African financial rand (Funds code) (discont", "ESP" => "Spanish Peseta", "ESA" => "Spanish peseta (account A)", "ESB" => "Spanish peseta (account B)", "LKR" => "Sri Lanka Rupee", "SDD" => "Sudanese Dinar", "SDP" => "Sudanese Pound", "SDG" => "Sudanese Pound", "SRD" => "Surinam Dollar", "SRG" => "Suriname guilder", "SZL" => "Lilangeni", "SEK" => "Swedish Krona", "CHE" => "WIR Euro", "CHW" => "WIR Franc", "SYP" => "Syrian Pound", "TWD" => "New Taiwan Dollar", "TJS" => "Somoni", "TJR" => "Tajikistan ruble", "TZS" => "Tanzanian Shilling", "THB" => "Baht", "TOP" => "Pa'anga", "TTD" => "Trinidata and Tobago Dollar", "TND" => "Tunisian Dinar", "TRY" => "New Turkish Lira", "TRL" => "Turkish lira A/05", "TMM" => "Manat", "RUR" => "Russian rubleA/97", "SUR" => "Soviet Union ruble", "UGX" => "Uganda Shilling", "UGS" => "Ugandan shilling A/87", "UAH" => "Hryvnia", "UAK" => "Ukrainian karbovanets", "AED" => "UAE Dirham", "GBP" => "Pound Sterling", "USN" => "US Dollar (Next Day)", "USS" => "US Dollar (Same Day)", "UYU" => "Peso Uruguayo", "UYN" => "Uruguay old peso", "UYI" => "Uruguay Peso en Unidades Indexadas", "UZS" => "Uzbekistan Sum", "VUV" => "Vatu", "VEF" => "Bolivar Fuerte", "VEB" => "Venezuelan Bolivar", "VND" => "Dong", "VNC" => "Vietnamese old dong", "YER" => "Yemeni Rial", "YUD" => "Yugoslav Dinar", "YUM" => "Yugoslav dinar (new)", "ZRN" => "Zairean New Zaire", "ZRZ" => "Zairean Zaire", "ZMK" => "Kwacha", "ZWD" => "Zimbabwe Dollar", "ZWC" => "Zimbabwe Rhodesian dollar");
         if (!array_key_exists($currency, $currency_codes)) {
             $currency = $data["core_settings"]->stripe_currency;
         }
         // Validate other form data!
         // If no errors, process the order:
         if (empty($errors)) {
             // create the charge on Stripe's servers - this will charge the user's card
             try {
                 // Include the Stripe library:
                 $this->load->file(APPPATH . 'helpers/stripe/lib/Stripe.php', true);
                 // set your secret key: remember to change this to your live secret key in production
                 // see your keys here https://manage.stripe.com/account
                 Stripe::setApiKey($stripe_keys["secret_key"]);
                 // Charge the order:
                 $charge = Stripe_Charge::create(array("amount" => $amount, "currency" => $currency, "card" => $token, "receipt_email" => $invoice->company->client->email, "description" => $invoice->reference));
                 // Check that it was paid:
                 if ($charge->paid == true) {
                     $attr = array();
                     $paid_date = date('Y-m-d', time());
                     $invoice->update_attributes(array('paid_date' => $paid_date, 'status' => 'Paid'));
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_payment_complete'));
                     log_message('error', 'Stripe: Payment for Invoice #' . $invoice->reference . ' successfully made');
                 } else {
                     // Charge was not paid!
                     $this->session->set_flashdata('message', 'error: Your payment could NOT be processed (i.e., you have not been charged) because the payment system rejected the transaction.');
                     log_message('error', 'Stripe: ERROR - Payment for Invoice #' . $invoice->reference . ' was not successful!');
                 }
             } catch (Stripe_CardError $e) {
                 // Card was declined.
                 $e_json = $e->getJsonBody();
                 $err = $e_json['error'];
                 $errors['stripe'] = $err['message'];
                 $this->session->set_flashdata('message', 'error: Card was declined!');
                 log_message('error', 'Stripe: ERROR - Credit Card was declined by Stripe! Payment process canceled for invoice #' . $invoice->reference . '.');
             } catch (Stripe_ApiConnectionError $e) {
                 // Network problem, perhaps try again.
             } catch (Stripe_InvalidRequestError $e) {
             } catch (Stripe_ApiError $e) {
                 // Stripe's servers are down!
             } catch (Stripe_CardError $e) {
                 // Something else that's not the customer's fault.
             }
         } else {
             $this->session->set_flashdata('message', 'error: ' . $errors["token"]);
             log_message('error', 'Stripe: ' . $errors["token"]);
         }
         redirect('invoices/view/' . $_POST['id']);
     } else {
         $this->view_data['invoices'] = Invoice::find_by_id($id);
         $this->view_data['public_key'] = $data["core_settings"]->stripe_key;
         $this->view_data['sum'] = $sum;
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_pay_with_credit_card');
         $this->view_data['form_action'] = 'invoices/stripepay';
         $this->content_view = 'invoices/_stripe';
     }
 }
开发者ID:timclifford,项目名称:freelance-manager,代码行数:91,代码来源:invoices.php

示例5: stripepay

 function stripepay($id = FALSE)
 {
     $this->load->file(APPPATH . 'helpers/stripe/lib/Stripe.php', true);
     $stripe_keys = array("secret_key" => "sk_test_BQokikJOvBiI2HlWgH4olfQ2", "publishable_key" => "pk_test_6pRNASCoBOKtIshFeQd4XMUh");
     if ($_POST) {
         unset($_POST['send']);
         $token = Stripe_Token::create(array("card" => array("number" => "4242424242424242", "exp_month" => 11, "exp_year" => 2015, "cvc" => "314")));
         // Stores errors:
         $errors = array();
         $email = $this->user->email;
         // Need a payment token:
         if (isset($_POST['stripeToken'])) {
             $token = $_POST['stripeToken'];
             // Check for a duplicate submission, just in case:
             // Uses sessions, you could use a cookie instead.
             if (isset($_SESSION['token']) && $_SESSION['token'] == $token) {
                 $errors['token'] = 'You have apparently resubmitted the form. Please do not do that.';
             } else {
                 // New submission.
                 $_SESSION['token'] = $token;
             }
         } else {
             $errors['token'] = 'The order cannot be processed. Please make sure you have JavaScript enabled and try again.';
             die;
         }
         // Set the order amount somehow:
         $amount = 2000;
         //$_POST['amount']; // $20, in cents
         // Validate other form data!
         // If no errors, process the order:
         if (empty($errors)) {
             // create the charge on Stripe's servers - this will charge the user's card
             try {
                 // set your secret key: remember to change this to your live secret key in production
                 // see your keys here https://manage.stripe.com/account
                 Stripe::setApiKey($stripe_keys['secret_key']);
                 // Charge the order:
                 $charge = Stripe_Charge::create(array("amount" => $amount, "currency" => "usd", "card" => $token, "description" => $email));
                 // Check that it was paid:
                 if ($charge->paid == true) {
                     echo "leuft!";
                     die;
                     // Store the order in the database.
                     // Send the email.
                     // Celebrate!
                 } else {
                     // Charge was not paid!
                     echo '<div class="alert alert-danger"><h4>Payment System Error!</h4>Your payment could NOT be processed (i.e., you have not been charged) because the payment system rejected the transaction. You can try again or use another card.</div>';
                     die;
                 }
             } catch (Stripe_CardError $e) {
                 // Card was declined.
                 $e_json = $e->getJsonBody();
                 $err = $e_json['error'];
                 $errors['stripe'] = $err['message'];
                 echo $err;
                 die;
             } catch (Stripe_ApiConnectionError $e) {
                 // Network problem, perhaps try again.
                 echo "Network problem, perhaps try again.";
                 die;
             } catch (Stripe_InvalidRequestError $e) {
                 // You screwed up in your programming. Shouldn't happen!
                 echo $e;
                 die;
             } catch (Stripe_ApiError $e) {
                 // Stripe's servers are down!
                 echo "Stripe's servers are down!";
                 die;
             } catch (Stripe_CardError $e) {
                 // Something else that's not the customer's fault.
                 echo "Something else that's not the customer's fault.";
                 die;
             }
         }
         /*$new_invoice_reference = $_POST['reference']+1;
         		$invoice_reference = Setting::first();
         		$invoice_reference->update_attributes(array('invoice_reference' => $new_invoice_reference));
               		*/
         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('invoices');
     } else {
         $this->view_data['invoices'] = Invoice::find_by_id($id);
         $this->view_data['public_key'] = $stripe_keys['publishable_key'];
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_pay_via_credit_card');
         $this->view_data['form_action'] = 'invoices/stripepay';
         $this->content_view = 'invoices/_stripe';
     }
 }
开发者ID:pratikbgit,项目名称:freelancerKit,代码行数:94,代码来源:invoices.php


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