Beispiel #1
0
function renderRow($unixTime, $fullArray)
{
    $out = "";
    switch ($fullArray["tipo"]) {
        case "SeguimientoDeServicio":
            $ods = OrdenDeServicioDAO::getByPK($fullArray["id_orden_de_servicio"]);
            $s = ServicioDAO::getByPK($ods->getIdServicio());
            $out .= '<strong> Seguimiento De Orden ' . $s->getNombreServicio() . ' ' . $fullArray["id_orden_de_servicio"] . ' </strong>';
            $out .= $fullArray["estado"];
            $u = $fullArray["id_usuario"];
            break;
        case "ClienteSeguimiento":
            $out .= '<strong> Seguimiento </strong>';
            $out .= $fullArray["texto"];
            $u = $fullArray["id_usuario"];
            break;
        case "OrdenDeServicio":
            $ods = OrdenDeServicioDAO::getByPK($fullArray["id_orden_de_servicio"]);
            $s = ServicioDAO::getByPK($ods->getIdServicio());
            $out .= '<strong>Nueva Orden de Servicio</strong> ' . $s->getNombreServicio() . ' ' . $fullArray["id_orden_de_servicio"] . ' ';
            $out .= $fullArray["descripcion"];
            $u = $fullArray["id_usuario"];
            break;
        case "Venta":
            if ($fullArray["cancelada"]) {
                $out .= '<strong><strike>Venta Cancelada ' . $fullArray["id_venta"] . '</strike></strong>';
            } else {
                $out .= '<strong>Venta ' . $fullArray["id_venta"] . '</strong>';
            }
            $out .= '&nbsp;' . FormatMoney($fullArray["total"]) . ' ' . $fullArray["tipo_de_venta"];
            $u = $fullArray["id_usuario"];
            break;
        case "Cotizacion":
            $out .= '<strong>Venta ' . $fullArray["id_venta"] . '</strong>';
            $u = $fullArray["id_usuario"];
            break;
    }
    //return json_encode( $fullVo );
    $u = UsuarioDAO::getByPK($u)->getNombre();
    $out .= '<br><div style="text-align: right; font-size:10px; color:gray">' . FormatTime($fullArray["fecha"]) . ' por ' . $u . "</div>";
    return $out;
}
 public static function OrdenDeServicio($id_orden)
 {
     //obtengamos datos de esta orden de servicio
     //el cliente
     $daoOrden = OrdenDeServicioDAO::getByPK($id_orden);
     $daoCliente = UsuarioDAO::getByPK($daoOrden->getIdUsuarioVenta());
     $daoAgente = UsuarioDAO::getByPK($daoOrden->getIdUsuario());
     $daoServicio = ServicioDAO::getByPK($daoOrden->getIdServicio());
     $pdf = self::createPdf("Orden de Servicio " . $id_orden, $daoServicio->getNombreServicio());
     self::printClient($pdf, $daoCliente);
     $opciones_tabla = array();
     $opciones_tabla['showLines'] = 0;
     $opciones_tabla['showHeadings'] = 0;
     $opciones_tabla['shaded'] = 0;
     $opciones_tabla['fontSize'] = 8;
     $opciones_tabla['xOrientation'] = 'right';
     $opciones_tabla['xPos'] = self::puntos_cm(7.5);
     $opciones_tabla['width'] = self::puntos_cm(11);
     $opciones_tabla['textCol'] = array(0, 0, 0);
     $opciones_tabla['titleFontSize'] = 12;
     $opciones_tabla['rowGap'] = 3;
     $opciones_tabla['colGap'] = 3;
     $datos = array(array("col" => "<b>Servicio</b>"), array("col" => $daoServicio->getCodigoServicio()), array("col" => "<b>Numero de orden</b>"), array("col" => $daoOrden->getIdOrdenDeServicio()), array("col" => "<b>Fecha de entrega</b>"), array("col" => ""));
     $pdf->ezSetY(self::puntos_cm(26.8));
     $opciones_tabla['xPos'] = self::puntos_cm(14.2);
     $opciones_tabla['width'] = self::puntos_cm(4);
     $opciones_tabla['showLines'] = 0;
     $opciones_tabla['shaded'] = 2;
     $opciones_tabla['shadeCol'] = array(1, 1, 1);
     $opciones_tabla['shadeCol2'] = array(0.8984375, 0.95703125, 0.99609375);
     $pdf->ezTable($datos, "", "", $opciones_tabla);
     /* ************************
      * PRODUCTOS
      * ************************* */
     $elementos = array(array('cantidad' => 'Detalles de la orden', 'unidad' => ''));
     $eP = $daoOrden->getExtraParams();
     if (!is_null($eP)) {
         $ePObj = json_decode($eP);
         foreach ($ePObj as $obj) {
             $row["cantidad"] = "<b>" . $obj->desc . "</b>";
             $row["unidad"] = $obj->value;
             $row["agrupacion"] = "";
             $row["descripcion"] = "";
             $row["precio"] = "";
             $row["importe"] = "";
             array_push($elementos, $row);
         }
     }
     $pdf->ezText("", 10, array('justification' => 'center'));
     $pdf->ezSetY(self::puntos_cm(18.6));
     $opciones_tabla['xPos'] = self::puntos_cm(2);
     $opciones_tabla['width'] = self::puntos_cm(16.2);
     $pdf->ezTable($elementos, "", "", $opciones_tabla);
     self::drawBasicGuide($pdf);
     $pdf->ezStream();
     return;
 }
