1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Merge branch 'master' of github.com:hillelcoren/invoice-ninja

This commit is contained in:
Hillel Coren 2014-06-29 12:39:29 +03:00
commit 7d41fcd7ac
12 changed files with 230 additions and 132 deletions

View File

@ -107,9 +107,9 @@ class AccountController extends \BaseController {
{
$accountGateway = $account->account_gateways[0];
$config = $accountGateway->config;
$configFields = json_decode($config);
foreach($configFields as $configField => $value)
{
$configFields->$configField = str_repeat('*', strlen($value));
@ -132,6 +132,13 @@ class AccountController extends \BaseController {
);
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
}
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
foreach($creditCardsArray as $card => $name)
{
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
}
$otherItem = array(
'value' => 1000000,
@ -140,7 +147,7 @@ class AccountController extends \BaseController {
'data-siteUrl' => ''
);
$recommendedGatewayArray['Other Options'] = $otherItem;
$data = [
'account' => $account,
'accountGateway' => $accountGateway,
@ -153,6 +160,7 @@ class AccountController extends \BaseController {
->orderBy('name')
->get(),
'recommendedGateways' => $recommendedGatewayArray,
'creditCardTypes' => $creditCards,
];
foreach ($data['gateways'] as $gateway)
@ -561,7 +569,7 @@ class AccountController extends \BaseController {
}
private function savePayments()
{
{
Validator::extend('notmasked', function($attribute, $value, $parameters)
{
return $value != str_repeat('*', strlen($value));
@ -596,6 +604,12 @@ class AccountController extends \BaseController {
}
}
}
$creditcards = Input::get('creditCardTypes');
if (count($creditcards) < 1)
{
$rules['creditCardTypes'] = 'required';
}
$validator = Validator::make(Input::all(), $rules);
@ -619,9 +633,16 @@ class AccountController extends \BaseController {
foreach ($fields as $field => $details)
{
$config->$field = trim(Input::get($gateway->id.'_'.$field));
}
}
$cardCount = 0;
foreach($creditcards as $card => $value)
{
$cardCount += intval($value);
}
$accountGateway->config = json_encode($config);
$accountGateway->accepted_credit_cards = $cardCount;
$account->account_gateways()->save($accountGateway);
}

View File

@ -229,8 +229,6 @@ class PaymentController extends \BaseController
}
}
/** HÄR SKALL DET HÄMTAS UT BILDER!!!!! **/
public function show_payment($invitationKey)
{
// For PayPal Express we redirect straight to their site
@ -252,12 +250,11 @@ class PaymentController extends \BaseController
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invoice = $invitation->invoice;
$client = $invoice->client;
$client = $invoice->client;
$accountGateway = $invoice->client->account->account_gateways[0];
$gateway = $invoice->client->account->account_gateways[0]->gateway;
$paymentLibrary = $gateway->paymentlibrary;
$mask = $invoice->client->account->account_gateways[0]->accepted_credit_cards;
$acceptedCreditCardTypes = Utils::getCreditcardTypes($mask);
$acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
$data = [
'showBreadcrumbs' => false,

View File

@ -6,7 +6,6 @@
**/
class SecurePaymentFormSeeder extends Seeder
{
public function run()
{
Eloquent::unguard();
@ -28,83 +27,161 @@ class SecurePaymentFormSeeder extends Seeder
DB::unprepared($statement);
$firstName = 'Oscar';
$lastName = 'Thompson';
$user = AccountGateway::create(array(
'account_id' => 1,
'user_id' => 1,
'gateway_id' => 4,
'config' => 'bla bla bla bla bla bla bla',
'public_id' => 1,
'accepted_credit_cards' => 18
));
$client = Client::create(array(
'user_id' => 1,
'account_id' => 1,
'currency_id' => 1,
'name' => $firstName.' '.$lastName,
'address1' => '2119 Howe Course',
'address2' => '2118 Howe Course',
'city' => 'West Chazport',
'state' => 'Utah',
'postal_code' => '31572',
'country_id' => 752,
'work_phone' => '012-345678',
'private_notes' => 'bla bla bla bla bla bla bla',
'balance' => 10.4,
'paid_to_date' => 10.2,
'website' => 'awebsite.com',
'industry_id' => 8,
'is_deleted' => 0,
'payment_terms' => 2,
'public_id' => 1,
'custom_value1' => $firstName,
'custom_value2' => $firstName
));
$contact = Contact::create(array(
'account_id' => 1,
'user_id' => 1,
'client_id' => 1,
'is_primary' => 0,
'send_invoice' => 0,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => 'an@email.com',
'phone' => '012-345678',
'public_id' => 1
));
$invoice = Invoice::create(array(
'client_id' => 1,
'user_id' => 1,
'account_id' => 1,
'invoice_number' => 1,
'discount' => 0.4,
'po_number' => $firstName,
'terms' => 'bla bla bla bla bla bla bla',
'public_notes' => 'bla bla bla bla bla bla bla',
'is_deleted' => 0,
'is_recurring' => 0,
'frequency_id' => 1,
'tax_name' => 'moms',
'tax_rate' => 33.0,
'amount' => 10.0,
'balance' => 8.0,
'public_id' => 1,
'is_quote' => 0
));
$invitation = Invitation::create(array(
'account_id' => 1,
'user_id' => 1,
'contact_id' => 1,
'invoice_id' => 1,
'invitation_key' => 'aaabbb',
'transaction_reference' => 'bla bla bla bla bla bla bla',
'public_id' => 1
));
//$firstName = 'Oscar';
// $lastName = 'Thompson';
// $firstName_2 = 'Philip';
// $lastName_2 = 'Jonsson';
//
// $user = AccountGateway::create(array(
// 'account_id' => 1,
// 'user_id' => 1,
// 'gateway_id' => 4,
// 'config' => '{"bla":"vla","bli":"cla"}',
// 'public_id' => 1,
// 'accepted_credit_cards' => 8
// ));
//
// $user2 = AccountGateway::create(array(
// 'account_id' => 2,
// 'user_id' => 2,
// 'gateway_id' => 5,
// 'config' => '{"bla":"vla","bli":"cla"}',
// 'public_id' => 2,
// 'accepted_credit_cards' => 7
// ));
//
// $client = Client::create(array(
// 'user_id' => 1,
// 'account_id' => 1,
// 'currency_id' => 1,
// 'name' => $firstName.' '.$lastName,
// 'address1' => '2119 Howe Course',
// 'address2' => '2118 Howe Course',
// 'city' => 'West Chazport',
// 'state' => 'Utah',
// 'postal_code' => '31572',
// 'country_id' => 752,
// 'work_phone' => '012-345678',
// 'private_notes' => 'bla bla bla bla bla bla bla',
// 'balance' => 10.4,
// 'paid_to_date' => 10.2,
// 'website' => 'awebsite.com',
// 'industry_id' => 8,
// 'is_deleted' => 0,
// 'payment_terms' => 2,
// 'public_id' => 1,
// 'custom_value1' => $firstName,
// 'custom_value2' => $firstName
// ));
//
// $client2 = Client::create(array(
// 'user_id' => 2,
// 'account_id' => 2,
// 'currency_id' => 1,
// 'name' => $firstName_2.' '.$lastName_2,
// 'address1' => '1118 Muma Road',
// 'address2' => '1118 Muma Road',
// 'city' => 'New Orleans',
// 'state' => 'Arizona',
// 'postal_code' => '31572',
// 'country_id' => 752,
// 'work_phone' => '012-345678',
// 'private_notes' => 'bla bla bla bla bla bla bla',
// 'balance' => 10.4,
// 'paid_to_date' => 10.2,
// 'website' => 'bodosite.com',
// 'industry_id' => 8,
// 'is_deleted' => 0,
// 'payment_terms' => 2,
// 'public_id' => 1,
// 'custom_value1' => $firstName_2,
// 'custom_value2' => $firstName_2
// ));
//
// $contact = Contact::create(array(
// 'account_id' => 1,
// 'user_id' => 1,
// 'client_id' => 1,
// 'is_primary' => 0,
// 'send_invoice' => 0,
// 'first_name' => $firstName,
// 'last_name' => $lastName,
// 'email' => 'an@email.com',
// 'phone' => '012-345678',
// 'public_id' => 1
// ));
//
// $contact2 = Contact::create(array(
// 'account_id' => 2,
// 'user_id' => 2,
// 'client_id' => 2,
// 'is_primary' => 0,
// 'send_invoice' => 0,
// 'first_name' => $firstName_2,
// 'last_name' => $lastName_2,
// 'email' => 'the@email.com',
// 'phone' => '012-345678',
// 'public_id' => 2
// ));
//
// $invoice = Invoice::create(array(
// 'client_id' => 1,
// 'user_id' => 1,
// 'account_id' => 1,
// 'invoice_number' => 1,
// 'discount' => 0.4,
// 'po_number' => $firstName,
// 'terms' => 'bla bla bla bla bla bla bla',
// 'public_notes' => 'bla bla bla bla bla bla bla',
// 'is_deleted' => 0,
// 'is_recurring' => 0,
// 'frequency_id' => 1,
// 'tax_name' => 'moms',
// 'tax_rate' => 33.0,
// 'amount' => 10.0,
// 'balance' => 8.0,
// 'public_id' => 1,
// 'is_quote' => 0
// ));
//
// $invoice2 = Invoice::create(array(
// 'client_id' => 2,
// 'user_id' => 2,
// 'account_id' => 2,
// 'invoice_number' => 2,
// 'discount' => 0.4,
// 'po_number' => $firstName_2,
// 'terms' => 'bla bla bla bla bla bla bla',
// 'public_notes' => 'bla bla bla bla bla bla bla',
// 'is_deleted' => 0,
// 'is_recurring' => 0,
// 'frequency_id' => 1,
// 'tax_name' => 'moms',
// 'tax_rate' => 33.0,
// 'amount' => 10.0,
// 'balance' => 8.0,
// 'public_id' => 2,
// 'is_quote' => 0
// ));
//
// $invitation = Invitation::create(array(
// 'account_id' => 1,
// 'user_id' => 1,
// 'contact_id' => 1,
// 'invoice_id' => 1,
// 'invitation_key' => 'aaabbb',
// 'transaction_reference' => 'bla bla bla bla bla bla bla',
// 'public_id' => 1
// ));
//
// $invitation2 = Invitation::create(array(
// 'account_id' => 2,
// 'user_id' => 2,
// 'contact_id' => 2,
// 'invoice_id' => 2,
// 'invitation_key' => 'cccddd',
// 'transaction_reference' => 'bla bla bla bla bla bla bla',
// 'public_id' => 2
// ));
}
}

View File

@ -441,40 +441,4 @@ class Utils
return $message;
}
public static function getCreditcardTypes($mask)
{
$arrayOfImages = [];
$flags = [
CREDIT_CARD_VISA => ['card' => 'Visa', 'text' => 'Visa'],
CREDIT_CARD_MASTER_CARD => ['card' => 'MasterCard', 'text' => 'Master Card'],
CREDIT_CARD_AMERICAN_EXPRESS => ['card' => 'AmericanExpress', 'text' => 'American Express'],
CREDIT_CARD_DINERS => ['card' => 'Diners', 'text' => 'Diners'],
CREDIT_CARD_DISCOVER => ['card' => 'Discover', 'text' => 'Discover']
];
foreach ($flags as $card => $name)
{
if (($mask & $card) == $card)
$arrayOfImages[] = ['source' => asset('images/Test-'.$name['card'].'-Icon.png'), 'alt' => $name['text']];
}
//if($mask & CREDIT_CARD_VISA)
// array_push($arrayOfImages, ['source' => asset('images/Test-Visa-Icon.png'), 'alt' => 'Visa']);
//
// if($mask & CREDIT_CARD_MASTER_CARD)
// array_push($arrayOfImages, ['source' => asset('images/Test-MasterCard-Icon.png'), 'alt' => 'Master Card']);
//
// if($mask & CREDIT_CARD_AMERICAN_EXPRESS)
// array_push($arrayOfImages, ['source' => asset('images/Test-AmericanExpress-Icon.png'), 'alt' => 'American Express']);
//
// if($mask & CREDIT_CARD_DINERS)
// array_push($arrayOfImages, ['source' => asset('images/Test-Diners-Icon.png'), 'alt' => 'Diners']);
//
// if($mask & CREDIT_CARD_DISCOVER)
// array_push($arrayOfImages, ['source' => asset('images/Test-Discover-Icon.png'), 'alt' => 'Discover']);
return $arrayOfImages;
}
}

View File

@ -6,4 +6,18 @@ class AccountGateway extends EntityModel
{
return $this->belongsTo('Gateway');
}
public function getCreditcardTypes()
{
$flags = unserialize(CREDIT_CARDS);
$arrayOfImages = [];
foreach ($flags as $card => $name)
{
if (($this->accepted_credit_cards & $card) == $card)
$arrayOfImages[] = ['source' => asset($name['card']), 'alt' => $name['text']];
}
return $arrayOfImages;
}
}

View File

@ -229,12 +229,20 @@ define('GATEWAY_GOOGLE', 33);
define('GATEWAY_QUICKBOOKS', 35);
*/
/** TEST VALUES FOR THE CREDIT CARDS **/
define('CREDIT_CARD_VISA', 1);
define('CREDIT_CARD_MASTER_CARD', 2);
define('CREDIT_CARD_AMERICAN_EXPRESS', 4);
define('CREDIT_CARD_DINERS', 8);
define('CREDIT_CARD_DISCOVER', 16);
/**
* TEST VALUES FOR THE CREDIT CARDS
* NUMBER IS FOR THE BINARY COUNT FOR WHICH IMAGES TO DISPLAY
* card IS FOR CARD IMAGE AND text IS FOR CARD NAME (TO ADD TO alt FOR IMAGE)
**/
$creditCards = [
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],
4 => ['card' => 'images/credit_cards/Test-AmericanExpress-Icon.png', 'text' => 'American Express'],
8 => ['card' => 'images/credit_cards/Test-Diners-Icon.png', 'text' => 'Diners'],
16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover']
];
define('CREDIT_CARDS', serialize($creditCards));
HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') {

View File

@ -19,6 +19,16 @@
@endif
@endforeach
@endif
<!-- TODO: creditcard-types IS SET IN JS FURTHER DOWN IN THE SCRIPT PART,
AND THEN IN INLINE STYLE. REMOVE THIS WHEN RAZI HAS FIXED THE IMAGES AND STYLE -->
<div class="two-column">
{{ Former::checkboxes('creditCardTypes[]')
->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)
->class('creditcard-types')
}}
</div>
<div class="two-column">
{{ Former::radios('recommendedGateway_id')->label('Recommended Gateways')
@ -104,6 +114,13 @@
$(this).after('<img src="' +$(this).attr('data-imageUrl') + '" /><br />');
$(this).parent().children().last().after('<a href="#" onclick="gatewayLink(\'' + $(this).attr('data-siteUrl') + '\')">Create an account</a>');
});
// TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />');
});
setFieldsShown();

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB