mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Don’t require client email address
This commit is contained in:
parent
49d648d6ef
commit
bbce6b8ce8
@ -21,9 +21,7 @@ class CreateClientRequest extends ClientRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'contacts' => 'valid_contacts',
|
||||
];
|
||||
$rules = [];
|
||||
|
||||
if ($this->user()->account->client_number_counter) {
|
||||
$rules['id_number'] = 'unique:clients,id_number,,id,account_id,' . $this->user()->account_id;
|
||||
|
@ -24,7 +24,7 @@ class CreateInvoiceRequest extends InvoiceRequest
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'client.contacts' => 'valid_contacts',
|
||||
'client' => 'required',
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'required|unique:invoices,invoice_number,,id,account_id,' . $this->user()->account_id,
|
||||
'discount' => 'positive',
|
||||
|
@ -21,9 +21,7 @@ class UpdateClientRequest extends ClientRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'contacts' => 'valid_contacts',
|
||||
];
|
||||
$rules = [];
|
||||
|
||||
if ($this->user()->account->client_number_counter) {
|
||||
$rules['id_number'] = 'unique:clients,id_number,'.$this->entity()->id.',id,account_id,' . $this->user()->account_id;
|
||||
|
@ -26,7 +26,7 @@ class UpdateInvoiceRequest extends InvoiceRequest
|
||||
$invoiceId = $this->entity()->id;
|
||||
|
||||
$rules = [
|
||||
'client.contacts' => 'valid_contacts',
|
||||
'client' => 'required',
|
||||
'invoice_items' => 'valid_invoice_items',
|
||||
'invoice_number' => 'required|unique:invoices,invoice_number,' . $invoiceId . ',id,account_id,' . $this->user()->account_id,
|
||||
'discount' => 'positive',
|
||||
|
@ -178,20 +178,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
return ! $value || strstr($value, '{$counter}');
|
||||
});
|
||||
|
||||
Validator::extend('valid_contacts', function ($attribute, $value, $parameters) {
|
||||
foreach ($value as $contact) {
|
||||
$validator = Validator::make($contact, [
|
||||
'email' => 'email|required_without:first_name',
|
||||
'first_name' => 'required_without:email',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Validator::extend('valid_invoice_items', function ($attribute, $value, $parameters) {
|
||||
$total = 0;
|
||||
foreach ($value as $item) {
|
||||
|
@ -523,7 +523,7 @@ $LANG = array(
|
||||
'www' => 'www',
|
||||
'logo' => 'Logo',
|
||||
'subdomain' => 'Subdomain',
|
||||
'provide_name_or_email' => 'Please provide a contact name or email',
|
||||
'provide_name_or_email' => 'Please provide a name or email',
|
||||
'charts_and_reports' => 'Charts & Reports',
|
||||
'chart' => 'Chart',
|
||||
'report' => 'Report',
|
||||
|
@ -122,11 +122,11 @@
|
||||
@endif
|
||||
|
||||
<div data-bind="with: client" class="invoice-contact">
|
||||
<div style="display:none" class="form-group" data-bind="visible: contacts().length > 0 && (contacts()[0].email() || contacts()[0].first_name()), foreach: contacts">
|
||||
<div style="display:none" class="form-group" data-bind="visible: contacts().length > 0, foreach: contacts">
|
||||
<div class="col-lg-8 col-lg-offset-4 col-sm-offset-4">
|
||||
<label class="checkbox" data-bind="attr: {for: $index() + '_check'}" onclick="refreshPDF(true)">
|
||||
<input type="hidden" value="0" data-bind="attr: {name: 'client[contacts][' + $index() + '][send_invoice]'}">
|
||||
<input type="checkbox" value="1" data-bind="checked: send_invoice, attr: {id: $index() + '_check', name: 'client[contacts][' + $index() + '][send_invoice]'}">
|
||||
<input type="checkbox" value="1" data-bind="visible: email || first_name || last_name, checked: send_invoice, attr: {id: $index() + '_check', name: 'client[contacts][' + $index() + '][send_invoice]'}">
|
||||
<span data-bind="html: email.display"></span>
|
||||
</label>
|
||||
@if ( ! $invoice->is_deleted && ! $invoice->client->is_deleted)
|
||||
@ -1466,13 +1466,11 @@
|
||||
}
|
||||
|
||||
function isSaveValid() {
|
||||
var isValid = false;
|
||||
var isValid = model.invoice().client().name ? true : false;
|
||||
for (var i=0; i<model.invoice().client().contacts().length; i++) {
|
||||
var contact = model.invoice().client().contacts()[i];
|
||||
if (isValidEmailAddress(contact.email()) || contact.first_name()) {
|
||||
if (isValidEmailAddress(contact.email()) || contact.first_name() || contact.last_name()) {
|
||||
isValid = true;
|
||||
} else {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -96,11 +96,11 @@ function ViewModel(data) {
|
||||
name = email;
|
||||
}
|
||||
|
||||
var isValid = true;
|
||||
var isValid = name ? true : false;
|
||||
var contacts = self.invoice().client().contacts();
|
||||
$(contacts).each(function(item, value) {
|
||||
if (!value.isValid()) {
|
||||
isValid = false;
|
||||
if (value.isValid()) {
|
||||
isValid = true;
|
||||
}
|
||||
});
|
||||
if (!isValid) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user