Beispiel #3
0
 function renderIdServicio($id)
 {
     $serv = ServicioDAO::getByPK($id);
     return $serv->getNombreServicio();
 }
Beispiel #4
0
function funcion_orden_de_servicio($id_orden_de_servicio)
{
    return OrdenDeServicioDAO::getByPK($id_orden_de_servicio) ? ServicioDAO::getByPK(OrdenDeServicioDAO::getByPK($id_orden_de_servicio)->getIdServicio())->getNombreServicio() : "---------";
}
Beispiel #5
0
function funcion_servicio($id_servicio)
{
    return ServicioDAO::getByPK($id_servicio) ? ServicioDAO::getByPK($id_servicio)->getNombreServicio() : "---------";
}
Beispiel #6
0
<?php

define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
//
// Parametros necesarios
//
$page->requireParam("sid", "GET", "Este servicio no existe.");
$este_servicio = ServicioDAO::getByPK($_GET["sid"]);
//
// Titulo de la pagina
//
$page->addComponent(new TitleComponent("Editar servicio " . $este_servicio->getNombreServicio(), 2));
//
// Forma de edicion
//
$form = new DAOFormComponent($este_servicio);
$form->beforeSend("foo");
$form->hideField(array("id_servicio", "activo", "extra_params", "control_existencia"));
$form->sendHidden("id_servicio");
$form->addApiCall("api/servicios/editar/", "POST");
$form->onApiCallSuccessRedirect("servicios.ver.php?sid=" . $_GET["sid"]);
$page->addComponent($form);
$page->partialRender();
?>
		<div id="editor-grid" style="margin-top: 5px"></div>
		<script type="text/javascript" charset="utf-8">

			var extraParamsStore, rowEditing;
