Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1633 | Revision 1635 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1633 Revision 1634
Zeile 22... Zeile 22...
22
        protected $description = 'Erstellt CSV-Dateien für Preisagenturen';
22
        protected $description = 'Erstellt CSV-Dateien für Preisagenturen';
Zeile 23... Zeile 23...
23
 
23
 
24
        /**
24
        /**
25
         * Execute the console command.
25
         * Execute the console command.
26
         *
26
         *
27
         * @return int
27
         * @return void
28
         */
28
         */
29
        public function handle(): int
29
        public function handle(): void
-
 
30
        {
30
        {
31
            $items = Item::with( 'price', 'medium.medium', "manufacturer" )->where( 'status', 0 )->get();
31
            $agencies = PriceAgency::where( 'shop_id', $GLOBALS["INI"]["shops_ID"] )->where( "status", "1" )->get();
32
            $agencies = PriceAgency::where( 'shop_id', $GLOBALS["INI"]["shops_ID"] )->where( "status", "1" )->get();
32
            foreach ( $agencies as $agency )
33
            foreach ( $agencies as $agency )
-
 
34
            {
33
            {
35
                $content = array();
34
                $this->info( $agency["name"] );
36
                $this->info( $agency["name"] );
35
                if ( !$agency["config"] )
37
                if ( !$agency["config"] )
36
                {
38
                {
37
                    $this->warn( "Agentur nicht komplett konfiguriert!" );
39
                    $this->warn( "Agentur nicht komplett konfiguriert!" );
Zeile 43... Zeile 45...
43
                    require $configFile;
45
                    require $configFile;
44
                }
46
                }
45
                else
47
                else
46
                {
48
                {
47
                    $this->error( "Konfigdatei " . $configFile . " existiert nicht!" );
49
                    $this->error( "Konfigdatei " . $configFile . " existiert nicht!" );
-
 
50
                    continue;
-
 
51
                }
-
 
52
                $fName = basename( parse_url( $agency["csv_url"], PHP_URL_PATH ) );
-
 
53
                $fName = storage_path() . "/" . $fName;
-
 
54
                $f = fopen( $fName, "w" );
-
 
55
                foreach ( $items as $item )
-
 
56
                {
-
 
57
                    foreach ( $content as $c )
-
 
58
                    {
-
 
59
                        list( $col, $required ) = $c;
-
 
60
 
-
 
61
                        // Inhalt ist vorhanden oder muss ausgewertet werden?
-
 
62
                        if ( isset( $item->$col ) )
-
 
63
                        {
-
 
64
                            $col = $item->$col;
-
 
65
                        }
-
 
66
                        elseif ( !stristr( $col, "return" ) )
-
 
67
                        {
-
 
68
                            $col = "";
-
 
69
                        }
-
 
70
                        else
-
 
71
                        {
-
 
72
                            $col = @eval( $col );
-
 
73
                        }
-
 
74
 
-
 
75
                        // Inhalt mit required vergleichen
-
 
76
                        /*
-
 
77
                        required
-
 
78
                        true: Wert muss vorhanden sein
-
 
79
                        false: Wert muss nicht vorhanden sein
-
 
80
                        string: Ausdruck muss string ergeben
-
 
81
                        */
-
 
82
 
-
 
83
                        if ( is_bool( $required ) )
-
 
84
                        {
-
 
85
                            if ( ( $required === true ) && ( !$col ) )
-
 
86
                            {
-
 
87
                                continue 2;
-
 
88
                            }
-
 
89
                        }
-
 
90
                        else
-
 
91
                        {
-
 
92
                            if ( !@eval( $required ) )
-
 
93
                            {
-
 
94
                                continue 2;
-
 
95
                            }
-
 
96
                        }
-
 
97
 
-
 
98
                        $buffer[] = $quote . $col . $quote;
-
 
99
                    } // foreach
-
 
100
                    fwrite( $f, implode( $trenner, $buffer ) . "\n" );
48
                }
101
                }
-
 
102
                fclose( $f );
49
            }
103
            }
50
            return count( $agencies );
-
 
51
        }
104
        }
52
    }
105
    }