// session = array echo '<table style="width:100%" >'; for ($aux = 0; $aux < count($_SESSION['produto']['editar'][$whatarray]); $aux++) { // percorre array de material if ($aux % 2 == 0) { //if else para tabela zebrada echo '<tr style="background-color:#ccc;">'; } else { echo '<tr style="background-color:#ddd;">'; } $id_qtd_tipo = explode(":", $_SESSION['produto']['editar'][$whatarray][$aux]); // separa os valores id e quantidade if ($id_qtd_tipo[2] == 'm') { // se for material $res = new Material(); $res = Material::get_material_id($id_qtd_tipo[0]); $uni = new Unidade_medida(); $uni = $uni->get_unidade_medida_by_id($res->id_unidade_medida); echo '<td ><span>' . $res->nome . ': </span></td><td><input id="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" onchange="increment(this.id)" style="width:70%; background-color: rgba(230,230,230,0.5)" type="number" value="' . $id_qtd_tipo[1] . '"> <span>' . $uni->sigla . '</span></td><td><a name="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" style="cursor:pointer" onclick="apagar(this.name,\'material\', \'editar\')"><img style="width:15px" src="../images/delete.png"></a></td>'; } else { if ($id_qtd_tipo[2] == 'p') { // se for produto $res = new Produto(); $res = $res->get_produto_id($id_qtd_tipo[0]); echo '<td ><span>' . $res->nome . ': </span></td><td><input id="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" onchange="increment(this.id)" style="width:70%; background-color: rgba(230,230,230,0.5)" type="number" value="' . $id_qtd_tipo[1] . '"></td><td><a name="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" style="cursor:pointer" onclick="apagar(this.name,\'material\', \'editar\')"><img style="width:15px" src="../images/delete.png"></a></td>'; } } echo '</tr>'; } echo '</table>'; }
$valor_total_produto = 0; if (!$materiais) { echo 'Nenhum material cadastrado<br /><br /><input onclick="fechar()" type="button" class="button" value="Concluir" >'; return; } echo '<div class="formulario" style="width:300px;"> <table style="width:100%; text-align:center;" border="0"> <tr><td colspan="3"><b>Materiais usados para ' . $produto->nome . '</b></td></tr>'; echo '<tr><td colspan="3"><div style="overflow-y:scroll; max-height:200px;">'; echo '<table style="text-align:center">'; echo '<tr><td><b><span>Nome</span></b></td><td><b><span>Quantidade</span></b></td><td><b><span>Custo por regiao</span></b></td></tr>'; for ($aux = 0; $aux < count($materiais); $aux++) { $id_material = explode(':', $materiais[$aux][1]); if ($id_material[1] == 'm') { //buscar materiais $res = Material::get_material_id($id_material[0]); $uni = new Unidade_medida(); $uni = $uni->get_unidade_medida_by_id($res->id_unidade_medida); if (isset($_SESSION['obra']['dados']['regioes']) && $_SESSION['obra']['dados']['regioes'] != 'no_sel') { $custo = Custo_regiao::get_valor($id_material[0], $_SESSION['obra']['dados']['regioes'], $_SESSION['id_empresa']); if ($custo) { $valor_total_produto = $valor_total_produto + $materiais[$aux][2] * $custo; $custo = 'R$ ' . number_format($custo, 2, ',', '.'); } else { $custo = '<a href="add_material.php?backto=a_pr_o®iao=' . Regiao::get_cod_regiao_by_id($_SESSION['obra']['dados']['regioes']) . '" onmouseover="info(\'pop' . $aux . '\')" onmouseout="fecharInfo(\'pop' . $aux . '\')"><span>Defina um valor custo</span></a> <div id="pop' . $aux . '" class="pop" style="display:none"> <div id="titulo' . $aux . '" class="title-info-config"><span>Informações</span></div> <div id="content' . $aux . '" class="content-info">Clique para definir um valor custo para esse material nessa região</div> </div> '; }