Beispiel #7
0
 private static function ValidarParametrosRegla($id_regla = null, $nombre = null, $id_producto = null, $id_clasificacion_producto = null, $id_unidad = null, $id_servicio = null, $id_clasificacion_servicio = null, $id_paquete = null, $cantidad_minima = null, $porcentaje_utilidad = null, $utilidad_neta = null, $metodo_redondeo = null, $margen_min = null, $margen_max = null, $secuencia = null)
 {
     //valida que la regla exista
     if (!is_null($id_regla)) {
         if (is_null(ReglaDAO::getByPK($id_regla))) {
             return "La regla " . $id_regla . " no existe";
         }
     }
     //valida que el nombre este en rango
     if (!is_null($nombre)) {
         if (!self::validarLongitudDeCadena($nombre, 0, 100)) {
             throw new InvalidDataException("nombre muy largo");
         }
     }
     //valida que el producto exista y este activo
     if (!is_null($id_producto)) {
         $producto = ProductoDAO::getByPK($id_producto);
         if (is_null($producto)) {
             return "El producto " . $id_producto . " no existe";
         }
         if (!$producto->getActivo()) {
             return "El producto " . $id_producto . " esta inactivo";
         }
     }
     //valida que la clasificacion de producto exista y este activa
     if (!is_null($id_clasificacion_producto)) {
         $clasificacion_producto = ClasificacionProductoDAO::getByPK($id_clasificacion_producto);
         if (is_null($clasificacion_producto)) {
             return "La clasificacion de producto " . $id_clasificacion_producto . " no existe";
         }
         if (!$clasificacion_producto->getActiva()) {
             return "La clasificacion de producto " . $id_clasificacion_producto . " no esta activa";
         }
     }
     //valida que la unidad exista y este activa
     if (!is_null($id_unidad)) {
         $unidad = UnidadDAO::getByPK($id_unidad);
         if (is_null($unidad)) {
             return "La unidad " . $id_unidad . " no existe";
         }
         if (!$unidad->getActiva()) {
             return "La unidad " . $id_unidad . " no esta activa";
         }
     }
     //valida que el servicio exista y este activo
     if (!is_null($id_servicio)) {
         $servicio = ServicioDAO::getByPK($id_servicio);
         if (is_null($servicio)) {
             return "El servicio " . $id_servicio . " no existe";
         }
         if (!$servicio->getActivo()) {
             return "El servicio " . $id_servicio . " no esta activo";
         }
     }
     //valida que la clasificacion de servicio exista y este activa
     if (!is_null($id_clasificacion_servicio)) {
         $clasificacion_servicio = ClasificacionServicioDAO::getByPK($id_clasificacion_servicio);
         if (is_null($clasificacion_servicio)) {
             return "La clasificacion de servicio " . $id_clasificacion_servicio . " no existe";
         }
         if (!$clasificacion_servicio->getActiva()) {
             return "La clasificacion de servicio " . $id_clasificacion_servicio . " no esta activa";
         }
     }
     //valida que el paquete exista y este activo
     if (!is_null($id_paquete)) {
         $paquete = PaqueteDAO::getByPK($id_paquete);
         if (is_null($paquete)) {
             return "El paquete " . $id_paquete . " no existe";
         }
         if (!$paquete->getActivo()) {
             return "El paquete " . $id_paquete . " esta inactivo";
         }
     }
     //valida que la cantidad minima este en rango
     if (!is_null($cantidad_minima)) {
         $e = self::validarNumero($cantidad_minima, 1.8E+200, "cantidad minima");
         if (is_string($e)) {
             return $e;
         }
     }
     //valida que el porcentaje de utilidad este en rango
     if (!is_null($porcentaje_utilidad)) {
         $e = self::validarNumero($porcentaje_utilidad, 1, "porcentaje_utilidad", -1);
         if (is_string($e)) {
             return $e;
         }
     }
     //valida que la utilidad neta este en rango
     if (!is_null($utilidad_neta)) {
         $e = self::validarNumero($utilidad_neta, 1.8E+200, "Utilidad neta", -1.8E+200);
         if (is_string($e)) {
             return $e;
         }
     }
     //valida que el metodo de redondeo este en rango
     if (!is_null($metodo_redondeo)) {
         $e = self::validarNumero($metodo_redondeo, 1.8E+200, "metodo_redondeo");
         if (is_string($e)) {
             return $e;
         }
     }
     //valida que el margen minimo este en rango
     if (!is_null($margen_min)) {
         $e = self::validarNumero($margen_min, 1.8E+200, "margen minimo");
         if (is_string($e)) {
             return $e;
         }
     }
     //valida que el margen maximo este en rango
     if (!is_null($margen_max)) {
         $e = self::validarNumero($margen_max, 1.8E+200, "margen maximo");
         if (is_string($e)) {
             return $e;
         }
     }
     //valida que la secuencia este en rango
     if (!is_null($secuencia)) {
         $e = self::validarNumero($secuencia, PHP_INT_MAX, "secuencia");
         if (is_string($e)) {
             return $e;
         }
     }
     //no se encontro error, regresa verdadero
     return true;
 }
