Inizializzazione dei dropdown di categoria e tags
This commit is contained in:
		
							parent
							
								
									957cc88a3f
								
							
						
					
					
						commit
						031e4957b4
					
				@ -22,12 +22,12 @@ class Categorie extends Model
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public static function listSpesa()
 | 
					    public static function listSpesa()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return DB::table('categories')->where('cat_uscita','=',1)->get(); 
 | 
					        return DB::table('categories')->where('cat_uscita','=',1)->orderBy('cat_name')->get(); 
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static function listEntrata()
 | 
					    public static function listEntrata()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return DB::table('categories')->where('cat_entrata','=',1)->get();
 | 
					        return DB::table('categories')->where('cat_entrata','=',1)->orderBy('cat_name')->get();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public static function inserisci($request){
 | 
					    public static function inserisci($request){
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,8 @@ use Rap2hpoutre\FastExcel\FastExcel;
 | 
				
			|||||||
class Movimenti extends Model
 | 
					class Movimenti extends Model
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use HasFactory;
 | 
					    use HasFactory;
 | 
				
			||||||
 | 
					    protected $dates = ['mov_data'];
 | 
				
			||||||
 | 
					    protected $casts = [ 'mov_data'=>'datetime'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static function getList() {
 | 
					    public static function getList() {
 | 
				
			||||||
        return DB::table('movimentis')
 | 
					        return DB::table('movimentis')
 | 
				
			||||||
@ -179,7 +181,8 @@ class Movimenti extends Model
 | 
				
			|||||||
                if($line['DARE']<>'')
 | 
					                if($line['DARE']<>'')
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                $dati=[
 | 
					                $dati=[
 | 
				
			||||||
                    'mov_data'=>self::dateFormat(0,$line['VALUTA']),
 | 
					                    'mov_data'=>self::dateFormat(0,$line['VALUTA']), //      date_format(date_create($movimento->mov_data),'d/m/Y'
 | 
				
			||||||
 | 
					                //    'mov_data'=>date_format(date_create($line['VALUTA']),'Y-m-d'),
 | 
				
			||||||
                    'mov_fk_categoria'=>1,
 | 
					                    'mov_fk_categoria'=>1,
 | 
				
			||||||
                    'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
 | 
					                    'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
 | 
				
			||||||
                    'mov_importo'=>'-'.trim(str_replace(',','.',(str_replace('.','',$line['DARE'])))),
 | 
					                    'mov_importo'=>'-'.trim(str_replace(',','.',(str_replace('.','',$line['DARE'])))),
 | 
				
			||||||
@ -191,6 +194,7 @@ class Movimenti extends Model
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    $dati=[
 | 
					                    $dati=[
 | 
				
			||||||
                        'mov_data'=>self::dateFormat(0,$line['VALUTA']),
 | 
					                        'mov_data'=>self::dateFormat(0,$line['VALUTA']),
 | 
				
			||||||
 | 
					                        //'mov_data'=>date_format(date_create($line['VALUTA']),'Y-m-d'),
 | 
				
			||||||
                        'mov_fk_categoria'=>1,
 | 
					                        'mov_fk_categoria'=>1,
 | 
				
			||||||
                        'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
 | 
					                        'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
 | 
				
			||||||
                        'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',$line['AVERE'])))),
 | 
					                        'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',$line['AVERE'])))),
 | 
				
			||||||
@ -216,11 +220,11 @@ class Movimenti extends Model
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if($type)
 | 
					        if($type)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $string=$string->format('Y-m-d');
 | 
					           // $string=$string->format('Y-m-d');
 | 
				
			||||||
            list($year,$month,$day) = explode('-',$string);
 | 
					            list($year,$month,$day) = explode('-',$string);
 | 
				
			||||||
            return $day.'/'.$month.'/'.$year;
 | 
					            return $day.'/'.$month.'/'.$year;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $string=$string->format('d/m/Y');
 | 
					           // $string=$string->format('d/m/Y');
 | 
				
			||||||
            list($day,$month,$year) =explode('/',$string);
 | 
					            list($day,$month,$year) =explode('/',$string);
 | 
				
			||||||
            return $year.'-'.$month.'-'.$day;
 | 
					            return $year.'-'.$month.'-'.$day;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										52
									
								
								public/js/app/movimenti.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								public/js/app/movimenti.js
									
									
									
									
										vendored
									
									
								
							@ -24,24 +24,32 @@ var strDate = d.getFullYear() + '-' +
 | 
				
			|||||||
$(document).on('click', '.open_modal_spesa', function() {
 | 
					$(document).on('click', '.open_modal_spesa', function() {
 | 
				
			||||||
	console.log(strDate);
 | 
						console.log(strDate);
 | 
				
			||||||
	$("#categoria").empty();
 | 
						$("#categoria").empty();
 | 
				
			||||||
 | 
						$("#tags").empty();
 | 
				
			||||||
	$('#form').find('input[type="text"], textarea, input[type="number"],input[type="date"],option').val("");
 | 
						$('#form').find('input[type="text"], textarea, input[type="number"],input[type="date"],option').val("");
 | 
				
			||||||
	$('#form').find('input[type="date"]').val(strDate);
 | 
						$('#form').find('input[type="date"]').val(strDate);
 | 
				
			||||||
	$('#myModal').modal('show');
 | 
						$('#myModal').modal('show');
 | 
				
			||||||
	$('.modal-title').text(' Nuovo movimento in uscita');
 | 
						$('.modal-title').text(' Nuovo movimento in uscita');
 | 
				
			||||||
	$('#form').attr('action', '/admin/movimenti/spesa');
 | 
						$('#form').attr('action', '/admin/movimenti/spesa');
 | 
				
			||||||
	$.getJSON("/admin/service/catlistSpesa", {}, function(data) {
 | 
						$.getJSON("/admin/service/catlistSpesa", {}, function(cats) {
 | 
				
			||||||
		$.each(data, function(i, item) {
 | 
							$.each(cats, function(i, cat) {
 | 
				
			||||||
			$("select[name='mov_fk_categoria']").append(
 | 
								$("select[name='mov_fk_categoria']").append(
 | 
				
			||||||
				new Option(item.cat_name, item.id)
 | 
									new Option(cat.cat_name, cat.id)
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
						$.getJSON("/admin/service/taglist", {}, function(tags) {
 | 
				
			||||||
 | 
							$.each(tags, function(i, tag) {
 | 
				
			||||||
 | 
								$("select[name='mov_fk_tags']").append(
 | 
				
			||||||
 | 
									new Option(tag.tag_name, tag.id)
 | 
				
			||||||
 | 
								)
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					 | 
				
			||||||
$(document).on('click', '.open_modal_entrata', function() {
 | 
					$(document).on('click', '.open_modal_entrata', function() {
 | 
				
			||||||
	console.log(strDate);
 | 
						console.log(strDate);
 | 
				
			||||||
	$("#categoria").empty();
 | 
						$("#categoria").empty();
 | 
				
			||||||
 | 
						$("#tags").empty();
 | 
				
			||||||
	$('#form').find('input[type="text"], textarea, input[type="number"],option').val("");
 | 
						$('#form').find('input[type="text"], textarea, input[type="number"],option').val("");
 | 
				
			||||||
	$('#form').find('input[type="date"]').val(strDate);
 | 
						$('#form').find('input[type="date"]').val(strDate);
 | 
				
			||||||
	$('#myModal').modal('show');
 | 
						$('#myModal').modal('show');
 | 
				
			||||||
@ -55,12 +63,20 @@ $(document).on('click', '.open_modal_entrata', function() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
						$.getJSON("/admin/service/taglist", {}, function(data) {
 | 
				
			||||||
 | 
							$.each(data, function(i, item) {
 | 
				
			||||||
 | 
								$("select[name='mov_fk_tags']").append(
 | 
				
			||||||
 | 
									new Option(item.tag_name, item.id)
 | 
				
			||||||
 | 
								)
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(document).on('click', '.open_modal_modifica', function() {
 | 
					$(document).on('click', '.open_modal_modifica', function() {
 | 
				
			||||||
	var url = "/admin/movimenti/modify";
 | 
						var url = "/admin/movimenti/modify";
 | 
				
			||||||
	var riga_id = $(this).val();
 | 
						var riga_id = $(this).val();
 | 
				
			||||||
	$("#categoria").empty();
 | 
						$("#categoria").empty();
 | 
				
			||||||
 | 
						$("#tags").empty();
 | 
				
			||||||
	$.getJSON(url + '/' + riga_id, function(data) {
 | 
						$.getJSON(url + '/' + riga_id, function(data) {
 | 
				
			||||||
		// success data
 | 
							// success data
 | 
				
			||||||
		console.log(data[0]);
 | 
							console.log(data[0]);
 | 
				
			||||||
@ -80,23 +96,29 @@ $(document).on('click', '.open_modal_modifica', function() {
 | 
				
			|||||||
		// $('.panel-heading').text('Modifica movimento');
 | 
							// $('.panel-heading').text('Modifica movimento');
 | 
				
			||||||
		$('#form').attr('action', '/admin/movimenti/modify');
 | 
							$('#form').attr('action', '/admin/movimenti/modify');
 | 
				
			||||||
		$('#form').append('<input type="hidden" name="id" value="' + riga_id + '">');
 | 
							$('#form').append('<input type="hidden" name="id" value="' + riga_id + '">');
 | 
				
			||||||
 | 
							$.getJSON("/admin/service/taglist", {}, function(data) {
 | 
				
			||||||
 | 
								$.each(data, function(i, item) {
 | 
				
			||||||
 | 
									$("select[name='mov_fk_tags']").append(
 | 
				
			||||||
 | 
										new Option(item.tag_name, item.id)
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							$.getJSON("/admin/service/catlist", {}, function(data) {
 | 
				
			||||||
 | 
								$.each(data, function(i, item) {
 | 
				
			||||||
 | 
									$("select[name='mov_fk_categoria']").append(
 | 
				
			||||||
 | 
										new Option(item.cat_name, item.id)
 | 
				
			||||||
 | 
									)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								);
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
$.getJSON("/admin/service/catlist", {}, function(data) {
 | 
					 | 
				
			||||||
	$.each(data, function(i, item) {
 | 
					 | 
				
			||||||
		$("select[name='mov_fk_categoria']").append(
 | 
					 | 
				
			||||||
			new Option(item.cat_name, item.id)
 | 
					 | 
				
			||||||
		)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	);
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$.getJSON("/admin/service/taglist", {}, function(data) {
 | 
					/*$.getJSON("/admin/service/taglist", {}, function(data) {
 | 
				
			||||||
	$.each(data, function(i, item) {
 | 
						$.each(data, function(i, item) {
 | 
				
			||||||
		$("select[name='mov_fk_tags']").append(
 | 
							$("select[name='mov_fk_tags']").append(
 | 
				
			||||||
			new Option(item.tag_name, item.id)
 | 
								new Option(item.tag_name, item.id)
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
});
 | 
					});*/
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,7 @@
 | 
				
			|||||||
            		@foreach( $movimenti as $movimento )
 | 
					            		@foreach( $movimenti as $movimento )
 | 
				
			||||||
            		<tr>
 | 
					            		<tr>
 | 
				
			||||||
            			<!-- <td>{{  date_format(date_create($movimento->mov_data),'d/m/Y'); }}</td>-->
 | 
					            			<!-- <td>{{  date_format(date_create($movimento->mov_data),'d/m/Y'); }}</td>-->
 | 
				
			||||||
            			<td>{{$movimento->mov_data}}</td>
 | 
					            			<td>{{ $movimento->mov_data}}</td>
 | 
				
			||||||
                        <td>{{ $movimento->cat_name; }}</td>
 | 
					                        <td>{{ $movimento->cat_name; }}</td>
 | 
				
			||||||
            			<td>{{ $movimento->mov_descrizione; }}</td>
 | 
					            			<td>{{ $movimento->mov_descrizione; }}</td>
 | 
				
			||||||
            			<td>€ {{ $movimento->mov_importo; }}</td>
 | 
					            			<td>€ {{ $movimento->mov_importo; }}</td>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user