PHP - Imprimir datos de Checkbox dentro de ciclo Foreach

 
Vista:

Imprimir datos de Checkbox dentro de ciclo Foreach

Publicado por Alan Steve (1 intervención) el 02/01/2020 16:25:21
Lo que trato de hacer aquí es implementar la función de imprimir las filas que se seleccionen, así sea una o varias, que solo se impriman las que tengan chequeado el checkbox. cabe decir que la tabla es formada con un foreach por lo que no estoy seguro de como implementar el checkbox ahí dentro, mis intentos anteriores terminaban en una tabla con una columna de checkboxes que iluminan la fila pero que no se imprimen. lo que hace actualmente el código es imprimir todas las filas presentes de la tabla.
Cualquier ayuda es apreciada.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
function imprimir3() {
    var objeto = document.getElementById('imprimeme3'); //obtenemos el objeto a imprimir
    var ventana = window.open('', '_blank'); //abrimos una ventana vacía nueva
    ventana.document.write(objeto.innerHTML); //imprimimos el HTML del objeto en la nueva ventana
    ventana.document.close(); //cerramos el documento
    ventana.print(); //imprimimos la ventana
    ventana.close(); //cerramos la ventana
}
 
<div class="tab-pane" id="TLL">
    <table class="table table-bordered" style="color: Black" id="table-3">
        <thead>
            <tr>
                <th><?php echo get_phrase('___'); ?></th>
                <th><?php echo get_phrase('Sem'); ?></th>
                <th><?php echo get_phrase('#'); ?></th>
                <th><?php echo get_phrase('Mecanico'); ?></th>
                <th><?php echo get_phrase('Movimientos (Jefe de Taller)'); ?></th>
                <th><?php echo get_phrase('Observaciones (Supervisor)'); ?></th>
                <th><?php echo get_phrase('Observaciones (Compras)'); ?></th>
                <th><?php echo get_phrase('Refacciones'); ?></th>
                <th><?php echo get_phrase('F.C.'); ?></th>
                <th><?php echo get_phrase('Empresa'); ?></th>
                <th style="width:1px"><?php echo get_phrase('T.F'); ?></th>
            </tr>
        </thead>
 
        <tbody>
            <?php
            $control_info    = $this->db->query("select * from controlsemanal where vendedora = 'Taller' and Indicador != '1' and Indicador !='100' ORDER BY FIELD (Id_Status,1,3,4,5,6,2,7,0) ");
            foreach ($control_info->result_array() as $row) {
                if ($row['TRN'] == 'SI') {
                    $Color = '#41B3BB';
                } elseif ($row['TRN'] != 'SI') {
                    if ($row['Status'] == 'VENTA') {
                        $Color = '#69E074';
                    } elseif ($row['Status'] == 'POSIBLE VENTA') {
                        $Color = '#E6DF65';
                    } elseif ($row['Status'] == 'GARANTIA') {
                        $Color = '#FB4545';
                    } elseif ($row['Status'] == 'SERVICIO DE REPARACION') {
                        $Color = '#F39523';
                    } elseif ($row['Status'] == 'DESABASTO') {
                        $Color = '#45A0D4';
                    } elseif ($row['Status'] == 'PRESTAMO') {
                        $Color = '#D074A3';
                    } elseif ($row['Status'] == 'SEGUIMIENTO') {
                        $Color = '#D5D8D8';
                    } elseif ($row['Status'] == 'SUBASTA') {
                        $Color = '#BDBDBD';
                    } elseif ($row['Status'] == 'SERVICIO INTERNO') {
                        $Color = '#9F6ED0';
                    }
                } ?>
 
                <tr>
                    <th><input type='checkbox' name="check" value="" class="toggle-checkbox"> </th>
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
 
                        <b>
                            <?php echo $row['Semana'] ?>
                        </b>
                    </td>
 
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <b>
                            <label>
                                <a <?php if ($User == 'practicante1@rte.mx'  or $User == 'practicante@rte.mx') {
                                    } else {
                                    ?> onclick="showAjaxModal('<?php echo base_url(); ?>index.php?modal/popup/edit_control/<?php echo $row['control_id'] ?>');" <?php } ?> class="title" style="color:black">
                                    <?php if ($row['Status'] == 'SEGUIMIENTO') { ?>
                                        SEG
                                        <span>
                                            <?php echo $row['Status'] ?>
                                        </span>
                                    <?php } else { ?>
                                        <?php echo $row['Referencia']; ?>
                                        <span>
                                            <?php echo $row['Marca']; ?>
                                        </span>
                                    <?php } ?>
                                </a>
                            </label>
                        </b>
                    </td>
 
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <b>
                            <a class="Mec" style="color:Black">
                                <?php echo $row['Mecanico'] ?>
                                <span>
                                    <?php echo $row['Mecanico1'] ?><br>
                                    <?php echo $row['Mecanico2'] ?><br>
                                    <?php echo $row['Mecanico3'] ?><br>
                                </span>
                            </a>
                        </b>
                    </td>
 
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <?php if ($row['UltimoMovimiento'] == "") { ?>
                            <label>
                                <a class="Mov" style="color:black">
                                    <?php echo substr($row['Movimientos'], 0, 40) . "..."; ?>
                                    <span>
                                        <?php echo $row['Movimientos'] ?>
                                    </span>
                                </a>
                            </label>
                        <?php } else { ?>
                            <b>
                                <label>
                                    <a class="Mov" style="color:black">
                                        <?php echo substr($row['UltimoMovimiento'], 0, 40) . "..."; ?>
                                        <span>
                                            <?php echo $row['Movimientos'] ?>
                                            <br>
                                            <?php echo $row['UltimoMovimiento'] ?>
                                        </span>
                                    </a>
                                </label>
                            </b>
                        <?php } ?>
                    </td>
 
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <?php if ($row['ObservacionesGerente'] == "") {
                        } else { ?>
                            <b>
                                <label>
                                    <a class="Mov" style="color:black">
                                        <?php echo substr($row['ObservacionesGerente'], 0, 40) . "..."; ?>
                                        <span>
                                            <?php echo $row['ObservacionesGerente'] ?>
                                        </span>
                                    </a>
                                </label>
                            </b>
                        <?php } ?>
                    </td>
 
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <?php if ($row['Observaciones'] == "") {
                        } else { ?>
                            <b>
                                <label>
                                    <a class="Mov" style="color:black">
                                        <?php echo substr($row['Observaciones'], 0, 40) . "..."; ?>
                                        <span>
                                            <?php echo $row['Observaciones'] ?>
                                        </span>
                                    </a>
                                </label>
                            </b>
                        <?php } ?>
                    </td>
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <b>
                            <label>
                                <a class="Mov" style="color:black">
                                    <?php
                                    if ($row['Refaccion'] != '') {
                                        echo substr($row['Refaccion'], 0, 40) . "...";
                                    } else {
                                        if ($row['Refacciones'] != "") {
                                            echo substr('REFACCIONES (Supervisor)<br>' . $row['Refacciones'], 0, 40) . "...";
                                        }
                                    }
                                    ?>
                                    <span>
                                        <?php if ($row['Refaccion'] != '') {
                                            echo 'Refacciones (Compras)<br>' . $row['Refaccion'];
                                            if ($row['Refacciones'] != "") {
                                                echo '<br>Refacciones (Supervisor)<br>' . $row['Refacciones'];
                                            }
                                        } else {
                                            if ($row['Refacciones'] != "") {
                                                echo 'Refacciones (Supervisor)<br>' . $row['Refacciones'];
                                            }
                                        }
                                        ?>
                                    </span>
                                </a>
                            </label>
                        </b>
                    </td>
                    <td style="background:<?php echo $Color; ?>;font-size:10px">
                        <b>
                            <?php echo $row['FechaCompromiso'] ?>
                        </b>
                    </td>
                    <td style="background:<?php echo $Color; ?>;font-size:10px"><b><label><a class="title" style="color:black"><?php echo $row['Empresa']; ?><span><?php echo $row['Cd_Estado'] ?><br><?php echo $row['Forma_Pago'] ?></span></a></label></b></td>
                    <?php
                    if ($row['Tipo_Falla'] == 'COMPLICADA') {
                        $TF = 'C';
                    } elseif ($row['Tipo_Falla'] == 'FACIL') {
                        $TF = 'F';
                    } elseif ($row['Tipo_Falla'] == 'PENDIENTE-REVISION') {
                        $TF = 'PR';
                    } elseif ($row['Tipo_Falla'] == 'OK') {
                        $TF = 'OK';
                    } elseif ($row['Tipo_Falla'] == 'YONQUE') {
                        $TF = 'Y';
                    }
                    ?>
                    <td style="background:<?php echo $Color; ?>;width:1px;font-size:10px"><b>
                            <center><label style="width:1px"><a class="TF" style="Color:black"><?php echo $TF; ?><span><?php echo $row['Tipo_Falla']; ?></span></a></label></center>
                        </b></td>
                </tr>
            <?php } ?>
       </tbody>
    </table>
