|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione |
| 5 | + * Copyright (C) DevCode s.r.l. |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +include_once __DIR__.'/../../core.php'; |
| 22 | + |
| 23 | +use Modules\ListiniCliente\Articolo; |
| 24 | +use Modules\ListiniCliente\Listino; |
| 25 | + |
| 26 | +switch (post('op')) { |
| 27 | + case 'change_prezzo': |
| 28 | + foreach ($id_records as $id) { |
| 29 | + $listino = Listino::find($id); |
| 30 | + |
| 31 | + $articoli = Articolo::where('id_listino', $id)->get(); |
| 32 | + foreach ($articoli as $articolo) { |
| 33 | + $articolo->sconto_percentuale = post('percentuale'); |
| 34 | + $articolo->save(); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + flash()->info(tr('Listini aggiornati!')); |
| 39 | + |
| 40 | + break; |
| 41 | +} |
| 42 | + |
| 43 | +$operations['change_prezzo'] = [ |
| 44 | + 'text' => '<span><i class="fa fa-refresh"></i> '.tr('Aggiorna sconto percentuale').'</span>', |
| 45 | + 'data' => [ |
| 46 | + 'title' => tr('Aggiornare lo sconto percentuale per i listini selezionati?'), |
| 47 | + 'msg' => tr('Per indicare uno sconto inserire la percentuale con il segno meno, al contrario per un rincaro inserire la percentuale senza segno.').'<br><br>{[ "type": "number", "label": "'.tr('Percentuale sconto/magg.').'", "name": "percentuale", "required": 1, "icon-after": "%" ]}', |
| 48 | + 'button' => tr('Procedi'), |
| 49 | + 'class' => 'btn btn-lg btn-warning', |
| 50 | + 'blank' => false, |
| 51 | + ], |
| 52 | +]; |
| 53 | + |
| 54 | +return $operations; |
0 commit comments