1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
| <?php
fortiz@lacorona.com.mx
function satxarre($nufa) {
require_once("dbi/clfactur.class.php");
require_once("dbi/clflinea.class.php");
require_once("dbi/clcadena.class.php");
require_once("dbi/clclient.class.php");
require_once("lib/cn_envio_bodega.php");
require_once("lib/cn_envio_export.php");
require_once("lib/getrefe.php");
global $conn;
error_reporting(E_ALL);
$fact = new Clfactur($conn,$nufa);
$clie = new Clclient($conn,(int)$fact->row['factnucl'],'renglon');
$cade = new Clcadena($conn,(int)$clie->row['clienuca'],'renglon');
$arr = array();
$arr['folio'] = substr($nufa,4);
$arr['fecha'] = str_replace(array('-',' ',':'),'',$fact->row["factfdoc"]);
$arr['serie'] = substr($nufa,0,4);
require "satxfoli.inc.php";
$arr['subTotal'] = $fact->row["factneto"]+$fact->row['factnet2'];
$arr['total'] = $fact->row["factimto"];
$arr['metodoDePago'] = "";
if ( cn_envio_bodega($fact->row["factnucl"]) &&
!cn_envio_export($fact->row["factnucl"])) {
$arr['tipoDeComprobante'] = "traslado";
$orig = trim($conn->GetOne("Select bodenomb from clbodega WHERE bodenubo = ".$fact->row["factnubo"]));
$dest = trim($conn->GetOne("Select bodenomb from clbodega WHERE bodenucl = ".$fact->row["factnucl"]));
$arr['formaDePago'] = "ESTE COMPROBANTE SE EXPIDE PARA TRANSPORTAR MERCANCIAS DE NUESTRA PROPIEDAD DE BODEGA $orig A BODEGA $dest";
} else {
$arr['tipoDeComprobante'] = "ingreso";
$arr['formaDePago'] = "EL PAGO DE ESTA FACTURA (CONTRAPRESTACION) SE EFECTUARA EN UNA SOLA EXHIBICION, SI POR ALGUNA RAZON NO FUERA ASI, EMITIREMOS LOS COMPROBANTES DE LAS PARCIALIDADES RESPECTIVAS";
}
$arr['Emisor']['nombre'] = "FABRICA DE JABON, LA CORONA, S.A. DE C.V.";
$arr['Emisor']['rfc'] = "FJC780315E91";
$arr['Emisor']['ExpedidoEn']['calle'] = $fact->row["factedir"];
$arr['Emisor']['ExpedidoEn']['noExterior'] = $fact->row["facteext"];
$arr['Emisor']['ExpedidoEn']['noInterior'] = $fact->row["facteint"];
$arr['Emisor']['ExpedidoEn']['localidad'] = substr($fact->row["factepob"],6);
$arr['Emisor']['ExpedidoEn']['municipio'] = substr($fact->row["factepob"],6);
$arr['Emisor']['ExpedidoEn']['estado'] = get_estado($fact->row["factepob"]);
$arr['Emisor']['ExpedidoEn']['pais'] = "MEXICO";
$arr['Emisor']['ExpedidoEn']['codigoPostal'] = substr($fact->row["factepob"],0,5);
$arr['Receptor']['nombre'] = $fact->row["factnopr"];
$arr['Receptor']['rfc'] = $fact->row["factrfca"];
if (strlen(trim($cade->row['cadecall']))) {
$a_edo = $cade->row["cadecoes"];
$a_calle = $cade->row["cadecall"];
$a_noExterior = $cade->row["cadenext"];
$a_noInterior = $cade->row["cadenint"];
$a_colonia = $cade->row["cadecolo"];
$a_localidad = $cade->getPueb("cadecoes","cademuni","cadepobl");
$a_municipio = $cade->getMuni("cadecoes","cademuni");
$a_codigoPostal = $cade->row["cadecodp"];
} else {
$a_edo = $fact->row["factedoe"];
$a_calle = $fact->row["factcdir"];
$a_noExterior = $fact->row["factnext"];
$a_noInterior = $fact->row["factnint"];
$a_colonia = $fact->row["factccol"];
$a_localidad = $fact->row["factnpue"];
$a_municipio = $fact->row["factnpue"];
$a_codigoPostal = $fact->row["factcodp"];
}
$edo = trim(getrefe("cte",6,"CLIECOES",$a_edo));
$pais = ($a_edo>40) ? $edo : "MEXICO";
$arr['Receptor']['Domicilio']['calle'] = $a_calle;
$arr['Receptor']['Domicilio']['noExterior'] = $a_noExterior;
$arr['Receptor']['Domicilio']['noInterior'] = $a_noInterior;
$arr['Receptor']['Domicilio']['colonia'] = $a_colonia;
$arr['Receptor']['Domicilio']['localidad'] = $a_localidad;
$arr['Receptor']['Domicilio']['municipio'] = $a_municipio;
$arr['Receptor']['Domicilio']['estado'] = $edo;
$arr['Receptor']['Domicilio']['pais'] = $pais;
$arr['Receptor']['Domicilio']['codigoPostal'] = $a_codigoPostal;
$fali = new Clflinea($conn, $nufa);
for ($i=0; $i<sizeof($fali->faliprod); $i++) {
$unid = $fali->faliunif[$i];
$impo = $fali->falineto[$i];
$arr['Conceptos'][$i+1]['descripcion'] = $fali->falideco[$i];
$arr['Conceptos'][$i+1]['cantidad'] = $unid;
$arr['Conceptos'][$i+1]['valorUnitario'] = round((double)$impo / (double)$unid,2);
$arr['Conceptos'][$i+1]['importe'] = $impo;
}
$arr['Traslados']['impuesto'] = "IVA";
$arr['Traslados']['tasa'] = $fact->row["factpoim"];
$arr['Traslados']['importe'] = $fact->row["factimpu"];
return($arr);
}
function get_estado($esta) {
$coes="XX";
if (stristr($esta,"AGUAS")) $coes="AGUASCALIENTES";
if (stristr($esta,"MEXICALI")) $coes="BAJA CALIFORNIA";
if (stristr($esta,"B.C.S.")) $coes="BAJA CALIFORNIA SUR";
if (stristr($esta,"CAMPE")) $coes="CAMPECHE";
if (stristr($esta,"TUXTLA")) $coes="CHIAPAS";
if (stristr($esta,"TAPACHULA")) $coes="CHIAPAS";
if (stristr($esta,"CHIH")) $coes="CHIHUAHUA";
if (stristr($esta,"COAH")) $coes="COAHUILA";
if (stristr($esta,"COLIMA")) $coes="COLIMA";
if (stristr($esta,"D.F.")) $coes="DISTRITO FEDERAL";
if (stristr($esta,"DURANGO")) $coes="DURANGO";
if (stristr($esta,"IRAPUATO")) $coes="GUANAJUATO";
if (stristr($esta,"ACAPULCO")) $coes="GUERRERO";
if (stristr($esta,"HIDALGO")) $coes="HIDALGO";
if (stristr($esta,"GUADALAJARA")) $coes="JALISCO";
if (stristr($esta,"XALOSTOC")) $coes="EDO. DE MEXICO";
if (stristr($esta,"MORELIA")) $coes="MICHOACAN";
if (stristr($esta,"MORELOS")) $coes="MORELOS";
if (stristr($esta,"NAYARIT")) $coes="NAYARIT";
if (stristr($esta,"GARZA")) $coes="NUEVO LEON";
if (stristr($esta,"OAX")) $coes="OAXACA";
if (stristr($esta,"PUEBLA")) $coes="PUEBLA";
if (stristr($esta,"QUERETARO")) $coes="QUERETARO";
if (stristr($esta,"QUINTANA")) $coes="QUINTANA ROO";
if (stristr($esta,"SAN LUIS")) $coes="SAN LUIS POTOSI";
if (stristr($esta,"CULIACAN")) $coes="SINALOA";
if (stristr($esta,"HERMOSILLO")) $coes="SONORA";
if (stristr($esta,"VILLAHERMOSA")) $coes="TABASCO";
if (stristr($esta,"ALTAMIRA")) $coes="TAMAULIPAS";
if (stristr($esta,"TLAXCALA")) $coes="TLAXCALA";
if (stristr($esta,"PARAJE NUEVO")) $coes="VERACRUZ";
if (stristr($esta,"UMAN")) $coes="YUCATAN";
if (stristr($esta,"ZACATECAS")) $coes="ZACATECAS";
return ($coes);
}
?> |