Beispiel #8
0
        print '{"success":true, "sesion": false }';
        break;
    case 2004:
        //revisar login
        $token = SesionController::Iniciar($args["p"], $args["u"], true);
        echo json_encode(array("success" => $token["login_succesful"], "text" => "Credenciales invalidas"));
        break;
    case 2005:
        //dispatch
        $debug = isset($args['DEBUG']) ? "?debug" : "";
        echo "<script>window.location = 'sucursal.php" . $debug . "'; </script>";
        break;
    case 3000:
        $c = new stdClass();
        $c->servicios = array();
        foreach (ServicioDAO::getAll() as $servicio) {
            array_push($c->servicios, array("id_servicio" => $servicio->getIdServicio(), "nombre_servicio" => $servicio->getNombreServicio()));
        }
        echo json_encode($c);
        break;
    case 3001:
        $c = new stdClass();
        $c->ordenesActivas = array();
        foreach (OrdenDeServicioDAO::search(new OrdenDeServicio(array("activa" => 1))) as $servicio) {
            array_push($c->ordenesActivas, array("id_orden_de_servicio" => $servicio->getIdOrdenDeServicio(), "nombre_servicio" => ServicioDAO::getByPK($servicio->getIdServicio())->getNombreServicio(), "nombre_cliente" => UsuarioDAO::getByPK($servicio->getIdUsuarioVenta())->getNombre()));
        }
        echo json_encode($c);
        break;
        break;
}
return;
    echo "SERVICIOS[" . $servicio->getIdServicio() . "] = {$servicio};";
}
?>
</script>

<form name = "orden_servicio" id = "orden_servicio">
    <table width = 100% border = 0 >
        <tr>
            <td>
                <label>Servicio</label>
            </td>
            <td>
                <select name = "id_servicio" id = "id_servicio" onChange = "formatForm()" >
                    <?php 
$options = "<option value = null>-------</option>";
foreach (ServicioDAO::getAll() as $servicio) {
    $options .= "<option value = \"{$servicio->getIdServicio()}-{$servicio->getMetodoCosteo()}-{$servicio->getCostoEstandar()}-{$servicio->getPrecio()}\">{$servicio->getNombreServicio()}</option>";
}
echo $options;
?>
                </select>
            </td>
            <td><label>Fecha Entrega</label></td>
            <td><div id = "render_date">&nbsp;</div></td>
        </tr>
        <tr>
            <td><label>Precio</label></td>
            <td><input type = "text" disabled = true name = "precio" id = "precio" value = "" /></td>
            <td><label>Adelanto</label></td>
            <td><input type = "text" name = "adelanto" id = "adelanto"value = "" /></td>
        <tr>
    $html .= "   <td>";
    if ($producto = ProductoDAO::getByPK($regla->getIdProducto())) {
        $html .= "       " . $producto->getNombreProducto();
    } else {
        $html .= "-";
    }
    $html .= "   </td>";
    $html .= "   <td>";
    if ($categoria = ClasificacionProductoDAO::getByPK($regla->getIdClasificacionProducto())) {
        $html .= "       " . $categoria->getNombre();
    } else {
        $html .= "-";
    }
    $html .= "   </td>";
    $html .= "   <td>";
    if ($servicio = ServicioDAO::getByPK($regla->getIdServicio())) {
        $html .= "       " . $servicio->getNombreServicio();
    } else {
        $html .= "-";
    }
    $html .= "   </td>";
    $html .= "   <td>";
    $html .= "       {$regla->getCantidadMinima()}";
    $html .= "   </td>";
    $html .= "</tr>";
}
echo $html;
?>
        
    </table>
</div>
//$page->addComponent($form);
$page->partialRender();
?>
		<div style="border:1px solid #99BBE8;	;box-sizing: border-box;
		-moz-box-sizing: border-box;
		-ms-box-sizing: border-box;
		-webkit-box-sizing: border-box; 
		margin-bottom: 20px" id="ext-gen1079">


		<table style="margin-bottom: 0px;margin-left: 0px;" border=1>
			<tbody>
			<tr colspan=2>
				<td	rowspan=2 style="width:300px">
				<?php 
