[Vtigercrm-developers] PBXManager Migration Script

Uma S uma.s at vtiger.com
Tue Feb 17 09:17:40 GMT 2015


Hi Alan,

Thanks! for notification. I had checked this with one of team member of
PBXManager, where i have a raised a trac
<http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/8472> ticket for same will
look into this soon.

On Mon, Feb 16, 2015 at 11:30 PM, Alan Lord (News) <alanslists at gmail.com>
wrote:

> I am completely baffled by this piece of code in the 600_to_610 migration
> file.
>
>  //Data migrate from old columns to new columns in vtiger_pbxmanager
>> $query = 'SELECT * FROM vtiger_pbxmanager';
>> $result = $adb->pquery($query, array());
>> $params = array();
>> $rowCount = $adb->num_rows($result);
>> for ($i = 0; $i < $rowCount; $i++) {
>>     $pbxmanagerid = $adb->query_result($result, $i, 'pbxmanagerid');
>>
>
>      $callfrom = $adb->query_result($result, $i, 'callfrom');
>>
> 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.
>
>      $callto = $adb->query_result($result, $i, 'callto');
>>
> This contains the html markup for the target module's detail view link.
>
>      $timeofcall = $adb->query_result($result, $i, 'timeofcall');
>>
> This is a mysql datetime value.
>
>      $status = $adb->query_result($result, $i, 'status');
>>
> Mostly "outgoing" in our cases.
>
>      $customer = PBXManager_Record_Model::lookUpRelatedWithNumber($
>> callfrom);
>>
> So this line appears to be trying to get the crmid of the customer. I see
> several problems with it:
>
> 1. It is only ever going to work for incoming calls where the callfrom
> might be populated with a Contact Name or number.
>
> 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.
>
> 3. The function in the Record model returns an array. So $customer will be
> an array.
>
>      $userIdQuery = $adb->pquery('SELECT userid FROM
>> vtiger_asteriskextensions WHERE asterisk_extension = ?', array($callto));
>>     $user = $adb->query_result($userIdQuery, $i, 'userid');
>>     if ($status == 'outgoing') {
>>         $callstatus = 'outbound';
>>     } else if ($status == 'incoming') {
>>         $callstatus = 'inbound';
>>     }
>>     //Update query
>>     $adb->pquery('UPDATE vtiger_pbxmanager SET customer = ? AND user = ?
>> AND totalduration = ? AND callstatus = ? WHERE pbxmanagerid = ?',
>> array($customer, $user, $timeofcall, $callstatus, $pbxmanagerid));
>>
> This line is trying to save an array ($customer) into the customer column
> of vtiger_pbxmanager which is a varchar(100) type column...
>
> It is also trying to save a datetime value ($timeofcall) into the
> totalduration column which is an integer type column..
>
> 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...
>
> Is it me or is this all completely bonkers?
>
>
>
> Al
>
>
> --
> Libertus Solutions
> http://www.libertus.co.uk
>
> _______________________________________________
> http://www.vtiger.com/
>



-- 
With
Best Regards
Uma.S
Vtiger Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20150217/54323bf7/attachment.html>


More information about the vtigercrm-developers mailing list