|
Nouveau Membre du Club
Inscription : juin 2012 Messages : 143 Détails du profil  Informations personnelles : Sexe :  Informations forums :
Inscription : juin 2012 Messages : 143 Points : 36 Points : 36
|
salut,
je veux faire une fonction une permet de retourner un montant à payer suite à l'envoi d'un numéro de prêt (loanAccount) par une requête http .
pour le moment j'ai une fonction qui prend comme paramètre un numéro de prêt (loanAccount) et retourne plusieurs information parmi elles le montant à payer
( en faite j'ai une application MASPC qui permet d'affiché des information lié à un numero de pret ,parmis ces information est le moatant à payer)
donc je veux utiliser cette fonction pour répondre à mon besoin bien sur en faisant un changement .
car cette fonction prend loanAccount comme paramètre envoyé par Post mais dans mon cas il dois être envoyé par Get
comme je dis je veux inspirer de cette fonction mais honnêtement je suis perdu pour comprendre l’enchainement et les appels à sous fonction car elle fait appel à d'autre fonction dans d'autres fichier
c'est pour cela je n'arrive pas à faire de changement .
je vous donne le code de cette fonction et les fichiers nécessaires à cette fonction
j'ai deux dossier sous www : GTW et MASPC
ces fichiers sous MASPC sont :
load_account.php
Code :
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
| <?php
@session_start();
include_once('definitions.php');
if (Def_Gateway_language == "English")
include_once('Mas_en.php');
else
include_once('Mas_fr.php');
if(isset ($_SESSION['login'])){
if($_SESSION['login'] == 1){
$_SESSION['CI'] = null;
$_SESSION['TH'] = null;
$_SESSION['PS'] = null;
//$_SESSION['DI'] = null;
$_SESSION['MP'] = null;
$_SESSION['loanAccount'] = null;
$_SESSION['NextAmountToPay'] = null;
$_SESSION['disbursment_permission'] = null;
$_SESSION['payment_permission'] = null;
$_SESSION['transaction_history'] = null;
$_SESSION['Disbursement_amount'] = null;
$_SESSION['Payment_amount'] = null;
$_SESSION['account_info'] = null;
$_SESSION['transaction_history'] = null;
$_SESSION['payment_schedule'] = null;
$_SESSION['apply_payment'] = null;
$_SESSION['disburs_loan'] = null;
$_SESSION['error'] = null;
$_SESSION['message'] = null;
$_SESSION['payAmount'] = null;
$_SESSION['Payment_receipId'] = null;
$_SESSION['client_name'] = null;
echo <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>Mobile Agent System</title>
<style>
h1 {
font: 25px bold Helvetica, Arial;
letter-spacing: -2px;
}
h2 {
font: 20px bold Helvetica, Arial;
}
h3 {
font: 14px bold Helvetica, Arial;
}
</style>
</head>
<body>
<div style="text-align: center; padding-top : 20px;">
<h1>Mobile Agent System</h1>
<h2>Loan Information</h2>
<h3><a href = missed_payments.php>
EOT;
echo Def_Missed_Payments_Title;
echo <<<EOT
</a>
<span class="options"> |</span>
<a href = index.php>
EOT;
echo Def_Logout;
echo <<<EOT
</a><h3>
</div>
<FORM method=post action="Get_values.php">
<div align="center">
<FIELDSET style="width:300px;">
<TABLE BORDER=0>
<TR>
<TD>
EOT;
echo Def_Loan_Number;
echo<<<EOT
</TD>
<TD><INPUT type=text name="loanAccount" ></TD>
</TR>
<TR>
<TD COLSPAN=2><INPUT type="submit" value="OK"></TD>
</TR>
</TABLE>
</FIELDSET>
</div>
</FORM>
EOT;
include("Footer.php");
echo <<<EOT
</body>
</html>
EOT;
}
else{ session_destroy(); include("index.php");}
}
else { session_destroy(); include("index.php");}
?> |
Get_values.php
Code :
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
| <?php
@session_start();
include_once("Request.php");
include_once("missed_payment_request.php");
include_once('definitions.php');
if (Def_Gateway_language == "English")
include_once('Mas_en.php');
else
include_once('Mas_fr.php');
function load($loanAccount, $type)
{
$Request = new Request_Gen($loanAccount);
$Request->load_account_data();
$_SESSION['CI'] = $Request->CI_tab;
$_SESSION['PS'] = $Request->PS_tab;
$_SESSION['TH'] = $Request->TH_tab;
include_once ("load_account_data.php");
if($type == 0){
$_SESSION['print'] = "payment_schedule";
header('Location: ./Mas_PC.php');
}
}
function load_missed_payments(){
$Request = new Request_MP();
$Request->get_missed_payments();
$MP_tab = $Request->MP_tab;
$_SESSION['MP']= $MP_tab;
//$MP_tab->result;
if ($Request != null){
if ($MP_tab != null) $_SESSION['message'] = $MP_tab->status;
else
$_SESSION['message'] = $MP_tab->reason;
}
else{
$_SESSION['message'] = "Def_Unexpected_Error";
}
header('Location: ./missed_payment.php');
}
function apply_payment($loanAccount, $payAmount, $receiptId){
$Request = new Request_Gen($loanAccount);
$Request->Apply_Payment($payAmount, $receiptId);
$PR_tab = $Request->PR_tab;
if ($PR_tab != null){
if ($PR_tab->status == "ok") $_SESSION['message'] = Def_Payment_Made;
else
$_SESSION['message'] = $PR_tab->reason;
}
else{
$_SESSION['message'] = Def_Unexpected_Error;
}
$_SESSION['print'] = "message";
load($loanAccount, 1);
header('Location: ./Mas_PC.php');
}
function disburs_loan($loanAccount, $receiptId){
$Request = new Request_Gen($loanAccount);
$Request->Disburs_loan($receiptId);
$DR_tab = $Request->DR_tab;
if ($DR_tab != null){
if ($DR_tab->status == "ok") $_SESSION['message'] = Def_Disbursment_Made;
else{
if ($DR_tab->reason == "baddate") $_SESSION['message'] = Def_Bad_Date;
elseif ($DR_tab->reason == "loginserverdown") $_SESSION['message'] = Def_Server_Not_Found;
else $_SESSION['message'] = $DR_tab->reason;
}
}
else{
$_SESSION['message'] = Def_Unexpected_Error;
}
$_SESSION['print'] = "message";
load($loanAccount, 1);
header('Location: ./Mas_PC.php');
}
if (isset($_POST['payAmount'])){
if (preg_match("/^([0-9]{1,7}?)(\.?)([0-9]{0,3}?)$/", $_POST['payAmount'])){
if (isset($_POST['Payment_receipId'])){
apply_payment($_SESSION['loanAccount'], $_POST['payAmount'], $_POST['Payment_receipId']);
$_SESSION['payAmount'] = $_POST['payAmount'];
$_SESSION['Payment_receipId'] = $_POST['Payment_receipId'];
}
else {
apply_payment($_SESSION['loanAccount'], $_POST['payAmount'], null);
$_SESSION['payAmount'] = $_POST['payAmount'];
$_SESSION['Payment_receipId'] = "";
}
}
else {
$_SESSION['print'] = "message";
$_SESSION['message'] = Def_Bad_Amount_Format;
header('Location: ./Mas_PC.php');
}
}
elseif (isset($_POST['disbursAmount'])){
if (isset($_POST['disbursreciepId'])){
disburs_loan($_SESSION['loanAccount'], $_POST['disbursreciepId']);
}
else {
disburs_loan($_SESSION['loanAccount'], null);
}
}
elseif (isset ($_SESSION['loanAccount']) && !isset($_POST['loanAccount'])){
load($_SESSION['loanAccount'], 0);
}
elseif (isset($_SESSION['missed_payments']) && !isset($_POST['loanAccount'])) {
load_missed_payments();
}
elseif (isset ($_GET['LoanAccount'])){
if (preg_match("/^[0-9]{15}$/", $_GET['LoanAccount'])){
load($_GET['LoanAccount'], 0);
}
}
elseif (isset($_POST['loanAccount'])){
if (preg_match("/^[0-9]{15}$/", $_POST['loanAccount'])){
$_SESSION['loanAccount'] = $_POST['loanAccount'];
load($_POST['loanAccount'], 0);
}
else {
$_SESSION['print'] = "message";
$_SESSION['message'] = Def_Bad_Loan_Format;
$_SESSION['error'] = "fatal_error";
header('Location: ./Mas_PC.php');
}
}
else {
$_SESSION['print'] = "message";
$_SESSION['message'] = Def_Bad_Loan_Format;
$_SESSION['error'] = "fatal_error";
header('Location: ./Mas_PC.php');
}
?> |
Request.php
Code :
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
| <?php
@session_start();
include_once ("definitions.php");
class Request_Gen{
private $login = Def_Gateway_login;
private $passworde = Def_Gateway_passworde;
private $host = Def_Gateway_host;
private $path = Def_Gateway_path;
private $Request_url;
private $connection = NULL;
var $CI_tab = array();//CI : Client Information
var $PS_tab = array();//PS : Payment Schedule
var $TH_tab = array();//TH : Transaction History
var $PR_tab = array();//PS : Payment Response
var $DI_tab = array();//DI : Disbursal Info
var $DR_tab = array();//DR : Disbursal Response
function __construct($loan_account){
if (Def_Use_Ssl === "yes")
$url = 'https://' . $this->host . '/';
else
$url = 'http://' . $this->host . '/';
if ($this->path != "")
$url .= $this->path . '/';
$url .= 'M_CMP_Gateway.php?';
$url .= 'userName=' . $this->login;
$url .= '&password=' . $this->passworde;
$url .= '&M_username=' . $_SESSION['userName'];
$url .= '&M_password=' . $_SESSION['password'];
$url .= '&accountNum=' . $loan_account;
$url .= '&Type=LC';
$url .= '&MAS=PC';
$url .= '&method=';
$this->Request_url = $url;
}
function load_account_data(){
$url = $this->Request_url . 'searchClient';
$url = http_build_url($url);
$connection = new HttpRequest ($url);
try {
$connection->send();
$this->CI_tab = json_decode ($connection->getResponseBody());
$url = $this->Request_url . 'getPaymentSchedule';
$url = http_build_url($url);
$connection = new HttpRequest ($url);
try {
$connection->send();
$this->PS_tab = json_decode ($connection->getResponseBody());
$url = $this->Request_url . 'getTransactionHistory';
$url = http_build_url($url);
$connection->setUrl($url);
try {
$connection->send();
$this->TH_tab = json_decode ($connection->getResponseBody());
}
catch (Exception $e){
//echo $e;
return null;
}
}
catch (Exception $e){
//echo $e;
return null;
}
}
catch (Exception $e){
//echo $e;
return null;
}
}
function Apply_Payment($payAmount, $receiptId){
$url = $this->Request_url . 'applyPayment';
$url .= '&payAmount=' . $payAmount;
if ($receiptId != null)
$url .= '&receiptId=' . $receiptId;
$url = http_build_url($url);
$connection = new HttpRequest ($url);
try {
$connection->send();
$this->PR_tab = json_decode ($connection->getResponseBody());
}
catch (Exception $e){
echo "reload";
}
}
function Disburs_info(){
$url = $this->Request_url . 'DisburseLoanInfo';
$url = http_build_url($url);
$connection = new HttpRequest ($url);
try{
$connection->send();
$this->DI_tab = json_decode ($connection->getResponseBody());
return $this->DI_tab;
}
catch (Exception $e){
echo "reload";
}
}
function Disburs_loan($receiptId){
$url = $this->Request_url . 'DisburseLoan';
if ($receiptId != null)
$url .= '&receiptId=' . $receiptId;
$url = http_build_url($url);
$connection = new HttpRequest ($url);
try{
$connection->send();
$this->DR_tab = json_decode ($connection->getResponseBody());
}
catch (Exception $e){
echo "reload";
}
}
}
?> |
load_account_data.php
Code :
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 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
| <?php
@session_start();
if (Def_Gateway_language == "English"){
include_once('Definitions_Eng.php');
include_once('Mas_en.php');
}
else {
include_once('Definitions_Fr.php');
include_once('Mas_fr.php');
}
function Account_Status_information($status){
if (preg_match(Def_Status_approved, $status)){
include_once("Request.php");
$_SESSION['disbursment_permission'] = 1;
$_SESSION['payment_permission'] = 0;
$Request = new Request_Gen($_SESSION['loanAccount']);
$DI_tab = $Request->Disburs_info();
if ($DI_tab->status == "ok"){
if (isset($DI_tab->result->Disbursement_amount)){
$_SESSION['Disbursement_amount'] = $DI_tab->result->Disbursement_amount;
$_SESSION['Payment_amount'] = $DI_tab->result->Payment_amount;
}
else
$_SESSION['disbursment_permission'] = 0;
}
}
elseif (preg_match(Def_Status_active, $status)){
$_SESSION['disbursment_permission'] = 0;
$_SESSION['payment_permission'] = 1;
}
else{
$_SESSION['disbursment_permission'] = 0;
$_SESSION['payment_permission'] = 0;
}
}
function message_to_text($reason){
if ($reason == "badlogin"){
$_SESSION['error'] = "fatal_error";
return Def_Bad_Login;
}
if ($reason == "badloanaccount"){
$_SESSION['error'] = "fatal_error";
return Def_Account_Not_Found;
}
elseif ($reason == "badstatus") return Def_Action_Denied;
// elseif ($reason == "baddate") return ;
elseif ($reason == "badamount") return Def_Bad_Amount;
elseif ($reason == "loginserverdown") return Def_Server_Not_Found;
// elseif ($reason == "errorload") return "";
else return $reason;
}
if(isset ($_SESSION['login'])){
if($_SESSION['login'] == 1){
$PS_tab = $_SESSION['PS'];
$CI_tab = $_SESSION['CI'];
$TH_tab = $_SESSION['TH'];
if($PS_tab != null){
if($PS_tab->action_name === 'Payment_Schedule' && $PS_tab->status === 'ok'){
$IP_D_Date = $PS_tab->result->InstallmentsPaid->dueDate;
$IP_D_Paid = $PS_tab->result->InstallmentsPaid->datePaid;
$IP_T = $PS_tab->result->InstallmentsPaid->total;
$ID_D_Date = $PS_tab->result->InstallmentsDue->dueDate;
$ID_T = $PS_tab->result->InstallmentsDue->total;
$FI_D_Date =$PS_tab->result->FutureInstallments->dueDate;
$FI_T = $PS_tab->result->FutureInstallments->total;
if (isset($ID_D_Date[0]) && isset($ID_T[0])){
$_SESSION['NextAmountToPay'] = "<TR>
<b>" . Def_Date ." : </b>
</TR>
<TR>";
$_SESSION['NextAmountToPay'] .= $ID_D_Date[0];
$_SESSION['NextAmountToPay'] .= "</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_amount ." : </b>
</TR>
<TR>";
$_SESSION['NextAmountToPay'] .= $ID_T[0];
$_SESSION['NextAmountToPay'] .= "</TR>";
}
else if (isset($FI_D_Date[0]) && isset($FI_T[0])){
$_SESSION['NextAmountToPay'] = "<TR>
<b>" . Def_Date ." : </b>
</TR>
<TR>";
$_SESSION['NextAmountToPay'] .= $FI_D_Date[0];
$_SESSION['NextAmountToPay'] .= "</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_amount ." : </b>
</TR>
<TR>";
$_SESSION['NextAmountToPay'] .= $FI_T[0];
$_SESSION['NextAmountToPay'] .= "</TR>";
}
$IP_Size = count($IP_D_Date);
$ID_Size = count($ID_D_Date);
$FI_Size = count($FI_D_Date);
$temp = "<div align=\"center\" style=\"padding-top : 10px;\">
<TABLE BORDER=0 WIDTH=350>
<TR>
<TD ALIGN=\"center\" COLSPAN=5><B>" . Def_Installments_Paid ."</B></TD>
</TR>
<TR>
<TD ALIGN=\"left\"><B>" . Def_Due_Date ."</B></TD>
<TD> </TD>
<TD ALIGN=\"left\"><B>" . Def_Date_Paid ."</B></TD>
<TD> </TD>
<TD ALIGN=\"right\"><B>" . Def_Total ."</B></TD>
</TR>";
for($i = 0; $i < $IP_Size; $i++){
$temp .= "<TR>
<TD>"; $temp .= $IP_D_Date[$i]; $temp .= "</TD>
<TD> </TD>
<TD>"; $temp .= $IP_D_Paid[$i]; $temp .= "</TD>
<TD> </TD>
<TD ALIGN=\"right\">"; $temp .= $IP_T[$i]; $temp .= "</TD>
</TR>";
};
$temp .= "</TABLE>
</div>";
//Installments Du
$temp .= "<div align=\"center\" style=\"padding-top : 10px;\">
<TABLE BORDER=0 WIDTH=350>
<TR>
<TD ALIGN=\"center\" COLSPAN=5><B>" . Def_Installments_Due ."</B></TD>
</TR>
<TR>
<TD ALIGN=\"left\"><B>" . Def_Due_Date ."</B></TD>
<TD> </TD>
<TD></TD>
<TD> </TD>
<TD ALIGN=\"right\"><B>" . Def_Total ."</B></TD>
</TR>";
for($i = 0; $i < $ID_Size; $i++){
$temp .= "<TR>
<TD>"; $temp .= $ID_D_Date[$i]; $temp .= "</TD>
<TD> </TD>
<TD></TD>
<TD> </TD>
<TD ALIGN=\"right\">"; $temp .= $ID_T[$i]; $temp .= "</TD>
</TR>";
};
$temp .= "</TABLE>
</div>";
//Future Installments
$temp .= "<div align=\"center\" style=\"padding-top : 10px;\">
<TABLE BORDER=0 WIDTH=350>
<TR>
<TD ALIGN=\"center\" COLSPAN=5><B>" . Def_Future_Installments ."</B></TD>
</TR>
<TR>
<TD ALIGN=\"left\"><B>" . Def_Due_Date ."</B></TD>
<TD> </TD>
<TD><B></B></TD>
<TD> </TD>
<TD ALIGN=\"right\"><B>" . Def_Total ."</B></TD>
</TR>";
for($i = 0; $i < $FI_Size; $i++){
$temp .= "<TR>
<TD>"; $temp .= $FI_D_Date[$i]; $temp .= "</TD>
<TD> </TD>
<TD></TD>
<TD> </TD>
<TD ALIGN=\"right\">"; $temp .= $FI_T[$i]; $temp .= "</TD>
</TR>";
};
$temp .= "</TABLE>
</div>";
$_SESSION['payment_schedule'] = $temp;
}
else{
$_SESSION['payment_schedule'] = message_to_text($PS_tab->reason);
}
}
else{
$_SESSION['payment_schedule'] = Def_Unexpected_Error;
}
if ($CI_tab != null){
if (isset($CI_tab->result->status) && isset($CI_tab->result->ID)){
if (isset ($CI_tab->result->group)){
$temp = "<TABLE BORDER=0>
<TR>
<b>" . Def_Account_Information ."</b>
</TR>
<TR>
<br>
</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_Group_Name ."</b>
</TR>
<TR>
<br>
</TR>
<TR>";
$temp .= $CI_tab->result->group;
$_SESSION['client_name'] = $CI_tab->result->group;
}
elseif (isset ($CI_tab->result->name)){
$temp = "<TABLE BORDER=0>
<TR>
<b>" . Def_Account_Information ."</b>
</TR>
<TR>
<br>
</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_Client_Name ."</b>
</TR>
<TR>
<br>
</TR>
<TR>";
$temp .= $CI_tab->result->name;
$_SESSION['client_name'] = $CI_tab->result->name;
}
$temp .= "</TR>
<TR>
<br>
</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_Mifos_ID ."</b>
</TR>
<TR>
<br>
</TR>
<TR>";
$temp .= $CI_tab->result->ID;
$temp .= "</TR>
<TR>
<br>
</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_Loan_Account ."</b>
</TR>
<TR>
<br>
</TR>
<TR>";
$temp .= $_SESSION['loanAccount'];
$temp .= "</TR>
<TR>
<br>
</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_Account_Status . "</b>
</TR>
<TR>
<br>
</TR>
<TR>";
$temp .= $CI_tab->result->status;
$temp .= "</TR>";
if (isset($_SESSION['NextAmountToPay'])){
$temp .="<TR>
<br>
</TR>
<TR>
<br>
</TR>
<TR>
<b>" . Def_Next_Payment_Due . "</b>
</TR>
<TR>
<br>
</TR>";
$temp .= $_SESSION['NextAmountToPay'];
$temp .="<TR>
<br>
</TR>";
}
$temp .= "</TABLE>";
Account_Status_information($CI_tab->result->status);
$_SESSION['account_info'] = $temp;
}
else{
$_SESSION['account_info'] = Def_No_Information_Found;
}
}
else{
$_SESSION['account_info'] = Def_Unexpected_Error;
}
if ($TH_tab != null) {
if($TH_tab->action_name === 'Transaction_History' && $TH_tab->status === 'ok'){
if ($TH_tab->result != null){
$TH_Date = $TH_tab->result->date;
$TH_Activity = $TH_tab->result->activity;
$TH_Amount = $TH_tab->result->amount;
$TH_Sold = $TH_tab->result->sold;
$TH_Size = count($TH_Date);
$temp = "<div align=\"center\" style=\"padding-top : 10px;\">
<TABLE BORDER=0>
<TR>
<TD><B>" . Def_Transaction_History . "</B></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD><B>" . Def_Date . "</B></TD>
<TD><B>" . Def_Activity . "</B></TD>
<TD> </TD>
<TD><B>" . Def_amount . "</B></TD>
<TD> </TD>
<TD><B>" . Def_Sold . "</B></TD>
</TR>";
for($i = 0; $i < $TH_Size; $i++){
$temp .= "<TR>
<TD>";$temp .= $TH_Date[$i]; $temp .= "</TD>
<TD>"; $temp .= $TH_Activity[$i]; $temp .= "</TD>
<TD> </TD>
<TD ALIGN=\"right\">"; $temp .= $TH_Amount[$i]; $temp .= "</TD>
<TD> </TD>
<TD ALIGN=\"right\">";$temp .= $TH_Sold[$i]; $temp .= "</TD>
</TR>";
};
$temp .= "</TABLE>
</div>";
$_SESSION['transaction_history'] = $temp;
}
else{
$_SESSION['transaction_history'] = Def_Transaction_History_Empty;
}
}
else{
$_SESSION['transaction_history'] = message_to_text($TH_tab->reason);
}
}
else{
$_SESSION['transaction_history'] = Def_Unexpected_Error;
}
if ($_SESSION['disbursment_permission'] == 1){
$temp = "<FORM method=post action=\"Get_values.php\" style = \"padding-top : 20px\">
<div align=\"center\">
<FIELDSET style=\"width:360px;\">
<LEGEND><B>" . Def_Disburs_Loan . "</B></LEGEND>
<TABLE BORDER=0>
<TR>
<TD>" . Def_Disbursement_amount . "</TD>
<TD><INPUT type=text name=\"disbursAmount\" readonly value=\"";
$temp .= $_SESSION['Disbursement_amount'];
$temp .= "\">
</TD></TR>
<TR>
<TD><br></TD>
</TR>
<TR>
<TD>" . Def_Payment_amount . "</TD>
<TD><INPUT type=text name=\"payamount\" readonly value=\"";
$temp .= $_SESSION['Payment_amount'];
$temp .= "\"></TD></TR>
<TR>
<TD><br></TD>
</TR>
<TR>
<TD>" . Def_ReceiptId . "</TD>
<TD><INPUT type=text name=\"disbursreciepId\"></TD>
</TR>
<TR>
<TD COLSPAN=2><INPUT type=\"submit\" value=\"OK\"></TD>
</TR>
</TABLE>
</FIELDSET>
</div>
</FORM>";
$_SESSION['disburs_loan'] = $temp;
}
else{
$_SESSION['disburs_loan'] = Def_Action_Denied;
}
if ($_SESSION['payment_permission'] == 1){
$temp = "<FORM method=post action=\"Get_values.php\" style = \"padding-top : 20px\">
<div align=\"center\">
<FIELDSET style=\"width:360px;\">
<LEGEND><B>" . Def_Apply_Payment . "</B></LEGEND>
<TABLE BORDER=0>
<TR>
<TD>" . Def_amount . " </TD>
<TD><INPUT type=text name=\"payAmount\"></TD>
</TR>
<TR>
<TD><br></TD>
</TR>
<TR>
<TD>" . Def_ReceiptId . " </TD>
<TD><INPUT type=text name=\"Payment_receipId\"></TD>
</TR>
<TR>
<TD COLSPAN=2><INPUT type=\"submit\" value=\"OK\"></TD>
</TR>
</TABLE>
</FIELDSET>
</div>
</FORM>";
$_SESSION['apply_payment'] = $temp;
}
else{
$_SESSION['apply_payment'] = Def_Action_Denied;
}
}
else{ session_destroy(); include("index.php");}
}
else { session_destroy(); include("index.php");}
?> |
Mas_PC.php
Code :
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
| <?php
@session_start();
function print_page(){
if (isset($_SESSION['print'])){
if ($_SESSION['print'] === "payment_schedule")
echo $_SESSION['payment_schedule'];
elseif ($_SESSION['print'] === "transaction_history")
echo $_SESSION['transaction_history'];
elseif ($_SESSION['print'] === "disburs_loan")
echo $_SESSION['disburs_loan'];
elseif ($_SESSION['print'] === "apply_payment")
echo $_SESSION['apply_payment'];
elseif ($_SESSION['print'] === "message")
echo $_SESSION['message'];
}
}
if(isset ($_SESSION['login'])){
if($_SESSION['login'] == 1){
echo <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8;" />
<html>
<head>
<title>Creova : Mobile Agent System</title>
<style>
h1 {
font: 25px bold Helvetica, Arial;
letter-spacing: -2px;
}
h2 {
font: 20px bold Helvetica, Arial;
}
h3 {
font: 18px bold Helvetica, Arial;
}
div {
font: 14px bold Helvetica, Arial;
}
div#options a:link, div#options a:visited {
text-decoration:none;
}
#options a:hover {
background:#F5F5F0 none repeat scroll 0 0;
color:#000000;
}
div#options {
text-align:left;
}
</style>
</head>
<body>
<DIV ALIGN=CENTER>
<TABLE BORDER="0">
<TR>
<TD COLSPAN = 4>
EOT;
if (isset($_SESSION['error']) && $_SESSION['error'] == "fatal_error")
include ("fatal_error_Menu.php");
else
include ("Menu.php");
echo <<<EOT
</TD>
</TR>
<TR>
<TD COLSPAN = 4><br></TD>
</TR>
<TR>
<TD ALIGN=CENTER width="150" bgcolor=#FFFF99 style="border:1px solid brown">
EOT;
if (isset($_SESSION['account_info']))
echo $_SESSION['account_info'];
else
echo "No Data";
echo <<<EOT
</TD>
<TD ALIGN=CENTER COLSPAN = 3 bgcolor=#DDDDDD>
EOT;
print_page();
echo <<<EOT
</TD>
</TR>
<TR>
<TD COLSPAN = 4><br></TD>
</TR>
<TR>
<TD COLSPAN = 4>
EOT;
include ("Footer.php");
echo <<<EOT
</TD>
</TR>
</TABLE>
<DIV>
</body>
</html>
EOT;
}
else{ session_destroy(); include("index.php");}
}
else { session_destroy(); include("index.php");}
?> |
definitions.php
Code :
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
| <?php
/*
** Gateway parameters.
*/
define("Def_Gateway_login", "gtwtest");
define("Def_Gateway_passworde", "test");
define("Def_Gateway_host", "localhost");
define("Def_Gateway_path", "GTW");
/*
** Administrator Login/Password of the Gateway.
*/
define("Def_Admin_login", "Admin");
define("Def_Admin_password", "GCM09F");
/*
** Language
*/
define("Def_Gateway_language", "Français");
/*
** SSL
*/
define("Def_Use_Ssl", "no");
?> |
Mas_fr.php
Code :
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
| <?php
/*
** French words definition
*/
/*
** Login Page
*/
define("Def_Username", "Nom d'utilisateur");
define("Def_Password", "Mot de passe");
/*
** Loan Information Page
*/
define("Def_Loan_Number", "Numéro du prêt");
/*
** Menu Page
*/
define("Def_Payment_Schedule", "Échéancier");
define("Def_Transaction_History", "Activités de compte");
define("Def_Apply_Payment", "Appliquer paiment");
define("Def_Disburs_Loan", "Débourser prêt");
define("Def_Reload", "Recharger");
define("Def_Change_Account", "Changer de compte");
define("Def_back", "Précédent");
define("Def_Logout", "Déconnexion");
/*
** Account Information Page
*/
define("Def_Account_Information", "Informations sur le compte");
define("Def_Client_Name", "Nom du client");
define("Def_Group_Name", "Nom du groupe");
define("Def_Mifos_ID", "ID Mifos");
define("Def_Loan_Account", "Numéro du prêt");
define("Def_Account_Status", "Statut du compte");
define("Def_Next_Payment_Due", "Prochain paiement");
define("Def_Date", "Date");
define("Def_amount", "Montant");
/*
** Payment Schedule Page
*/
define("Def_Installments_Paid", "Remboursements payés");
define("Def_Due_Date", "Date prévue");
define("Def_Date_Paid", "Date de paiement");
define("Def_Total", "Total");
define("Def_Installments_Due", "Rembourssements en retards");
define("Def_Future_Installments", "Remboursements future");
/*
** Missed Payments Page
*/
define("Def_Missed_Payments_Title", "Payements en retard");
define("Def_MP_Loan_Account_ID", "numéro de prét");
define("Def_MP_Customer_Name", "Nom du client");
define("Def_MP_Customer_global_Account_ID", "ID Mifos");
define("Def_MP_Due_Date", "Date d'échéance");
define("Def_MP_Total", "Total");
/*
** Transaction History Page
*/
//define("Def_Transaction_History", "");
//define("Def_Date", "");
define("Def_Activity", "Activité");
//define("Def_amount", "");
define("Def_Sold", "Sold");
/*
** Apply Payment Page
*/
//define("Def_Apply_Payment", "Appliquer un payment");
//define("Def_amount", "");
define("Def_ReceiptId", "Numéro du Reçu");
/*
** Disburse Loan Page
*/
//define("Def_Disburs_Loan", "");
define("Def_Disbursement_amount", "Montant á déboursser");
define("Def_Payment_amount", "Montant á payer");
//define("Def_ReceiptId", "");
/*
** ALL MESSAGES
*/
define("Def_Action_Denied", "Action refusé, Le statut du compte ne permet pas cette action, <br> ou bien l'utilisateur n'a pas les droits suffisants pour effectuer cette t âche");
define("Def_Unexpected_Error", "Une Erreure inatendue c'est produite, merci de recharger les informations du compte");
define("Def_Transaction_History_Empty", "Aucune transaction n'a été effectuée sur ce compte");
define("Def_No_Information_Found", "Aucune information trouvée");
define("Def_Bad_Login", "L'identifient ou le mot de passe introduit sont incorrecte,<br> Merci de vous réidentifier");
define("Def_Account_Not_Found", "Le compte demandé n'existe pas, ou bien n'est pas un compte de prêt.");
define("Def_Server_Not_Found", "Le serveur n'est pas accessible, merci de recharger le compte et de verifier vos paramétres.");
define("Def_Disbursment_Made", "Déboursement effectué avec succes.");
define("Def_Bad_Date", "Le prêt ne peut être débourser avant le rendez-vous");
define("Def_Bad_Loan_Format", "Le format du Numéro de prêt saisi est invalide.");
define("Def_Bad_Amount_Format", "Le format du montant saisi est invalide.");
define("Def_Bad_Amount", "Le montant saisi est invalide.");
// we creat a part of html page of payment successful
define("Def_Payment_Made", "<div align=\"center\">Paiement effectué avec succès.<br><br>Voulez vous imprimer un reçu ?<br<br></div>
<FORM method=post action=\"print_reciept.php\">
<div align=\"center\">
<TABLE BORDER=0>
<TR>
<TD COLSPAN=2><INPUT type=\"submit\" value=\"OK\"></TD>
</TR>
</TABLE>
</div>
</FORM> ");
?> |
ces fichiers sont sous GTW
M_CMP_Gateway.php
Code :
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
| <?php
include("M_Interface.php");
include("CMP_Interface.php");
include("Json_Gen.php");
$Json_msg_array = array ( 'action_name' => array(),
'status' => array(),
'reason' => array(),
'result' => array(),
'login' => array(),
'IP' => array(),
'Type' => array(),
'account_num' => array());
$CMP_Interface = new CMP_Interface();
$data = $CMP_Interface->get_data();
$login = $CMP_Interface->get_login();
$pass = $CMP_Interface->get_pass();
$Json_gen = new Json_gen();
$MAS=$CMP_Interface->get_MAS();
if ($data[0] < 600){
$M_Interface = new M_Interface($login, $pass, $data[1], $data[2],$MAS);
$CMP_Interface->execute($M_Interface, $data[0], $CMP_Interface->is_cmp);
}
else {
if ($data[0] < 610){
$Json_msg_array['action_name'] = "Unknown";
if ($data[0] == 601) $Json_msg_array['reason'] = "badmethod";
else if ($data[0] == 602) $Json_msg_array['reason'] = "badtype";
else if ($data[0] == 603) $Json_msg_array['reason'] = "badlogin";
else if ($data[0] == 604) $Json_msg_array['reason'] = "badurl";
else if ($data[0] == 605) $Json_msg_array['reason'] = "badparameter";
}
else {
if ($data[0] < 620){
$Json_msg_array['action_name'] = "Transaction_History";
if ($data[0] == 611) $Json_msg_array['reason'] = "badurl";
else if ($data[0] == 612) $Json_msg_array['reason'] = "badloanaccount";
}
else if ($data[0] < 630){
$Json_msg_array['action_name'] = "Payment_Schedule";
if ($data[0] == 621) $Json_msg_array['reason'] = "badurl";
else if ($data[0] == 622) $Json_msg_array['reason'] = "badloanaccount";
}
else if ($data[0] < 640){
$Json_msg_array['action_name'] = "Apply_Payment";
if ($data[0] == 631) $Json_msg_array['reason'] = "badurl";
else if ($data[0] == 632) $Json_msg_array['reason'] = "badloanaccount";
else if ($data[0] == 633) $Json_msg_array['reason'] = "badamount";
}
else if ($data[0] < 650){
$Json_msg_array['action_name'] = "DisburseLoan";
if ($data[0] == 641) $Json_msg_array['reason'] = "badloanaccount";
else if ($data[0] == 642) $Json_msg_array['reason'] = "badparameter";
else if ($data[0] == 643) $Json_msg_array['reason'] = "nonauthorized";
}
else if ($data[0] < 660){
$Json_msg_array['action_name'] = "searchClient";
if ($data[0] == 652) $Json_msg_array['reason'] = "badloanaccount";
}
}
$Json_msg_array['status'] = "error";
$Json_msg_array['result'] = null;
$Json_gen->generate_jason($Json_msg_array, $CMP_Interface->is_cmp);
}
?> |
M_Interface.php
Code :
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 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
| <?php
include("M_Connection.php");
include("Request_Gen.php");
include_once("Html_Parser.php");
if (Def_Gateway_language == "English")
include_once('Definitions_Eng.php');
else
include_once('Definitions_Fr.php');
class M_Interface{
private $M_Connection;
private $Request_Gen;
private $Html_Parser;
Private $Json_gen;
var $status = "";
var $reason = "";
var $data_tab_result;
var $login;
var $Type;
var $IP;
var $account_num;
var $Json_msg_array = array ( 'action_name' => array(),
'status' => array(),
'reason' => array(),
'result' => array(),
'login' => array(),
'IP' => array(),
'Type' => array(),
'account_num' => array());
function __construct($login, $pass, $account_num, $param,$MAS){
$this->M_Connection = new M_Connection($login, $pass, $account_num);
$server_url = $this->M_Connection->get_server_url();
$this->IP=$_SERVER['REMOTE_ADDR'];
$this->Type=$MAS;
$this->account_num=$account_num;
$this->login=$login;
$cookies = $this->M_Connection->get_cookies();
$flowkey = $this->M_Connection->get_flowkey();
$this->Request_Gen = new Request_Gen($server_url, $cookies, $flowkey, $account_num,$param);
$this->Html_Parser = new Html_Parser();
$this->Json_gen = new Json_gen();
}
function apply_payment($is_cmp){
if ($this->M_Connection->is_connected == 1){
$url = $this->Request_Gen->build_payment_page_url();
$this->M_Connection->send_request($url);
if ($this->M_Connection->get_resp_code() == '200')
{
$url = $this->Request_Gen->build_apply_payment_url();
$this->M_Connection->send_request($url);
$html_code = $this->M_Connection->get_html_code();
$this->Html_Parser->control_payment($html_code);
if ($this->M_Connection->get_resp_code() == '200' && $this->Html_Parser->control != 0)
{
$this->status = "ok";
$this->reason = null;
}
else{
$this->status = "error";
$this->reason = "badamount";
}
}
else{
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
}
else {
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
$this->Json_msg_array['action_name'] = "Apply_Payment";
$this->Json_msg_array['status'] = $this->status;
$this->Json_msg_array['reason'] = $this->reason;
$this->Json_msg_array['login'] = $this->login;
$this->Json_msg_array['IP'] = $this->IP;
$this->Json_msg_array['result'] = null;
$this->Json_msg_array['account_num'] = $this->account_num;
$this->Json_msg_array['Type'] = $this->Type;
$this->Json_gen->generate_jason($this->Json_msg_array, $is_cmp);
}
function get_transaction_history($is_cmp){
if ($this->M_Connection->is_connected == 1){
$url = $this->Request_Gen->build_transaction_history_url();
$this->M_Connection->send_request($url);
if ($this->M_Connection->get_resp_code() == '200')
{
$html_code = $this->M_Connection->get_html_code();
$history_data_tab = $this->Html_Parser->get_data_tab_history($html_code);
if ($this->Html_Parser->control != 0) {
$this->status = "ok";
$this->reason = null;
$this->data_tab_result = $history_data_tab;
}
else{
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
}
else{
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
}
else {
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
$this->Json_msg_array['action_name'] = "Transaction_History";
$this->Json_msg_array['status'] = $this->status;
$this->Json_msg_array['reason'] = $this->reason;
$this->Json_msg_array['login'] = $this->login;
$this->Json_msg_array['IP'] = $this->IP;
$this->Json_msg_array['result'] = $this->data_tab_result;
$this->Json_msg_array['account_num'] = $this->account_num;
$this->Json_msg_array['Type'] = $this->Type;
$this->Json_gen->generate_jason($this->Json_msg_array, $is_cmp);
}
function get_payment_schedule($is_cmp){
if ($this->M_Connection->is_connected == 1){
$url = $this->Request_Gen->build_payment_schedule_url();
$this->M_Connection->send_request($url);
if ($this->M_Connection->get_resp_code() == '200')
{
$html_code = $this->M_Connection->get_html_code();
$schedule_data_tab = $this->Html_Parser->get_data_tab_schedule($html_code);
if ($this->Html_Parser->control != 0) {
$this->status = "ok";
$this->reason = null;
$this->data_tab_result = $schedule_data_tab;
}
else{
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
}
else{
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
}
else {
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
$this->Json_msg_array['action_name'] = "Payment_Schedule";
$this->Json_msg_array['status'] = $this->status;
$this->Json_msg_array['reason'] = $this->reason;
$this->Json_msg_array['login'] = $this->login;
$this->Json_msg_array['IP'] = $this->IP;
$this->Json_msg_array['result'] = $this->data_tab_result;
$this->Json_msg_array['account_num'] = $this->account_num;
$this->Json_msg_array['Type'] = $this->Type;
$this->Json_gen->generate_jason($this->Json_msg_array, $is_cmp);
}
function Disburse_Loan_info(){
$this->Json_msg_array['result'] = null;
if ($this->M_Connection->is_connected == 1){
if (preg_match(Def_Status_Application_Approved, $this->M_Connection->account_status)){
$url = $this->Request_Gen->build_Load_Disburse_Loan_url();
$this->M_Connection->send_request($url);
$html_code = $this->M_Connection->get_html_code();
$this->Json_msg_array['result'] = $this->Html_Parser->get_disbursal_information($html_code);
$this->status = "ok";
}
else{
$this->status = "error";
$this->reason = "badstatus";
}
}
else {
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
$this->Json_msg_array['action_name'] = "Disburse_Loan_info";
$this->Json_msg_array['status'] = $this->status;
$this->Json_msg_array['reason'] = $this->reason;
$this->Json_msg_array['login'] = $this->login;
$this->Json_msg_array['IP'] = $this->IP;
$this->Json_msg_array['account_num'] = $this->account_num;
$this->Json_msg_array['Type'] = $this->Type;
$this->Json_gen->generate_jason($this->Json_msg_array, false);
}
function Disburse_Loan(){
$this->Json_msg_array['result'] = null;
if ($this->M_Connection->is_connected == 1){
if (preg_match(Def_Status_Application_Approved, $this->M_Connection->account_status)){
$url = $this->Request_Gen->build_Load_Disburse_Loan_url();
$this->M_Connection->send_request($url);
$html_code = $this->M_Connection->get_html_code();
$this->Json_msg_array['result'] = $this->Html_Parser->get_disbursal_information($html_code);
$this->Html_Parser->permission_control($html_code);
if ($this->M_Connection->get_resp_code() == '200' && $this->Html_Parser->control != 0){
$url = $this->Request_Gen->build_Update_Disburse_Loan_url();
$this->M_Connection->send_request($url);
$html_code = $this->M_Connection->get_html_code();
$this->reason = $this->Html_Parser->control_disbursal($html_code);
if ($this->M_Connection->get_resp_code() == '200' && $this->Html_Parser->control != 0){
$this->status = "ok";
}
else {
$this->status = "error";
}
}
else {
$this->status = "error";
$this->reason = "badpermission";
}
}
else{
$this->status = "error";
$this->reason = "badstatus";
}
}
else {
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
$this->Json_msg_array['action_name'] = "Disburse_Loan";
$this->Json_msg_array['status'] = $this->status;
$this->Json_msg_array['reason'] = $this->reason;
$this->Json_msg_array['login'] = $this->login;
$this->Json_msg_array['IP'] = $this->IP;
$this->Json_msg_array['account_num'] = $this->account_num;
$this->Json_msg_array['Type'] = $this->Type;
$this->Json_gen->generate_jason($this->Json_msg_array, false);
}
function search_client(){
$this->Json_msg_array['result'] = null;
if ($this->M_Connection->is_connected == 1){
$url = $this->Request_Gen->build_client_search();
$this->M_Connection->send_request($url);
if ($this->M_Connection->get_resp_code() == '200'){
$html_code = $this->M_Connection->get_html_code();
$client_name = $this->Html_Parser->get_client_name($html_code);
$this->status = "ok";
$this->Json_msg_array['result'] = $client_name;
}
else{
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
}
else {
$this->status = "error";
$this->reason = $this->M_Connection->connection_msg;
}
$this->Json_msg_array['action_name'] = "search_client";
$this->Json_msg_array['status'] = $this->status;
$this->Json_msg_array['reason'] = $this->reason;
$this->Json_msg_array['login'] = $this->login;
$this->Json_msg_array['IP'] = $this->IP;
$this->Json_msg_array['account_num'] = $this->account_num;
$this->Json_msg_array['Type'] = $this->Type;
$this->Json_gen->generate_jason($this->Json_msg_array, false);
}
function set_login($login, $pass){
$this->M_Connection->set_login($login, $pass);
}
}
?> |
Request_Parser.php
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php
/************************/
// Request //
// Parser //
/************************/
class Request_Parser{
function Execute_Action($M_Interface, $code_action, $is_cmp){
if ($code_action == "100") $M_Interface->get_transaction_history($is_cmp);
else if ($code_action == "200") $M_Interface->get_payment_schedule($is_cmp);
else if ($code_action == "300") $M_Interface->apply_payment($is_cmp);
else if ($code_action == "400") $M_Interface->Disburse_Loan();
else if ($code_action == "450") $M_Interface->Disburse_Loan_info();
else if ($code_action == "500") $M_Interface->search_client();
}
}
?> |
M_Connection.php
Code :
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
| <?php
/************************/
//Mifos Connection Layer//
/***********************/
//
include_once("Html_Parser.php");
include_once("Definitions.php");
class M_Connection{
//Information used to establish connection with mifos server and to comunicat with.
private $host = Def_Mifos_host;
private $port = Def_Mifos_port;
private $path = Def_Mifos_path;
private $server_url; // The format of the Server URL is : "http://host:port/path/"
private $cookies = NULL;
private $flowkey = NULL;
private $mifos_connection = NULL;
var $account_status = NULL;
//login is an array which contains the Gateway's Username and Password used to be identified in Mifos System.
private $login = array('j_username' => Def_MIS_login, 'j_password' => Def_MIS_password);
var $is_connected = 0;
var $connection_msg = "";
//Set methods to change Mifos server information.
function set_host($host){
$this->host = $host;
$this->init_server_url();
}
function set_port($port){
$this->port = $port;
$this->init_server_url();
}
function set_path($path){
$this->path = $path;
$this->init_server_url();
}
function set_login($username, $password){
$this->login['j_username'] = $username;
$this->login['j_password'] = $password;
}
//Get methodes used to get Mifos server information.
function get_host(){
return ($this->host);
}
function get_port(){
return($this->port);
}
function get_path(){
return($this->path);
}
function get_server_url(){
return($this->server_url);
}
function get_login($field){
return($this->login[$field]);
}
function get_cookies(){
return($this->cookies);
}
function get_flowkey(){
return($this->flowkey);
}
function get_resp_code(){
return($this->mifos_connection->getResponseCode());
}
//Initialization methods
function init_server_url(){
$url = 'http://' . $this->host;
$url .= ':' . $this->port;
$url .= '/' . $this->path . '/';
$this->server_url = $url;
}
private function init_cookies(){
$option = $this->mifos_connection->getResponseCookies();
$cookies = $option[0]->cookies["JSESSIONID"];
$this->cookies = $cookies;
}
private function init_flowkey(){
$html = $this->get_html_code();
preg_match('/currentFlowKey.{22}/', $html, $matches );
$this->flowkey = substr($matches[0], -13);
}
//The constructor of this class, establish connection with Mifos server by login and save the session.
function __construct($login = NULL, $pass = NULL, $account_num = NULL){
//server addres initialization.
$this->init_server_url();
if ($login != NULL && $pass != NULL) $this->set_login($login, $pass);
//if ($account_num != NULL){
//login to server.
$login_url = $this->server_url . 'j_spring_security_check?';
$login_url = http_build_url($login_url);
$this->mifos_connection = new HttpRequest ($login_url, HttpRequest::METH_POST);
$this->mifos_connection->addPostFields($this->login);
try {
$this->mifos_connection->send();
if ($this->mifos_connection->getResponseCode() != '302'){
$this->connection_msg = "badlogin";
$this->is_connected = 0;
return;}
$this->init_cookies();
//find the account in Mifos.
if ($account_num != NULL){
$url = $this->server_url . 'loanAccountAction.do;jsessionid=';
$url .= $this->cookies . '?method=get';
$url .= '&globalAccountNum=' . $account_num;
$url = http_build_url($url);
try {
$this->send_request($url);
if ($this->mifos_connection->getResponseCode() == '200'){
//initialize Flow Key if account exists.
$this->is_connected = 1;
$this->init_flowkey();
$status_parser = new Html_Parser();
$html_code = $this->get_html_code();
$this->account_status = $status_parser->account_status($html_code);
}
else {
$this->connection_msg = "badloanaccount";
$this->is_connected = 0;
return;
}
}
catch (HttpException $ex) {
$this->connection_msg = "loanAccountserverdown";
$this->is_connected = 0;
}
}
else $this->is_connected = 1;
}
catch (HttpException $ex) {
$this->connection_msg = "loginserverdown";
$this->is_connected = 0;
}
}
//The destructor logout from Mifos server.
function __destruct(){
if ($this->is_connected == 1){
$logout_url = $this->server_url . 'loginAction.do;jsessionid=' . $this->cookies . '?method=logout';
$logout_url = http_build_url($logout_url);
try {
$this->send_request($logout_url);
$this->is_connected = 0;
}
catch (HttpException $ex) {
$this->connection_msg = "logoutserverdown";
$this->is_connected = 0;
}
}
}
//
function send_request($url){
$this->mifos_connection->setUrl($url);
$this->mifos_connection->send();
}
function get_html_code(){
return $this->mifos_connection->getResponseBody();
}
}
?> |
comme je dis la fonction qui est responsable de la recuperation des informations liés à loanAccount est load qui est dans Get_values.php qui est sous MACPC
et je pense que suite à des sous appel que cette fonction get_payment_schedule de M_Interface.php qui est responsable à la recuperation des information sous format json
bien sur dans ces fonction il y'a des appels inutiles ( fichies comme Footer.php et des fonctions) pour repondre à mes besoins .
merci d'avance
mon but est juste la consultation de cette fonction :
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13
| function load($loanAccount, $type)
{
$Request = new Request_Gen($loanAccount);
$Request->load_account_data();
$_SESSION['CI'] = $Request->CI_tab;
$_SESSION['PS'] = $Request->PS_tab;
$_SESSION['TH'] = $Request->TH_tab;
include_once ("load_account_data.php");
if($type == 0){
$_SESSION['print'] = "payment_schedule";
header('Location: ./Mas_PC.php');
}
} |
du fichier Get_values.php
cette fonction fonctionne dans le cas où loanAccount est envoyé par :
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <FORM method=post action="Get_values.php">
<div align="center">
<FIELDSET style="width:300px;">
<TABLE BORDER=0>
<TR>
<TD>
EOT;
echo Def_Loan_Number;
echo<<<EOT
</TD>
<TD><INPUT type=text name="loanAccount" ></TD>
</TR>
<TR>
<TD COLSPAN=2><INPUT type="submit" value="OK"></TD>
</TR>
</TABLE>
</FIELDSET>
</div>
</FORM> |
du loan_account.php
cette fonction donne comme résultat plusieurs information ( montant à payer......) et elle les affiche dans une autre page web
mon but est d'afficher seulement le montant à payer retourné par cette fonction dans le navigateur
pas d'autre information
et par la suite modfier le fonctionnement de cette fonction c'est à dire la fonction load du fichier Get_values.php devrai prendre loanAccount par get c'est à dire le fichier Get_values.php sera de cette forme
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| $ACCOUNT_NUM=$_GET['ACCOUNT_NUM'];
function load($loanAccount, $type)
{
$Request = new Request_Gen($loanAccount);
$Request->load_account_data();
$_SESSION['CI'] = $Request->CI_tab;
$_SESSION['PS'] = $Request->PS_tab;
$_SESSION['TH'] = $Request->TH_tab;
include_once ("load_account_data.php");
if($type == 0){
$_SESSION['print'] = "payment_schedule";
header('Location: ./Mas_PC.php');
}
if (isset ($_GET['ACCOUNT_NUM'])){
if (preg_match("/^[0-9]{15}$/", $_GET['ACCOUNT_NUM'])){
load($_GET['ACCOUNT_NUM'], 0);
}
}
} |
mais avant tout je dois retourné de la fonction load seulement le montant pas d'autre information
|