Changeset 976

Show
Ignore:
Timestamp:
08/26/08 08:31:08 (3 months ago)
Author:
areski
Message:

bug on call-daily if too many cards on the system !!!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/admin/Public/call-daily-load.php

    r777 r976  
    44include ("../lib/admin.smarty.php"); 
    55 
    6 if (! has_rights (ACX_CALL_REPORT)){  
     6if (! has_rights (ACX_CALL_REPORT)) {  
    77        Header ("HTTP/1.0 401 Unauthorized"); 
    88        Header ("Location: PP_error.php?c=accessdenied");           
     
    1111 
    1212 
    13  
    1413getpost_ifset(array('current_page', 'fromstatsday_sday', 'fromstatsmonth_sday', 'days_compare', 'min_call', 'posted',  'dsttype', 'srctype', 'clidtype', 'channel', 'resulttype', 'stitle', 'atmenu', 'current_page', 'order', 'sens', 'dst', 'src', 'clid', 'userfieldtype', 'userfield', 'accountcodetype', 'accountcode', 'customer', 'entercustomer','entertariffgroup' ,'enterprovider', 'entertrunk', 'enterratecard')); 
    1514 
    1615 
    17 if (!isset ($current_page) || ($current_page == "")){  
    18                $current_page=0;  
    19        
     16if (!isset ($current_page) || ($current_page == "")) {         
     17        $current_page=0;  
     18
    2019 
    2120// this variable specifie the debug type (0 => nothing, 1 => sql result, 2 => boucle checking, 3 other value checking) 
     
    2524$FG_TABLE_NAME="cc_call t1 LEFT OUTER JOIN cc_trunk t3 ON t1.id_trunk = t3.id_trunk"; 
    2625 
    27 if ($_SESSION["is_admin"]==0){ 
    28         //$FG_TABLE_NAME.=", cc_card t2"; 
    29 } 
    3026 
    3127// THIS VARIABLE DEFINE THE COLOR OF THE HEAD TABLE 
    3228$FG_TABLE_HEAD_COLOR = "#D1D9E7"; 
    33  
    34  
    3529$FG_TABLE_EXTERN_COLOR = "#7F99CC"; //#CC0033 (Rouge) 
    3630$FG_TABLE_INTERN_COLOR = "#EDF3FF"; //#FFEAFF (Rose) 
    37  
    38  
    39  
    40  
    4131// THIS VARIABLE DEFINE THE COLOR OF THE HEAD TABLE 
    4232$FG_TABLE_ALTERNATE_ROW_COLOR[] = "#FFFFFF"; 
     
    4434 
    4535 
    46  
    47 //$link = DbConnect(); 
    4836$DBHandle  = DbConnect(); 
    49  
    50 // The variable Var_col would define the col that we want show in your table 
    51 // First Name of the column in the html page, second name of the field 
    5237$FG_TABLE_COL = array(); 
    5338 
     
    5944 
    6045$FG_TABLE_COL[]=array (gettext("Calldate"), "starttime", "15%", "center", "SORT", "19", "", "", "", "", "", "display_dateformat"); 
    61 //$FG_TABLE_COL[]=array ("Callend", "stoptime", "15%", "center", "SORT", "19"); 
    62  
    63  
    64 //$FG_TABLE_COL[]=array ("Source", "source", "20%", "center", "SORT", "30"); 
    65  
    6646$FG_TABLE_COL[]=array (gettext("CalledNumber"), "calledstation", "15%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix"); 
    6747$FG_TABLE_COL[]=array (gettext("Destination"), "destination", "15%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix"); 
    68 //$FG_TABLE_COL[]=array ("Country",  "calledcountry", "10%", "center", "SORT", "30", "lie", "country", "countryname", "countrycode='%id'", "%1"); 
    69 //$FG_TABLE_COL[]=array ("Site", "site_id", "7%", "center", "sort", "15", "lie", "site", "name", "id='%id'", "%1"); 
    70  
    7148$FG_TABLE_COL[]=array (gettext("Duration"), "sessiontime", "7%", "center", "SORT", "30", "", "", "", "", "", "display_minute"); 
    72  
    7349$FG_TABLE_COL[]=array (gettext("CardUsed"), "username", "11%", "center", "SORT", "", "30", "", "", "", "", "linktocustomer"); 
    7450$FG_TABLE_COL[]=array (gettext("terminatecause"), "terminatecause", "10%", "center", "SORT", "30"); 
    7551$FG_TABLE_COL[]=array (gettext("IAX/SIP"), "sipiax", "6%", "center", "SORT",  "", "list", $yesno); 
    76 //$FG_TABLE_COL[]=array ("DestID", "destID", "12%", "center", "SORT", "30"); 
    77  
    78 //if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Con_charg", "connectcharge", "12%", "center", "SORT", "30"); 
    79 //if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Dis_charg", "disconnectcharge", "12%", "center", "SORT", "30"); 
    80 //if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Sec/mn", "secpermin", "12%", "center", "SORT", "30"); 
    81  
    82  
    83 //if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Buycosts", "buycosts", "12%", "center", "SORT", "30"); 
    8452$FG_TABLE_COL[]=array (gettext("InitialRate"), "calledrate", "10%", "center", "SORT", "30", "", "", "", "", "", "display_2dec"); 
    8553$FG_TABLE_COL[]=array (gettext("Cost"), "sessionbill", "10%", "center", "SORT", "30", "", "", "", "", "", "display_2bill"); 
     
    9462 
    9563$FG_COL_QUERY='t1.starttime, t1.calledstation, t1.destination, t1.sessiontime, t1.username, t1.terminatecause, t1.sipiax, t1.calledrate, t1.sessionbill'; 
    96 // t1.stoptime, 
    97  
    9864$FG_COL_QUERY_GRAPH='t1.starttime, t1.sessiontime'; 
    9965 
     
    11076$FG_TOTAL_TABLE_COL = $FG_NB_TABLE_COL; 
    11177if ($FG_DELETION || $FG_EDITION) $FG_TOTAL_TABLE_COL++; 
    112  
    11378//This variable define the Title of the HTML table 
    11479$FG_HTML_TABLE_TITLE= gettext(" - Call Logs - "); 
    115  
    11680//This variable define the width of the HTML table 
    11781$FG_HTML_TABLE_WIDTH="90%"; 
     
    12589 
    12690 
    127 if ( is_null ($order) || is_null($sens) )
     91if (is_null ($order) || is_null($sens))
    12892        $order = $FG_TABLE_DEFAULT_ORDER; 
    12993        $sens  = $FG_TABLE_DEFAULT_SENS; 
     
    13195 
    13296 
    133 if ($posted==1){ 
    134   $SQLcmd = ''; 
    135    
    136   //$SQLcmd = do_field($SQLcmd, 'src', 'source'); 
    137   $SQLcmd = do_field($SQLcmd, 'dst', 'calledstation'); 
    138   if ($_POST['before']) { 
    139     if (strpos($SQLcmd, 'WHERE') > 0) {         $SQLcmd = "$SQLcmd AND "; 
    140     }else{                                                              $SQLcmd = "$SQLcmd WHERE "; } 
    141     $SQLcmd = "$SQLcmd t1.starttime <'".$_POST['before']."'"; 
    142   } 
    143   if ($_POST['after']) {    if (strpos($SQLcmd, 'WHERE') > 0) {      $SQLcmd = "$SQLcmd AND "; 
    144   } else {      $SQLcmd = "$SQLcmd WHERE ";    } 
    145     $SQLcmd = "$SQLcmd t1.starttime >'".$_POST['after']."'"; 
    146   } 
    147    
    148 
    149  
    150  
    151 if (isset($customer)  &&  ($customer>0)){ 
     97if ($posted==1) { 
     98        $SQLcmd = ''; 
     99          
     100        //$SQLcmd = do_field($SQLcmd, 'src', 'source'); 
     101        $SQLcmd = do_field($SQLcmd, 'dst', 'calledstation'); 
     102        if ($_POST['before']) { 
     103                if (strpos($SQLcmd, 'WHERE') > 0) { 
     104                        $SQLcmd = "$SQLcmd AND "; 
     105                }else{ 
     106                        $SQLcmd = "$SQLcmd WHERE "; 
     107                } 
     108                $SQLcmd = "$SQLcmd t1.starttime <'".$_POST['before']."'"; 
     109        } 
     110        if ($_POST['after']) { 
     111                if (strpos($SQLcmd, 'WHERE') > 0) { 
     112                        $SQLcmd = "$SQLcmd AND "; 
     113                } else { 
     114                        $SQLcmd = "$SQLcmd WHERE "; 
     115                } 
     116                $SQLcmd = "$SQLcmd t1.starttime >'".$_POST['after']."'"; 
     117        } 
     118
     119 
     120 
     121if (isset($customer)  &&  ($customer>0)) { 
    152122        if (strlen($SQLcmd)>0) $SQLcmd.=" AND "; 
    153123        else $SQLcmd.=" WHERE "; 
    154124        $SQLcmd.=" username='$customer' "; 
    155 }else
    156         if (isset($entercustomer)  &&  ($entercustomer>0))
     125} else
     126        if (isset($entercustomer)  &&  ($entercustomer>0))
    157127                if (strlen($SQLcmd)>0) $SQLcmd.=" AND "; 
    158128                else $SQLcmd.=" WHERE "; 
     
    160130        } 
    161131} 
    162 if ($_SESSION["is_admin"] == 1) 
    163 
    164         if (isset($enterprovider) && $enterprovider > 0) { 
    165                 if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
    166                 $SQLcmd .= " t3.id_provider = '$enterprovider' "; 
    167         } 
    168         if (isset($entertrunk) && $entertrunk > 0) { 
    169                 if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
    170                 $SQLcmd .= " t3.id_trunk = '$entertrunk' "; 
    171         } 
    172                 if (isset($entertariffgroup) && $entertariffgroup > 0) { 
    173                         if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
    174                         $SQLcmd .= "t1.id_tariffgroup = '$entertariffgroup'"; 
    175                 } 
    176                 if (isset($enterratecard) && $enterratecard > 0) { 
    177                         if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
    178                         $SQLcmd .= "t1.id_ratecard = '$enterratecard'"; 
    179                 } 
    180          
     132if ($_SESSION["is_admin"] == 1) { 
     133    if (isset($enterprovider) && $enterprovider > 0) { 
     134        if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
     135        $SQLcmd .= " t3.id_provider = '$enterprovider' "; 
     136    } 
     137    if (isset($entertrunk) && $entertrunk > 0) { 
     138        if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
     139        $SQLcmd .= " t3.id_trunk = '$entertrunk' "; 
     140    } 
     141        if (isset($entertariffgroup) && $entertariffgroup > 0) { 
     142                if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
     143                $SQLcmd .= "t1.id_tariffgroup = '$entertariffgroup'"; 
     144        } 
     145        if (isset($enterratecard) && $enterratecard > 0) { 
     146                if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE "; 
     147                $SQLcmd .= "t1.id_ratecard = '$enterratecard'"; 
     148        } 
    181149} 
    182150 
    183151 
    184152$date_clause=''; 
    185 // Period (Month-Day) 
    186  
    187  
    188153if (!isset($fromstatsday_sday)){         
    189         $fromstatsday_sday = date("d"); 
    190         $fromstatsmonth_sday = date("Y-m");      
    191 
    192  
    193  
    194  
    195 //if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND calldate <= '$fromstatsmonth_sday-$fromstatsday_sday+23' AND calldate >= SUBDATE('$fromstatsmonth_sday-$fromstatsday_sday',INTERVAL $days_compare DAY)"; 
    196  
    197 if (DB_TYPE == "postgres"){      
    198         if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND t1.starttime < date'$fromstatsmonth_sday-$fromstatsday_sday'+ INTERVAL '1 DAY' AND t1.starttime >= date'$fromstatsmonth_sday-$fromstatsday_sday'"; 
    199 }else{ 
    200         if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND t1.starttime < ADDDATE('$fromstatsmonth_sday-$fromstatsday_sday',INTERVAL 1 DAY) AND t1.starttime >= '$fromstatsmonth_sday-$fromstatsday_sday'";   
     154        $fromstatsday_sday              = date("d"); 
     155        $fromstatsmonth_sday    = date("Y-m");   
     156
     157 
     158if (DB_TYPE == "postgres") {     
     159        if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday))  
     160                $date_clause.=" AND t1.starttime < date'$fromstatsmonth_sday-$fromstatsday_sday'+ INTERVAL '1 DAY' AND t1.starttime >= date'$fromstatsmonth_sday-$fromstatsday_sday'"; 
     161} else { 
     162        if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday))  
     163                $date_clause.=" AND t1.starttime < ADDDATE('$fromstatsmonth_sday-$fromstatsday_sday',INTERVAL 1 DAY) AND t1.starttime >= '$fromstatsmonth_sday-$fromstatsday_sday'";   
    201164} 
    202165 
    203166if ($FG_DEBUG == 3) echo "<br>$date_clause<br>"; 
    204  
    205167 
    206168   
    207169if (strpos($SQLcmd, 'WHERE') > 0) {  
    208170        $FG_TABLE_CLAUSE = substr($SQLcmd,6).$date_clause;  
    209 }elseif (strpos($date_clause, 'AND') > 0)
     171} elseif (strpos($date_clause, 'AND') > 0)
    210172        $FG_TABLE_CLAUSE = substr($date_clause,5);  
    211173} 
    212174 
    213 if ($_POST['posted']==1)
     175if ($_POST['posted']==1)
    214176        $list = $instance_table -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, $order, $sens, null, null, $FG_LIMITE_DISPLAY, $current_page*$FG_LIMITE_DISPLAY); 
    215          
    216177        $list_total = $instance_table_graph -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, null, null, null, null, null, null); 
    217178} 
     
    219180 
    220181if ($FG_DEBUG == 3) echo "<br>Clause : $FG_TABLE_CLAUSE"; 
    221 //$nb_record = $instance_table -> Table_count ($FG_TABLE_CLAUSE); 
    222182$nb_record = count($list_total); 
    223183if ($FG_DEBUG >= 1) var_dump ($list); 
     
    225185 
    226186 
    227 if ($nb_record<=$FG_LIMITE_DISPLAY){  
     187if ($nb_record<=$FG_LIMITE_DISPLAY) { 
    228188        $nb_record_max=1; 
    229 }else{  
     189} else {  
    230190        $nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)+1); 
    231191} 
     
    237197/*************************************************************/ 
    238198 
    239  
    240 $instance_table_customer = new Table("cc_card", "id,  username, lastname"); 
    241  
    242 $FG_TABLE_CLAUSE = ""; 
    243 /*if ($_SESSION["is_admin"]==0){         
    244         $FG_TABLE_CLAUSE =" IDmanager='".$_SESSION["pr_reseller_ID"]."'";        
    245 }*/ 
    246  
    247 $list_customer = $instance_table_customer -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, "id", "ASC", null, null, null, null); 
    248  
    249 $nb_customer = count($list_customer); 
    250  
    251 ?> 
    252  
    253 <?php 
    254         $smarty->display('main.tpl'); 
     199$smarty->display('main.tpl'); 
     200 
    255201?> 
    256202 
     
    547493</center> 
    548494 
    549 <?php  }else{ ?> 
     495<?php  } else { ?> 
    550496        <center><h3><?php echo gettext("No calls in your selection");?>.</h3></center> 
    551497<?php  } ?> 
    552498 
    553499<br><br> 
     500 
    554501<?php 
    555         $smarty->display('footer.tpl'); 
     502 
     503$smarty->display('footer.tpl'); 
     504 
    556505?> 


Google