|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione |
| 4 | + * Copyright (C) DevCode s.r.l. |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License |
| 17 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | + |
| 20 | +include_once __DIR__.'/../../core.php'; |
| 21 | + |
| 22 | +$block_edit = $record['is_bloccato']; |
| 23 | + |
| 24 | +$idtipiintervento = ['-1']; |
| 25 | + |
| 26 | +// Loop fra i tipi di attività e i relativi costi del tipo intervento (tutti quelli abilitati) |
| 27 | +$rs = $dbo->fetchArray('SELECT `co_contratti_tipiintervento`.*, `in_tipiintervento`.`costo_orario`, `in_tipiintervento`.`costo_km` AS `costo_km_standard`, `in_tipiintervento`.`costo_diritto_chiamata`, `in_tipiintervento_lang`.`title` FROM `co_contratti_tipiintervento` INNER JOIN `in_tipiintervento` ON `in_tipiintervento`.`id` = `co_contratti_tipiintervento`.`idtipointervento` LEFT JOIN `in_tipiintervento_lang` ON `in_tipiintervento_lang`.`id_record` = `in_tipiintervento`.`id` AND `in_tipiintervento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).' WHERE `idcontratto`='.prepare($id_record).' AND `co_contratti_tipiintervento`.`is_abilitato` = 1 ORDER BY `in_tipiintervento_lang`.`title`'); |
| 28 | + |
| 29 | +if (!empty($rs)) { |
| 30 | + echo ' |
| 31 | + <table class="table table-striped table-sm table-bordered"> |
| 32 | + <tr> |
| 33 | + <th width="300">'.tr('Tipo attività').'</th> |
| 34 | +
|
| 35 | + <th>'.tr('Addebito orario').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th> |
| 36 | + <th>'.tr('Addebito km').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th> |
| 37 | + <th>'.tr('Addebito diritto ch.').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th> |
| 38 | +
|
| 39 | + <th width="120" '.($block_edit ? 'style="display:none;"' : '').'></th> |
| 40 | + </tr>'; |
| 41 | + |
| 42 | + for ($i = 0; $i < sizeof($rs); ++$i) { |
| 43 | + $is_abilitato = !empty($rs[$i]['is_abilitato']); |
| 44 | + $costo_ore = !empty($rs[$i]['costo_ore']) ? $rs[$i]['costo_ore'] : $rs[$i]['costo_orario']; |
| 45 | + $costo_km = !empty($rs[$i]['costo_km']) ? $rs[$i]['costo_km'] : $rs[$i]['costo_km_standard']; |
| 46 | + $costo_dirittochiamata = !empty($rs[$i]['costo_dirittochiamata']) ? $rs[$i]['costo_dirittochiamata'] : $rs[$i]['costo_diritto_chiamata']; |
| 47 | + echo ' |
| 48 | + <tr> |
| 49 | + <td>'.$rs[$i]['title'].'</td> |
| 50 | +
|
| 51 | + <td> |
| 52 | + {[ "type": "number", "name": "costo_ore['.$rs[$i]['idtipointervento'].']", "value": "'.$costo_ore.'", "disabled": '.(!$is_abilitato ? '1' : '0').' ]} |
| 53 | + </td> |
| 54 | +
|
| 55 | + <td> |
| 56 | + {[ "type": "number", "name": "costo_km['.$rs[$i]['idtipointervento'].']", "value": "'.$costo_km.'", "disabled": '.(!$is_abilitato ? '1' : '0').' ]} |
| 57 | + </td> |
| 58 | +
|
| 59 | + <td> |
| 60 | + {[ "type": "number", "name": "costo_dirittochiamata['.$rs[$i]['idtipointervento'].']", "value": "'.$costo_dirittochiamata.'", "disabled": '.(!$is_abilitato ? '1' : '0').' ]} |
| 61 | + </td> |
| 62 | +
|
| 63 | + <td class="text-center" '.($block_edit ? 'style="display:none;"' : '').'> |
| 64 | + <button type="button" class="btn btn-warning btn-xs" data-card-widget="tooltip" title="Importa valori da tariffe standard" onclick="if( confirm(\'Importare i valori dalle tariffe standard?\') ){ $.post( \''.base_path_osm().'/modules/contratti/actions.php\', { op: \'import\', idcontratto: \''.$id_record.'\', idtipointervento: \''.$rs[$i]['idtipointervento'].'\' }, function(data){ location.href=\''.base_path_osm().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'\'; } ); }"> |
| 65 | + <i class="fa fa-download"></i> |
| 66 | + </button> |
| 67 | + <button type="button" class="btn btn-'.($is_abilitato ? 'danger' : 'success').' btn-xs" data-card-widget="tooltip" title="'.($is_abilitato ? tr('Disabilita') : tr('Abilita')).'" onclick="toggleTipoAttivita('.$rs[$i]['idtipointervento'].', this)"> |
| 68 | + <i class="fa fa-'.($is_abilitato ? 'times' : 'check').'"></i> |
| 69 | + </button> |
| 70 | + <button type="button" class="btn btn-info btn-xs" data-card-widget="tooltip" title="'.tr('Aggiungi riga ore').'" onclick="aggiungiRigaOre('.$rs[$i]['idtipointervento'].', \''.$rs[$i]['title'].'\')" '.(!$is_abilitato ? 'style="display:none;"' : '').'> |
| 71 | + <i class="fa fa-plus"></i> |
| 72 | + </button> |
| 73 | + </td> |
| 74 | +
|
| 75 | + </tr>'; |
| 76 | + |
| 77 | + $idtipiintervento[] = prepare($rs[$i]['idtipointervento']); |
| 78 | + } |
| 79 | + echo ' |
| 80 | + </table>'; |
| 81 | +} |
| 82 | + |
| 83 | +echo ' |
| 84 | + <button type="button" onclick="$(this).next().toggleClass(\'hide\');" class="btn btn-info btn-sm" '.($block_edit ? 'style="display:none;"' : '').'><i class="fa fa-th-list"></i> '.tr('Mostra tipi di attività disabilitati').'</button> |
| 85 | + <div class="hide">'; |
| 86 | + |
| 87 | +// Loop fra i tipi di attività e i relativi costi del tipo intervento (quelli disabilitati) |
| 88 | +$rs = $dbo->fetchArray('SELECT `co_contratti_tipiintervento`.*, `in_tipiintervento`.`costo_orario`, `in_tipiintervento`.`costo_km` AS `costo_km_standard`, `in_tipiintervento`.`costo_diritto_chiamata`, `in_tipiintervento_lang`.`title` FROM `co_contratti_tipiintervento` INNER JOIN `in_tipiintervento` ON `in_tipiintervento`.`id` = `co_contratti_tipiintervento`.`idtipointervento` LEFT JOIN `in_tipiintervento_lang` ON (`in_tipiintervento`.`id`=`in_tipiintervento_lang`.`id_record` AND `in_tipiintervento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `co_contratti_tipiintervento`.`idtipointervento` NOT IN('.implode(',', array_map(prepare(...), $idtipiintervento)).') AND `idcontratto`='.prepare($id_record).' AND `co_contratti_tipiintervento`.`is_abilitato` = 0 ORDER BY `title`'); |
| 89 | + |
| 90 | +if (!empty($rs)) { |
| 91 | + echo ' |
| 92 | + <div class="clearfix"> </div> |
| 93 | + <table class="table table-striped table-sm table-bordered"> |
| 94 | + <tr> |
| 95 | + <th width="300">'.tr('Tipo attività').'</th> |
| 96 | +
|
| 97 | + <th>'.tr('Addebito orario').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th> |
| 98 | + <th>'.tr('Addebito km').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th> |
| 99 | + <th>'.tr('Addebito diritto ch.').' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th> |
| 100 | +
|
| 101 | + <th width="120" '.($block_edit ? 'style="display:none;"' : '').'></th> |
| 102 | + </tr>'; |
| 103 | + |
| 104 | + for ($i = 0; $i < sizeof($rs); ++$i) { |
| 105 | + $is_abilitato = !empty($rs[$i]['is_abilitato']); |
| 106 | + echo ' |
| 107 | + <tr> |
| 108 | + <td>'.$rs[$i]['title'].'</td> |
| 109 | +
|
| 110 | + <td> |
| 111 | + {[ "type": "number", "name": "costo_ore['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_orario'].'", "icon-after": "<i class=\'fa fa-euro\'></i>", "disabled": '.(!$is_abilitato ? '1' : '0').' ]} |
| 112 | + </td> |
| 113 | +
|
| 114 | + <td> |
| 115 | + {[ "type": "number", "name": "costo_km['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_km_standard'].'", "icon-after": "<i class=\'fa fa-euro\'></i>", "disabled": '.(!$is_abilitato ? '1' : '0').' ]} |
| 116 | + </td> |
| 117 | +
|
| 118 | + <td> |
| 119 | + {[ "type": "number", "name": "costo_dirittochiamata['.$rs[$i]['idtipointervento'].']", "value": "'.$rs[$i]['costo_diritto_chiamata'].'", "icon-after": "<i class=\'fa fa-euro\'></i>", "disabled": '.(!$is_abilitato ? '1' : '0').' ]} |
| 120 | + </td> |
| 121 | +
|
| 122 | + <td class="text-center" '.($block_edit ? 'style="display:none;"' : '').'> |
| 123 | + <button type="button" class="btn btn-'.($is_abilitato ? 'danger' : 'success').' btn-xs" data-card-widget="tooltip" title="'.($is_abilitato ? tr('Disabilita') : tr('Abilita')).'" onclick="toggleTipoAttivita('.$rs[$i]['idtipointervento'].', this)"> |
| 124 | + <i class="fa fa-'.($is_abilitato ? 'times' : 'check').'"></i> |
| 125 | + </button> |
| 126 | + <button type="button" class="btn btn-info btn-xs" data-card-widget="tooltip" title="'.tr('Aggiungi riga ore').'" onclick="aggiungiRigaOre('.$rs[$i]['idtipointervento'].', \''.$rs[$i]['title'].'\')" '.(!$is_abilitato ? 'style="display:none;"' : '').'> |
| 127 | + <i class="fa fa-plus"></i> |
| 128 | + </button> |
| 129 | + </td> |
| 130 | +
|
| 131 | + </tr>'; |
| 132 | + } |
| 133 | + echo ' |
| 134 | + </table>'; |
| 135 | +} |
| 136 | +echo ' |
| 137 | +
|
| 138 | + </div>'; |
0 commit comments