I have this code below for VoIP PBX systems wich is looking in a database for a Call log. You can see the default search options here. I want to modify this search option like this, but i don't know how...
You have the php code HEREso if you can help me, I apreciate. thanks.
Help with php - sql code
Moderator: General Moderators
Welcome to the forums.
Please be advised, you will not find much help by saying "please look at this image, please read this 500 line PHP script and help figure my problem out for me".
You have two choices at this point.
You can hire someone to do this for you (in which case there is a forum section meant for that),
or
you can do some legwork, explain your problem in (much) more detail, and we can try to help you.
Please be advised, you will not find much help by saying "please look at this image, please read this 500 line PHP script and help figure my problem out for me".
You have two choices at this point.
You can hire someone to do this for you (in which case there is a forum section meant for that),
or
you can do some legwork, explain your problem in (much) more detail, and we can try to help you.
ok ...bdlang wrote:you can do some legwork, explain your problem in (much) more detail, and we can try to help you.
this code below is a search option from a database ... so this option is looking only for the recordings that I entered in "destination" field.
Now I want to search in the database after 3 "destination" fields. So, for exemple, if I enter 3800 in "destination 1", 3401 in "destination 2", and 3502 in "destination 3", to search only this recordings... and to display in "destination"column only the recordings with these numbers: 3800, 3401 and 3802.
How can I do this?
Code: Select all
<!-- ** ** ** ** ** Part for the research ** ** ** ** ** -->
<center>
<FORM METHOD=POST ACTION="<?php echo $_SERVER['PHP_SELF']?>?s=<?php echo $s?>&t=<?php echo $t?>&order=<?php echo $order?>&sens=<?php echo $sens?>¤t_page=<?php echo $current_page?>">
<INPUT TYPE="hidden" NAME="posted" value=1>
<INPUT TYPE="hidden" NAME="current_page" value=0>
<table class="bar-status" width="75%" border="0" cellspacing="1" cellpadding="2" align="center">
<tbody>
<tr>
<td class="bar-search" align="left" bgcolor="#555577">
<font face="verdana" size="1" color="#ffffff"><b> DESTINATION</b></font>
</td>
<td class="bar-search" align="left" bgcolor="#cddeff">
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td> <INPUT TYPE="text" NAME="dst" value="<?php echo $dst?>"></td>
<td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="dsttype" value="1" <?php if((!isset($dsttype))||($dsttype==1)){?>checked<?php }?>>Exact</td>
<td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="dsttype" value="2" <?php if($dsttype==2){?>checked<?php }?>>Begins with</td>
<td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="dsttype" value="3" <?php if($dsttype==3){?>checked<?php }?>>Contains</td>
<td class="bar-search" align="center" bgcolor="#cddeff"><input type="radio" NAME="dsttype" value="4" <?php if($dsttype==4){?>checked<?php }?>>Ends with</td>
</tr></table></td>
</tr>
Code: Select all
$FG_TABLE_COL[]=array ("Calldate", "calldate", "18%", "center", "SORT", "19");
$FG_TABLE_COL[]=array ("Channel", "channel", "13%", "center", "", "30", "", "", "", "", "", "display_acronym");
$FG_TABLE_COL[]=array ("Source", "src", "14%", "center", "", "30");
$FG_TABLE_COL[]=array ("Caller ID", "clid", "26%", "center", "", "80");
$FG_TABLE_COL[]=array ("Destination", "dst", "14%", "center", "SORT", "30");
$FG_TABLE_COL[]=array ("Disposition", "disposition", "9%", "center", "", "30");
if ((!isset($resulttype)) || ($resulttype=="min")) $minute_function= "display_minute";
$FG_TABLE_COL[]=array ("Duration", "duration", "6%", "center", "SORT", "30", "", "", "", "", "", "$minute_function");
$FG_TABLE_DEFAULT_ORDER = "calldate";
$FG_TABLE_DEFAULT_SENS = "DESC";
$FG_COL_QUERY='calldate, channel, src, clid, dst, disposition, duration';
$FG_LIMITE_DISPLAY=25;
$FG_NB_TABLE_COL=count($FG_TABLE_COL);
$FG_TOTAL_TABLE_COL = $FG_NB_TABLE_COL;
if ($FG_DELETION || $FG_EDITION) $FG_TOTAL_TABLE_COL++;
$FG_HTML_TABLE_TITLE=" - Call Logs - ";
$FG_HTML_TABLE_WIDTH="100%";
if ($FG_DEBUG == 3) echo "<br>Table : $FG_TABLE_NAME - Col_query : $FG_COL_QUERY";
$instance_table = new Table($FG_TABLE_NAME, $FG_COL_QUERY);
$instance_table_graph = new Table($FG_TABLE_NAME, $FG_COL_QUERY_GRAPH);
if ( is_null ($order) || is_null($sens) ){
$order = $FG_TABLE_DEFAULT_ORDER;
$sens = $FG_TABLE_DEFAULT_SENS;
}
if ($posted==1){
function do_field_duration($sql,$fld, $fldsql){
$fldtype = $fld.'type';
global $$fld;
global $$fldtype;
if (isset($$fld) && ($$fld!='')){
if (strpos($sql,'WHERE') > 0){
$sql = "$sql AND ";
}else{
$sql = "$sql WHERE ";
}
$sql = "$sql $fldsql";
if (isset ($$fldtype)){
switch ($$fldtype) {
case 1: $sql = "$sql ='".$$fld."'"; break;
case 2: $sql = "$sql <= '".$$fld."'"; break;
case 3: $sql = "$sql < '".$$fld."'"; break;
case 4: $sql = "$sql > '".$$fld."'"; break;
case 5: $sql = "$sql >= '".$$fld."'"; break;
}
}else{ $sql = "$sql = '".$$fld."'"; }
}
return $sql;
}
function do_field($sql,$fld){
$fldtype = $fld.'type';
global $$fld;
global $$fldtype;
if (isset($$fld) && ($$fld!='')){
if (strpos($sql,'WHERE') > 0){
$sql = "$sql AND ";
}else{
$sql = "$sql WHERE ";
}
$sql = "$sql $fld";
if (isset ($$fldtype)){
switch ($$fldtype) {
case 1: $sql = "$sql='".$$fld."'"; break;
case 2: $sql = "$sql LIKE '".$$fld."%'"; break;
case 3: $sql = "$sql LIKE '%".$$fld."%'"; break;
case 4: $sql = "$sql LIKE '%".$$fld."'";
}
}else{ $sql = "$sql LIKE '%".$$fld."%'"; }
}
return $sql;
}
$SQLcmd = '';
$SQLcmd = do_field($SQLcmd, 'clid');
$SQLcmd = do_field($SQLcmd, 'src');
$SQLcmd = do_field($SQLcmd, 'dst');
$SQLcmd = do_field($SQLcmd, 'channel');
$SQLcmd = do_field_duration($SQLcmd, 'duration1', 'duration');
$SQLcmd = do_field_duration($SQLcmd, 'duration2', 'duration');
}
$QUERY = "SELECT substring(calldate,1,10) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(calldate,1,10)"; //extract(DAY from calldate)
$res = $DBHandle -> query($QUERY);
$num = $res -> numRows();
for($i=0;$i<$num;$i++)
{
$list_total_day [] = $res -> fetchRow();
}
if ($FG_DEBUG == 3) echo "<br>Clause : $FG_TABLE_CLAUSE";
$nb_record = $instance_table -> Table_count ($FG_TABLE_CLAUSE);
}
if ($FG_DEBUG >= 1) var_dump ($list);
if ($nb_record<=$FG_LIMITE_DISPLAY){
$nb_record_max=1;
}else{
if ($nb_record % $FG_LIMITE_DISPLAY == 0){
$nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY));
}else{
$nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)+1);
}
}
if ($FG_DEBUG == 3) echo "<br>Nb_record : $nb_record";
if ($FG_DEBUG == 3) echo "<br>Nb_record_max : $nb_record_max";
?>