* Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file cfdixml/cfdixmlindex.php * \ingroup cfdixml * \brief Home page of cfdixml top menu */ // print_r($_POST);exit; // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; } // Try main.inc.php using relative path if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; dol_include_once('/cfdixml/lib/cfdixml.lib.php'); // dol_include_once('/cfdixml/lib/form.lib.php'); dol_include_once('/cfdixml/class/cfdiutils.class.php'); dol_include_once('/cfdixml/class/facturalo.class.php'); // Load translation files required by the page $langs->loadLangs(array("cfdixml@cfdixml")); $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); // $hookmanager->initHooks(array('cfdixmlpaymentcard', 'globalcard')); $invoice = new Facture($db); $payment = new Paiement($db); $societe = new Societe($db); $extrafields = new ExtraFields($db); $formfile = new FormFile($db); $payment->fetch($id); $payment->fetch_optionals(); // Validate if Inivoice have PUE and reject $sql = 'SELECT f.rowid as facid'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf,' . MAIN_DB_PREFIX . 'facture as f,' . MAIN_DB_PREFIX . 'societe as s'; $sql .= ' WHERE pf.fk_facture = f.rowid'; $sql .= ' AND f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN (' . getEntity('invoice') . ')'; $sql .= ' AND pf.fk_paiement = ' . ((int) $payment->id); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); $invoice->fetch($obj->facid); $extrafields->fetch_name_optionals_label($invoice->table_element); $societe->fetch($invoice->socid); // echo '
';print_r($invoice);exit;
            if ($invoice->array_options['options_cfdixml_metodopago'] == 'PUE') {
                setEventMessage('No se puede timbrar un pago de una factura PUE o la/s factura/s no está/n timbrada/s', 'errors');
                header('Location:' . DOL_MAIN_URL_ROOT . '/compta/paiement/card.php?id=' . $payment->id);
                exit;
            }
            $i++;
        }
    }
}

//Action