<div style="display:none" id="imprimeme3">
        <table border="1" style="color: Black; border-collapse: collapse;height:100px">
            <tr>
                <th colspan="9">
                    <font style='Font-size: 25px'>Taller</font>
                </th>
            </tr>
            <tr>
                <td><?php echo get_phrase('Sem'); ?></td>
                <td><?php echo get_phrase('#'); ?></td>
                <td><?php echo get_phrase('Mecanico'); ?></td>
                <td><?php echo get_phrase('Movimientos (Jefe de Taller)'); ?></td>
                <td><?php echo get_phrase('Observaciones'); ?></td>
                <td><?php echo get_phrase('Refacciones'); ?></td>
                <td><?php echo get_phrase('F.C.'); ?></td>
                <td><?php echo get_phrase('Empresa'); ?></td>
                <td><?php echo get_phrase('T.F'); ?></td>
            </tr>
 
            <?php
            $control_info    = $this->db->query("select * from controlsemanal where (vendedora = 'Taller') and Indicador != '1' and Indicador !='100' and Status != 'Servicio Externo' ORDER BY FIELD (Id_Status,1,3,4,5,6,2,7,0)");
            foreach ($control_info->result_array() as $row) {
                $S = $row["Semana"];
                $E = explode("-", $S);
            ?>
                <tr>
                    <td style="width:10px">
                        <b>
                            <center><?php echo $E[1] ?></center>
                        </b>
                    </td>
 
                    <td style="width:100px">
                        <b>
                            <center><?php if ($row['Status'] == 'SEGUIMIENTO') { ?>
                                    SEG
                                <?php } else { ?>
                                    <label>
                                        <?php if ($row['TRN'] == 'SI') {
                                            echo 'TRN';
                                        } else {
                                            echo $row['Referencia'];
                                        } ?>
                                        <br>
                                        <?php echo $row['Marca'] ?>
                                        <br>
                                        (<?php echo $row['Status'] ?>)
                                    </label>
                                <?php } ?>
                            </center>
                        </b>
                    </td>
 
                    <td style="width:100px">
                        <b>
                            <center>
                                <?php echo '- ' . $row['Mecanico']; ?>
                                <?php if ($row['Mecanico1'] != '') {
                                    echo '<br>- ' . $row['Mecanico1'];
                                } ?>
                                <?php if ($row['Mecanico2'] != '') {
                                    echo '<br>- ' . $row['Mecanico2'];
                                } ?>
                                <?php if ($row['Mecanico3'] != '') {
                                    echo '<br>- ' . $row['Mecanico3'];
                                } ?>
                            </center>
                        </b>
                    </td>
 
                    <td style="width:550px">
                        <?php if ($row['UltimoMovimiento'] == "" and $row['Movimientos'] == "") {
                        } else { ?>
                            <b>
                                <?php echo $row['Movimientos'] ?>
                                <br>
                                <?php echo $row['UltimoMovimiento'] ?>
                            </b>
                        <?php } ?>
                    </td>
 
                    <td style="width:550px">
                        <?php if ($row['Observaciones'] == "") {
                        } else { ?>
                            <b>
                                <?php echo 'Observaciones (Compras)<br>' . $row['Observaciones'] ?>
                            </b>
                        <?php } ?>
 
                        <?php if ($row['ObservacionesGerente'] == "") {
                        } else { ?>
                            <b>
                                <?php echo '<br><br>Observaciones (Supervisor)<br>' . $row['ObservacionesGerente'] ?>
                            </b>
                        <?php } ?>
                    </td>
                    <td style="width:150px">
                        <b>
                            <?php
                            if ($row['Refaccion'] != '') {
                                echo 'Refacciones (Compras)<br>' . $row['Refaccion'];
                                if ($row['Refacciones'] != '') {
                                    echo '<br>Refacciones (Supervisor)<br>' . $row['Refacciones'];
                                }
                            } else {
                                if ($row['Refacciones'] != '') {
                                    echo 'Refacciones (Supervisor)<br>' . $row['Refacciones'];
                                }
                            }
                            ?>
                        </b>
                    </td>
                    <td style="width:70px"><b>
                            <center><?php echo $row['FechaCompromiso'] ?></center>
                        </b></td>
                    <td style="width:150px">
                        <b>
                            <center>
                                <label>
                                    <?php if (!empty($row['Empresa'])) {
                                        echo $row['Empresa'];
                                    } ?>
                                    <br>
                                    <?php if (!empty($row['Cd_Estado'])) {
                                        echo '<br>' . $row['Cd_Estado'];
                                    } ?>
                                    <br>
                                    <?php if (!empty($row['Forma_Pago'])) {
                                        echo '<br>' . $row['Forma_Pago'];
                                    } ?>
                                </label>
                            </center>
                        </b>
                    </td>
                    <?php
                    if ($row['Tipo_Falla'] == 'COMPLICADA') {
                        $TF = 'C';
                    } elseif ($row['Tipo_Falla'] == 'FACIL') {
                        $TF = 'F';
                    } elseif ($row['Tipo_Falla'] == 'PENDIENTE-REVISION') {
                        $TF = 'PR';
                    } elseif ($row['Tipo_Falla'] == 'OK') {
                        $TF = 'OK';
                    } elseif ($row['Tipo_Falla'] == 'YONQUE') {
                        $TF = 'Y';
                    }
                    ?>
                    <td style=""><b>
                            <center><label><?php echo $TF; ?></label></center>
                        </b></td>
                </tr>
            <?php } ?>
        </table>
    </div>
 
    <center>
        <button style="border:0;background:#04998A;color:white;width: 550px;height:50px;font-size: 30px" onclick="imprimir3();">
            <b>IMPRIMIR</b>
        </button>
    </center>
</div>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder