Example #1
0
                } else {
                    echo json_encode(array("band" => "false"));
                }
                break;
            case 'del':
                $obj = new TCliente(hexdec($_POST['id']));
                if ($obj->eliminar()) {
                    echo json_encode(array("band" => "true"));
                } else {
                    echo json_encode(array("band" => "false"));
                }
                break;
            case 'autocomplete':
                $db = TBase::conectaDB();
                $rs = $db->Execute("select idCliente from cliente where nombre like '%" . $_GET['term'] . "%'");
                $obj = new TCliente();
                $datos = array();
                while (!$rs->EOF) {
                    $el = array();
                    $obj->setId($rs->fields['idCliente']);
                    $el['id'] = $obj->getId();
                    $el['label'] = $obj->getNombre();
                    $el['identificador'] = $obj->getId();
                    array_push($datos, $el);
                    $rs->moveNext();
                }
                echo json_encode($datos);
                break;
        }
        break;
}
Example #2
0
            $rs->moveNext();
        }
        $smarty->assign("comentarios", $datos);
        $datos = array();
        foreach (array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre") as $id => $val) {
            $rs = $db->Execute("select count(*) as compras from pedido where idCliente = " . $_GET['id'] . " and extract(month from registro) = " . ($id + 1));
            array_push($datos, array("nombre" => $val, "totalCompras" => $rs->fields['compras']));
        }
        $smarty->assign("meses", $datos);
        $rs = $db->Execute("select entrega, entregaCliente from pedido where idCliente = " . $_GET['id'] . " order by entregaCliente, entrega");
        $smarty->assign("ultimaCompra", $rs->fields['entregaCliente'] == '' ? $rs->fields['entrega'] : $rs->fields['entregaCliente']);
        $fecha = new DateTime($rs->fields['entregaCliente'] == '' ? $rs->fields['entrega'] : $rs->fields['entregaCliente']);
        $now = new DateTime();
        $interval = $now->diff($fecha);
        $smarty->assign("diferenciaUltimaCompra", array("mes" => $interval->format('%m'), "dias" => $interval->format('%d')));
        break;
    case 'ccrm':
        switch ($objModulo->getAction()) {
            case 'setClasificacion':
                $cliente = new TCliente($_POST['id']);
                $cliente->setClasificacion($_POST['clasificacion']);
                echo json_encode(array("band" => $cliente->guardar()));
                break;
            case 'addComentario':
                $db = TBase::conectaDB();
                $rs = $db->Execute("insert into comentariocliente (idCliente, fecha, texto) value (" . $_POST['id'] . ", now(), '" . $_POST['comentario'] . "')");
                echo json_encode(array("band" => $rs ? true : false));
                break;
        }
        break;
}