if ($action == 'stamp') {


    if ($payment->array_options['options_cfdixml_UUID']) {
        setEventMessage('El pago ya está timbrado', 'errors');
        header('Location:' . $_SERVER['PHP_SELF'] . '?id=' . $payment->id);
        exit;
    }


    if (empty($payment->array_options['options_cfdixml_control'])) {
		$sql = "SELECT datec from " . MAIN_DB_PREFIX . "paiement WHERE rowid = ". $object->id;
		$resql = $db->query($sql);
		$fecha_pago = "";
		if($resql) {
			$obj = $db->fetch_object($resql);
			$fecha_pago =$obj->datec;
		}

        $comprobanteAtributos["Fecha"] = str_replace(" ", "T", $fecha_pago);  // genera con hora local
		;
			//date("Y-m-d") . "T" . date("H:i:s");
        $sql = "INSERT INTO " . MAIN_DB_PREFIX . "paiement_extrafields ";
        $sql .= " (fk_object,cfdixml_control) VALUES (" . $id . ",'" . date('Y-m-d') . 'T' . date('H:i:s') . "')";
        $result = $db->query($sql);
    } else {
        $comprobanteAtributos["Fecha"] = $payment->array_options['options_cfdixml_control'];
    }

    $comprobanteAtributos["Moneda"]               = "XXX";
    $comprobanteAtributos["SubTotal"]             = 0;
    $comprobanteAtributos["Total"]                = 0;
    $comprobanteAtributos["TipoDeComprobante"]    = "P";
    $comprobanteAtributos["LugarExpedicion"]      = $conf->global->MAIN_INFO_SOCIETE_ZIP;
    $comprobanteAtributos["Version"]              = "4.0";
    $comprobanteAtributos["Exportacion"]          = "01";

    $receptor = getReceptor($invoice, $societe);
    $receptor['UsoCFDI'] = 'CP01'; //TODO: Make dynamic

    $cfdiutils = new CfdiUtils();
    // echo '
';print_r(getPayments($payment));exit;
    $xml = $cfdiutils->preCfdi(
        $comprobanteAtributos,
        getEmisor(),
        $receptor,
        'concepto',
        getPayments($payment),
        $conf->global->CFDIXML_CER_FILE,
        $conf->global->CFDIXML_KEY_FILE,
        $conf->global->CFDIXML_CERKEY_PASS
    );
    // echo '
';print_r($xml);exit;

    if (!file_exists($conf->cfdixml->multidir_output[$invoice->entity] . '/payment/' . dol_sanitizeFileName($payment->ref) . "/" . $payment->ref . ".xml")) {
        mkdir($conf->cfdixml->multidir_output[$invoice->entity] . '/payment/' . dol_sanitizeFileName($payment->ref), 0755, true);
    }
    $filedir = $conf->cfdixml->multidir_output[$invoice->entity] . '/payment/' . dol_sanitizeFileName($payment->ref);

    $file_xml = fopen($filedir . "/" . $payment->ref . ".xml", "w");
    fwrite($file_xml, utf8_encode($xml));
    fclose($file_xml);


    /* Finkok */
    $cfdi = $cfdiutils->quickStamp($xml, $conf->global->CFDIXML_WS_TOKEN, $conf->global->CFDIXML_WS_MODE);

    //FINKOK
    if ($cfdi['code'] == '400') setEventMessage($cfdi['data'], 'errors');
    if ($cfdi['code'] == '400') header('Location:' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id);
    if ($cfdi['code'] == '200' || $cfdi['code'] == '307') goto saveXML;
    if ($cfdi['code'] != '200') {

        setEventMessage($cfdi['code'] . ' - ' . $cfdi['message'], 'errors');
        header('Location:' . $_SERVER['PHP_SELF'] . '?id=' . $payment->id);
        $invoice->array_options['options_cfdixml_control'] = '';
        $invoice->update($user, 1);
    }
    exit;
    saveXML:
    $data = $cfdiutils->getData($cfdi['data']);


    /* Facturalo */

    // if ($conf->global->CFDIXML_WS_MODE == 'TEST') $url = $conf->global->CFDIXML_WS_TEST;
    // if ($conf->global->CFDIXML_WS_MODE == 'PRODUCTION') $url = $conf->global->CFDIXML_WS_PRODUCTION;

    // $conexion = new Conexion($url);
    // $cfdi = $conexion->operacion_timbrar3($conf->global->CFDIXML_WS_TOKEN, $xml);
    // if ($cfdi['code'] == '307') goto saveXML;
    // if ($cfdi['code'] != '200') {

    //     setEventMessage($cfdi['mensaje'], 'errors');
    //     header('Location:' . $_SERVER['PHP_SELF'] . '?id=' . $payment->id);
    //     exit;
    // }


    $sql = "UPDATE " . MAIN_DB_PREFIX . "paiement_extrafields SET ";
    $sql .= "cfdixml_UUID = '" . $data['UUID'] . "',";
    $sql .= "cfdixml_fechatimbrado = '" . $data['FechaTimbrado'] . "',";
    $sql .= "cfdixml_sellosat ='" . $data['SelloSAT'] . "',";
    $sql .= "cfdixml_certsat = '" . $data['CertSAT'] . "',";
    $sql .= "cfdixml_sellocfd ='" . $data['SelloCFD'] . "',";
    $sql .= "cfdixml_certcfd ='" . $data['CertCFD'] . "',";
    $sql .= "cfdixml_cadenaorig ='" . $data['CadenaOriginal'] . "',";
    $sql .= "cfdixml_xml ='" . base64_encode($cfdi['data']) . "',";
    $sql .= "cfdixml_control = ''";
    $sql .= " WHERE fk_object = " . $id;

    $result = $db->query($sql);

    $filedir = $conf->cfdixml->multidir_output[$invoice->entity] . '/payment/' . dol_sanitizeFileName($payment->ref);

    $file_xml = fopen($filedir . "/" . $payment->ref . '_' . $data['UUID'] . ".xml", "w");
    fwrite($file_xml, mb_convert_encoding($cfdi['data'], 'utf8'));
    fclose($file_xml);
    $invoice->generateDocument('cfdixml', $langs, false, false);

    setEventMessage('Factura timbrada con éxito UUID:' . $data['UUID'], 'mesgs');
    header('Location:' . $_SERVER['PHP_SELF'] . '?id=' . $payment->id);
    exit;
}
if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') {
    //echo '