$este_servicio = ServicioDAO::getByPK($esta_orden->getIdServicio());
echo "<h3> " . $este_servicio->getNombreServicio() . "</h3>";
echo "<strong>Precio final</strong><div id='editarPrecioT1'> " . FormatMoney($esta_orden->getPrecio()) . "</div><br>";
$duracion = time() - $esta_orden->getFechaOrden();
$duracion /= 60;
$duracion = (int) $duracion;
$tiempos = "minutos";
if ($duracion > 60) {
    $duracion /= 60;
    $duracion = (int) $duracion;
    $tiempos = "horas";
}
echo "<strong>Duracion de la orden</strong><div>" . $duracion . " " . $tiempos . " </div>";
?>
				</td>
				<td >
 /**
  *
  *Da de baja un servicio que ofrece una empresa
  *
  * @param id_servicio int Id del servicio que ser� eliminado
  **/
 public static function Eliminar($id_servicio)
 {
     Logger::log("Desactivando servicio " . $id_servicio . " ...");
     //valida que el servicio exista y que no haya sido desactivado antes
     $validar = self::validarParametrosServicio($id_servicio);
     if (is_string($validar)) {
         Logger::error($validar);
         throw new InvalidDataException($validar);
     }
     //Si el servicio forma parte de algun paquete activo no puede ser eliminado
     $servicios_paquete = OrdenDeServicioPaqueteDAO::search(new OrdenDeServicioPaquete(array("id_servicio" => $id_servicio)));
     foreach ($servicios_paquete as $servicio_paquete) {
         $paquete = PaqueteDAO::getByPK($servicio_paquete->getIdServicio());
         if ($paquete->getActivo()) {
             Logger::error("No se puede borrar este servicio pues el paquete " . $paquete->getIdPaquete() . " aun lo contiene");
             throw new Exception("No se puede borrar este servicio pues el paquete " . $paquete->getIdPaquete() . " aun lo contiene");
         }
     }
     $servicio = ServicioDAO::getByPK($id_servicio);
     $servicio->setActivo(0);
     //revisar que no tenga ordenes de servicio activas
     $res = OrdenDeServicioDAO::search(new OrdenDeServicio(array("id_servicio" => $id_servicio, "activa" => 1)));
     if (sizeof($res) > 0) {
         Logger::log("Intento borrar un servicio que tiene ordenes de servicio activas... ");
         throw new BusinessLogicException("Imposible eliminar un servicio que tiene ordenes abiertas");
     }
     //Se obtienen los registros de las tablas servicio_empresa, servicio_clasificacion e impuesto_servicio
     //pues seran eliminados
     $servicios_empresa = ServicioEmpresaDAO::search(new ServicioEmpresa(array("id_servicio" => $id_servicio)));
     $servicios_clasificacion = ServicioClasificacionDAO::search(new ServicioClasificacion(array("id_servicio" => $id_servicio)));
     $impuestos_servicio = ImpuestoServicioDAO::search(new ImpuestoServicio(array("id_servicio" => $id_servicio)));
     DAO::transBegin();
     try {
         ServicioDAO::save($servicio);
         foreach ($servicios_empresa as $servicio_empresa) {
             ServicioEmpresaDAO::delete($servicio_empresa);
         }
         foreach ($servicios_clasificacion as $servicio_clasificacion) {
             ServicioClasificacionDAO::delete($servicio_clasificacion);
         }
         foreach ($impuestos_servicio as $impuesto_servicio) {
             ImpuestoServicioDAO::delete($impuesto_servicio);
         }
     } catch (Exception $e) {
         DAO::transRollback();
         Logger::error("No se ha podido descativar el servicio " . $id_servicio . " : " . $e);
         throw new Exception("No se ha podido descativar el servicio " . $id_servicio);
     }
     DAO::transEnd();
     LOgger::log("El servicio ha sido eliminado exitosamente");
 }
<?php

