Merge remote-tracking branch 'upstream/develop' into wepay-integration

This commit is contained in:
Joshua Dwire 2016-05-25 11:14:14 -04:00
commit 6ddbbbc64d
4 changed files with 72 additions and 51 deletions

View File

@ -18,7 +18,7 @@ class AddDocuments extends Migration {
$table->boolean('invoice_embed_documents')->default(1);
$table->boolean('document_email_attachment')->default(1);
});
\DB::table('accounts')->update(array('logo' => ''));
Schema::dropIfExists('documents');
Schema::create('documents', function($t)
@ -41,14 +41,14 @@ class AddDocuments extends Migration {
$t->timestamps();
$t->foreign('account_id')->references('id')->on('accounts');
$t->foreign('user_id')->references('id')->on('users');
$t->foreign('invoice_id')->references('id')->on('invoices');
$t->foreign('expense_id')->references('id')->on('expenses');
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
$t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade');
$t->unique( array('account_id','public_id') );
});
});
}
/**
* Reverse the migrations.
@ -65,7 +65,7 @@ class AddDocuments extends Migration {
$table->dropColumn('invoice_embed_documents');
$table->dropColumn('document_email_attachment');
});
Schema::dropIfExists('documents');
}
}

View File

@ -1311,6 +1311,7 @@ $LANG = array(
'new_start_date' => 'New start date',
'security' => 'Security',
'see_whats_new' => 'See what\'s new in v:version',
'wait_for_upload' => 'Please wait for the document upload to complete.',
'view_dashboard' => 'View Dashboard',
'client_session_expired' => 'Session Expired',

View File

@ -249,7 +249,7 @@
public_id:document.public_id(),
status:Dropzone.SUCCESS,
accepted:true,
url:document.preview_url()||document.url(),
url:document.url(),
mock:true,
index:i
};

View File

@ -998,47 +998,59 @@
})
// Initialize document upload
dropzone = new Dropzone('#document-upload .dropzone', {
url:{!! json_encode(url('document')) !!},
params:{
_token:"{{ Session::getToken() }}"
},
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
addRemoveLinks:true,
@foreach(['default_message', 'fallback_message', 'fallback_text', 'file_too_big', 'invalid_file_type', 'response_error', 'cancel_upload', 'cancel_upload_confirmation', 'remove_file'] as $key)
"dict{{Utils::toClassCase($key)}}":"{{trans('texts.dropzone_'.$key)}}",
@endforeach
maxFileSize:{{floatval(MAX_DOCUMENT_SIZE/1000)}},
});
if(dropzone instanceof Dropzone){
dropzone.on("addedfile",handleDocumentAdded);
dropzone.on("removedfile",handleDocumentRemoved);
dropzone.on("success",handleDocumentUploaded);
for (var i=0; i<model.invoice().documents().length; i++) {
var document = model.invoice().documents()[i];
var mockFile = {
name:document.name(),
size:document.size(),
type:document.type(),
public_id:document.public_id(),
status:Dropzone.SUCCESS,
accepted:true,
url:document.preview_url()||document.url(),
mock:true,
index:i
};
dropzone.emit('addedfile', mockFile);
dropzone.emit('complete', mockFile);
if(document.preview_url()){
dropzone.emit('thumbnail', mockFile, document.preview_url()||document.url());
}
else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){
dropzone.emit('thumbnail', mockFile, document.url());
}
dropzone.files.push(mockFile);
window.dropzone = false;
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (window.dropzone) {
return;
}
}
var target = $(e.target).attr('href') // activated tab
if (target != '#attached-documents') {
return;
}
window.dropzone = new Dropzone('#document-upload .dropzone', {
url:{!! json_encode(url('document')) !!},
params:{
_token:"{{ Session::getToken() }}"
},
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
addRemoveLinks:true,
@foreach(['default_message', 'fallback_message', 'fallback_text', 'file_too_big', 'invalid_file_type', 'response_error', 'cancel_upload', 'cancel_upload_confirmation', 'remove_file'] as $key)
"dict{{Utils::toClassCase($key)}}":"{{trans('texts.dropzone_'.$key)}}",
@endforeach
maxFileSize:{{floatval(MAX_DOCUMENT_SIZE/1000)}},
});
if(dropzone instanceof Dropzone){
dropzone.on("addedfile",handleDocumentAdded);
dropzone.on("removedfile",handleDocumentRemoved);
dropzone.on("success",handleDocumentUploaded);
for (var i=0; i<model.invoice().documents().length; i++) {
var document = model.invoice().documents()[i];
var mockFile = {
name:document.name(),
size:document.size(),
type:document.type(),
public_id:document.public_id(),
status:Dropzone.SUCCESS,
accepted:true,
url:document.url(),
mock:true,
index:i
};
dropzone.emit('addedfile', mockFile);
dropzone.emit('complete', mockFile);
if(document.preview_url()){
dropzone.emit('thumbnail', mockFile, document.preview_url());
}
else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){
dropzone.emit('thumbnail', mockFile, document.url());
}
dropzone.files.push(mockFile);
}
}
});
@endif
});
@ -1222,7 +1234,7 @@
}
}
preparePdfData('');
submitAction('');
}
function getSendToEmails() {
@ -1257,6 +1269,11 @@
}
function onFormSubmit(event) {
if (window.countUploadingDocuments > 0) {
alert("{!! trans('texts.wait_for_upload') !!}");
return false;
}
if (!isSaveValid()) {
model.showClientForm();
return false;
@ -1431,6 +1448,7 @@
model.invoice().invoice_number(number);
}
window.countUploadingDocuments = 0;
@if ($account->hasFeature(FEATURE_DOCUMENTS))
function handleDocumentAdded(file){
// open document when clicked
@ -1442,6 +1460,7 @@
if(file.mock)return;
file.index = model.invoice().documents().length;
model.invoice().addDocument({name:file.name, size:file.size, type:file.type});
window.countUploadingDocuments++;
}
function handleDocumentRemoved(file){
@ -1452,6 +1471,7 @@
function handleDocumentUploaded(file, response){
file.public_id = response.document.public_id
model.invoice().documents()[file.index].update(response.document);
window.countUploadingDocuments--;
refreshPDF(true);
if(response.document.preview_url){