2015-10-14 16:15:39 +02:00
@ extends ( 'header' )
2015-03-16 22:45:25 +01:00
@ section ( 'head' )
@ parent
2015-12-10 12:03:45 +01:00
@ include ( 'money_script' )
2016-01-07 08:08:30 +01:00
@ foreach ( $account -> getFontFolders () as $font )
< script src = " { { asset('js/vfs_fonts/'. $font .'.js') }} " type = " text/javascript " ></ script >
@ endforeach
2016-06-05 21:55:23 +02:00
< script src = " { { asset('pdf.built.js') }}?no_cache= { { NINJA_VERSION }} " type = " text/javascript " ></ script >
2016-02-25 11:16:27 +01:00
< script src = " { { asset('js/lightbox.min.js') }} " type = " text/javascript " ></ script >
2016-07-21 14:35:23 +02:00
< link href = " { { asset('css/lightbox.css') }} " rel = " stylesheet " type = " text/css " />
2017-06-21 10:07:59 +02:00
@ stop
2015-04-27 14:28:40 +02:00
2017-06-21 10:07:59 +02:00
@ section ( 'head_css' )
@ parent
2016-09-05 07:10:39 +02:00
2017-06-21 10:07:59 +02:00
< style type = " text/css " >
. label - group {
display : none ;
}
</ style >
2015-03-16 22:45:25 +01:00
@ stop
2016-06-05 21:55:23 +02:00
@ section ( 'content' )
2015-03-16 22:45:25 +01:00
@ parent
2015-10-14 16:15:39 +02:00
@ include ( 'accounts.nav' , [ 'selected' => ACCOUNT_INVOICE_DESIGN , 'advanced' => true ])
2016-09-05 07:10:39 +02:00
@ include ( 'accounts.partials.invoice_fields' )
2015-03-16 22:45:25 +01:00
< script >
2015-04-01 21:57:02 +02:00
var invoiceDesigns = { !! $invoiceDesigns !! };
2016-01-07 08:08:30 +01:00
var invoiceFonts = { !! $invoiceFonts !! };
2017-05-08 21:10:39 +02:00
var invoice = { !! json_encode ( $invoice ) !! };
2016-06-05 21:55:23 +02:00
2015-03-16 22:45:25 +01:00
function getDesignJavascript () {
var id = $ ( '#invoice_design_id' ) . val ();
if ( id == '-1' ) {
2016-06-05 21:55:23 +02:00
showMoreDesigns ();
2015-03-16 22:45:25 +01:00
$ ( '#invoice_design_id' ) . val ( 1 );
2016-01-07 08:08:30 +01:00
return invoiceDesigns [ 0 ] . javascript ;
2016-06-05 21:55:23 +02:00
} else {
2015-07-21 20:51:56 +02:00
var design = _ . find ( invoiceDesigns , function ( design ){ return design . id == id });
return design ? design . javascript : '' ;
2015-03-16 22:45:25 +01:00
}
}
2016-01-07 08:08:30 +01:00
function loadFont ( fontId ){
var fontFolder = '' ;
$ . each ( window . invoiceFonts , function ( i , font ){
if ( font . id == fontId ) fontFolder = font . folder ;
});
if ( ! window . ninjaFontVfs [ fontFolder ]){
window . loadingFonts = true ;
jQuery . getScript ({ !! json_encode ( asset ( 'js/vfs_fonts/%s.js' )) !! } . replace ( '%s' , fontFolder ), function (){ window . loadingFonts = false ; ninjaLoadFontVfs (); refreshPDF ()})
}
}
2016-06-05 21:55:23 +02:00
2015-04-14 13:07:50 +02:00
function getPDFString ( cb ) {
2016-04-19 04:35:18 +02:00
invoice . features = {
customize_invoice_design : {{ Auth :: user () -> hasFeature ( FEATURE_CUSTOMIZE_INVOICE_DESIGN ) ? 'true' : 'false' }},
remove_created_by : {{ Auth :: user () -> hasFeature ( FEATURE_REMOVE_CREATED_BY ) ? 'true' : 'false' }},
invoice_settings : {{ Auth :: user () -> hasFeature ( FEATURE_INVOICE_SETTINGS ) ? 'true' : 'false' }}
};
2016-03-23 23:40:42 +01:00
invoice . account . invoice_embed_documents = $ ( '#invoice_embed_documents' ) . is ( " :checked " );
2015-03-16 22:45:25 +01:00
invoice . account . hide_paid_to_date = $ ( '#hide_paid_to_date' ) . is ( " :checked " );
invoice . invoice_design_id = $ ( '#invoice_design_id' ) . val ();
2016-04-19 09:51:57 +02:00
invoice . account . page_size = $ ( '#page_size option:selected' ) . text ();
2016-09-05 14:28:59 +02:00
invoice . account . invoice_fields = ko . mapping . toJSON ( model );
2016-06-05 21:55:23 +02:00
2015-03-16 22:45:25 +01:00
NINJA . primaryColor = $ ( '#primary_color' ) . val ();
NINJA . secondaryColor = $ ( '#secondary_color' ) . val ();
2015-05-22 09:22:24 +02:00
NINJA . fontSize = parseInt ( $ ( '#font_size' ) . val ());
2016-04-19 09:51:57 +02:00
NINJA . headerFont = $ ( '#header_font_id option:selected' ) . text ();
NINJA . bodyFont = $ ( '#body_font_id option:selected' ) . text ();
2016-06-05 21:55:23 +02:00
2017-06-21 12:35:55 +02:00
var fields = { !! json_encode ( App\Models\Account :: $customLabels ) !! };
2015-05-27 22:20:35 +02:00
for ( var i = 0 ; i < fields . length ; i ++ ) {
var field = fields [ i ];
var val = $ ( '#labels_' + field ) . val ();
2017-06-21 12:35:55 +02:00
if ( ! invoiceLabels [ field + '_orig' ]) {
invoiceLabels [ field + '_orig' ] = invoiceLabels [ field ];
}
invoiceLabels [ field ] = val || invoiceLabels [ field + '_orig' ];
2015-10-16 07:32:02 +02:00
}
2015-05-27 22:20:35 +02:00
2015-10-16 07:32:02 +02:00
generatePDF ( invoice , getDesignJavascript (), true , cb );
2015-03-16 22:45:25 +01:00
}
2017-06-21 10:07:59 +02:00
function updateFieldLabels () {
@ foreach ( App\Models\Account :: $customLabels as $field )
if ( $ ( '#labels_{{ $field }}' ) . val ()) {
$ ( '.{{ $field }}-label-group' ) . show ();
} else {
$ ( '.{{ $field }}-label-group' ) . hide ();
}
@ endforeach
}
function onFieldChange () {
var $select = $ ( '#label_field' );
var id = $select . val ();
2017-06-21 12:35:55 +02:00
$select . val ( null ) . blur ();
2017-06-21 10:07:59 +02:00
$ ( '.' + id + '-label-group' ) . fadeIn ();
2017-11-06 18:26:33 +01:00
showUsedFields ();
}
function showUsedFields () {
$ ( '#label_field > option' ) . each ( function ( key , option ) {
var isUsed = $ ( '#labels_' + option . value ) . is ( ':visible' );
$ ( this ) . css ( 'color' , isUsed ? '#888' : 'black' );
});
2017-06-21 10:07:59 +02:00
}
2016-06-05 21:55:23 +02:00
$ ( function () {
2015-03-16 22:45:25 +01:00
var options = {
preferredFormat : 'hex' ,
2016-04-19 04:35:18 +02:00
disabled : { !! Auth :: user () -> hasFeature ( FEATURE_CUSTOMIZE_INVOICE_DESIGN ) ? 'false' : 'true' !! },
2015-03-16 22:45:25 +01:00
showInitial : false ,
showInput : true ,
allowEmpty : true ,
clickoutFiresChange : true ,
};
$ ( '#primary_color' ) . spectrum ( options );
$ ( '#secondary_color' ) . spectrum ( options );
2016-01-07 08:40:46 +01:00
$ ( '#header_font_id' ) . change ( function (){ loadFont ( $ ( '#header_font_id' ) . val ())});
$ ( '#body_font_id' ) . change ( function (){ loadFont ( $ ( '#body_font_id' ) . val ())});
2016-06-05 21:55:23 +02:00
2017-06-21 10:07:59 +02:00
updateFieldLabels ();
2015-03-16 22:45:25 +01:00
refreshPDF ();
2017-11-06 18:26:33 +01:00
setTimeout ( function () {
showUsedFields ();
}, 1 );
2015-03-16 22:45:25 +01:00
});
2016-06-05 21:55:23 +02:00
</ script >
2015-03-16 22:45:25 +01:00
< div class = " row " >
2015-10-15 21:37:01 +02:00
< div class = " col-md-12 " >
2015-03-16 22:45:25 +01:00
2016-01-07 08:08:30 +01:00
{ !! Former :: open () -> addClass ( 'warn-on-exit' ) -> onchange ( 'if(!window.loadingFonts)refreshPDF()' ) !! }
2016-06-05 21:55:23 +02:00
2016-04-19 09:51:57 +02:00
{ !! Former :: populateField ( 'invoice_design_id' , $account -> invoice_design_id ) !! }
2017-06-01 18:13:13 +02:00
{ !! Former :: populateField ( 'quote_design_id' , $account -> quote_design_id ) !! }
2016-06-29 21:48:56 +02:00
{ !! Former :: populateField ( 'body_font_id' , $account -> getBodyFontId ()) !! }
{ !! Former :: populateField ( 'header_font_id' , $account -> getHeaderFontId ()) !! }
2016-04-19 09:51:57 +02:00
{ !! Former :: populateField ( 'font_size' , $account -> font_size ) !! }
{ !! Former :: populateField ( 'page_size' , $account -> page_size ) !! }
{ !! Former :: populateField ( 'invoice_embed_documents' , intval ( $account -> invoice_embed_documents )) !! }
{ !! Former :: populateField ( 'primary_color' , $account -> primary_color ) !! }
{ !! Former :: populateField ( 'secondary_color' , $account -> secondary_color ) !! }
2015-04-01 21:57:02 +02:00
{ !! Former :: populateField ( 'hide_paid_to_date' , intval ( $account -> hide_paid_to_date )) !! }
2016-01-31 22:42:20 +01:00
{ !! Former :: populateField ( 'all_pages_header' , intval ( $account -> all_pages_header )) !! }
{ !! Former :: populateField ( 'all_pages_footer' , intval ( $account -> all_pages_footer )) !! }
2018-04-11 22:18:01 +02:00
{ !! Former :: populateField ( 'background_image_id' , $account -> background_image ? $account -> background_image -> public_id : null ) !! }
2015-09-07 11:07:55 +02:00
2016-09-05 07:10:39 +02:00
@ foreach ( $invoiceLabels as $field => $value )
2015-05-29 19:57:03 +02:00
{ !! Former :: populateField ( " labels_ { $field } " , $value ) !! }
@ endforeach
2015-03-16 22:45:25 +01:00
2016-09-05 07:10:39 +02:00
< div style = " display:none " >
2016-09-05 14:28:59 +02:00
{ !! Former :: text ( 'invoice_fields_json' ) -> data_bind ( 'value: ko.mapping.toJSON(model)' ) !! }
2016-09-05 07:10:39 +02:00
</ div >
2015-04-20 16:34:23 +02:00
< div class = " panel panel-default " >
< div class = " panel-heading " >
< h3 class = " panel-title " > { !! trans ( 'texts.invoice_design' ) !! } </ h3 >
</ div >
2015-05-27 22:20:35 +02:00
2016-09-05 14:28:59 +02:00
< div class = " panel-body " >
2015-10-15 21:37:01 +02:00
< div role = " tabpanel " >
< ul class = " nav nav-tabs " role = " tablist " style = " border: none " >
2016-09-05 14:28:59 +02:00
< li role = " presentation " class = " active " >< a href = " #general_settings " aria - controls = " general_settings " role = " tab " data - toggle = " tab " > {{ trans ( 'texts.general_settings' ) }} </ a ></ li >
< li role = " presentation " >< a href = " #invoice_labels " aria - controls = " invoice_labels " role = " tab " data - toggle = " tab " > {{ trans ( 'texts.invoice_labels' ) }} </ a ></ li >
< li role = " presentation " >< a href = " #invoice_fields " aria - controls = " invoice_fields " role = " tab " data - toggle = " tab " > {{ trans ( 'texts.invoice_fields' ) }} </ a ></ li >
2017-10-27 10:46:08 +02:00
< li role = " presentation " >< a href = " #product_fields " aria - controls = " product_fields " role = " tab " data - toggle = " tab " > {{ trans ( 'texts.product_fields' ) }} </ a ></ li >
2016-09-05 14:28:59 +02:00
< li role = " presentation " >< a href = " #invoice_options " aria - controls = " invoice_options " role = " tab " data - toggle = " tab " > {{ trans ( 'texts.invoice_options' ) }} </ a ></ li >
2015-10-15 21:37:01 +02:00
</ ul >
</ div >
< div class = " tab-content " >
2016-09-05 14:28:59 +02:00
< div role = " tabpanel " class = " tab-pane active " id = " general_settings " >
2015-10-15 21:37:01 +02:00
< div class = " panel-body " >
2016-01-10 19:40:04 +01:00
< div class = " row " >
< div class = " col-md-6 " >
2017-06-01 18:13:13 +02:00
{ !! Former :: select ( 'invoice_design_id' )
2018-04-15 21:31:26 +02:00
-> label ( 'invoice_design' )
2017-06-01 18:13:13 +02:00
-> fromQuery ( $invoiceDesigns , 'name' , 'id' ) !! }
{ !! Former :: select ( 'quote_design_id' )
-> label ( 'quote_design' )
-> fromQuery ( $invoiceDesigns , 'name' , 'id' ) !! }
2016-01-10 19:40:04 +01:00
{ !! Former :: select ( 'body_font_id' )
-> fromQuery ( $invoiceFonts , 'name' , 'id' ) !! }
{ !! Former :: select ( 'header_font_id' )
-> fromQuery ( $invoiceFonts , 'name' , 'id' ) !! }
</ div >
< div class = " col-md-6 " >
{{ Former :: setOption ( 'TwitterBootstrap3.labelWidths.large' , 6 ) }}
{{ Former :: setOption ( 'TwitterBootstrap3.labelWidths.small' , 6 ) }}
2016-04-19 09:51:57 +02:00
{ !! Former :: select ( 'page_size' )
-> options ( $pageSizes ) !! }
2016-06-05 21:55:23 +02:00
2016-01-10 19:40:04 +01:00
{ !! Former :: text ( 'font_size' )
-> type ( 'number' )
-> min ( '0' )
-> step ( '1' ) !! }
{ !! Former :: text ( 'primary_color' ) !! }
{ !! Former :: text ( 'secondary_color' ) !! }
2016-04-19 09:51:57 +02:00
2016-01-10 19:40:04 +01:00
{{ Former :: setOption ( 'TwitterBootstrap3.labelWidths.large' , 4 ) }}
{{ Former :: setOption ( 'TwitterBootstrap3.labelWidths.small' , 4 ) }}
</ div >
</ div >
2016-09-21 11:43:47 +02:00
< div class = " help-block " style = " padding-top:16px " >
2016-01-10 19:40:04 +01:00
{{ trans ( 'texts.color_font_help' ) }}
</ div >
2015-10-15 21:37:01 +02:00
</ div >
</ div >
2016-09-05 14:28:59 +02:00
< div role = " tabpanel " class = " tab-pane " id = " invoice_labels " >
2015-10-15 21:37:01 +02:00
< div class = " panel-body " >
2015-11-21 22:10:26 +01:00
< div class = " row " >
< div class = " col-md-6 " >
2017-06-21 10:07:59 +02:00
{ !! Former :: select ( 'label_field' )
2017-06-21 12:35:55 +02:00
-> placeholder ( 'select_label' )
-> label ( 'label' )
2017-06-21 10:07:59 +02:00
-> onchange ( 'onFieldChange()' )
-> options ( array_combine ( App\Models\Account :: $customLabels , Utils :: trans ( App\Models\Account :: $customLabels ))) !! }
2017-01-16 10:38:34 +01:00
</ div >
< div class = " col-md-6 " >
2017-07-09 19:06:34 +02:00
@ foreach ( App\Models\Account :: $customLabels as $field )
{ !! Former :: text ( 'labels_' . $field )
-> label ( $field )
-> addGroupClass ( $field . '-label-group label-group' ) !! }
@ endforeach
2015-11-21 22:10:26 +01:00
</ div >
</ div >
2015-10-15 21:37:01 +02:00
</ div >
</ div >
2016-09-05 14:28:59 +02:00
< div role = " tabpanel " class = " tab-pane " id = " invoice_fields " >
2016-09-02 16:53:16 +02:00
< div class = " panel-body " >
2017-10-27 10:46:08 +02:00
< div class = " row " id = " invoiceFields " >
2016-09-05 07:10:39 +02:00
@ include ( 'accounts.partials.invoice_fields_selector' , [ 'section' => 'invoice_fields' , 'fields' => INVOICE_FIELDS_INVOICE ])
@ include ( 'accounts.partials.invoice_fields_selector' , [ 'section' => 'client_fields' , 'fields' => INVOICE_FIELDS_CLIENT ])
2016-09-05 14:28:59 +02:00
@ include ( 'accounts.partials.invoice_fields_selector' , [ 'section' => 'account_fields1' , 'fields' => INVOICE_FIELDS_ACCOUNT ])
@ include ( 'accounts.partials.invoice_fields_selector' , [ 'section' => 'account_fields2' , 'fields' => INVOICE_FIELDS_ACCOUNT ])
</ div >
2016-09-21 11:43:47 +02:00
< div class = " row " style = " padding-top:30px " >
< div class = " pull-left help-block " >
2017-10-27 10:46:08 +02:00
{{ trans ( 'texts.invoice_fields_help' ) }}
2016-09-21 11:43:47 +02:00
</ div >
2017-10-27 10:46:08 +02:00
< div class = " pull-right " style = " padding-right:14px " >
{ !! Button :: normal ( trans ( 'texts.reset' )) -> small ()
2016-09-05 14:28:59 +02:00
-> withAttributes ([ 'onclick' => ' sweetConfirm ( function () {
2017-10-29 09:02:17 +01:00
resetInvoiceFields ();
2017-10-27 10:46:08 +02:00
}) ' ]) !! }
2016-09-05 14:28:59 +02:00
</ div >
2016-09-02 16:53:16 +02:00
</ div >
</ div >
</ div >
2017-10-27 10:46:08 +02:00
< div role = " tabpanel " class = " tab-pane " id = " product_fields " >
< div class = " panel-body " >
< div class = " row " id = " productFields " >
@ include ( 'accounts.partials.invoice_fields_selector' , [ 'section' => 'product_fields' , 'fields' => INVOICE_FIELDS_PRODUCT , 'colWidth' => 6 ])
@ include ( 'accounts.partials.invoice_fields_selector' , [ 'section' => 'task_fields' , 'fields' => INVOICE_FIELDS_TASK , 'colWidth' => 6 ])
</ div >
< div class = " row " style = " padding-top:30px " >
< div class = " pull-left help-block " >
{{ trans ( 'texts.product_fields_help' ) }}
</ div >
< div class = " pull-right " style = " padding-right:14px " >
{ !! Button :: normal ( trans ( 'texts.reset' )) -> small ()
-> withAttributes ([ 'onclick' => ' sweetConfirm ( function () {
2017-10-29 09:02:17 +01:00
resetProductFields ();
2017-10-27 10:46:08 +02:00
}) ' ]) !! }
</ div >
</ div >
</ div >
</ div >
2016-09-05 14:28:59 +02:00
< div role = " tabpanel " class = " tab-pane " id = " invoice_options " >
2015-10-15 21:37:01 +02:00
< div class = " panel-body " >
2018-04-11 22:18:01 +02:00
@ if ( auth () -> user () -> isEnterprise ())
{ !! Former :: select ( 'background_image_id' )
-> label ( 'background_image' )
-> addOption ( '' , '' )
2018-04-17 14:43:11 +02:00
-> fromQuery ( \App\Models\Document :: scope () -> proposalImages () -> get (), function ( $model ) { return $model -> name . ' - ' . Utils :: formatNumber ( $model -> size / 1000 , null , 1 ) . ' KB' ; }, 'public_id' )
2018-07-08 13:01:01 +02:00
-> help ( $account -> isModuleEnabled ( ENTITY_PROPOSAL )
? trans ( 'texts.background_image_help' , [ 'link' => link_to ( '/proposals/create?show_assets=true' , trans ( 'texts.proposal_editor' ), [ 'target' => '_blank' ])])
//: trans('texts.enable_proposals_for_background', ['link' => link_to('/settings/account_management', trans('texts.click_here'), ['target' => '_blank'])])
: 'To upload a background image <a href="http://www.ninja.test/settings/account_management" target="_blank">click here</a> to enable the proposals module.'
) !! }
2018-04-11 22:18:01 +02:00
@ endif
{ !! Former :: checkbox ( 'hide_paid_to_date' ) -> text ( trans ( 'texts.hide_paid_to_date_help' )) -> value ( 1 ) !! }
{ !! Former :: checkbox ( 'invoice_embed_documents' ) -> text ( trans ( 'texts.invoice_embed_documents_help' )) -> value ( 1 ) !! }
< br />
{ !! Former :: inline_radios ( 'all_pages_header' )
-> label ( trans ( 'texts.all_pages_header' ))
-> radios ([
trans ( 'texts.first_page' ) => [ 'value' => 0 , 'name' => 'all_pages_header' ],
trans ( 'texts.all_pages' ) => [ 'value' => 1 , 'name' => 'all_pages_header' ],
]) -> check ( $account -> all_pages_header ) !! }
{ !! Former :: inline_radios ( 'all_pages_footer' )
-> label ( trans ( 'texts.all_pages_footer' ))
-> radios ([
trans ( 'texts.last_page' ) => [ 'value' => 0 , 'name' => 'all_pages_footer' ],
trans ( 'texts.all_pages' ) => [ 'value' => 1 , 'name' => 'all_pages_footer' ],
]) -> check ( $account -> all_pages_footer ) !! }
2016-01-31 22:42:20 +01:00
</ div >
</ div >
2015-10-15 21:37:01 +02:00
</ div >
2015-04-20 16:34:23 +02:00
</ div >
</ div >
2015-03-16 22:45:25 +01:00
2017-11-03 09:19:03 +01:00
< center class = " buttons " >
{ !! $account -> getCustomDesign ( CUSTOM_DESIGN1 ) ?
2017-06-01 18:13:13 +02:00
DropdownButton :: primary ( trans ( 'texts.customize' ))
-> withContents ( $account -> present () -> customDesigns )
-> large () :
Button :: primary ( trans ( 'texts.customize' ))
-> appendIcon ( Icon :: create ( 'edit' ))
-> asLinkTo ( URL :: to ( '/settings/customize_design' ) . '?design_id=' . CUSTOM_DESIGN1 )
2017-11-03 09:19:03 +01:00
-> large () !! }
{ !! Auth :: user () -> hasFeature ( FEATURE_CUSTOMIZE_INVOICE_DESIGN ) ?
2016-06-29 21:48:56 +02:00
Button :: success ( trans ( 'texts.save' ))
-> submit () -> large ()
-> appendIcon ( Icon :: create ( 'floppy-disk' ))
-> withAttributes ([ 'class' => 'save-button' ]) :
2017-11-03 09:19:03 +01:00
false !! }
</ center >
2015-10-16 07:32:02 +02:00
2015-04-01 21:57:02 +02:00
{ !! Former :: close () !! }
2015-03-16 22:45:25 +01:00
</ div >
2015-10-15 21:37:01 +02:00
</ div >
2015-03-16 22:45:25 +01:00
@ include ( 'invoices.pdf' , [ 'account' => Auth :: user () -> account , 'pdfHeight' => 800 ])
2016-06-05 21:55:23 +02:00
@ stop