';print_r($_GET);exit;

    //Finkok
    $cfdiutils = null;
    $cfdiutils = new CfdiUtils();
    try {
        $result = $cfdiutils->CancelDocument(
            $payment->array_options['options_cfdixml_UUID'],
            GETPOST('motivo'),
            $conf->global->CFDIXML_WS_MODE,
            $conf->global->CFDIXML_CER_FILE,
            $conf->global->CFDIXML_KEY_FILE,
            $conf->global->CFDIXML_CERKEY_PASS,
            $conf->global->CFDIXML_WS_TOKEN
        );


        //Finkok
        // echo '
';print_r($result->voucher());echo '
'; // echo '
';print_r($result->date());echo '
'; // echo '
';print_r($result->statusCode());echo '
'; // exit; $xmlcanceled = $result->voucher(); $filedir = $conf->cfdixml->multidir_output[$invoice->entity] . '/payment/' . dol_sanitizeFileName($payment->ref); //Finkok $file_xml = fopen($filedir . "/ACUSE_CANCELACION_" . $payment->ref . '_' . $payment->array_options['options_cfdixml_UUID'] . ".xml", "w"); fwrite($file_xml, mb_convert_encoding($xmlcanceled,'UTF8')); fclose($file_xml); // //Provisional FIX $sql = "UPDATE " . MAIN_DB_PREFIX . "paiement_extrafields "; $sql .= " SET cfdixml_fechacancelacion = '" . $result->date() . "'"; $result->statusCode() ? $sql .= ", cfdixml_codigocancelacion = '" . $result->statusCode() . "'" : null; $sql .= ", cfdixml_xml_cancelacion = \"" . base64_encode($xmlcanceled) . "\""; $sql .= " WHERE fk_object = " . $payment->id; $result = $db->query($sql); $db->commit(); // Not update correct invoice, update $object ¿why? // $invoicetocancel->array_options['options_cfdixml_fechacancelacion'] = $result->date(); // $invoicetocancel->array_options['options_cfdixml_codigoncelacion'] = $result->statusCode(); // $invoicetocancel->array_options['options_cfdixml_xml_cancel'] = $xmlcanceled; // $result = $invoicetocancel->update($user, 1); } catch (Exception $e) { dol_syslog("Exception Cancel Invoice: " . $e); } } if ($action == 'builddoc') { $invoice->generateDocument('cfdixml', $langs, false, false); } //View $form = new Form($db); llxHeader('', $langs->trans("REP")); $head = payment_prepare_head($payment); print dol_get_fiche_head($head, 'pagocfdi', $langs->trans('SupplierPayment'), -1, 'payment'); $linkback = '' . $langs->trans("BackToList") . ''; dol_banner_tab($payment, 'ref', $linkback, 1, 'ref', 'ref', ''); // print '

Pestaña Obsoleta

'; // print '

Dirijase al menú CFDIXML - Pagos para registrar un nuevo complemento de pago

'; print '
'; print '
'; print '
'; print ''; //Versión Pago print ''; print ''; //TODO make dynamic print ''; //Versión Pago print ''; print $payment->array_options['options_cfdixml_UUID'] ? '' : ''; //TODO make dynamic print ''; //Fecha pago print ''; print ''; print ''; print ''; //Uso del CFDI print ''; print ''; print ''; print ''; //Bank Account $bankline = new AccountLine($db); if ($payment->fk_account > 0) { $bankline->fetch($payment->bank_line); if ($bankline->rappro) { $disable_delete = 1; $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); } print ''; print ''; print ''; print ''; } //Accoutancy Register print ''; print ''; print ''; print ''; print '
Complemento de pago Versión 2.0
EstadoTimbradoEstado Sin timbrar
Fecha del Pago' . dol_print_date($payment->date, '%d/%m/%Y %H:%m') . '
Uso del CFDI'; print $payment->array_options['options_cfdixml_usocfdi'] ? $payment->array_options['options_cfdixml_usocfdi'] : 'P01 - Por Definir'; print '
' . $langs->trans('BankAccount') . ''; $accountstatic = new Account($db); $accountstatic->fetch($bankline->fk_account); print $accountstatic->getNomUrl(1); print '
' . $langs->trans('BankTransactionLine') . ''; if ($payment->fk_account > 0) { // var_dump($bankline); print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted'); } print '
'; print '
'; //Amount print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; //Paymnent Method print ''; print ''; print ''; print ''; //Operation Number print ''; print ''; print ''; print ''; //Currency print ''; print ''; print ''; print ''; //Multicurrency Exchange print ''; print ''; print ''; print ''; print ''; //File CEP print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
Total Pago'; // echo '
';print_r($payment);exit;
print price($payment->amount, '', $langs, 0, -1, -1, $conf->currency);
print '
Método de pago'; // echo '
';print_r($payment);exit;
print $payment->type_label;
print '
Número de Operación'; // echo '
';print_r($payment);exit;
print $payment->num_payment;
print '
Moneda'; echo $conf->currency; print '
Tipo de Cambio'; print 'N/D'; // echo $conf->currency; print '
Complemento Electrónico de Pago
'; print ''; print ''; print ''; print '
'; print '
'; print '
'; print '
'; if ($payment->array_options['options_cfdixml_UUID']) { print '
'; print ''; print ''; print ''; print ''; print ''; // print ''; print ''; // print ''; // print ''; print '
CFDI Recibo de Pago
UUID' . $payment->array_options['options_cfdixml_UUID'] . '
Fecha de timbrado' . $payment->array_options['options_cfdixml_fechatimbrado'] . '
Certificado SAT' . $payment->array_options['options_cfdixml_certsat'] . '
Sello SAT'.$payment->array_options['options_cfdixml_sellosat'].'
Certificado CFD' . $payment->array_options['options_cfdixml_certcfd'] . '
Sello CFD'.$payment->array_options['options_cfdixml_sellocfd'].'
Cadena Original'.$payment->array_options['options_cfdixml_cadenaorig'].'
'; print '
'; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
Detalles Complemento Electrónico de Pago
EmisorReceptor
RFC BancoRFC Banco
Num Cta BancoNum Cta Banco
Cadena de Pago
Certificado del pago
Cadena original del pago
Sello del pago
'; print '
'; print '

