function crearSolicitudTarea($tipo, $id, $fecha_inicio, $fecha_fin, $titulo, $descripcion, $encargado, $prioridad, $proyeccion, $url) { LogController::logWebServiceIn('Llamada a web service: ' . __FILE__ . ' - ' . __FUNCTION__, compact('tipo', 'id', 'fecha_inicio', 'fecha_fin', 'titulo', 'descripcion', 'encargado', 'prioridad', 'proyeccion', 'url')); $returnMessage = ""; $handlerAttachmentCore = new AttachmentCore(); $handlerRequestCore = new RequestCore(); $handlerUserCore = new UserCore(); $handlerFlowSettingsCore = new FlowSettingsCore(); // Tomar datos de aprobador $flow = Flow::find(FLOW_TAREAS); $creador = User::find($encargado); if ($creador) { $jefe = User::find($creador->user_reports_to); if (!$jefe) { $jefe = User::find($flow->flow_administrator); } // Crear solicitud $request_flow = $flow->flow_id; $request_id = $handlerRequestCore->getLastGeneralRequestId() + 1; $inner_request_id = $handlerRequestCore->getLastGeneralRequestId($request_flow) + 1; $request_name = "Aprobación: " . $titulo; $request_description = "Aprobación de tarea: " . $descripcion; $request_createdby = $creador->user_id; $request_assignedto = $jefe->user_id; $handlerRequestCore->createNewRequest($request_id, $inner_request_id, $request_flow, $request_name, $request_description, $request_createdby, $request_assignedto); Tarea::create(["ef_id" => $request_id, "ext_id" => $id, "tipo" => $tipo, "titulo" => $titulo, "descripcion" => $descripcion, "encargado" => $request_createdby, "aprobador_1" => $request_assignedto, "aprobador_2" => "", "fecha_inicio" => $fecha_inicio, "fecha_fin" => $fecha_fin, "prioridad" => $prioridad, "proyeccion" => $proyeccion]); RequestMetadataCore::set($request_id, "APR-DOBLE-APROBACION", "No"); RequestMetadataCore::set($request_id, "APR-APROBADO", "No"); RequestMetadataCore::set($request_id, "APR-COMENTARIO", ""); //Tomar archivo de campo url y adjuntar if ($url != '') { $tmpFileName = basename($url); file_put_contents($tmpFileName, fopen($url, 'r')); $filetype = FlowSettingsCore::get($request_flow, "APR_FILE_ADJUNTO"); $handlerAttachmentCore->addAttachmentToRequest($request_id, $filetype, dirname(__FILE__) . "/" . $tmpFileName, $_SESSION["environment_path"], "admin", "Adjunto de tarea"); } } else { $returnMessage = "ERROR: Usuario " . $encargado . " no existe en BPM. Imposible continuar"; } return $returnMessage; }
public static function getAttachments($id_lang, $id_product, $include = true) { if (Module::isInstalled('agilemultipleseller')) { $id_seller_for_filter = AgileSellerManager::get_id_seller_for_filter4att(); if ((int) $id_seller_for_filter <= 0) { return parent::getAttachments($id_lang, $id_product, $include); } return Db::getInstance()->executeS(' SELECT * FROM ' . _DB_PREFIX_ . 'attachment a LEFT JOIN ' . _DB_PREFIX_ . 'object_owner oo ON oo.entity = \'attachment\' AND a.id_attachment = oo.id_object LEFT JOIN ' . _DB_PREFIX_ . 'attachment_lang al ON (a.id_attachment = al.id_attachment AND al.id_lang = ' . (int) $id_lang . ') WHERE (oo.id_owner = ' . $id_seller_for_filter . ' OR oo.id_owner = 0) AND a.id_attachment ' . ($include ? 'IN' : 'NOT IN') . ' ( SELECT pa.id_attachment FROM ' . _DB_PREFIX_ . 'product_attachment pa WHERE id_product = ' . (int) $id_product . ' )'); } else { return parent::getAttachments($id_lang, $id_product, $include); } }
function crearDocumentoYSolicitud($arrayCabecera, $arrayLineas, $tmpString, $rideContent, $rideExtension, $fullXml) { $handlerRequestCore = new RequestCore(); $handlerAttachmentCore = new AttachmentCore(); $handlerRequestMetadataCore = new RequestMetadataCore(); // Verificar el usuario creador / al que se asignará $creator = Responsable::whereRuc($arrayCabecera['ruc'])->lists('responsable')->implode(','); if (empty($creator)) { $creator = FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, "RDE_DEF_ASIGNACION"); } if ($arrayCabecera["tipo_doc"] == "FAC") { $customStep = FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, "RDE_STEP_FACTURAS"); } else { $customStep = FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, "RDE_STEP_OTROS"); $creator = ''; } // Crear solicitud por cada proveedor $request_flow = FLOW_RECEPCIONDOCUMENTOS; $request_id = $handlerRequestCore->getLastGeneralRequestId() + 1; $inner_request_id = $handlerRequestCore->getLastGeneralRequestId($request_flow) + 1; $request_name = $request_description = $arrayCabecera["tipo_doc"] . " - " . $arrayCabecera["razonSocial"]; $request_createdby = "admin"; $request_id = $handlerRequestCore->createNewRequest($request_id, $inner_request_id, $request_flow, $request_name, $request_description, $request_createdby, $creator, $customStep); // Crear documento $arrayCabecera['ef_id'] = $request_id; $documento = Documento::create($arrayCabecera); // Setear id_documento en líneas e insertar foreach ($arrayLineas as &$linea) { $linea['id_documento'] = $documento->id; DocumentoLinea::create($linea); } // Guardar archivos temporales en disco $xmlFile = dirname(__FILE__) . "/facturas/tmpAttachments/tmp.xml"; $pdfFile = dirname(__FILE__) . "/facturas/tmpAttachments/tmp." . $rideExtension; $filetypeXml = FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, "RDE_FILE_XML"); $filetypePdf = FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, "RDE_FILE_PDF"); //file_put_contents($xmlFile, $tmpString); file_put_contents($xmlFile, $fullXml); $handlerAttachmentCore->addAttachmentToRequest($request_id, $filetypeXml, $xmlFile, $_SESSION["environment_path"], "admin", "Documento XML"); if (!empty($rideExtension) && !empty($rideContent)) { file_put_contents($pdfFile, $rideContent); $handlerAttachmentCore->addAttachmentToRequest($request_id, $filetypePdf, $pdfFile, $_SESSION["environment_path"], "admin", "Documento PDF"); } // Setear variables de solicitud $handlerRequestMetadataCore->setVariable($request_id, "RDE-TIPO-DOCUMENTO", $arrayCabecera["tipo_doc"]); $handlerRequestMetadataCore->setVariable($request_id, "RDE-NUM-DOCUMENTO", $arrayCabecera["estab"] . "-" . $arrayCabecera["ptoEmi"] . "-" . $arrayCabecera["secuencial"]); $handlerRequestMetadataCore->setVariable($request_id, "RDE-NOMBRE-PROVEEDOR", $arrayCabecera["razonSocial"]); }
require_once APP_BASEPATH . "/includes/Entities/Request/RequestCore.php"; require_once APP_BASEPATH . "/includes/Entities/RequestMetadata/RequestMetadataCore.php"; require_once APP_BASEPATH . "/includes/Entities/FlowSettings/FlowSettingsCore.php"; require_once APP_BASEPATH . "/includes/Entities/Attachment/AttachmentCore.php"; require_once APP_BASEPATH . "/includes/Entities/Filetype/FiletypeCore.php"; require_once $_SESSION["environment_path"] . "/customcode/Reclamos/includes/Entities/General/GeneralCore.php"; require_once $_SESSION["environment_path"] . "/customcode/Reclamos/includes/Entities/Clase/ClaseCore.php"; require_once $_SESSION["environment_path"] . "/customcode/Reclamos/includes/Entities/Reclamo/ReclamoCore.php"; require_once $_SESSION["environment_path"] . "/customcode/Reclamos/includes/Entities/ReclamoDetalle/ReclamoDetalleCore.php"; define("CURRENT_FLOW", "1"); $handlerRequestCore = new RequestCore(); $handlerReclamoCore = new ReclamoCore(); $handlerReclamoDetalleCore = new ReclamoDetalleCore(); $handlerRequestMetadataCore = new RequestMetadataCore(); $handlerFlowSettingsCore = new FlowSettingsCore(); $handlerAttachmentCore = new AttachmentCore(); $handlerFiletypeCore = new FiletypeCore(); $handlerGeneralCore = new GeneralCore(); $handlerClaseCore = new ClaseCore(); if ($_POST["cliente_pais"] == "ECU") { $tipo = "venta_local"; $creador = $handlerFlowSettingsCore->getSettingValue(CURRENT_FLOW, "REC_PRO_USUARIO_VL"); $asignado_a = $handlerFlowSettingsCore->getSettingValue(CURRENT_FLOW, "REC_PRO_USUARIO_VL"); } else { $tipo = "exportacion"; $creador = $handlerFlowSettingsCore->getSettingValue(CURRENT_FLOW, "REC_PRO_USUARIO_EXP"); $asignado_a = $handlerFlowSettingsCore->getSettingValue(CURRENT_FLOW, "REC_PRO_USUARIO_EXP"); } $customStep = ""; if (isset($_POST["reclamo_extemporaneo"])) { if ($_POST["reclamo_extemporaneo"] == "1") {
public function insertReclamo() { $input = Request::createFromGlobals(); $handlerRequestCore = new \RequestCore(); $handlerAttachmentCore = new \AttachmentCore(); $clase = Clase::find($input->reclamo['clase']); // Asignar creador $creador = $asignado_a = FlowSettingsCore::get(FLOW_RECLAMOS, "REC_PRO_USUARIO_VL"); if (FlowSettingsCore::get(FLOW_RECLAMOS, "REC_PRO_REGION_EXT") == $input->reclamo['region']) { $creador = $asignado_a = FlowSettingsCore::get(FLOW_RECLAMOS, "REC_PRO_USUARIO_EXP"); } $extemporaneo = false; $customStep = ""; foreach ($input->facturas as $factura) { if ($factura['infoFactura']['extemporaneo'] == true) { $customStep = FlowSettingsCore::get(FLOW_RECLAMOS, "REC_STEP_EXTEMPORANEAS"); $asignado_a = FlowSettingsCore::get(FLOW_RECLAMOS, "REC_USER_EXTEMPORANEAS"); $extemporaneo = true; break; } } $request_id = $handlerRequestCore->createNewRequest(0, 0, FLOW_RECLAMOS, "Reclamo - " . date("Y-m-d") . " - " . $input->cliente['nombre'], "Reclamo - " . date("Y-m-d") . " - " . $input->cliente['nombre'], $creador, $asignado_a, $customStep); $reclamo = Reclamo::create(['ef_id' => $request_id, 'cliente_codigo' => $input->cliente['codigo'], 'cliente_nombre' => $input->cliente['nombre'], 'cliente_identificacion' => $input->cliente['identificacion'], 'cliente_direccion' => $input->cliente['direccion'], 'contacto_nombre' => $input->contacto['nombre'], 'contacto_telefono' => $input->contacto['telefono'], 'contacto_email' => $input->contacto['email'], 'reclamo_descripcion' => $input->reclamo['descripcion'], 'reclamo_fecha_inicio' => date('Y-m-d H:i:s'), 'reclamo_clase' => $input->reclamo['clase'], 'reclamo_region' => $input->reclamo['region'], 'reclamo_extemporaneo' => $extemporaneo ? 1 : 0, 'reclamo_num_interno' => $input->reclamo['num_interno'], 'reclamo_monto' => $input->reclamo['total_reclamo'], 'visita_requiere' => 0]); $listaFacturas = array(); foreach ($input->facturas as $factura) { foreach ($factura['detalles'] as $detalle) { if ($detalle['cantidad_reclamo'] > 0 || $detalle['cantidad_no_facturado'] > 0) { if ($detalle['cantidad_no_facturado'] > 0) { $cantidad = $detalle['cantidad_no_facturado']; $valor = $detalle['valor_no_facturado']; $lote = $detalle['lote_no_facturado']; } else { $cantidad = $detalle['cantidad_reclamo']; $valor = $detalle['cantidad_reclamo'] * $detalle['precioUnitario']; $lote = $detalle['lote']; } ReclamoDetalle::create(['reclamo_id' => $reclamo->id, 'factura' => $factura['infoFactura']['numero_factura'], 'factura_fecha' => $factura['infoFactura']['fechaEmision'], 'producto_comercial' => $detalle['clase'], 'codigo_item' => $detalle['codigoPrincipal'], 'descripcion_item' => $detalle['descripcion'], 'precio_unitario' => $detalle['precioUnitario'], 'cantidad_original' => $detalle['cantidad'], 'cantidad_reclamo' => $cantidad, 'valor_reclamo' => $valor, 'lote_reclamo' => $lote]); $listaFacturas[] = $factura['infoFactura']['numero_factura']; } } } $listaFacturas = array_unique($listaFacturas); foreach ($input->adjuntos as $adjunto) { $handlerAttachmentCore->addAttachmentToRequest($request_id, $adjunto['filetype']['filetype_id'], $adjunto['filename'], APP_ENVPATH, 'admin', 'Adjunto del cliente'); } RequestMetadataCore::set($request_id, 'REC-CODIGO-CLIENTE', $input->cliente['codigo']); RequestMetadataCore::set($request_id, 'REC-NOMBRE-CLIENTE', $input->cliente['nombre']); RequestMetadataCore::set($request_id, 'REC-IDENTIFICACION-CLIENTE', $input->cliente['identificacion']); RequestMetadataCore::set($request_id, 'REC-EMAIL-CLIENTE', $input->cliente['email']); RequestMetadataCore::set($request_id, 'REC-EMAIL-CONTACTO', $input->contacto['email']); RequestMetadataCore::set($request_id, 'REC-CLASE', $clase->nombre); RequestMetadataCore::set($request_id, 'REC-NUMERO-FACTURA', implode(',', $listaFacturas)); RequestMetadataCore::set($request_id, 'REC-NUMERO-REC-CLIENTE', $input->reclamo['num_interno']); RequestMetadataCore::set($request_id, 'REC-DESCRIPCION', $input->reclamo['descripcion']); RequestMetadataCore::set($request_id, 'REC-MONTO-DECISION', $input->reclamo['total_reclamo']); $request = EFRequest::find($request_id); echo $request->request_inner_id; }
/** * Process product attachments * * @param object $product * @param array $data */ public function processAttachments($product, $data) { \AttachmentCore::attachToProduct($product->id, $data); }
/** * Get product attachments * * @return array */ private function getProductAttachments() { return array_map(function ($a) { return $a['id_attachment']; }, \AttachmentCore::getAttachments($this->locales[0]['id_lang'], $this->product->id, true)); }