return; } } $row = getRow('needs', 'need_id = ' . getParam()); $act = $row['deleted']; $act = !$act; if (isset($_POST['reason']) or $act == 0) { updateFieldWhere('needs', 'deleted', $act, 'need_id = ' . getParam()); if (isset($_POST['reason']) and ($_POST['reason'] == 1 or $_POST['reason'] == 2)) { updateFieldWhere('needs', 'delreason', $_POST['reason'], 'need_id = ' . getParam()); } if (isset($_POST['reason']) and $_POST['reason'] == 1) { updateFieldWhere('needs', 'need_full', 1, 'need_id = ' . getParam()); updateFieldWhere('needs', 'deleted', 0, 'need_id = ' . getParam()); } redirect(0, getCurrentLink()); return; } ?> <form class="simpleform" action="" method="POST"> Pažymėkite šalinimo priežastį:<br><br> <input checked="checked" name="reason" type="radio" value="1" />padovanota / padėta ne per sistemą<br> <input name="reason" type="radio" value="2" />nebereikalinga pagalba / nebereikalingas daiktas<br> <br><input type="submit" value="Siųsti" /> </form> <?php return; } $tablefields = $sortby = array(); $tablehead = array('titles' => array(), 'columns' => array()); $rg = 0;
function formatTable($object, $cols, $head = false, $sort = false, $viewed = false, $class = false) { if (!empty($object)) { echo '<table class="admintbl ' . $class . '">'; if ($head) { echo '<thead><tr>'; foreach ($head['titles'] as $key => $h) { $finaltitle = $h; $colspan = isset($head['merge']) && array_key_exists($key, $head['merge']) ? ' colspan="' . $head['merge'][$key] . '"' : ''; $columns = isset($head['columns']) && array_key_exists($key, $head['columns']) ? ' class="' . $head['columns'][$key] . '"' : ''; if ($sort && array_key_exists($key, $sort)) { $parameters = preg_replace("/([?&])rikiuoti=\\w+(&|\$)/", "\$2", $_SERVER['QUERY_STRING']); $parameters = preg_replace("/([?&])tvarka=\\w+(&|\$)/", "\$2", $parameters); $parameters = preg_replace("/([?&])page=\\w+(&|\$)/", "\$2", $parameters); $sortvalue = $sort[$key]; $gettvarka = isset($_GET['tvarka']) ? $_GET['tvarka'] : ''; switch ($gettvarka) { case 'asc': $ordervalue = 'desc'; $arr = 'fa fa-angle-up'; break; case 'desc': $ordervalue = 'asc'; $arr = 'fa fa-angle-down'; break; default: $ordervalue = 'desc'; $arr = 'fa fa-angle-up'; } $getrikiuoti = isset($_GET['rikiuoti']) ? $_GET['rikiuoti'] : ''; $arrow = $sort[$key] == $getrikiuoti ? $arr : ''; echo '<th' . $colspan . $columns . '><a href="index.php?' . $parameters . '&rikiuoti=' . $sortvalue . '&tvarka=' . $ordervalue . '&page=' . pageNum() . '">' . $finaltitle . ' <i class="' . $arrow . '"></i></a></th>'; } else { echo '<th' . $colspan . $columns . '>' . $finaltitle . '</th>'; } } echo '</tr></thead>'; } foreach ($object as $o) { if ($viewed && (isset($o['user_active']) and $o['user_active'] == 0 or isset($o['deleted']) and $o['deleted'] == 1)) { echo '<tr class="unmarked">'; } else { echo '<tr>'; } $count = 0; foreach ($cols as $key => $col) { $columns = isset($head['columns']) && array_key_exists($key, $head['columns']) ? ' ' . $head['columns'][$key] : ''; $title = isset($head['title']) && array_key_exists($key, $head['title']) ? $head['title'][$key] : ''; echo '<td class="col' . $count . $columns . '" title="' . ($title == true ? rtrim(str_replace('<br>', "\n", $o[$col]), ', ') : NULL) . '">'; $count = $count + 1; if (is_array($col)) { if (array_key_exists('action', $col)) { if (array_key_exists(4, $col['action']) && $col['action'][4] != false) { $func = $col['action'][4]; $color = $func($o[$col['action'][0]]); } else { $color = $col['action'][3]; } echo '<a class="' . (array_key_exists(5, $col['action']) ? 'responsive-normal ' : '') . 'actionbutton ' . $color . '" href="' . getCurrentLink() . '&veiksmas=' . $col['action'][1] . '¶m=' . $o[$col['action'][0]] . '">' . $col['action'][2] . '</a>'; if (array_key_exists(5, $col['action'])) { echo '<a class="responsive-small responsive-verysmall actionbutton ' . $color . '" href="' . getCurrentLink() . '&veiksmas=' . $col['action'][1] . '¶m=' . $o[$col['action'][0]] . '" title="' . $col['action'][2] . '"></a>'; } } elseif (array_key_exists('converter', $col)) { $value = $o[$col['converter'][0]]; $fun = $col['converter'][1]; $arg = isset($col['converter'][2]) ? $col['converter'][2] : false; echo $fun($value, $arg); } elseif (array_key_exists('convArray', $col)) { $value = $col['convArray'][0]; $values = array(); foreach ($value as $vl) { $values[] = $o[$vl]; } $fun = $col['convArray'][1]; $arg = isset($col['convArray'][2]) ? $col['convArray'][2] : false; echo $fun($values, $arg); } elseif (array_key_exists('editable', $col)) { $value = $o[$col['editable'][0]]; $field = $col['editable'][0]; $valueid = $o[$col['editable'][1]]; $class = $col['editable'][2]; $len = $col['editable'][3]; echo '<form action="" method="post"><input type="hidden" name="editableid" value="' . $valueid . '"><input type="hidden" name="editablefield" value="' . $field . '"><input title="Įvedę duomenis paspauskite ENTER" name="editable" type="text" value="' . $value . '" class="' . $class . '" maxlength="' . $len . '"></form>'; } } else { if ($col == 'null') { echo ''; } else { if (isset($_GET['srch'])) { echo str_replace(ucfirst($_GET['srch']), '<span class="srch_marker">' . ucfirst($_GET['srch']) . '</span>', str_replace($_GET['srch'], '<span class="srch_marker">' . $_GET['srch'] . '</span>', $o[$col])); } else { echo $o[$col]; } } } echo '</td>'; } echo '</tr>'; } echo '</table>'; } else { echo '<i class="">Nėra duomenų</i>'; } }