<div dir="ltr">Hi Alan,<div><br></div><div>Thanks! for notification. I had checked this with one of team member of PBXManager, where i have a raised a <a href="http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/8472">trac</a> ticket for same will look into this soon.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 16, 2015 at 11:30 PM, Alan Lord (News) <span dir="ltr"><<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am completely baffled by this piece of code in the 600_to_610 migration file.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
//Data migrate from old columns to new columns in vtiger_pbxmanager<br>
$query = 'SELECT * FROM vtiger_pbxmanager';<br>
$result = $adb->pquery($query, array());<br>
$params = array();<br>
$rowCount = $adb->num_rows($result);<br>
for ($i = 0; $i < $rowCount; $i++) {<br>
    $pbxmanagerid = $adb->query_result($result, $i, 'pbxmanagerid');<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    $callfrom = $adb->query_result($result, $i, 'callfrom');<br>
</blockquote>
In most of our customers' vtiger systems this column contains the vtiger user's Firstname & Lastname as a string. It does *not* contain a phone number.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    $callto = $adb->query_result($result, $i, 'callto');<br>
</blockquote>
This contains the html markup for the target module's detail view link.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    $timeofcall = $adb->query_result($result, $i, 'timeofcall');<br>
</blockquote>
This is a mysql datetime value.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    $status = $adb->query_result($result, $i, 'status');<br>
</blockquote>
Mostly "outgoing" in our cases.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    $customer = PBXManager_Record_Model::<u></u>lookUpRelatedWithNumber($<u></u>callfrom);<br>
</blockquote>
So this line appears to be trying to get the crmid of the customer. I see several problems with it:<br>
<br>
1. It is only ever going to work for incoming calls where the callfrom might be populated with a Contact Name or number.<br>
<br>
2. The function in the Record model is expecting to be passed a number, not a name so it's a complete waste of time for outgoing calls.<br>
<br>
3. The function in the Record model returns an array. So $customer will be an array.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    $userIdQuery = $adb->pquery('SELECT userid FROM vtiger_asteriskextensions WHERE asterisk_extension = ?', array($callto));<br>
    $user = $adb->query_result($<u></u>userIdQuery, $i, 'userid');<br>
    if ($status == 'outgoing') {<br>
        $callstatus = 'outbound';<br>
    } else if ($status == 'incoming') {<br>
        $callstatus = 'inbound';<br>
    }<br>
    //Update query<br>
    $adb->pquery('UPDATE vtiger_pbxmanager SET customer = ? AND user = ? AND totalduration = ? AND callstatus = ? WHERE pbxmanagerid = ?', array($customer, $user, $timeofcall, $callstatus, $pbxmanagerid));<br>
</blockquote>
This line is trying to save an array ($customer) into the customer column of vtiger_pbxmanager which is a varchar(100) type column...<br>
<br>
It is also trying to save a datetime value ($timeofcall) into the totalduration column which is an integer type column..<br>
<br>
It seems to me that this snippet of code will never really do anything useful. And when you have a vtiger_pbxmanager table with nearly 500,000 rows of outbound call records it spends an awfully long time doing absolutely nothing...<br>
<br>
Is it me or is this all completely bonkers?<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
<br>
Al<br>
<br>
<br>
-- <br>
Libertus Solutions<br>
<a href="http://www.libertus.co.uk" target="_blank">http://www.libertus.co.uk</a><br>
<br>
______________________________<u></u>_________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">With<br>Best Regards<br>Uma.S<br><div>Vtiger Team</div></div></div>
</div>