Location: PHPKode > projects > MembersGear > membersgear/includes/get_vendor_report_data.php
<?php
require_once("../config/config.php");
require_once(INCLUDE_DIR."/report_class.php");
require_once(INCLUDE_DIR."/PaygearWebserviceClient.php");  

if(isset($_POST))
 {
        $btndetect= $_POST['searchClikDetect'];
         if($btndetect=="search2")
         {
                     $userId=decrypt(PAYGEAR_USERID);
                     $startDate = $_POST['ctl00_ContentPlaceHolder1_txtStartDate'];
                     $endDate   = $_POST['ctl00_ContentPlaceHolder1_txtEndDate'];
                     $pReportType= $_POST['ddltransaction'];
                     $pIsRefundChecked= $_POST['ctl00_ContentPlaceHolder1_chkRefund']; 
                     $pIsRefundChecked=(int)$pIsRefundChecked;
                     $pIsBonusChecked =$_POST['ctl00_ContentPlaceHolder1_chkBonus'];  
                     $pIsBonusChecked=(int)$pIsBonusChecked;
                     $pIsChargeBackChecked=0;
                     $pIsAffiliateCommissionChecked= $_POST['ctl00_ContentPlaceHolder1_chkAffiliateCommission']; 
                     $pIsAffiliateCommissionChecked=(int)$pIsAffiliateCommissionChecked;
                     $PaygearCommission=$_POST['ctl00_ContentPlaceHolder1_chkPaygearCommission'];  
                     $PaygearCommission=(int)$PaygearCommission;
                     $pLastName=$_POST['ctl00_ContentPlaceHolder1_txtLastName'];
                     $pEmail=$_POST['ctl00_ContentPlaceHolder1_txtEmail'];
                     $pAffiliate=$_POST['affiliate'];
                     $pItem=$_POST['product'];
                     $pVendorName=$_POST['vendor'];
                     
                     $PaygearWebserviceClient=new PaygearWebserviceClient();
                     $response=$PaygearWebserviceClient->getVendorSalesData($userId,$startDate,$endDate,$pReportType,$pIsRefundChecked,$pIsBonusChecked,$pIsChargeBackChecked,$pIsAffiliateCommissionChecked,$PaygearCommission,$pLastName,$pEmail,$pAffiliate,$pItem,$pVendorName);
                     $len=sizeof($response['GetPaygearVendorTotalSalesDataResult']['ArrayOfString'][0]['string']);
                        if($response['GetPaygearVendorTotalSalesDataResult']['ArrayOfString'][0]['string']!="0" and $response['GetPaygearVendorTotalSalesDataResult']['ArrayOfString'][0]['string']!=null)
                              $flag="true";
                     
         }
         else if($btndetect=="search1")
         {
            
             $etransId= $_POST['etransid'];
             $userid=decrypt(PAYGEAR_USERID);
             $PaygearWebserviceClient=new PaygearWebserviceClient();
             $response=$PaygearWebserviceClient->getVendorSalesDataByEtranId($etransId,$userid);
              $len=sizeof($response['SearchPaygearSaleByETransactionResult']['ArrayOfString'][0]['string']); 
              if($response['SearchPaygearSaleByETransactionResult']['ArrayOfString'][0]['string']!="0" and $response['SearchPaygearSaleByETransactionResult']['ArrayOfString'][0]['string']!=null)
                $flag="true";
             
         }
        else if($btndetect=="ordersearch")
        {
              $orderId= $_POST['orderid'];
              $userid=decrypt(PAYGEAR_USERID);
              $PaygearWebserviceClient=new PaygearWebserviceClient();
              $response=$PaygearWebserviceClient->getVendorSalesDataByOrderId($orderId,$userid);
              $len=sizeof($response['SearchPaygearSaleByOrderIdResult']['ArrayOfString'][0]['string']); 
              if($response['SearchPaygearSaleByOrderIdResult']['ArrayOfString'][0]['string']!="0" and $response['SearchPaygearSaleByOrderIdResult']['ArrayOfString'][0]['string']!=null)
                $flag="true";
          
         }     
         
         if($flag=="true")
         {  
                                 $table='<table cellspacing="2" cellpadding="2" border="0" style="width: 895px; border-collapse: collapse;" id="grid" class="reportgrid" >
                                     <tbody><tr class="reportgridmain">
                                     <th align="left" style="width: 50px;" scope="col">OrderId</th><th align="left" style="width: 70px;" scope="col">Date</th><th align="left" scope="col">Transactionid</th><th align="left" scope="col">Vendor</th><th align="left" scope="col">Product Name</th><th align="left" scope="col" style="width: 80px;">Customer</th><th align="left" scope="col">Affiliate</th><th align="right" scope="col">Actual Price</th><th align="center" style="width: 50px;" scope="col">Purchase Bonus</th><th align="center" style="width: 50px;" scope="col">Sold At</th><th align="center" style="width: 50px;" scope="col">Paygear Fee</th><th align="center" style="width: 50px;" scope="col">Affiliate Commission</th><th align="right" scope="col">Refund</th>
                            </tr>';
                            $objReportClass=new report_class();
                            for($i=1;$i<$len;$i++)
                             {
                                 
                                  if($btndetect=="search2")
                                     $string=$response['GetPaygearVendorTotalSalesDataResult']['ArrayOfString'][0]['string'][$i];
                                  else if($btndetect=="search1")
                                     $string=$response['SearchPaygearSaleByETransactionResult']['ArrayOfString'][0]['string'][$i];
                                  else if($btndetect=="ordersearch") 
                                     $string=$response['SearchPaygearSaleByOrderIdResult']['ArrayOfString'][0]['string'][$i];       
                                
                                 $arr=$objReportClass->spliteValuesofReport($string); 
                                 
                                 
                                 $tranIdLen=strlen(trim($arr[28]));
                                 if($tranIdLen>15)
                                  {
                                       $firstString=trim(substr($arr[28],0,8));
                                       $secondString=trim(substr($arr[28],8));
                                       $arr[28]=$firstString."<br>".$secondString;
                                       
                                   }  
                                 
                                  $tranVendorLen=strlen(trim($arr[3]));
                                  if($tranVendorLen>15)
                                  {
                                       $firstString=trim(substr($arr[3],0,8));
                                       $secondString=trim(substr($arr[3],8));
                                       $arr[3]=$firstString."<br>".$secondString;
                                       
                                   }
                                   
                                  $prodLen=strlen(trim($arr[4]));
                                  if($prodLen>15)
                                  {
                                       $firstString=trim(substr($arr[4],0,8));
                                       $secondString=trim(substr($arr[4],8));
                                       $arr[4]=$firstString."<br>".$secondString;
                                       
                                   }
                                   
                                  $custLen=strlen(trim($arr[5]));
                                  if($custLen>15)
                                  {
                                       $firstString=trim(substr($arr[5],0,8));
                                       $secondString=trim(substr($arr[5],8));
                                       $arr[5]=$firstString."<br>".$secondString;
                                       
                                   } 
                                   
                                  $AffiliateLen=strlen(trim($arr[19]));
                                  if($AffiliateLen>15)
                                  {
                                       $firstString=trim(substr($arr[19],0,8));
                                       $secondString=trim(substr($arr[19],8));
                                       $arr[19]=$firstString."<br>".$secondString;
                                       
                                   }                                    
                                 
                                  $lsoldat=number_format(((float)$arr[21]-(float)$arr[22]),2);        
                                  
                                    $table.='<tr class="contentRow1_grid">
                                                               <td align="left" style="width: 45px;">
                                                                   '.trim($arr[1]).'
                                                                </td><td align="left" style="width: 70px;">
                                                                    '.trim($arr[27]).'
                                                                </td><td align="left" style="width:50px;">
                                                                    '.trim($arr[28]).'
                                                                </td><td align="left">
                                                                    '.trim($arr[3]).'
                                                                </td><td align="middle">
                                                                    '.trim($arr[4]).'
                                                                </td><td align="left" style="width: 80px;">
                                                                    '.trim($arr[5]).'
                                                                </td><td align="left">
                                                                    '.trim($arr[19]).'
                                                                </td>
                                                                </td><td align="right">
                                                                    '.trim(number_format($arr[21]*1,2)).'
                                                                </td>
                                                                <td align="right">
                                                                    '.trim($arr[22]).'
                                                                </td>
                                                                 <td align="right">
                                                                    '.trim($lsoldat).'
                                                                </td>
                                                                  <td align="right">
                                                                    '.trim($arr[23]).'
                                                                </td>
                                                                      <td align="right">
                                                                    '.trim($arr[24]).'
                                                                </td>
                                                                  </td>
                                                                      <td align="right">
                                                                    '.trim($arr[25]).'
                                                                </td>
                                                                
                                </tr>';
                                
                                
                                   if($btndetect=="search2")
                                      $getSubReportDataString=$objReportClass->getsubReportData($response['GetPaygearVendorTotalSalesDataResult']['ArrayOfString'][1]['string'],$arr[1]);
                                   else if($btndetect=="search1")
                                       $getSubReportDataString=$objReportClass->getsubReportData($response['SearchPaygearSaleByETransactionResult']['ArrayOfString'][1]['string'],$arr[1]);
                                     else if($btndetect=="ordersearch")       
                                       $getSubReportDataString=$objReportClass->getsubReportData($response['SearchPaygearSaleByOrderIdResult']['ArrayOfString'][1]['string'],$arr[1]);    
                                  
                                   if(isset($getSubReportDataString) or $getSubReportDataString!="")
                                     $table.=$getSubReportDataString;    
                             }
                            
                             
                             /* js("var tbl = document.getElementById('grid');
                                  var lastRow = tbl.rows.length;
                                  var iteration = lastRow;
                                  var row = tbl.insertRow(lastRow);
                                  var cellLeft = row.insertCell(0);
                                  var textNode = document.createTextNode(iteration);
                                  cellLeft.appendChild(textNode);
                                   var cellRight = row.insertCell(1);
                                  
                              "); */
                              
                           $table.="</table>";   
                           echo $table;
                           //aprint('tblResult',$table);
         }
        else
         {
             $noDatafoundTable='<center><table><tr><td class="left-side-text">No Data Found</td></tr></table></center>';
             //aprint('tblResult',$noDatafoundTable);   
              echo $noDatafoundTable;
             
         } 
                               
     
}    
 
 exit;  

?>
Return current item: MembersGear