Как мне это сделать? Я хочу заказать следующую таблицу, в которой записи с 4 значками идут первыми, а записи с 3 значками - после. Я использую сторону сервера следующим образом:
Мне больше нечего спросить, но сайт просит меня написать больше текста, чтобы заполнить, я поставил это
Мне больше нечего спросить, но сайт просит меня написать больше текста, чтобы заполнить, я поставил это
![enter image description here](https://i.stack.imgur.com/ZwqPM.png)
HTML Табла:
<table id="fileData" class="datatablere" width="100%" cellspacing="0">
<thead>
<tr>
<th style="width: 10%; text-align: left;" class="ui-state-default">Cliente</th>
<th style="width: 37%; text-align: left;" class="ui-state-default">Productos</th>
<th style="width: 7%; text-align: left;" class="ui-state-default">Cantidad</th>
<th style="width: 10%; text-align: left;" class="ui-state-default">Precio</th>
<th style="width: 10%; text-align: left;" class="ui-state-default">Entrega</th>
<th style="width: 13%; text-align: left;" class="ui-state-default">Fecha ingreso</th>
<th class="ui-state-default" style="width: 13%; text-align: center;">Acción</th>
</tr>
</thead>
</table>
JS:
var rTable = $('.datatablere').dataTable( {
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"sPaginationType": "full_numbers",
"aaSorting": [[ 0, "asc" ]],
"iDisplayLength": 10,
"bJQueryUI": true,
"sDom": '<"H"frlT>t<"F"ip>',
"oLanguage": {
"sLengthMenu": "Mostrar _MENU_ recetas",
"sSearch": "Buscar:",
"sInfo": "Mostrando _START_ a _END_ de _TOTAL_ recetas",
"sZeroRecords": "No hay recetas coincidentes encontradas",
"sInfoFiltered": "(filtrado entre _MAX_ recetas)",
"sInfoEmpty": "Mostrando 0 a 0 de 0 recetas",
"oPaginate" : {
"sFirst" : "Primero",
"sLast" : "Ultimo",
"sNext" : "Siguiente",
"sPrevious" : "Anterior"
}
},
"aoColumns": [
{ "bSortable": false},
{ "bSortable": false},
{ "bSortable": false, "sClass": "text-center"},
{ "bSortable": false},
{ "bSortable": false, "sClass": "text-center"},
{ "bSortable": false, "sClass": "text-center"},
{ "bSortable": true, "sClass": "text-center" }
],
"bProcessing": true,
"serverSide": true,
"ajax":{
url :"server_processing.php",
type: "post",
error: function(){
$("#employee_grid_processing").css("display","none");
}
}
} );
server_processing.php:
<?php
//include connection file
include_once("st_inc/connection.php");
// initilize all variable
$params = $columns = $totalRecords = $data = array();
$params = $_REQUEST;
//define index of column
$columns = array(
//0 =>'nombre'
/*1 => 'dni',
2 => 'domicilio',
3 => 'telefono',
4 => 'movil'*/
//5 => 'fecha_ingreso'
);
$where = $sqlTot = $sqlRec = "";
// check search value exist
if( !empty($params['search']['value']) ) {
$where .= " AND CONCAT_WS(' ', LTRIM(RTRIM(clientes.nombre)), LTRIM(RTRIM(clientes.apellido))) LIKE '%".$params['search']['value']."%' ";
//$where .=" ( producto LIKE '%".$params['search']['value']."%' ) ";
/*$where .=" OR dni LIKE '%".$params['search']['value']."%' ";
$where .=" OR domicilio LIKE '%".$params['search']['value']."%' ";
$where .=" OR telefono LIKE '%".$params['search']['value']."%' ";
$where .=" OR movil LIKE '%".$params['search']['value']."%' )";*/
/*$where .=" OR celular LIKE '%".$params['search']['value']."%' ";
$where .=" OR afiliado LIKE '%".$params['search']['value']."%' )";*/
//$where .=" OR ciudad LIKE '%".$params['search']['value']."%' )";
}
$fecha = explode("-", date("Y-m-d", time()));
$sql = "SELECT clientes.nombre, clientes.apellido, recetas.idreceta FROM recetas INNER JOIN clientes ON (recetas.idcliente=clientes.idcliente) AND YEAR(recetas.fecha_ingreso) = '".$fecha[0]."' ";
$sqlTot .= $sql;
$sqlRec .= $sql;
if(isset($where) && $where != '') {
$sqlTot .= $where;
$sqlRec .= $where;
}
//$sqlRec .= " ORDER BY ". $columns[$params['order'][0]['column']]." ".$params['order'][0]['dir']." LIMIT ".$params['start']." ,".$params['length']." ";
$sqlRec .= " LIMIT ".$params['start']." ,".$params['length']." ";
$queryTot = mysql_query($sqlTot, $connection) or die("database error:". mysql_error($connection));
$totalRecords = mysql_num_rows($queryTot);
$queryRecords = mysql_query($sqlRec, $connection) or die("error to fetch employees data");
while( $row = mysql_fetch_row($queryRecords) ) {
$row[0] = ucwords($row['0'].' '.$row['1']);
$sqlped = "select * from pedidos where idreceta = '$row[2]'";
$resped = mysql_query($sqlped);
$t = 0; $tne = 0; $ic='';
while ($rowped = mysql_fetch_assoc($resped)) {
// calculate $t and $tne
}
if ($t == $tne) {
$ic = '<a style="cursor: pointer;" target="_blank" href="imprimir.php?id='.$id.'"><img src="imagenes/136.png" width="20" height="20" /></a> ';
$ic .= '<img src="imagenes/OK_Verde.png" width="22" height="22" />';
$ic .= ' <a href="add_receta.php?eid='.$id.'" onClick="return confirm(\'¿Está seguro que desea eliminar esta receta?\');"><img src="imagenes/delete.png" width="18" height="18" /></a>';
}else{
$ic = '<a style="cursor: pointer;" target="_blank" href="imprimir.php?id='.$id.'"><img src="imagenes/136.png" width="20" height="20" /></a> ';
$ic .= '<a href="add_receta.php?rid='.$id.'"><img width="18" height="18" src="imagenes/edit.png" /></a> ';
$ic .= "<a style='cursor: pointer;' onClick='toolEntrega(\"tool_entrega.php?id_rec=".$id."\", \"Nueva entrega\", \"440\", \"180\");'><img width='18' height='18' src='imagenes/classy/26.png' /></a>";
$ic .= ' <a href="add_receta.php?eid='.$id.'" onClick="return confirm(\'¿Está seguro que desea eliminar esta receta?\');"><img src="imagenes/delete.png" width="18" height="18" /></a>';
}
$row[6] = $ic;
$data[] = $row;
}
$json_data = array(
"draw" => intval( $params['draw'] ),
"recordsTotal" => intval( $totalRecords ),
"recordsFiltered" => intval($totalRecords),
"data" => $data
);
echo json_encode($json_data);
?>