'; print '
'; print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; //Print invoices // Validate if Inivoice have PUE and reject // $sql = 'SELECT f.rowid as facid'; // $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf,' . MAIN_DB_PREFIX . 'facture as f,' . MAIN_DB_PREFIX . 'societe as s'; // $sql .= ' WHERE pf.fk_facture = f.rowid'; // $sql .= ' AND f.fk_soc = s.rowid'; // $sql .= ' AND f.entity IN (' . getEntity('invoice') . ')'; // $sql .= ' AND pf.fk_paiement = ' . ((int) $payment->id); // $resql = null; // $resql = $db->query($sql); // if ($resql) { // $num = $db->num_rows($resql); // if ($num > 0) { // $i = 0; // while ($i < $num) { // print ''; // $obj = $db->fetch_object($resql); // $invoice->fetch($obj->facid); // //factura // print ''; // // total factura // print ''; // $sql = "SELECT count(*) as nb from " . MAIN_DB_PREFIX . "paiement_facture where fk_facture = " . $obj->facid; // $sql .= " AND fk_paiement <> " . $id; // $resqlpay = $db->query($sql); // if ($resqlpay) { // $objtotalpay = $db->fetch_object($resqlpay); // if ($objtotalpay->nb > 0) { // //TODO: verify if all payments before this have's UUID // } else { // $sql = "SELECT amount from " . MAIN_DB_PREFIX . "paiement_facture where fk_facture = " . $obj->facid; // $sql .= " AND fk_paiement = " . $id; // $resqlp = $db->query($sql); // if ($resqlp) { // $objpay = $db->fetch_object($resqlp); // //Saldo Anterior // print ''; // //Total Pagado // $totalpay = $objpay->amount + ($objpay->amount - $invoice->total_ttc); // print ''; // //Saldo insoluto // $restopay = $invoice->total_ttc - $totalpay; // print ''; // $i++; // } // } // } //New Solution for multiple invoices // Validate if Invoice have PUE and reject $sql = 'SELECT f.rowid as facid'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf,' . MAIN_DB_PREFIX . 'facture as f,' . MAIN_DB_PREFIX . 'societe as s'; $sql .= ' WHERE pf.fk_facture = f.rowid'; $sql .= ' AND f.fk_soc = s.rowid'; $sql .= ' AND f.entity IN (' . getEntity('invoice') . ')'; $sql .= ' AND pf.fk_paiement = ' . ((int) $payment->id); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { $i = 0; while ($i < $num) { print ''; $obj = $db->fetch_object($resql); $invoice->fetch($obj->facid); // Factura print ''; // Total factura print ''; // Obtener todos los pagos anteriores para esta factura $sql = "SELECT SUM(pf.amount) as total_paid FROM " . MAIN_DB_PREFIX . "paiement_facture as pf LEFT JOIN " . MAIN_DB_PREFIX . "paiement as p ON pf.fk_paiement = p.rowid WHERE pf.fk_facture = " . $obj->facid . " AND pf.fk_paiement < " . $id; $resqlprevpay = $db->query($sql); $total_paid_prev = 0; if ($resqlprevpay && ($row = $db->fetch_object($resqlprevpay))) { $total_paid_prev = $row->total_paid ?: 0; } // Obtener el monto del pago actual $sql = "SELECT amount FROM " . MAIN_DB_PREFIX . "paiement_facture WHERE fk_facture = " . $obj->facid . " AND fk_paiement = " . $id; $resqlcurrpay = $db->query($sql); $current_payment = 0; if ($resqlcurrpay && ($row = $db->fetch_object($resqlcurrpay))) { $current_payment = $row->amount; } // Cálculos $saldo_anterior = $invoice->total_ttc - $total_paid_prev; $total_paid = $total_paid_prev + $current_payment; $saldo_insoluto = $invoice->total_ttc - $total_paid; // Saldo Anterior print ''; // Total Pagado print ''; // Parcialidad print ''; // Saldo insoluto print ''; print ''; $i++; } } } print ''; print '
FacturaTotal facturaSaldo anteriorMonto pagoParcialidadSaldo insoluto
' . $invoice->getNomUrl(1) . '' . price($invoice->total_ttc, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '' . price($invoice->total_ttc, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '' . price($totalpay, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '
'; // //Parcialidad // //Make dynamic // print '
'; // if (empty($payment->array_options['options_cfdixml_UUID'])) { // print getPaymentNum($invoice); // } else { // $filename = dol_sanitizeFileName($payment->ref); // $filedir = $conf->cfdixml->multidir_output[$conf->entity] . '/payment/' . dol_sanitizeFileName($payment->ref); // if (file_exists($filedir . '/' . $filename . '_' . $payment->array_options['options_cfdixml_UUID'] . '.xml')) { // $data = file_get_contents($filedir . '/' . $filename . '_' . $payment->array_options['options_cfdixml_UUID'] . '.xml'); // print getPaymentNum($invoice, $data); // } // //'_'. $data->UUID .".xml" // } // print '' . price($restopay, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '
'; // } // } // } // print '
' . $invoice->getNomUrl(1) . '' . price($invoice->total_ttc, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '' . price($saldo_anterior, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '' . price($total_paid, 2, '', 1, 2, -1, $invoice->multicurrency_code) . ''; $payment_num = getPaymentsNum($invoice, $total_paid_prev); print $payment_num; print '' . price($saldo_insoluto, 2, '', 1, 2, -1, $invoice->multicurrency_code) . '
'; //Action Buttons if($action == 'cancel'){ $cancelacion = getDictionaryValues('cancelacion'); $formquestion = [ 'text' => '

