diff --git a/app/config/packages/anahkiasen/former/config.php b/app/config/packages/anahkiasen/former/config.php index 67a2829540eb..a4625318375c 100755 --- a/app/config/packages/anahkiasen/former/config.php +++ b/app/config/packages/anahkiasen/former/config.php @@ -42,7 +42,7 @@ 'required_class' => 'required', // A facultative text to append to the labels of required fields - 'required_text' => '*', + 'required_text' => '', //'*', // Translations //////////////////////////////////////////////////////////////////// diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 911f70cee45a..7b61e8fdc38d 100755 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -422,7 +422,7 @@ class AccountController extends \BaseController { if ($gatewayId) { - $accountGateway = new AccountGateway; + $accountGateway = AccountGateway::createNew(); $accountGateway->gateway_id = $gatewayId; $config = new stdClass; diff --git a/app/controllers/CreditController.php b/app/controllers/CreditController.php index 619239e9cfb5..af84bae7ca5c 100755 --- a/app/controllers/CreditController.php +++ b/app/controllers/CreditController.php @@ -77,6 +77,7 @@ class CreditController extends \BaseController { 'url' => 'credits', 'title' => '- New Credit', 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), + 'invoices' => Invoice::scope()->with('client')->where('balance','>',0)->orderBy('invoice_number')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('credits.edit', $data); @@ -128,9 +129,12 @@ class CreditController extends \BaseController { } else { $credit = Credit::createNew(); } + + $invoiceId = Input::get('invoice') && Input::get('invoice') != "-1" ? Invoice::getPrivateId(Input::get('invoice')) : null; $credit->client_id = Client::getPrivateId(Input::get('client')); $credit->credit_date = Utils::toSqlDate(Input::get('credit_date')); + $credit->invoice_id = $invoiceId; $credit->amount = floatval(Input::get('amount')); $credit->currency_id = Input::get('currency_id') ? Input::get('currency_id') : null; $credit->save(); diff --git a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php index 27bd519a6ee4..1753654cf81d 100755 --- a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php +++ b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php @@ -145,19 +145,6 @@ class ConfideSetupUsersTable extends Migration { $t->boolean('visible')->default(true); }); - Schema::create('account_gateways', function($t) - { - $t->increments('id'); - $t->unsignedInteger('account_id'); - $t->unsignedInteger('gateway_id'); - $t->timestamps(); - - $t->text('config'); - - $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); - $t->foreign('gateway_id')->references('id')->on('gateways'); - }); - Schema::create('users', function($t) { $t->increments('id'); @@ -186,6 +173,26 @@ class ConfideSetupUsersTable extends Migration { $t->unique( array('account_id','public_id') ); }); + Schema::create('account_gateways', function($t) + { + $t->increments('id'); + $t->unsignedInteger('account_id'); + $t->unsignedInteger('user_id'); + $t->unsignedInteger('gateway_id'); + $t->timestamps(); + $t->softDeletes(); + + $t->text('config'); + + $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); + $t->foreign('gateway_id')->references('id')->on('gateways'); + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + + $t->unsignedInteger('public_id')->index(); + $t->unique( array('account_id','public_id') ); + }); + + Schema::create('password_reminders', function($t) { $t->string('email'); @@ -448,6 +455,7 @@ class ConfideSetupUsersTable extends Migration { $t->unsignedInteger('account_id')->index(); $t->unsignedInteger('user_id'); $t->unsignedInteger('client_id')->index()->nullable(); + $t->unsignedInteger('invoice_id')->nullable(); $t->unsignedInteger('contact_id')->nullable(); $t->unsignedInteger('currency_id')->default(1); $t->timestamps(); @@ -460,6 +468,7 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('account_id')->references('id')->on('accounts'); $t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade'); + $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->foreign('contact_id')->references('id')->on('contacts'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; $t->foreign('currency_id')->references('id')->on('currencies'); diff --git a/app/models/AccountGateway.php b/app/models/AccountGateway.php index a49d922f3e6a..f62861f2f6b1 100755 --- a/app/models/AccountGateway.php +++ b/app/models/AccountGateway.php @@ -1,6 +1,6 @@ invoice_id) { - $activity->invoice_id = $payment->invoice_id; + $activity->invoice_id = $credit->invoice_id; $invoice = $credit->invoice; $invoice->balance = $invoice->amount - $credit->amount; diff --git a/app/models/EntityModel.php b/app/models/EntityModel.php index b333d9368ff4..ae9ea81a487c 100755 --- a/app/models/EntityModel.php +++ b/app/models/EntityModel.php @@ -3,6 +3,8 @@ class EntityModel extends Eloquent { protected $softDelete = true; + protected $hidden = ['id', 'created_at', 'deleted_at', 'updated_at']; + public static function createNew($parent = false) { $className = get_called_class(); diff --git a/app/ninja/repositories/InvoiceRepository.php b/app/ninja/repositories/InvoiceRepository.php index 0d7065bae014..9566c925f5ea 100755 --- a/app/ninja/repositories/InvoiceRepository.php +++ b/app/ninja/repositories/InvoiceRepository.php @@ -80,7 +80,7 @@ class InvoiceRepository } $invoice = (array) $input; - $rules = ['invoice_number' => 'unique:invoices,invoice_number,' . $input->id]; + $rules = ['invoice_number' => 'unique:invoices,invoice_number,' . $invoice['invoice_number'] . ',id,account_id,' . \Auth::user()->account_id]; $validator = \Validator::make($invoice, $rules); if ($validator->fails()) diff --git a/app/views/clients/edit.blade.php b/app/views/clients/edit.blade.php index bd1285cbb1d8..b7fb500b45d3 100755 --- a/app/views/clients/edit.blade.php +++ b/app/views/clients/edit.blade.php @@ -21,6 +21,26 @@
+ + {{ Former::legend('Organization') }} + {{ Former::text('name')->data_bind("attr { placeholder: placeholderName }") }} + {{ Former::text('website') }} + {{ Former::text('work_phone')->label('Phone') }} + + + {{ Former::legend('Address') }} + {{ Former::text('address1')->label('Street') }} + {{ Former::text('address2')->label('Apt/Floor') }} + {{ Former::text('city') }} + {{ Former::text('state') }} + {{ Former::text('postal_code') }} + {{ Former::select('country_id')->addOption('','')->label('Country') + ->fromQuery($countries, 'name', 'id')->select($client ? $client->country_id : '') }} + + +
+
+ {{ Former::legend('Contacts') }}
-
- - - {{ Former::legend('Organization') }} - {{ Former::text('name') }} - {{ Former::text('website') }} - {{ Former::text('work_phone')->label('Phone') }} - - - {{ Former::legend('Address') }} - {{ Former::text('address1')->label('Street') }} - {{ Former::text('address2')->label('Apt/Floor') }} - {{ Former::text('city') }} - {{ Former::text('state') }} - {{ Former::text('postal_code') }} - {{ Former::select('country_id')->addOption('','')->label('Country') - ->fromQuery($countries, 'name', 'id')->select($client ? $client->country_id : '') }} - -
@@ -99,6 +99,16 @@ function ContactsModel() { var self = this; self.contacts = ko.observableArray(); + + self.placeholderName = ko.computed(function() { + if (self.contacts().length == 0) return ''; + var contact = self.contacts()[0]; + if (contact.first_name() || contact.last_name()) { + return contact.first_name() + ' ' + contact.last_name(); + } else { + return contact.email(); + } + }); } @if ($client) diff --git a/app/views/credits/edit.blade.php b/app/views/credits/edit.blade.php index 127ef900369b..05113368629d 100755 --- a/app/views/credits/edit.blade.php +++ b/app/views/credits/edit.blade.php @@ -30,6 +30,7 @@ @endif {{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }} + {{ Former::select('invoice')->addOption('', '')->addGroupClass('invoice-select') }} {{ Former::text('amount') }} {{ Former::text('credit_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }} {{ Former::select('currency_id')->addOption('','')->label('Currency') @@ -50,19 +51,18 @@