$MT[0] = '';
    $row = '';
    $rowx = '';
    $channel_live = 1;
    if (strlen($conf_exten) < 1 || strlen($exten) < 1) {
        $channel_live = 0;
        echo "Conf Exten {$conf_exten} nie jest prawidłowy or Exten {$exten} nie jest prawidłowy\n";
        exit;
    } else {
        $stmt = "UPDATE conferences set extension='{$exten}' where server_ip = '{$server_ip}' and conf_exten = '{$conf_exten}';";
        if ($format == 'debug') {
            echo "\n<!-- {$stmt} -->";
        }
        $rslt = mysql_query($stmt, $link);
        if ($mel > 0) {
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '03013', $user, $server_ip, $session_name, $one_mysql_log);
        }
    }
    echo "Konferencja {$conf_exten} został zarejestrowany {$exten}\n";
}
if ($format == 'debug') {
    $ENDtime = date("U");
    $RUNtime = $ENDtime - $StarTtime;
    echo "\n<!-- czas działania skyptu: {$RUNtime} sekundy -->";
    echo "\n</body>\n</html>\n";
}
exit;
##### MySQL Error Logging #####
function mysql_error_logging($NOW_TIME, $link, $mel, $stmt, $query_id, $user, $server_ip, $session_name, $one_mysql_log)
{
    $NOW_TIME = date("Y-m-d H:i:s");
	echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n";
	$loop_count++;
	}

}


################################################################################
### CalLBacKCounT - send the count of the USERONLY callbacks for an agent
################################################################################
if ($ACTION == 'CalLBacKCounT')
{
$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='******' and campaign_id='$campaign' and status NOT IN('INACTIVE','DEAD');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
			if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00180',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$cbcount=$row[0];

echo "$cbcount";
}




if ($format=='debug') 
{
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtime);
echo "\n<!-- χρόνος εκτέλεσης: $RUNtime δευτερόλεπτα -->";
echo "\n</body>\n</html>\n";
Beispiel #3
0
 }
 if (strlen($D_s_ip[2]) < 3) {
     $D_s_ip[2] = "0{$D_s_ip['2']}";
 }
 if (strlen($D_s_ip[3]) < 2) {
     $D_s_ip[3] = "0{$D_s_ip['3']}";
 }
 if (strlen($D_s_ip[3]) < 3) {
     $D_s_ip[3] = "0{$D_s_ip['3']}";
 }
 $server_ip_dialstring = "{$D_s_ip['0']}{$S}{$D_s_ip['1']}{$S}{$D_s_ip['2']}{$S}{$D_s_ip['3']}{$S}";
 ##### grab the datails of all active scripts in the system
 $stmt = "SELECT script_id,script_name FROM vicidial_scripts WHERE active='Y' order by script_id limit 1000;";
 $rslt = mysql_query($stmt, $link);
 if ($mel > 0) {
     mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '01051', $VD_login, $server_ip, $session_name, $one_mysql_log);
 }
 if ($DB) {
     echo "{$stmt}\n";
 }
 $MM_scripts = mysql_num_rows($rslt);
 $e = 0;
 while ($e < $MM_scripts) {
     $row = mysql_fetch_row($rslt);
     $MMscriptid[$e] = $row[0];
     $MMscriptname[$e] = urlencode($row[1]);
     $MMscriptids = "{$MMscriptids}'{$MMscriptid[$e]}',";
     $MMscriptnames = "{$MMscriptnames}'{$MMscriptname[$e]}',";
     $e++;
 }
 $MMscriptids = substr("{$MMscriptids}", 0, -1);