Cancelar fiscalmente el pago ' . $payment->ref . '

', ['type' => 'select', 'name' => 'motivo', 'id' => 'motivo', 'label' => 'Motivo', 'values' => $cancelacion] ]; $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $payment->id, $langs->trans('cancel'), '', 'confirm_cancel', $formquestion, 0, 1, 310, 500); print $formconfirm; echo ''; } if ($action == 'presend') { $modelmail = ''; $defaulttopic = 'Enviar correo'; //$diroutput = $conf->cfdixml->multidir_output[$invoice->entity] . '/payment/' . dol_sanitizeFileName($payment->ref).'/'; //$diroutput = $conf->cfdixml->dir_output."/test/"; //$trackid = 'email_payment'.$id; //$trackid = $payment->id; $object = $payment; print '
'; dol_include_once('/cfdixml/tpl/other_card_presend.tpl.php'); print '
'; } else { print '
'; if(!empty($payment->array_options['options_cfdixml_UUID'])){ if(empty($payment->array_options['options_cfdixml_fechacancelacion'])) print 'Cancelar Pago'; } // print $payment->array_options['options_cfdixml_UUID'] ? : ''; print $payment->array_options['options_cfdixml_UUID'] ? 'Regenerar PDF' : ''; print $payment->array_options['options_cfdixml_UUID'] ? 'Enviar email' : 'Timbrar CFDI'; print '
'; print '
'; print ''; print ''; // Generated documents // echo'
';print_r($payment);exit;
	//Solución temporal
	$filename = 'payment/' . dol_sanitizeFileName($payment->ref);
	$filedir = $conf->cfdixml->multidir_output[$conf->entity] . '/payment/' . dol_sanitizeFileName($payment->ref);
	// $sql =" UPDATE ".MAIN_DB_PREFIX."ecm_files SET share = '". base64_encode($payment->ref.".xml"). "' WHERE filename = '". $payment->ref."_".$payment->array_options['options_cfdixml_UUID'].".xml';";
	// echo $sql;
	// $resql = $db->query($sql);
	// $sql = " UPDATE " . MAIN_DB_PREFIX . "ecm_files SET share = '" . base64_encode($payment->ref . ".pdf") . "' WHERE filename = '" . $payment->ref . "_" . $payment->array_options['options_cfdixml_UUID'] . ".pdf';";
	// 	$urlsource = $_SERVER['PHP_SELF'].'?id='.$payment->id;
	// $resql = $db->query($sql);

	print $formfile->showdocuments(
		'cfdixml',
		$filename,
		$filedir,
		$urlsource,
		$genallowed,
		$delallowed,
		$payment->model_pdf,
		1,
		0,
		0,
		28,
		0,
		'',
		'',
		'',
		$soc->default_lang,
		'',
		$payment,
		0,
		'remove_file_comfirm'
	);

    // $filename = dol_sanitizeFileName($payment->ref);
    // $filedir = $conf->cfdixml->multidir_output[$conf->entity] . '/payment/' . dol_sanitizeFileName($payment->ref);
    // $files = scandir($filedir);
    // foreach ($files as $file) {

    //     if ($file === '.' || $file === '..') {
    //     } else {

    //         print '
'; // print ''; // print ''; // } // } //TODO: Foreach documents print '
Documentos
' . $file . '
'; print '
'; } print '
'; print '
'; // End of page llxFooter(); $db->close();