
Php MVC auxilioooo
Publicado por miguel (4 intervenciones) el 25/04/2014 22:37:01
Buenas un alma caritativa que me ayude a pasar esto a MVC en php Solo es una pagina pero tengo dudas de lo que va en el controlador y de que va en el Modelo
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
session_start();
$sessionID = $_SESSION['sessionID'];
$nombreusr=$_SESSION['usr_login_name'];
$idusr = $_SESSION['usr_id'];
$nro = $_SESSION['nroCompra'];
$ciUsr = $_SESSION['ci'];
$nomUsr = $_SESSION['nombreC'];
$tlfMovil = $_SESSION['telM'];
$tlfCasa = $_SESSION['telC'];
$totalF = $_SESSION['total'];
$subtotal = $_SESSION['subtotal'];
$IVA = $_SESSION['IVA'];
$email = $_SESSION['email'];
$orderId =$_SESSION['nroCompra'];
$loginID=$_SESSION['login_id'];
$clientID=$_SESSION['idCliente'];
$phone_number_cell =$_SESSION['telM'];
$iddir=$_SESSION['iddir'];
$idsurc=$_SESSION['idsur'];
$numerotarjetac = "";
$ERR=0;
$ERROR="";
include('../../../colocarHttps.php');
include('../../../enviaSMS.php');
if ($nombreusr == '')
{
$err = 'Error de Acceso!, no se a iniciado aun su session!';
echo "<SCRIPT language='Javascript' type='text/javascript'> document.location.href='../../../compras-online.php?err=$err';</script>";
}
if ($_POST['enviar'] == "PAGAR")
{
if ($_POST['n_extra']==2) // tarjeta
{
// en caso de ser tarjeta de credito entra por aca
if ($_POST['tipoT'] !="" )
{
$autorizerId = $_POST['tipoT'] ;
}
else
{
$mostrarError = " No ha seleccionado el tipo de Tarjeta de Credito. ";
$ERR=1;
}
if($_POST['mes'] != "0" && $_POST['annio'] != "0" )
{
$mes = $_POST['mes'] ;
$aniu= $_POST['annio'] ;
$c_exp_date = $mes . $aniu;
}
else
{
$mostrarError = $mostrarError . " No ha seleccionado mes y año en Fecha de Vencimiento de su Tarjeta de Credito. ";
$ERR=1;
}
if ($_POST['numerotarjetac'] !="" )
{
$c_number = $_POST['numerotarjetac'] ;
}
else
{
$mostrarError = $mostrarError . "No ha ingresado su Numero de Tarjeta de Credito. ";
$ERR=1;
}
if ($_POST['clavetar'] !="" )
{
$c_seg_code= $_POST['clavetar'] ;
}
else
{
$mostrarError = $mostrarError . "No ha ingresado su Código de Seguridad de Tarjeta de Credito.";
$ERR=1;
}
if ($_POST['ciUsr'] !="" )
{
$id_doc= $_POST['ciUsr'] ;
}
else
{
$mostrarError = $mostrarError . "No ha ingresado su cedula de Tarjetahabiente es incorrecta";
$ERR=1;
}
if ($_POST['nomUsr'] !="" )
{
$c_label= $_POST['nomUsr'] ;
}
else
{
$mostrarError = $mostrarError . "No ha ingresado su Nombre Tarjetahabiente.";
$ERR=1;
}
if($_POST['tlfCasa'] !="")
{
$tlf = $_POST['tlfCasa'] ;
}
else
{
$ERR = 1;
}
if ($ERR== 0)
{
// proceso de pago empieza aca
require("../../../db_conection.php");
$queryConfig = "SELECT mercanthId as Id, merchantKey as Keyb FROM t_orion_ext_bank_config where idclient = 1;";
$resultConfig = mysql_query($queryConfig);
$rowConfig= mysql_fetch_array( $resultConfig );
$merchantId = $rowConfig['Id'] ;
$merchantKey = $rowConfig['Keyb'] ;
if ($_POST['amount'] > 0 ) $amount = $_POST['amount'] ;
else $amount = $_SESSION['total'];
if($_POST['subtotal'] > 0 ) $subtotal = $_POST['subtotal'] ;
else $subtotal =$_SESSION['subtotal'];
if($_POST['IVAG'] > 0 ) $IVAG = $_POST['IVAG'] * $subtotal;
else $IVAG =$_SESSION['IVA'] *$subtotal;
if($_POST['n_extra'] != 0) $type = $_POST['n_extra'] ;
if($_POST['ORDER'] != "") $orderId =$_POST['ORDER'];
else $orderId =$_SESSION['nroCompra'];
// se guarda en header
$queryheader = "INSERT INTO t_orion_ext_menu_sale_header ( `sub_total`, `neto`,`iva`, `total`, `fecha_apertura`, `type_pay`, `n_orden`,`id_client_adress`, `id_sucursal`,`id_cliente`,`id_login`,`carritoSession`) VALUES ($subtotal,$subtotal,$IVAG,$amount, NOW() ,$type,'$orderId',$iddir,$idsurc,$clientID,$loginID,'$sessionID');";
$resultheader = mysql_query($queryheader);
$merchantUSN=mysql_insert_id();
// se actualiza la orden en carrito
$datos_post = array("merchantId" => $merchantId , "merchantKey" => $merchantKey ,"merchantUSN" => $merchantUSN , "amount" => "$amount", "orderId" => $orderId , "authorizerId" => $autorizerId, "c_exp_date"=>$c_exp_date , "c_number"=>$c_number , "c_seg_code"=> $c_seg_code,"id_doc"=>$id_doc,"c_label"=>$c_label,"name_user"=>$nombreusr,"email_user"=>$email,"phone_number"=>$phone_number_cell,"phone_number_cell"=>$phone_number_cell);
$datos_post = json_encode($datos_post);
// $mostrarError =$datos_post ;
// se crean las opciones que van a ir en el contenido hacie el http
$opciones = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => 'json=' .$datos_post
)
);
// se crea un contexto de opciones
$contexto = stream_context_create($opciones);
// se recibe y se escribe el contexto en la url
try {
// se ubica el recurso en la red
$resultado = @file_get_contents('https://www.elcineexpress.com:8443/OrionCore/orion/ext/HttpOrionPayCreditCartCommit', false, $contexto);
if ($resultado == false)
{
// SI FALLA POR ACA
$ERROR = "Disculpe en estos momentos el Servicio se encuentra inaccesible...<br> Intentelo mas tarde por el menu de mis compras. ";
$SESSION['sessionID'] = "";
$SESSION['sessionID'] = SessionIDRandomString (50);
$SESSION['sessionID'] = "";
throw new Exception($ERROR);
}
else
{
// SI PROCESO POR ACA
$ERROR = "";
$SESSION['sessionID'] = "";
$SESSION['sessionID'] = SessionIDRandomString (50);
$SESSION['sessionID'] = "";
echo "<script language='javascript' type='text/javascript'> document.location.href='ventana.php?ERR=$ERROR'; </script>";
}
}
catch (Exception $e)
{
// SE LANZA EL ERROR POR ACA
// se actualiza la orden a 0 por que fallo el webserver
$updatequeryheader = " update t_orion_ext_menu_sale_header set status_process = 0 where n_orden = '$orderId';";
$resultUpdateHeader = mysql_query($updatequeryheader);
//
$ERROR = $e->getMessage();
$SESSION['sessionID'] = "";
$SESSION['sessionID'] = SessionIDRandomString (50);
$SESSION['sessionID'] = "";
echo "<script language='javascript' type='text/javascript'> document.location.href='ventana.php?ERR=$ERROR'; </script>";
}
echo "<script language='javascript' type='text/javascript'> document.location.href='ventana.php?ERR=$ERROR'; </script>";
}
}
}
else
{
if ($_POST['enviar'] == "PROCESAR COMPRA"){
if($_POST['n_extra']==1)
{
// pago en efectivo
$orderId =$_SESSION['nroCompra'];
if ($_POST['amount'] > 0 ) $amount = $_POST['amount'] ;
else $amount = $_SESSION['total'];
if($_POST['subtotal'] > 0 ) $subtotal = $_POST['subtotal'] ;
else $subtotal =$_SESSION['subtotal'];
if($_POST['IVAG'] > 0 ) $IVAG = $_POST['IVAG'] * $subtotal;
else $IVAG =$_SESSION['IVA'] *$subtotal;
if($_POST['n_extra'] != 0) $type = $_POST['n_extra'] ;
$queryheader = "INSERT INTO t_orion_ext_menu_sale_header ( `sub_total`, `neto`,`iva`, `total`, `fecha_apertura`, `type_pay`, `n_orden`, `id_client_adress`, `id_sucursal`,`status_process`,`id_cliente`,`id_login`,`carritoSession`) VALUES ($subtotal,$subtotal,$IVAG,$amount, NOW() ,$type,'$orderId',$iddir,$idsurc,1,$clientID,$loginID,'$sessionID');";
$resultConfig = mysql_query($queryheader);
$mostrarError =$datos_post ;
$resultado = enviarPagoEfectivo ($orderId, $nombreusr, $idusr , $phone_number_cell);
$msg = "";
$SESSION['sessionID'] = "";
$SESSION['sessionID'] = SessionIDRandomString (50);
$SESSION['sessionID'] = "";
echo "<script language='javascript' type='text/javascript'> document.location.href='ventana.php?MSG=$msg'; </script>";
}
}}
Valora esta pregunta


0