Beispiel #4
0
function custom_list_fields_values($lead_id, $list_id, $uniqueid, $user)
{
    $STARTtime = date("U");
    $TODAY = date("Y-m-d");
    $NOW_TIME = date("Y-m-d H:i:s");
    $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|';
    require "dbconnect.php";
    $CFoutput = '';
    $stmt = "SHOW TABLES LIKE \"custom_{$list_id}\";";
    if ($DB > 0) {
        echo "{$stmt}";
    }
    $rslt = mysql_query($stmt, $link);
    if ($mel > 0) {
        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05002', $user, $server_ip, $session_name, $one_mysql_log);
    }
    $tablecount_to_print = mysql_num_rows($rslt);
    if ($tablecount_to_print > 0) {
        $stmt = "SELECT count(*) from custom_{$list_id};";
        if ($DB > 0) {
            echo "{$stmt}";
        }
        $rslt = mysql_query($stmt, $link);
        if ($mel > 0) {
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05003', $user, $server_ip, $session_name, $one_mysql_log);
        }
        $fieldscount_to_print = mysql_num_rows($rslt);
        if ($fieldscount_to_print > 0) {
            $rowx = mysql_fetch_row($rslt);
            $custom_records_count = $rowx[0];
            $select_SQL = '';
            $stmt = "SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='{$list_id}' order by field_rank,field_order,field_label;";
            $rslt = mysql_query($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05004', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $fields_to_print = mysql_num_rows($rslt);
            $fields_list = '';
            $o = 0;
            while ($fields_to_print > $o) {
                $rowx = mysql_fetch_row($rslt);
                $A_field_id[$o] = $rowx[0];
                $A_field_label[$o] = $rowx[1];
                $A_field_name[$o] = $rowx[2];
                $A_field_description[$o] = $rowx[3];
                $A_field_rank[$o] = $rowx[4];
                $A_field_help[$o] = $rowx[5];
                $A_field_type[$o] = $rowx[6];
                $A_field_options[$o] = $rowx[7];
                $A_field_size[$o] = $rowx[8];
                $A_field_max[$o] = $rowx[9];
                $A_field_default[$o] = $rowx[10];
                $A_field_cost[$o] = $rowx[11];
                $A_field_required[$o] = $rowx[12];
                $A_multi_position[$o] = $rowx[13];
                $A_name_position[$o] = $rowx[14];
                $A_field_order[$o] = $rowx[15];
                $A_field_value[$o] = '';
                if (!preg_match("/\\|{$A_field_label[$o]}\\|/", $vicidial_list_fields)) {
                    if ($A_field_type[$o] == 'DISPLAY' or $A_field_type[$o] == 'SCRIPT') {
                        $select_SQL .= "8,";
                        $A_field_select[$o] = '----EMPTY----';
                    } else {
                        $select_SQL .= "{$A_field_label[$o]},";
                        $A_field_select[$o] = $A_field_label[$o];
                    }
                } else {
                    $select_SQL .= "8,";
                    $A_field_value[$o] = '--A--' . $A_field_label[$o] . '--B--';
                }
                $o++;
                $rank_select .= "<option>{$o}</option>";
            }
            $o++;
            $rank_select .= "<option>{$o}</option>";
            $last_rank = $o;
            $select_SQL = preg_replace("/.\$/", '', $select_SQL);
            $list_lead_ct = 0;
            if (strlen($select_SQL) > 0) {
                ##### BEGIN grab the data from custom table for the lead_id
                $stmt = "SELECT {$select_SQL} FROM custom_{$list_id} where lead_id='{$lead_id}' LIMIT 1;";
                $rslt = mysql_query($stmt, $link);
                if ($mel > 0) {
                    mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05005', $user, $server_ip, $session_name, $one_mysql_log);
                }
                if ($DB) {
                    echo "{$stmt}\n";
                }
                $list_lead_ct = mysql_num_rows($rslt);
            }
            if ($list_lead_ct > 0) {
                $row = mysql_fetch_row($rslt);
                $o = 0;
                while ($fields_to_print >= $o) {
                    $A_field_value[$o] = trim("{$row[$o]}");
                    if ($A_field_select[$o] == '----EMPTY----') {
                        $A_field_value[$o] = '';
                    }
                    if (preg_match("/\\|{$A_field_label[$o]}\\|/", $vicidial_list_fields)) {
                        $A_field_value[$o] = '--A--' . $A_field_label[$o] . '--B--';
                    }
                    $o++;
                }
            } else {
                if ($DB) {
                    echo "ERROR: no custom data for this lead: {$lead_id}\n";
                }
            }
            ##### END grab the data from custom table for the lead_id
            $CFoutput .= "<input type=hidden name=stage id=stage value=\"SUBMIT\">\n";
            $CFoutput .= "<center><TABLE cellspacing=2 cellpadding=2>\n";
            if ($fields_to_print < 1) {
                $CFoutput .= "<tr bgcolor=white align=center><td colspan=4><font size=1>There are no custom fields for this list</td></tr>";
            }
            $o = 0;
            $last_field_rank = 0;
            while ($fields_to_print > $o) {
                $helpHTML = '';
                if (strlen($A_field_help[$o]) > 0) {
                    $helpHTML = "&nbsp; <a href=\"javascript:open_help('HELP_{$A_field_label[$o]}','{$A_field_help[$o]}');\">help+</a>";
                }
                if ($last_field_rank == "{$A_field_rank[$o]}") {
                    $CFoutput .= " &nbsp; &nbsp; &nbsp; &nbsp; ";
                } else {
                    $CFoutput .= "</td></tr>\n";
                    $CFoutput .= "<tr bgcolor=white><td align=";
                    if ($A_name_position[$o] == 'TOP' or $A_field_type[$o] == 'SCRIPT') {
                        $CFoutput .= "left colspan=2";
                    } else {
                        $CFoutput .= "right";
                    }
                    $CFoutput .= "><font size=2>";
                }
                if ($A_field_type[$o] != 'SCRIPT' and $A_field_type[$o] != 'HIDDEN') {
                    $CFoutput .= "<B>{$A_field_name[$o]}</B>";
                }
                if ($A_name_position[$o] == 'TOP' or $A_field_type[$o] == 'SCRIPT') {
                    $CFoutput .= " &nbsp; <span style=\"position:static;\" id=P_HELP_{$A_field_label[$o]}></span><span style=\"position:static;background:white;\" id=HELP_{$A_field_label[$o]}> {$helpHTML}</span><BR>";
                } else {
                    if ($last_field_rank == "{$A_field_rank[$o]}") {
                        $CFoutput .= " &nbsp;";
                    } else {
                        $CFoutput .= "</td><td align=left><font size=2>";
                    }
                }
                $field_HTML = '';
                if ($A_field_type[$o] == 'SELECT') {
                    $field_HTML .= "<select size=1 name={$A_field_label[$o]} id={$A_field_label[$o]}>\n";
                }
                if ($A_field_type[$o] == 'MULTI') {
                    $field_HTML .= "<select MULTIPLE size={$A_field_size[$o]} name={$A_field_label[$o]}[] id={$A_field_label[$o]}[]>\n";
                }
                if ($A_field_type[$o] == 'SELECT' or $A_field_type[$o] == 'MULTI' or $A_field_type[$o] == 'RADIO' or $A_field_type[$o] == 'CHECKBOX') {
                    $field_options_array = explode("\n", $A_field_options[$o]);
                    $field_options_count = count($field_options_array);
                    $te = 0;
                    while ($te < $field_options_count) {
                        if (preg_match("/,/", $field_options_array[$te])) {
                            $field_selected = '';
                            $field_options_value_array = explode(",", $field_options_array[$te]);
                            if ($A_field_type[$o] == 'SELECT' or $A_field_type[$o] == 'MULTI') {
                                if (strlen($A_field_value[$o]) > 0) {
                                    if (preg_match("/{$field_options_value_array['0']}/", $A_field_value[$o])) {
                                        $field_selected = 'SELECTED';
                                    }
                                } else {
                                    if ($A_field_default[$o] == "{$field_options_value_array['0']}") {
                                        $field_selected = 'SELECTED';
                                    }
                                }
                                $field_HTML .= "<option value=\"{$field_options_value_array['0']}\" {$field_selected}>{$field_options_value_array['1']}</option>\n";
                            }
                            if ($A_field_type[$o] == 'RADIO' or $A_field_type[$o] == 'CHECKBOX') {
                                if ($A_multi_position[$o] == 'VERTICAL') {
                                    $field_HTML .= " &nbsp; ";
                                }
                                if (strlen($A_field_value[$o]) > 0) {
                                    if (preg_match("/{$field_options_value_array['0']}/", $A_field_value[$o])) {
                                        $field_selected = 'CHECKED';
                                    }
                                } else {
                                    if ($A_field_default[$o] == "{$field_options_value_array['0']}") {
                                        $field_selected = 'CHECKED';
                                    }
                                }
                                $field_HTML .= "<input type={$A_field_type[$o]} name={$A_field_label[$o]}[] id={$A_field_label[$o]}[] value=\"{$field_options_value_array['0']}\" {$field_selected}> {$field_options_value_array['1']}\n";
                                if ($A_multi_position[$o] == 'VERTICAL') {
                                    $field_HTML .= "<BR>\n";
                                }
                            }
                        }
                        $te++;
                    }
                }
                if ($A_field_type[$o] == 'SELECT' or $A_field_type[$o] == 'MULTI') {
                    $field_HTML .= "</select>\n";
                }
                if ($A_field_type[$o] == 'TEXT') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    $field_HTML .= "<input type=text size={$A_field_size[$o]} maxlength={$A_field_max[$o]} name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$A_field_value[$o]}\">\n";
                }
                if ($A_field_type[$o] == 'AREA') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    $field_HTML .= "<textarea name={$A_field_label[$o]} id={$A_field_label[$o]} ROWS={$A_field_max[$o]} COLS={$A_field_size[$o]}>{$A_field_value[$o]}</textarea>";
                }
                if ($A_field_type[$o] == 'DISPLAY') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= "{$A_field_default[$o]}\n";
                }
                if ($A_field_type[$o] == 'READONLY') {
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= "<input type=hidden name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$A_field_value[$o]}\"> {$A_field_value[$o]}\n";
                }
                if ($A_field_type[$o] == 'HIDDEN') {
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= "<input type=hidden name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$A_field_value[$o]}\">\n";
                }
                if ($A_field_type[$o] == 'SCRIPT') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= "{$A_field_options[$o]}\n";
                }
                if ($A_field_type[$o] == 'DATE') {
                    if (strlen($A_field_default[$o]) < 1 or $A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = 0;
                    }
                    $day_diff = $A_field_default[$o];
                    $default_date = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("d") + $day_diff, date("Y")));
                    if (strlen($A_field_value[$o]) > 0) {
                        $default_date = $A_field_value[$o];
                    }
                    $field_HTML .= "<input type=text size=11 maxlength=10 name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$default_date}\" onclick=\"f_tcalToggle()\">\n";
                    $field_HTML .= "<script language=\"JavaScript\">\n";
                    $field_HTML .= "var o_cal = new tcal ({\n";
                    $field_HTML .= "\t'formname': 'form_custom_fields',\n";
                    $field_HTML .= "\t'controlname': '{$A_field_label[$o]}'});\n";
                    $field_HTML .= "o_cal.a_tpl.yearscroll = false;\n";
                    $field_HTML .= "</script>\n";
                }
                if ($A_field_type[$o] == 'TIME') {
                    $minute_diff = $A_field_default[$o];
                    $default_time = date("H:i:s", mktime(date("H"), date("i") + $minute_diff, date("s"), date("m"), date("d"), date("Y")));
                    $default_hour = date("H", mktime(date("H"), date("i") + $minute_diff, date("s"), date("m"), date("d"), date("Y")));
                    $default_minute = date("i", mktime(date("H"), date("i") + $minute_diff, date("s"), date("m"), date("d"), date("Y")));
                    if (strlen($A_field_value[$o]) > 2) {
                        $default_time = $A_field_value[$o];
                        $time_field_value = explode(':', $default_time);
                        $default_hour = $time_field_value[0];
                        $default_minute = $time_field_value[1];
                    }
                    $field_HTML .= "<input type=hidden name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$default_time}\">";
                    $field_HTML .= "<SELECT name=HOUR_{$A_field_label[$o]} id=HOUR_{$A_field_label[$o]}>";
                    $field_HTML .= "<option>00</option>";
                    $field_HTML .= "<option>01</option>";
                    $field_HTML .= "<option>02</option>";
                    $field_HTML .= "<option>03</option>";
                    $field_HTML .= "<option>04</option>";
                    $field_HTML .= "<option>05</option>";
                    $field_HTML .= "<option>06</option>";
                    $field_HTML .= "<option>07</option>";
                    $field_HTML .= "<option>08</option>";
                    $field_HTML .= "<option>09</option>";
                    $field_HTML .= "<option>10</option>";
                    $field_HTML .= "<option>11</option>";
                    $field_HTML .= "<option>12</option>";
                    $field_HTML .= "<option>13</option>";
                    $field_HTML .= "<option>14</option>";
                    $field_HTML .= "<option>15</option>";
                    $field_HTML .= "<option>16</option>";
                    $field_HTML .= "<option>17</option>";
                    $field_HTML .= "<option>18</option>";
                    $field_HTML .= "<option>19</option>";
                    $field_HTML .= "<option>20</option>";
                    $field_HTML .= "<option>21</option>";
                    $field_HTML .= "<option>22</option>";
                    $field_HTML .= "<option>23</option>";
                    $field_HTML .= "<OPTION value=\"{$default_hour}\" selected>{$default_hour}</OPTION>";
                    $field_HTML .= "</SELECT>";
                    $field_HTML .= "<SELECT name=MINUTE_{$A_field_label[$o]} id=MINUTE_{$A_field_label[$o]}>";
                    $field_HTML .= "<option>00</option>";
                    $field_HTML .= "<option>05</option>";
                    $field_HTML .= "<option>10</option>";
                    $field_HTML .= "<option>15</option>";
                    $field_HTML .= "<option>20</option>";
                    $field_HTML .= "<option>25</option>";
                    $field_HTML .= "<option>30</option>";
                    $field_HTML .= "<option>35</option>";
                    $field_HTML .= "<option>40</option>";
                    $field_HTML .= "<option>45</option>";
                    $field_HTML .= "<option>50</option>";
                    $field_HTML .= "<option>55</option>";
                    $field_HTML .= "<OPTION value=\"{$default_minute}\" selected>{$default_minute}</OPTION>";
                    $field_HTML .= "</SELECT>";
                }
                if ($A_name_position[$o] == 'LEFT' and $A_field_type[$o] != 'SCRIPT' and $A_field_type[$o] != 'HIDDEN') {
                    $CFoutput .= " {$field_HTML} <span style=\"position:static;\" id=P_HELP_{$A_field_label[$o]}></span><span style=\"position:static;background:white;\" id=HELP_{$A_field_label[$o]}> {$helpHTML}</span>";
                } else {
                    $CFoutput .= " {$field_HTML}\n";
                }
                $last_field_rank = $A_field_rank[$o];
                $o++;
            }
            $CFoutput .= "</td></tr></table>\n";
        } else {
            $CFoutput .= "ERROR: no custom list fields\n";
        }
    } else {
        $CFoutput .= "ERROR: no custom list fields table\n";
    }
    ##### BEGIN parsing for vicidial variables #####
    if (preg_match("/--A--/", $CFoutput)) {
        if (eregi('--A--user_custom_', $CFoutput) or eregi('--A--fullname', $CFoutput)) {
            $stmt = "select custom_one,custom_two,custom_three,custom_four,custom_five,full_name from vicidial_users where user='******';";
            if ($DB) {
                echo "{$stmt}\n";
            }
            $rslt = mysql_query($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05006', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $VUC_ct = mysql_num_rows($rslt);
            if ($VUC_ct > 0) {
                $row = mysql_fetch_row($rslt);
                $user_custom_one = trim($row[0]);
                $user_custom_two = trim($row[1]);
                $user_custom_three = trim($row[2]);
                $user_custom_four = trim($row[3]);
                $user_custom_five = trim($row[4]);
                $fullname = trim($row[5]);
            }
        }
        if (eregi('--A--dialed_', $CFoutput)) {
            $dialed_number = $phone_number;
            $dialed_label = 'NONE';
            ### find the dialed number and label for this call
            $stmt = "SELECT phone_number,alt_dial from vicidial_log where uniqueid='{$uniqueid}';";
            if ($DB) {
                echo "{$stmt}\n";
            }
            $rslt = mysql_query($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05008', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $vl_dialed_ct = mysql_num_rows($rslt);
            if ($vl_dialed_ct > 0) {
                $row = mysql_fetch_row($rslt);
                $dialed_number = $row[0];
                $dialed_label = $row[1];
            }
        }
        ##### grab the data from vicidial_list for the lead_id
        $stmt = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='{$lead_id}' LIMIT 1;";
        $rslt = mysql_query($stmt, $link);
        if ($mel > 0) {
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05007', $user, $server_ip, $session_name, $one_mysql_log);
        }
        if ($DB) {
            echo "{$stmt}\n";
        }
        $list_lead_ct = mysql_num_rows($rslt);
        if ($list_lead_ct > 0) {
            $row = mysql_fetch_row($rslt);
            $dispo = trim($row[3]);
            $tsr = trim($row[4]);
            $vendor_id = trim($row[5]);
            $vendor_lead_code = trim($row[5]);
            $source_id = trim($row[6]);
            $list_id = trim($row[7]);
            $gmt_offset_now = trim($row[8]);
            $phone_code = trim($row[10]);
            $phone_number = trim($row[11]);
            $title = trim($row[12]);
            $first_name = trim($row[13]);
            $middle_initial = trim($row[14]);
            $last_name = trim($row[15]);
            $address1 = trim($row[16]);
            $address2 = trim($row[17]);
            $address3 = trim($row[18]);
            $city = trim($row[19]);
            $state = trim($row[20]);
            $province = trim($row[21]);
            $postal_code = trim($row[22]);
            $country_code = trim($row[23]);
            $gender = trim($row[24]);
            $date_of_birth = trim($row[25]);
            $alt_phone = trim($row[26]);
            $email = trim($row[27]);
            $security = trim($row[28]);
            $comments = trim($row[29]);
            $called_count = trim($row[30]);
            $rank = trim($row[32]);
            $owner = trim($row[33]);
        }
        $CFoutput = eregi_replace('--A--lead_id--B--', "{$lead_id}", $CFoutput);
        $CFoutput = eregi_replace('--A--vendor_id--B--', "{$vendor_id}", $CFoutput);
        $CFoutput = eregi_replace('--A--vendor_lead_code--B--', "{$vendor_lead_code}", $CFoutput);
        $CFoutput = eregi_replace('--A--list_id--B--', "{$list_id}", $CFoutput);
        $CFoutput = eregi_replace('--A--gmt_offset_now--B--', "{$gmt_offset_now}", $CFoutput);
        $CFoutput = eregi_replace('--A--phone_code--B--', "{$phone_code}", $CFoutput);
        $CFoutput = eregi_replace('--A--phone_number--B--', "{$phone_number}", $CFoutput);
        $CFoutput = eregi_replace('--A--title--B--', "{$title}", $CFoutput);
        $CFoutput = eregi_replace('--A--first_name--B--', "{$first_name}", $CFoutput);
        $CFoutput = eregi_replace('--A--middle_initial--B--', "{$middle_initial}", $CFoutput);
        $CFoutput = eregi_replace('--A--last_name--B--', "{$last_name}", $CFoutput);
        $CFoutput = eregi_replace('--A--address1--B--', "{$address1}", $CFoutput);
        $CFoutput = eregi_replace('--A--address2--B--', "{$address2}", $CFoutput);
        $CFoutput = eregi_replace('--A--address3--B--', "{$address3}", $CFoutput);
        $CFoutput = eregi_replace('--A--city--B--', "{$city}", $CFoutput);
        $CFoutput = eregi_replace('--A--state--B--', "{$state}", $CFoutput);
        $CFoutput = eregi_replace('--A--province--B--', "{$province}", $CFoutput);
        $CFoutput = eregi_replace('--A--postal_code--B--', "{$postal_code}", $CFoutput);
        $CFoutput = eregi_replace('--A--country_code--B--', "{$country_code}", $CFoutput);
        $CFoutput = eregi_replace('--A--gender--B--', "{$gender}", $CFoutput);
        $CFoutput = eregi_replace('--A--date_of_birth--B--', "{$date_of_birth}", $CFoutput);
        $CFoutput = eregi_replace('--A--alt_phone--B--', "{$alt_phone}", $CFoutput);
        $CFoutput = eregi_replace('--A--email--B--', "{$email}", $CFoutput);
        $CFoutput = eregi_replace('--A--security_phrase--B--', "{$security_phrase}", $CFoutput);
        $CFoutput = eregi_replace('--A--comments--B--', "{$comments}", $CFoutput);
        $CFoutput = eregi_replace('--A--user--B--', "{$user}", $CFoutput);
        $CFoutput = eregi_replace('--A--pass--B--', "{$pass}", $CFoutput);
        $CFoutput = eregi_replace('--A--campaign--B--', "{$campaign}", $CFoutput);
        $CFoutput = eregi_replace('--A--server_ip--B--', "{$server_ip}", $CFoutput);
        $CFoutput = eregi_replace('--A--session_id--B--', "{$session_id}", $CFoutput);
        $CFoutput = eregi_replace('--A--dialed_number--B--', "{$dialed_number}", $CFoutput);
        $CFoutput = eregi_replace('--A--dialed_label--B--', "{$dialed_label}", $CFoutput);
        $CFoutput = eregi_replace('--A--source_id--B--', "{$source_id}", $CFoutput);
        $CFoutput = eregi_replace('--A--rank--B--', "{$rank}", $CFoutput);
        $CFoutput = eregi_replace('--A--owner--B--', "{$owner}", $CFoutput);
        $CFoutput = eregi_replace('--A--fullname--B--', "{$fullname}", $CFoutput);
        $CFoutput = eregi_replace('--A--uniqueid--B--', "{$uniqueid}", $CFoutput);
        $CFoutput = eregi_replace('--A--user_custom_one--B--', "{$user_custom_one}", $CFoutput);
        $CFoutput = eregi_replace('--A--user_custom_two--B--', "{$user_custom_two}", $CFoutput);
        $CFoutput = eregi_replace('--A--user_custom_three--B--', "{$user_custom_three}", $CFoutput);
        $CFoutput = eregi_replace('--A--user_custom_four--B--', "{$user_custom_four}", $CFoutput);
        $CFoutput = eregi_replace('--A--user_custom_five--B--', "{$user_custom_five}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_number_a--B--', "{$preset_number_a}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_number_b--B--', "{$preset_number_b}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_number_c--B--', "{$preset_number_c}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_number_d--B--', "{$preset_number_d}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_number_e--B--', "{$preset_number_e}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_dtmf_a--B--', "{$preset_dtmf_a}", $CFoutput);
        $CFoutput = eregi_replace('--A--preset_dtmf_b--B--', "{$preset_dtmf_b}", $CFoutput);
        $CFoutput = eregi_replace('--A--did_id--B--', "{$did_id}", $CFoutput);
        $CFoutput = eregi_replace('--A--did_extension--B--', "{$did_extension}", $CFoutput);
        $CFoutput = eregi_replace('--A--did_pattern--B--', "{$did_pattern}", $CFoutput);
        $CFoutput = eregi_replace('--A--did_description--B--', "{$did_description}", $CFoutput);
        $CFoutput = eregi_replace('--A--closecallid--B--', "{$closecallid}", $CFoutput);
        $CFoutput = eregi_replace('--A--xfercallid--B--', "{$xfercallid}", $CFoutput);
        $CFoutput = eregi_replace('--A--agent_log_id--B--', "{$agent_log_id}", $CFoutput);
        # custom fields replacement
        $o = 0;
        while ($fields_to_print > $o) {
            $CFoutput = eregi_replace("--A--{$A_field_label[$o]}--B--", "{$A_field_value[$o]}", $CFoutput);
            $o++;
        }
        if ($DB > 0) {
            echo "{$CFoutput}<BR>\n";
        }
    }
    ##### END parsing for vicidial variables #####
    return $CFoutput;
}
function custom_list_fields_values($lead_id, $list_id, $uniqueid, $user)
{
    $STARTtime = date("U");
    $TODAY = date("Y-m-d");
    $NOW_TIME = date("Y-m-d H:i:s");
    $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|';
    require "dbconnect_mysqli.php";
    $CFoutput = '';
    $stmt = "SHOW TABLES LIKE \"custom_{$list_id}\";";
    if ($non_latin > 0) {
        $rslt = mysql_to_mysqli("SET NAMES 'UTF8'", $link);
    }
    if ($DB > 0) {
        echo "{$stmt}";
    }
    $rslt = mysql_to_mysqli($stmt, $link);
    if ($mel > 0) {
        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05002', $user, $server_ip, $session_name, $one_mysql_log);
    }
    $tablecount_to_print = mysqli_num_rows($rslt);
    if ($tablecount_to_print > 0) {
        $stmt = "SELECT count(*) from custom_{$list_id};";
        if ($DB > 0) {
            echo "{$stmt}";
        }
        $rslt = mysql_to_mysqli($stmt, $link);
        if ($mel > 0) {
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05003', $user, $server_ip, $session_name, $one_mysql_log);
        }
        $fieldscount_to_print = mysqli_num_rows($rslt);
        if ($fieldscount_to_print > 0) {
            $rowx = mysqli_fetch_row($rslt);
            $custom_records_count = $rowx[0];
            $select_SQL = '';
            $stmt = "SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='{$list_id}' order by field_rank,field_order,field_label;";
            $rslt = mysql_to_mysqli($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05004', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $fields_to_print = mysqli_num_rows($rslt);
            $fields_list = '';
            $o = 0;
            while ($fields_to_print > $o) {
                $rowx = mysqli_fetch_row($rslt);
                $A_field_id[$o] = $rowx[0];
                $A_field_label[$o] = $rowx[1];
                $A_field_name[$o] = $rowx[2];
                $A_field_description[$o] = $rowx[3];
                $A_field_rank[$o] = $rowx[4];
                $A_field_help[$o] = $rowx[5];
                $A_field_type[$o] = $rowx[6];
                $A_field_options[$o] = $rowx[7];
                $A_field_size[$o] = $rowx[8];
                $A_field_max[$o] = $rowx[9];
                $A_field_default[$o] = $rowx[10];
                $A_field_cost[$o] = $rowx[11];
                $A_field_required[$o] = $rowx[12];
                $A_multi_position[$o] = $rowx[13];
                $A_name_position[$o] = $rowx[14];
                $A_field_order[$o] = $rowx[15];
                $A_field_value[$o] = '';
                if (!preg_match("/\\|{$A_field_label[$o]}\\|/i", $vicidial_list_fields)) {
                    if ($A_field_type[$o] == 'DISPLAY' or $A_field_type[$o] == 'SCRIPT') {
                        $select_SQL .= "8,";
                        $A_field_select[$o] = '----EMPTY----';
                    } else {
                        $select_SQL .= "{$A_field_label[$o]},";
                        $A_field_select[$o] = $A_field_label[$o];
                    }
                } else {
                    $select_SQL .= "8,";
                    $A_field_value[$o] = '--A--' . $A_field_label[$o] . '--B--';
                }
                $o++;
                $rank_select .= "<option>{$o}</option>";
            }
            $o++;
            $rank_select .= "<option>{$o}</option>";
            $last_rank = $o;
            $select_SQL = preg_replace("/.\$/", '', $select_SQL);
            $list_lead_ct = 0;
            if (strlen($select_SQL) > 0) {
                ##### BEGIN grab the data from custom table for the lead_id
                $stmt = "SELECT {$select_SQL} FROM custom_{$list_id} where lead_id='{$lead_id}' LIMIT 1;";
                $rslt = mysql_to_mysqli($stmt, $link);
                if ($mel > 0) {
                    mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05005', $user, $server_ip, $session_name, $one_mysql_log);
                }
                if ($DB) {
                    echo "{$stmt}\n";
                }
                $list_lead_ct = mysqli_num_rows($rslt);
            }
            if ($list_lead_ct > 0) {
                $row = mysqli_fetch_row($rslt);
                $o = 0;
                while ($fields_to_print >= $o) {
                    $A_field_value[$o] = trim("{$row[$o]}");
                    if ($A_field_select[$o] == '----EMPTY----') {
                        $A_field_value[$o] = '';
                    }
                    if (preg_match("/\\|{$A_field_label[$o]}\\|/i", $vicidial_list_fields)) {
                        $A_field_value[$o] = '--A--' . $A_field_label[$o] . '--B--';
                    }
                    $o++;
                }
            } else {
                if ($DB) {
                    echo _QXZ("ERROR: no custom data for this lead: ") . "{$lead_id}\n";
                }
            }
            ##### END grab the data from custom table for the lead_id
            $CFoutput .= "<input type=hidden name=stage id=stage value=\"SUBMIT\">\n";
            $CFoutput .= "<center><TABLE cellspacing=2 cellpadding=2>\n";
            if ($fields_to_print < 1) {
                $CFoutput .= "<tr bgcolor=white align=center><td colspan=4><font size=1>" . _QXZ("There are no custom fields for this list") . "</td></tr>";
            }
            $o = 0;
            $last_field_rank = 0;
            while ($fields_to_print > $o) {
                $helpHTML = '';
                if (strlen($A_field_help[$o]) > 0) {
                    $helpHTML = "&nbsp; <a href=\"javascript:open_help('HELP_{$A_field_label[$o]}','{$A_field_help[$o]}');\">" . _QXZ("help") . "+</a>";
                }
                if ($last_field_rank == "{$A_field_rank[$o]}") {
                    $CFoutput .= " &nbsp; &nbsp; &nbsp; &nbsp; ";
                } else {
                    $CFoutput .= "</td></tr>\n";
                    $CFoutput .= "<tr bgcolor=white><td align=";
                    if ($A_name_position[$o] == 'TOP' or $A_field_type[$o] == 'SCRIPT') {
                        $CFoutput .= "left colspan=2";
                    } else {
                        $CFoutput .= "right";
                    }
                    $CFoutput .= "><font size=2>";
                }
                if ($A_field_type[$o] != 'SCRIPT' and $A_field_type[$o] != 'HIDDEN' and $A_field_type[$o] != 'HIDEBLOB') {
                    $CFoutput .= "<B>{$A_field_name[$o]}</B>";
                }
                if ($A_name_position[$o] == 'TOP' or $A_field_type[$o] == 'SCRIPT') {
                    $CFoutput .= " &nbsp; <span style=\"position:static;\" id=P_HELP_{$A_field_label[$o]}></span><span style=\"position:static;background:white;\" id=HELP_{$A_field_label[$o]}> {$helpHTML}</span><BR>";
                } else {
                    if ($last_field_rank == "{$A_field_rank[$o]}") {
                        $CFoutput .= " &nbsp;";
                    } else {
                        $CFoutput .= "</td><td align=left><font size=2>";
                    }
                }
                $field_HTML = '';
                if ($A_field_type[$o] == 'SELECT') {
                    $field_HTML .= "<select size=1 name={$A_field_label[$o]} id={$A_field_label[$o]}>\n";
                }
                if ($A_field_type[$o] == 'MULTI') {
                    $field_HTML .= "<select MULTIPLE size={$A_field_size[$o]} name={$A_field_label[$o]}[] id={$A_field_label[$o]}[]>\n";
                }
                if ($A_field_type[$o] == 'SELECT' or $A_field_type[$o] == 'MULTI' or $A_field_type[$o] == 'RADIO' or $A_field_type[$o] == 'CHECKBOX') {
                    $field_options_array = explode("\n", $A_field_options[$o]);
                    $field_options_count = count($field_options_array);
                    $te = 0;
                    while ($te < $field_options_count) {
                        if (preg_match("/,/", $field_options_array[$te])) {
                            $field_selected = '';
                            $field_options_value_array = explode(",", $field_options_array[$te]);
                            if ($A_field_type[$o] == 'SELECT' or $A_field_type[$o] == 'MULTI') {
                                if (strlen($A_field_value[$o]) > 0) {
                                    if (preg_match("/{$field_options_value_array['0']}/", $A_field_value[$o])) {
                                        $field_selected = 'SELECTED';
                                    }
                                } else {
                                    if ($A_field_default[$o] == "{$field_options_value_array['0']}") {
                                        $field_selected = 'SELECTED';
                                    }
                                }
                                $field_HTML .= "<option value=\"{$field_options_value_array['0']}\" {$field_selected}>" . _QXZ("{$field_options_value_array['1']}") . "</option>\n";
                            }
                            if ($A_field_type[$o] == 'RADIO' or $A_field_type[$o] == 'CHECKBOX') {
                                if ($A_multi_position[$o] == 'VERTICAL') {
                                    $field_HTML .= " &nbsp; ";
                                }
                                if (strlen($A_field_value[$o]) > 0) {
                                    if (preg_match("/{$field_options_value_array['0']}/", $A_field_value[$o])) {
                                        $field_selected = 'CHECKED';
                                    }
                                } else {
                                    if ($A_field_default[$o] == "{$field_options_value_array['0']}") {
                                        $field_selected = 'CHECKED';
                                    }
                                }
                                $field_HTML .= "<input type={$A_field_type[$o]} name={$A_field_label[$o]}[] id={$A_field_label[$o]}[] value=\"{$field_options_value_array['0']}\" {$field_selected}> " . _QXZ("{$field_options_value_array['1']}") . "\n";
                                if ($A_multi_position[$o] == 'VERTICAL') {
                                    $field_HTML .= "<BR>\n";
                                }
                            }
                        }
                        $te++;
                    }
                }
                if ($A_field_type[$o] == 'SELECT' or $A_field_type[$o] == 'MULTI') {
                    $field_HTML .= "</select>\n";
                }
                if ($A_field_type[$o] == 'TEXT') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    $field_HTML .= "<input type=text size={$A_field_size[$o]} maxlength={$A_field_max[$o]} name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"" . _QXZ("{$A_field_value[$o]}") . "\">\n";
                }
                if ($A_field_type[$o] == 'AREA') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    $field_HTML .= "<textarea name={$A_field_label[$o]} id={$A_field_label[$o]} ROWS={$A_field_max[$o]} COLS={$A_field_size[$o]}>{$A_field_value[$o]}</textarea>";
                }
                if ($A_field_type[$o] == 'DISPLAY') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= _QXZ("{$A_field_default[$o]}") . "\n";
                }
                if ($A_field_type[$o] == 'READONLY') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    #	if (strlen($A_field_value[$o]) < 1) {$A_field_value[$o] = $A_field_default[$o];}
                    $field_HTML .= "<input type=hidden name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$A_field_value[$o]}\"> " . _QXZ("{$A_field_value[$o]}") . "\n";
                }
                if ($A_field_type[$o] == 'HIDDEN' or $A_field_type[$o] == 'HIDEBLOB') {
                    if (strlen($A_field_value[$o]) < 1) {
                        $A_field_value[$o] = $A_field_default[$o];
                    }
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= "<input type=hidden name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$A_field_value[$o]}\">\n";
                }
                if ($A_field_type[$o] == 'SCRIPT') {
                    if ($A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = '';
                    }
                    $field_HTML .= "{$A_field_options[$o]}\n";
                }
                if ($A_field_type[$o] == 'DATE') {
                    if (strlen($A_field_default[$o]) < 1 or $A_field_default[$o] == 'NULL') {
                        $A_field_default[$o] = 0;
                    }
                    $day_diff = $A_field_default[$o];
                    $default_date = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("d") + $day_diff, date("Y")));
                    if (strlen($A_field_value[$o]) > 0) {
                        $default_date = $A_field_value[$o];
                    }
                    $field_HTML .= "<input type=text size=11 maxlength=10 name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$default_date}\" onclick=\"f_tcalToggle()\">\n";
                    $field_HTML .= "<script language=\"JavaScript\">\n";
                    $field_HTML .= "var o_cal = new tcal ({\n";
                    $field_HTML .= "\t'formname': 'form_custom_fields',\n";
                    $field_HTML .= "\t'controlname': '{$A_field_label[$o]}'});\n";
                    $field_HTML .= "o_cal.a_tpl.yearscroll = false;\n";
                    $field_HTML .= "</script>\n";
                }
                if ($A_field_type[$o] == 'TIME') {
                    $minute_diff = $A_field_default[$o];
                    $default_time = date("H:i:s", mktime(date("H"), date("i") + $minute_diff, date("s"), date("m"), date("d"), date("Y")));
                    $default_hour = date("H", mktime(date("H"), date("i") + $minute_diff, date("s"), date("m"), date("d"), date("Y")));
                    $default_minute = date("i", mktime(date("H"), date("i") + $minute_diff, date("s"), date("m"), date("d"), date("Y")));
                    if (strlen($A_field_value[$o]) > 2) {
                        $default_time = $A_field_value[$o];
                        $time_field_value = explode(':', $default_time);
                        $default_hour = $time_field_value[0];
                        $default_minute = $time_field_value[1];
                    }
                    $field_HTML .= "<input type=hidden name={$A_field_label[$o]} id={$A_field_label[$o]} value=\"{$default_time}\">";
                    $field_HTML .= "<SELECT name=HOUR_{$A_field_label[$o]} id=HOUR_{$A_field_label[$o]}>";
                    $field_HTML .= "<option>00</option>";
                    $field_HTML .= "<option>01</option>";
                    $field_HTML .= "<option>02</option>";
                    $field_HTML .= "<option>03</option>";
                    $field_HTML .= "<option>04</option>";
                    $field_HTML .= "<option>05</option>";
                    $field_HTML .= "<option>06</option>";
                    $field_HTML .= "<option>07</option>";
                    $field_HTML .= "<option>08</option>";
                    $field_HTML .= "<option>09</option>";
                    $field_HTML .= "<option>10</option>";
                    $field_HTML .= "<option>11</option>";
                    $field_HTML .= "<option>12</option>";
                    $field_HTML .= "<option>13</option>";
                    $field_HTML .= "<option>14</option>";
                    $field_HTML .= "<option>15</option>";
                    $field_HTML .= "<option>16</option>";
                    $field_HTML .= "<option>17</option>";
                    $field_HTML .= "<option>18</option>";
                    $field_HTML .= "<option>19</option>";
                    $field_HTML .= "<option>20</option>";
                    $field_HTML .= "<option>21</option>";
                    $field_HTML .= "<option>22</option>";
                    $field_HTML .= "<option>23</option>";
                    $field_HTML .= "<OPTION value=\"{$default_hour}\" selected>{$default_hour}</OPTION>";
                    $field_HTML .= "</SELECT>";
                    $field_HTML .= "<SELECT name=MINUTE_{$A_field_label[$o]} id=MINUTE_{$A_field_label[$o]}>";
                    $field_HTML .= "<option>00</option>";
                    $field_HTML .= "<option>05</option>";
                    $field_HTML .= "<option>10</option>";
                    $field_HTML .= "<option>15</option>";
                    $field_HTML .= "<option>20</option>";
                    $field_HTML .= "<option>25</option>";
                    $field_HTML .= "<option>30</option>";
                    $field_HTML .= "<option>35</option>";
                    $field_HTML .= "<option>40</option>";
                    $field_HTML .= "<option>45</option>";
                    $field_HTML .= "<option>50</option>";
                    $field_HTML .= "<option>55</option>";
                    $field_HTML .= "<OPTION value=\"{$default_minute}\" selected>{$default_minute}</OPTION>";
                    $field_HTML .= "</SELECT>";
                }
                if ($A_name_position[$o] == 'LEFT' and $A_field_type[$o] != 'SCRIPT' and $A_field_type[$o] != 'HIDDEN' and $A_field_type[$o] != 'HIDEBLOB') {
                    $CFoutput .= " {$field_HTML} <span style=\"position:static;\" id=P_HELP_{$A_field_label[$o]}></span><span style=\"position:static;background:white;\" id=HELP_{$A_field_label[$o]}> {$helpHTML}</span>";
                } else {
                    $CFoutput .= " {$field_HTML}\n";
                }
                $last_field_rank = $A_field_rank[$o];
                $o++;
            }
            $CFoutput .= "</td></tr></table>\n";
        } else {
            $CFoutput .= _QXZ("ERROR: no custom list fields") . "\n";
        }
    } else {
        $CFoutput .= _QXZ("ERROR: no custom list fields table") . "\n";
    }
    ##### BEGIN parsing for vicidial variables #####
    $NOTESout = '';
    if (preg_match("/--A--/", $CFoutput)) {
        if (preg_match('/--A--user_custom_/i', $CFoutput) or preg_match('/--A--fullname/i', $CFoutput)) {
            $stmt = "select custom_one,custom_two,custom_three,custom_four,custom_five,full_name from vicidial_users where user='******';";
            if ($DB) {
                echo "{$stmt}\n";
            }
            $rslt = mysql_to_mysqli($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05006', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $VUC_ct = mysqli_num_rows($rslt);
            if ($VUC_ct > 0) {
                $row = mysqli_fetch_row($rslt);
                $user_custom_one = trim($row[0]);
                $user_custom_two = trim($row[1]);
                $user_custom_three = trim($row[2]);
                $user_custom_four = trim($row[3]);
                $user_custom_five = trim($row[4]);
                $fullname = trim($row[5]);
            }
        }
        if (preg_match('/--A--dialed_/i', $CFoutput)) {
            $dialed_number = $phone_number;
            $dialed_label = _QXZ("NONE");
            ### find the dialed number and label for this call
            $stmt = "SELECT phone_number,alt_dial from vicidial_log where uniqueid='{$uniqueid}';";
            if ($DB) {
                echo "{$stmt}\n";
            }
            $rslt = mysql_to_mysqli($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05008', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $vl_dialed_ct = mysqli_num_rows($rslt);
            if ($vl_dialed_ct > 0) {
                $row = mysqli_fetch_row($rslt);
                $dialed_number = $row[0];
                $dialed_label = $row[1];
            }
        }
        if (preg_match('/--A--TABLEper_call_notes--B--/i', $CFoutput)) {
            ### BEGIN Gather Call Log and notes ###
            if ($hide_call_log_info != 'Y') {
                if ($search != 'logfirst') {
                    $NOTESout .= _QXZ("CALL LOG FOR THIS LEAD:") . "<br>\n";
                }
                $NOTESout .= "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0 WIDTH={$stage}>";
                $NOTESout .= "<TR>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:10px;font-family:sans-serif;\"><B> &nbsp; # &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("DATE/TIME") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("AGENT") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("LENGTH") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("STATUS") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("PHONE") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("CAMPAIGN") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("IN/OUT") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("ALT") . " &nbsp; </font></TD>";
                $NOTESout .= "<TD BGCOLOR=\"#CCCCCC\"><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; " . _QXZ("HANGUP") . " &nbsp; </font></TD>";
                #	$NOTESout .= "</TR><TR>";
                #	$NOTESout .= "<TD BGCOLOR=\"#CCCCCC\" COLSPAN=9><font style=\"font-size:11px;font-family:sans-serif;\"><B> &nbsp; FULL NAME &nbsp; </font></TD>";
                $NOTESout .= "</TR>";
                $stmt = "SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,alt_dial,comments,uniqueid,user from vicidial_log where lead_id='{$lead_id}' order by call_date desc limit 10000;";
                $rslt = mysql_to_mysqli($stmt, $link);
                if ($mel > 0) {
                    mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05014', $user, $server_ip, $session_name, $one_mysql_log);
                }
                $out_logs_to_print = mysqli_num_rows($rslt);
                if ($format == 'debug') {
                    $NOTESout .= "|{$out_logs_to_print}|{$stmt}|";
                }
                $g = 0;
                $u = 0;
                while ($out_logs_to_print > $u) {
                    $row = mysqli_fetch_row($rslt);
                    $ALLsort[$g] = "{$row['0']}-----{$g}";
                    $ALLstart_epoch[$g] = $row[0];
                    $ALLcall_date[$g] = $row[1];
                    $ALLcampaign_id[$g] = $row[2];
                    $ALLlength_in_sec[$g] = $row[3];
                    $ALLstatus[$g] = $row[4];
                    $ALLphone_code[$g] = $row[5];
                    $ALLphone_number[$g] = $row[6];
                    $ALLlead_id[$g] = $row[7];
                    $ALLhangup_reason[$g] = $row[8];
                    $ALLalt_dial[$g] = $row[9];
                    $ALLuniqueid[$g] = $row[11];
                    $ALLuser[$g] = $row[12];
                    $ALLin_out[$g] = "OUT-AUTO";
                    if ($row[10] == 'MANUAL') {
                        $ALLin_out[$g] = "OUT-MANUAL";
                    }
                    $stmtA = "SELECT call_notes FROM vicidial_call_notes WHERE lead_id='{$ALLlead_id[$g]}' and vicidial_id='{$ALLuniqueid[$g]}';";
                    $rsltA = mysql_to_mysqli($stmtA, $link);
                    if ($mel > 0) {
                        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05015', $user, $server_ip, $session_name, $one_mysql_log);
                    }
                    $out_notes_to_print = mysqli_num_rows($rslt);
                    if ($out_notes_to_print > 0) {
                        $rowA = mysqli_fetch_row($rsltA);
                        $Allcall_notes[$g] = $rowA[0];
                        if (strlen($Allcall_notes[$g]) > 0) {
                            $Allcall_notes[$g] = "<b>" . _QXZ("NOTES:") . " </b> " . _QXZ("{$Allcall_notes[$g]}");
                        }
                    }
                    $stmtA = "SELECT full_name FROM vicidial_users WHERE user='******';";
                    $rsltA = mysql_to_mysqli($stmtA, $link);
                    if ($mel > 0) {
                        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05016', $user, $server_ip, $session_name, $one_mysql_log);
                    }
                    $users_to_print = mysqli_num_rows($rslt);
                    if ($users_to_print > 0) {
                        $rowA = mysqli_fetch_row($rsltA);
                        $ALLuser[$g] .= " - {$rowA['0']}";
                    }
                    $Allcounter[$g] = $g;
                    $g++;
                    $u++;
                }
                $stmt = "SELECT start_epoch,call_date,campaign_id,length_in_sec,status,phone_code,phone_number,lead_id,term_reason,queue_seconds,uniqueid,closecallid,user from vicidial_closer_log where lead_id='{$lead_id}' order by call_date desc limit 10000;";
                $rslt = mysql_to_mysqli($stmt, $link);
                if ($mel > 0) {
                    mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05017', $user, $server_ip, $session_name, $one_mysql_log);
                }
                $in_logs_to_print = mysqli_num_rows($rslt);
                if ($format == 'debug') {
                    $NOTESout .= "|{$in_logs_to_print}|{$stmt}|";
                }
                $u = 0;
                while ($in_logs_to_print > $u) {
                    $row = mysqli_fetch_row($rslt);
                    $ALLsort[$g] = "{$row['0']}-----{$g}";
                    $ALLstart_epoch[$g] = $row[0];
                    $ALLcall_date[$g] = $row[1];
                    $ALLcampaign_id[$g] = $row[2];
                    $ALLlength_in_sec[$g] = $row[3] - $row[9];
                    if ($ALLlength_in_sec[$g] < 0) {
                        $ALLlength_in_sec[$g] = 0;
                    }
                    $ALLstatus[$g] = $row[4];
                    $ALLphone_code[$g] = $row[5];
                    $ALLphone_number[$g] = $row[6];
                    $ALLlead_id[$g] = $row[7];
                    $ALLhangup_reason[$g] = $row[8];
                    $ALLuniqueid[$g] = $row[10];
                    $ALLclosecallid[$g] = $row[11];
                    $ALLuser[$g] = $row[12];
                    $ALLalt_dial[$g] = "MAIN";
                    $ALLin_out[$g] = "IN";
                    $stmtA = "SELECT call_notes FROM vicidial_call_notes WHERE lead_id='{$ALLlead_id[$g]}' and vicidial_id='{$ALLclosecallid[$g]}';";
                    $rsltA = mysql_to_mysqli($stmtA, $link);
                    if ($mel > 0) {
                        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05018', $user, $server_ip, $session_name, $one_mysql_log);
                    }
                    $in_notes_to_print = mysqli_num_rows($rslt);
                    if ($in_notes_to_print > 0) {
                        $rowA = mysqli_fetch_row($rsltA);
                        $Allcall_notes[$g] = $rowA[0];
                        if (strlen($Allcall_notes[$g]) > 0) {
                            $Allcall_notes[$g] = "<b>" . _QXZ("NOTES") . ": </b> " . _QXZ("{$Allcall_notes[$g]}");
                        }
                    }
                    $stmtA = "SELECT full_name FROM vicidial_users WHERE user='******';";
                    $rsltA = mysql_to_mysqli($stmtA, $link);
                    if ($mel > 0) {
                        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05019', $user, $server_ip, $session_name, $one_mysql_log);
                    }
                    $users_to_print = mysqli_num_rows($rslt);
                    if ($users_to_print > 0) {
                        $rowA = mysqli_fetch_row($rsltA);
                        $ALLuser[$g] .= " - {$rowA['0']}";
                    }
                    $Allcounter[$g] = $g;
                    $g++;
                    $u++;
                }
                if ($g > 0) {
                    sort($ALLsort, SORT_NUMERIC);
                } else {
                    $NOTESout .= "<tr bgcolor=white><td colspan=11 align=center>" . _QXZ("No calls found") . "</td></tr>";
                }
                $u = 0;
                while ($g > $u) {
                    $sort_split = explode("-----", $ALLsort[$u]);
                    $i = $sort_split[1];
                    if (preg_match("/1\$|3\$|5\$|7\$|9\$/i", $u)) {
                        $bgcolor = 'bgcolor="#B9CBFD"';
                    } else {
                        $bgcolor = 'bgcolor="#9BB9FB"';
                    }
                    $phone_number_display = $ALLphone_number[$i];
                    if ($disable_alter_custphone == 'HIDE') {
                        $phone_number_display = 'XXXXXXXXXX';
                    }
                    $u++;
                    $NOTESout .= "<tr {$bgcolor}>";
                    $NOTESout .= "<td><font size=1>{$u}</td>";
                    $NOTESout .= "<td align=right><font size=2>{$ALLcall_date[$i]}</td>";
                    $NOTESout .= "<td align=right><font size=2> {$ALLuser[$i]}</td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLlength_in_sec[$i]}</td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLstatus[$i]}</td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLphone_code[$i]} {$phone_number_display} </td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLcampaign_id[$i]} </td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLin_out[$i]} </td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLalt_dial[$i]} </td>\n";
                    $NOTESout .= "<td align=right><font size=2> {$ALLhangup_reason[$i]} </td>\n";
                    $NOTESout .= "</TR><TR>";
                    $NOTESout .= "<td></td>";
                    $NOTESout .= "<TD {$bgcolor} COLSPAN=9 align=left><font style=\"font-size:11px;font-family:sans-serif;\"> " . _QXZ("{$Allcall_notes[$i]}") . " </font></TD>";
                    $NOTESout .= "</tr>\n";
                }
                $NOTESout .= "</TABLE>";
                $NOTESout .= "<BR>";
            }
            ### END Gather Call Log and notes ###
        }
        ##### grab the data from vicidial_list for the lead_id
        $stmt = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='{$lead_id}' LIMIT 1;";
        $rslt = mysql_to_mysqli($stmt, $link);
        if ($mel > 0) {
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '05007', $user, $server_ip, $session_name, $one_mysql_log);
        }
        if ($DB) {
            echo "{$stmt}\n";
        }
        $list_lead_ct = mysqli_num_rows($rslt);
        if ($list_lead_ct > 0) {
            $row = mysqli_fetch_row($rslt);
            $dispo = trim($row[3]);
            $tsr = trim($row[4]);
            $vendor_id = trim($row[5]);
            $vendor_lead_code = trim($row[5]);
            $source_id = trim($row[6]);
            $list_id = trim($row[7]);
            $gmt_offset_now = trim($row[8]);
            $phone_code = trim($row[10]);
            $phone_number = trim($row[11]);
            $title = trim($row[12]);
            $first_name = trim($row[13]);
            $middle_initial = trim($row[14]);
            $last_name = trim($row[15]);
            $address1 = trim($row[16]);
            $address2 = trim($row[17]);
            $address3 = trim($row[18]);
            $city = trim($row[19]);
            $state = trim($row[20]);
            $province = trim($row[21]);
            $postal_code = trim($row[22]);
            $country_code = trim($row[23]);
            $gender = trim($row[24]);
            $date_of_birth = trim($row[25]);
            $alt_phone = trim($row[26]);
            $email = trim($row[27]);
            $security = trim($row[28]);
            $comments = trim($row[29]);
            $called_count = trim($row[30]);
            $rank = trim($row[32]);
            $owner = trim($row[33]);
        }
        $CFoutput = preg_replace('/--A--lead_id--B--/i', "{$lead_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--vendor_id--B--/i', "{$vendor_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--vendor_lead_code--B--/i', "{$vendor_lead_code}", $CFoutput);
        $CFoutput = preg_replace('/--A--list_id--B--/i', "{$list_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--gmt_offset_now--B--/i', "{$gmt_offset_now}", $CFoutput);
        $CFoutput = preg_replace('/--A--phone_code--B--/i', "{$phone_code}", $CFoutput);
        $CFoutput = preg_replace('/--A--phone_number--B--/i', "{$phone_number}", $CFoutput);
        $CFoutput = preg_replace('/--A--title--B--/i', "{$title}", $CFoutput);
        $CFoutput = preg_replace('/--A--first_name--B--/i', "{$first_name}", $CFoutput);
        $CFoutput = preg_replace('/--A--middle_initial--B--/i', "{$middle_initial}", $CFoutput);
        $CFoutput = preg_replace('/--A--last_name--B--/i', "{$last_name}", $CFoutput);
        $CFoutput = preg_replace('/--A--address1--B--/i', "{$address1}", $CFoutput);
        $CFoutput = preg_replace('/--A--address2--B--/i', "{$address2}", $CFoutput);
        $CFoutput = preg_replace('/--A--address3--B--/i', "{$address3}", $CFoutput);
        $CFoutput = preg_replace('/--A--city--B--/i', "{$city}", $CFoutput);
        $CFoutput = preg_replace('/--A--state--B--/i', "{$state}", $CFoutput);
        $CFoutput = preg_replace('/--A--province--B--/i', "{$province}", $CFoutput);
        $CFoutput = preg_replace('/--A--postal_code--B--/i', "{$postal_code}", $CFoutput);
        $CFoutput = preg_replace('/--A--country_code--B--/i', "{$country_code}", $CFoutput);
        $CFoutput = preg_replace('/--A--gender--B--/i', "{$gender}", $CFoutput);
        $CFoutput = preg_replace('/--A--date_of_birth--B--/i', "{$date_of_birth}", $CFoutput);
        $CFoutput = preg_replace('/--A--alt_phone--B--/i', "{$alt_phone}", $CFoutput);
        $CFoutput = preg_replace('/--A--email--B--/i', "{$email}", $CFoutput);
        $CFoutput = preg_replace('/--A--security_phrase--B--/i', "{$security_phrase}", $CFoutput);
        $CFoutput = preg_replace('/--A--comments--B--/i', "{$comments}", $CFoutput);
        $CFoutput = preg_replace('/--A--user--B--/i', "{$user}", $CFoutput);
        $CFoutput = preg_replace('/--A--pass--B--/i', "{$pass}", $CFoutput);
        $CFoutput = preg_replace('/--A--campaign--B--/i', "{$campaign}", $CFoutput);
        $CFoutput = preg_replace('/--A--server_ip--B--/i', "{$server_ip}", $CFoutput);
        $CFoutput = preg_replace('/--A--session_id--B--/i', "{$session_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--dialed_number--B--/i', "{$dialed_number}", $CFoutput);
        $CFoutput = preg_replace('/--A--dialed_label--B--/i', "{$dialed_label}", $CFoutput);
        $CFoutput = preg_replace('/--A--source_id--B--/i', "{$source_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--rank--B--/i', "{$rank}", $CFoutput);
        $CFoutput = preg_replace('/--A--owner--B--/i', "{$owner}", $CFoutput);
        $CFoutput = preg_replace('/--A--fullname--B--/i', "{$fullname}", $CFoutput);
        $CFoutput = preg_replace('/--A--uniqueid--B--/i', "{$uniqueid}", $CFoutput);
        $CFoutput = preg_replace('/--A--user_custom_one--B--/i', "{$user_custom_one}", $CFoutput);
        $CFoutput = preg_replace('/--A--user_custom_two--B--/i', "{$user_custom_two}", $CFoutput);
        $CFoutput = preg_replace('/--A--user_custom_three--B--/i', "{$user_custom_three}", $CFoutput);
        $CFoutput = preg_replace('/--A--user_custom_four--B--/i', "{$user_custom_four}", $CFoutput);
        $CFoutput = preg_replace('/--A--user_custom_five--B--/i', "{$user_custom_five}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_number_a--B--/i', "{$preset_number_a}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_number_b--B--/i', "{$preset_number_b}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_number_c--B--/i', "{$preset_number_c}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_number_d--B--/i', "{$preset_number_d}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_number_e--B--/i', "{$preset_number_e}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_dtmf_a--B--/i', "{$preset_dtmf_a}", $CFoutput);
        $CFoutput = preg_replace('/--A--preset_dtmf_b--B--/i', "{$preset_dtmf_b}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_id--B--/i', "{$did_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_extension--B--/i', "{$did_extension}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_pattern--B--/i', "{$did_pattern}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_description--B--/i', "{$did_description}", $CFoutput);
        $CFoutput = preg_replace('/--A--closecallid--B--/i', "{$closecallid}", $CFoutput);
        $CFoutput = preg_replace('/--A--xfercallid--B--/i', "{$xfercallid}", $CFoutput);
        $CFoutput = preg_replace('/--A--agent_log_id--B--/i', "{$agent_log_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--call_id--B--/i', "{$call_id}", $CFoutput);
        $CFoutput = preg_replace('/--A--called_count--B--/i', "{$called_count}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_custom_one--B--/i', "{$did_custom_one}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_custom_two--B--/i', "{$did_custom_two}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_custom_three--B--/i', "{$did_custom_three}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_custom_four--B--/i', "{$did_custom_four}", $CFoutput);
        $CFoutput = preg_replace('/--A--did_custom_five--B--/i', "{$did_custom_five}", $CFoutput);
        $CFoutput = preg_replace('/--A--TABLEper_call_notes--B--/i', "{$NOTESout}", $CFoutput);
        # custom fields replacement
        $o = 0;
        while ($fields_to_print > $o) {
            $CFoutput = preg_replace("/--A--{$A_field_label[$o]}--B--/i", "{$A_field_value[$o]}", $CFoutput);
            $o++;
        }
        if ($DB > 0) {
            echo "{$CFoutput}<BR>\n";
        }
    }
    ##### END parsing for vicidial variables #####
    return $CFoutput;
}
function status_group_gather($status_group_id, $record_type)
{
    global $NOW_TIME, $link, $mel, $user, $server_ip, $session_name, $one_mysql_log;
    $status_group_statuses = '';
    $cs_ct = 0;
    if (strlen($status_group_id) > 0 and $status_group_id != 'NONE') {
        $stmt = "SELECT status,status_name,scheduled_callback,min_sec,max_sec from vicidial_campaign_statuses where campaign_id='{$status_group_id}' and selectable='Y';";
        if ($DB) {
            echo "{$stmt}\n";
        }
        $rslt = mysql_to_mysqli($stmt, $link);
        if ($mel > 0) {
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00654', $user, $server_ip, $session_name, $one_mysql_log);
        }
        if ($rslt) {
            $cs_ct = mysqli_num_rows($rslt);
        }
        $i = 0;
        while ($cs_ct > $i) {
            $row = mysqli_fetch_row($rslt);
            $status = $row[0];
            $status_name = $row[1];
            $scheduled_callback = $row[2];
            $min_sec = $row[3];
            $max_sec = $row[4];
            $status_group_statuses .= "{$status}|{$status_name}|{$scheduled_callback}|{$min_sec}|{$max_sec},";
            $i++;
        }
        if (strlen($status_group_statuses) > 0) {
            $status_group_statuses = substr("{$status_group_statuses}", 0, -1);
        }
    }
    return $status_group_statuses;
}
Beispiel #7
0
function get_audited_comments($lead_id, $format, $user, $mel, $NOW_TIME, $link, $server_ip, $session_name, $one_mysql_log)
{
    global $ACcount;
    global $ACcomments;
    $stmt = "select user_id,comment from vicidial_comments where lead_id='{$lead_id}';";
    if ($mel > 0) {
        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, "00142-65-AuditComments:{$stmt} LeadID: {$lead_id},{$format},{$user},{$mel},{$NOW_TIME},{$link},{$server_ip},{$session_name},{$one_mysql_log}", $user, $server_ip, $session_name, $one_mysql_log);
    }
    $rslt = mysql_query($stmt, $link);
    if ($mel > 0) {
        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00142-69-AuditComments', $user, $server_ip, $session_name, $one_mysql_log);
    }
    $ACcount = mysql_num_rows($rslt);
    mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00142-72-AuditComments $ACcount=' . $ACcount, $user, $server_ip, $session_name, $one_mysql_log);
    if ($ACcount > 0) {
        $i = 0;
        while ($i < $ACcount) {
            $row = mysql_fetch_row($rslt);
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00142-77-AuditComments UserID=' . $row[0], $user, $server_ip, $session_name, $one_mysql_log);
            $ACcomments .= "UserID: {$row['0']}\n";
            mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00142-79-AuditComments Comment=' . $row[1], $user, $server_ip, $session_name, $one_mysql_log);
            $ACcomments .= $row[1];
            $ACcomments .= "\n----------------------------------\n";
            $i++;
        }
        return true;
    } else {
        return false;
    }
}
function get_audited_comments($lead_id, $format, $user, $mel, $NOW_TIME, $link, $server_ip, $session_name, $one_mysql_log)
{
    global $ACcount;
    global $ACcomments;
    $stmt = "SELECT user_id,comment,timestamp from vicidial_comments where lead_id='{$lead_id}' order by timestamp desc;";
    $rslt = mysql_to_mysqli($stmt, $link);
    if ($mel > 0) {
        mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00142-69-AuditComments', $user, $server_ip, $session_name, $one_mysql_log);
    }
    $ACcount = mysqli_num_rows($rslt);
    if ($ACcount > 0) {
        $i = 0;
        while ($i < $ACcount) {
            $row = mysqli_fetch_row($rslt);
            $C_user[$i] = $row[0];
            $C_comment[$i] = $row[1];
            $C_date[$i] = $row[2];
            $i++;
        }
        $i = 0;
        while ($i < $ACcount) {
            $C_name[$i] = 'Unknown';
            $C_level[$i] = '1';
            $FCS = '';
            $FCE = '';
            $stmt = "SELECT full_name,user_level from vicidial_users where user='******';";
            $rslt = mysql_to_mysqli($stmt, $link);
            if ($mel > 0) {
                mysql_error_logging($NOW_TIME, $link, $mel, $stmt, '00142-70-AuditCommentsUser', $user, $server_ip, $session_name, $one_mysql_log);
            }
            $Ucount = mysqli_num_rows($rslt);
            if ($Ucount > 0) {
                $row = mysqli_fetch_row($rslt);
                $C_name[$i] = $row[0];
                $C_level[$i] = $row[1];
            }
            if ($C_level[$i] > 7) {
                $FCS = '--------ADMINFONTBEGIN--------';
                $FCE = '--------ADMINFONTEND--------';
            }
            $ACcomments .= _QXZ("UserID: {$FCS}%1s - %2s{$FCE},  Date: %3s", 0, '', $C_user[$i], $C_name[$i], $C_date[$i]) . "\n";
            $ACcomments .= $C_comment[$i];
            $ACcomments .= "\n----------------------------------\n";
            $i++;
        }
        return true;
    } else {
        return false;
    }
}