|
19 | 19 | */ |
20 | 20 |
|
21 | 21 | include_once __DIR__.'/../../../core.php'; |
| 22 | + |
22 | 23 | use Models\Module; |
| 24 | +use Modules\Anagrafiche\Anagrafica; |
23 | 25 |
|
24 | 26 | $idarticolo = get('idarticolo'); |
25 | 27 | $limit = get('limit'); |
|
42 | 44 | (`subtotale`-`sconto`)/`qta` AS costo_unitario, |
43 | 45 | `co_documenti`.`numero` AS n_documento, |
44 | 46 | `co_documenti`.`numero_esterno` AS n2_documento, |
45 | | - `co_documenti`.`data` AS data_documento |
| 47 | + `co_documenti`.`data` AS data_documento, |
| 48 | + `co_documenti`.`idanagrafica` AS idanagrafica |
46 | 49 | FROM |
47 | 50 | `co_righe_documenti` |
48 | 51 | INNER JOIN `co_documenti` ON `co_documenti`.`id` = `co_righe_documenti`.`iddocumento` |
|
57 | 60 | (`subtotale`-`sconto`)/`qta` AS costo_unitario, |
58 | 61 | (SELECT `numero` FROM `dt_ddt` WHERE `id`=`idddt`) AS n_documento, |
59 | 62 | (SELECT `numero_esterno` FROM `dt_ddt` WHERE `id`=`idddt`) AS n2_documento, |
60 | | - (SELECT `data` FROM `dt_ddt` WHERE `id`=`idddt`) AS data_documento |
| 63 | + (SELECT `data` FROM `dt_ddt` WHERE `id`=`idddt`) AS data_documento, |
| 64 | + `dt_ddt`.`idanagrafica` AS idanagrafica |
61 | 65 | FROM |
62 | 66 | `dt_righe_ddt` |
63 | 67 | INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` |
|
103 | 107 | ((`subtotale` - `sconto`) / `qta` * IF(`co_tipidocumento`.`reversed`, -1, 1)) AS costo_unitario, |
104 | 108 | `co_documenti`.`numero` AS n_documento, |
105 | 109 | `co_documenti`.`numero_esterno` AS n2_documento, |
106 | | - `co_documenti`.`data` AS data_documento |
| 110 | + `co_documenti`.`data` AS data_documento, |
| 111 | + `co_documenti`.`idanagrafica` AS idanagrafica |
107 | 112 | FROM |
108 | 113 | `co_righe_documenti` |
109 | 114 | INNER JOIN `co_documenti` ON `co_documenti`.`id` = `co_righe_documenti`.`iddocumento` |
|
119 | 124 | (`subtotale` - `sconto`) / `qta` AS costo_unitario, |
120 | 125 | `dt_ddt`.`numero` AS n_documento, |
121 | 126 | `dt_ddt`.`numero_esterno` AS n2_documento, |
122 | | - `dt_ddt`.`data` AS data_documento |
| 127 | + `dt_ddt`.`data` AS data_documento, |
| 128 | + `dt_ddt`.`idanagrafica` AS idanagrafica |
123 | 129 | FROM |
124 | 130 | `dt_righe_ddt` |
125 | 131 | INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` |
|
128 | 134 | WHERE |
129 | 135 | `idarticolo` = '.prepare($idarticolo).' AND `dir` = "entrata" |
130 | 136 | ORDER BY |
131 | | - `id` DESC'); |
| 137 | + data_documento |
| 138 | + DESC LIMIT 0,20'); |
132 | 139 |
|
133 | 140 | if (sizeof($documenti) > 0) { |
134 | 141 | echo "<table class='table table-striped table-bordered table-extra-condensed' >\n"; |
135 | 142 | echo "<tr><th width='180'>Documento</th>\n"; |
136 | | - echo "<th width='100' class='text-right' >Totale</th></tr>\n"; |
| 143 | + echo "<th width='170'>Anagrafica</th>\n"; |
| 144 | + echo "<th width='80' class='text-right' >Totale</th></tr>\n"; |
137 | 145 |
|
138 | 146 | for ($i = 0; $i < sizeof($documenti); ++$i) { |
139 | 147 | ($documenti[$i]['n2_documento'] != '') ? $n_documento = $documenti[$i]['n2_documento'] : $n_documento = $documenti[$i]['n_documento']; |
140 | 148 |
|
141 | 149 | $link_id = Module::where('name', $documenti[$i]['modulo'])->first()->id; |
142 | 150 | echo "<tr><td class='first_cell text-left'><a href='".base_path().'/editor.php?id_module='.$link_id.'&id_record='.$documenti[$i]['id']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">".$documenti[$i]['tipo'].' n. '.$n_documento.' del '.Translator::dateToLocale($documenti[$i]['data_documento'])." </a></td>\n"; |
| 151 | + $anagrafica = Anagrafica::find($documenti[$i]['idanagrafica']); |
| 152 | + echo "<td class='table_cell text-left'>".$anagrafica->ragione_sociale."</td>\n"; |
143 | 153 | echo "<td class='table_cell text-right'>".moneyFormat($documenti[$i]['costo_unitario'])."</td></tr>\n"; |
144 | 154 | $ids[] = '"'.$documenti[$i]['id'].'"'; |
145 | 155 | } |
|
188 | 198 | WHERE |
189 | 199 | `idarticolo` = '.prepare($idarticolo).' AND `dir` = "uscita" |
190 | 200 | ORDER BY |
191 | | - `id` DESC'); |
| 201 | + data_documento |
| 202 | + DESC LIMIT 0,20'); |
192 | 203 |
|
193 | 204 | if (sizeof($documenti) > 0) { |
194 | 205 | echo "<table class='table table-striped table-bordered table-extra-condensed' >\n"; |
195 | 206 | echo "<tr><th width='180'>Documento</th>\n"; |
196 | | - echo "<th width='100' class='text-right' >Totale</th></tr>\n"; |
| 207 | + echo "<th width='170'>Anagrafica</th>\n"; |
| 208 | + echo "<th width='80' class='text-right' >Totale</th></tr>\n"; |
197 | 209 |
|
198 | 210 | for ($i = 0; $i < sizeof($documenti); ++$i) { |
199 | 211 | ($documenti[$i]['n2_documento'] != '') ? $n_documento = $documenti[$i]['n2_documento'] : $n_documento = $documenti[$i]['n_documento']; |
200 | 212 |
|
201 | 213 | $link_id = Module::where('name', $documenti[$i]['modulo'])->first()->id; |
202 | 214 | echo "<tr><td class='first_cell text-left'><a href='".base_path().'/editor.php?id_module='.$link_id.'&id_record='.$documenti[$i]['id']."' target=\"_blank\" title=\"Apri il documento su una nuova finestra\">".$documenti[$i]['tipo'].' n. '.$n_documento.' del '.Translator::dateToLocale($documenti[$i]['data_documento'])." </a></td>\n"; |
| 215 | + $anagrafica = Anagrafica::find($documenti[$i]['idanagrafica']); |
| 216 | + echo "<td class='table_cell text-left'>".$anagrafica->ragione_sociale."</td>\n"; |
203 | 217 | echo "<td class='table_cell text-right'>".moneyFormat($documenti[$i]['costo_unitario'])."</td></tr>\n"; |
204 | 218 | $ids[] = '"'.$documenti[$i]['id'].'"'; |
205 | 219 | } |
|
0 commit comments