public function getDocumento($id = '')
 {
     $input = Request::createFromGlobals();
     if ($id == '') {
         $id = $input->id;
     }
     return Documento::with(['lineas.lineas_distribucion', 'lineas_distribucion', 'recepciones_efectivas.ordencompra.clase'])->find($id);
 }
예제 #2
0
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"]);
}
예제 #3
0
 public function generarPDF()
 {
     $input = Request::createFromGlobals();
     $task = Task::find($input->task_id);
     if ($task->task_step == \FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, 'RDE_FILE_OUTPUT_STEP')) {
         $documento = Documento::with(['lineas.lineas_distribucion', 'lineas_distribucion'])->whereEfId($input->request_id)->first();
         $filename = APP_TMPPATH . 'distribucion.pdf';
         PDFController::generatePDF(view('RecepcionDocumentos.PDF.distribucion_costo', ['documento' => $documento]), false, $filename);
         (new \AttachmentCore())->addAttachmentToRequest($input->request_id, \FlowSettingsCore::get(FLOW_RECEPCIONDOCUMENTOS, 'RDE_FILE_OUTPUT'), $filename, APP_ENVPATH, $_SESSION['user_id'], 'Formulario de distribución');
     }
     return array("status" => true, "message" => "");
 }
예제 #4
0
 public function getFacturasElectronicas()
 {
     $input = Request::createFromGlobals();
     return Documento::with('lineas')->whereTipoDoc('FAC')->get();
 }
예제 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $record = Documento::find($id)->delete();
     return new AjaxResponse('success', '');
 }