define("BYPASS_INSTANCE_CHECK", false);
require_once "../../../server/bootstrap.php";
$page = new GerenciaComponentPage();
//
// Parametros necesarios
//
$page->requireParam("oid", "GET", "Esta orden de servicio no existe.");
$esta_orden = OrdenDeServicioDAO::getByPK($_GET["oid"]);
$customer = UsuarioDAO::getByPK($esta_orden->getIdUsuarioVenta());
$link_to_customer = "<a href='clientes.ver.php?cid=" . $esta_orden->getIdUsuarioVenta() . "'>";
$link_to_customer .= $customer->getNombre();
$link_to_customer .= "</a>";
$page->addComponent(new TitleComponent("Orden de servicio " . $_GET["oid"] . " para " . $link_to_customer, 2));
$form = new DAOFormComponent($esta_orden);
$form->setEditable(true);
$form->hideField(array("id_usuario_venta", "extra_params", "motivo_cancelacion", "fecha_entrega", "cancelada", "adelanto", "activa", "id_usuario", "descripcion", "fecha_orden"));
$form->renameField(array("id_orden_de_servicio" => "id_orden"));
$form->sendHidden("id_orden");
$form->addApiCall("api/servicios/orden/editar", "POST");
$form->createComboBoxJoin("id_servicio", "nombre_servicio", ServicioDAO::getAll(), $esta_orden->getIdServicio());
//$form->createComboBoxJoin("id_usuario_asignado", "nombre", UsuarioDAO::getAll(), $esta_orden->getIdUsuarioAsignado());
$personal = UsuarioDAO::buscarEmpleados();
$form->createComboBoxJoinDistintName($field_name = "id_usuario_asignado", $table_name = "id_usuario", $field_name_in_values = "nombre", $values_array = $personal, $selected_value = null);
$form->createComboBoxJoin("id_usuario", "nombre", UsuarioDAO::getAll(), $esta_orden->getIdUsuario());
$form->onApiCallSuccessRedirect("servicios.detalle.orden.php?oid=" . $_GET["oid"]);
//$form->createComboBoxJoinDistintName("id_usuario_venta", "id_usuario", "nombre", UsuarioDAO::getAll(), $esta_orden->getIdUsuarioVenta());
$page->addComponent($form);
$page->render();
Beispiel #14
0
 /**
  *
  *Muestra los productos y/o servicios englobados en este paquete as? como las sucursales y las empresas donde lo ofrecen
  *
  * @param id_paquete int Id del paquete a visualizar sus detalles
  * @return detalle_paquete json Informacion del detalle del paquete
  **/
 public static function Detalle($id_paquete)
 {
     Logger::log("consiguiendo los detalles del paquete");
     //valida que el paquete exista
     $paquete = PaqueteDAO::getByPK($id_paquete);
     if (is_null($paquete)) {
         Logger::error("El paquete " . $id_paquete . " no existe");
         throw new Exception("El paquete " . $id_paquete . " no existe");
     }
     //En el primer campo de un arreglo se almacena el paquete en sí, en el segundo las empresas en las que esta disponible el paquete,
     //en el tercero las sucursales en las que esta disponible, en el cuarto los productos que contiene y en el quinto los servicios
     $detalle_paquete = array();
     array_push($detalle_paquete, $paquete);
     $empresas = array();
     $paquetes_empresa = PaqueteEmpresaDAO::search(new PaqueteEmpresa(array("id_paquete" => $id_paquete)));
     foreach ($paquetes_empresa as $paquete_empresa) {
         array_push($empresas, EmpresaDAO::getByPK($paquete_empresa->getIdEmpresa()));
     }
     array_push($detalle_paquete, $empresas);
     $sucursales = array();
     $paquetes_sucursal = PaqueteSucursalDAO::search(new PaqueteSucursal(array("id_paquete" => $id_paquete)));
     foreach ($paquetes_sucursal as $paquete_sucursal) {
         array_push($sucursales, SucursalDAO::getByPK($paquete_sucursal->getIdSucursal()));
     }
     array_push($detalle_paquete, $sucursales);
     $productos = array();
     $productos_paquete = ProductoPaqueteDAO::search(new ProductoPaquete(array("id_paquete" => $id_paquete)));
     foreach ($productos_paquete as $producto_paquete) {
         array_push($productos, ProductoDAO::getByPK($producto_paquete->getIdProducto()));
     }
     array_push($detalle_paquete, $productos);
     $servicios = array();
     $servicios_paquete = OrdenDeServicioPaqueteDAO::search(new OrdenDeServicioPaquete(array("id_paquete" => $id_paquete)));
     foreach ($servicios_paquete as $servicio_paquete) {
         array_push($servicios, ServicioDAO::getByPK($servicio_paquete->getIdServicio()));
     }
     array_push($detalle_paquete, $servicios);
     Logger::log("Detalle de paquete " . $id_paquete . " conseguido exitosamente con " . count($empresas) . "\n                empresas, " . count($sucursales) . " sucursales, " . count($productos) . " productos y " . count($servicios) . " servicios");
     return $detalle_paquete;
 }