PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/Migration/DBChanges/510rc_to_510.php

https://bitbucket.org/yousef_fadila/vtiger
PHP | 53 lines | 30 code | 12 blank | 11 comment | 1 complexity | c874c91c4b64edf6813baaac75539d00 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /*+********************************************************************************
  3. * The contents of this file are subject to the vtiger CRM Public License Version 1.0
  4. * ("License"); You may not use this file except in compliance with the License
  5. * The Original Code is: vtiger CRM Open Source
  6. * The Initial Developer of the Original Code is vtiger.
  7. * Portions created by vtiger are Copyright (C) vtiger.
  8. * All Rights Reserved.
  9. *********************************************************************************/
  10. //5.1.0 RC to 5.1.0 database changes
  11. //we have to use the current object (stored in PatchApply.php) to execute the queries
  12. $adb = $_SESSION['adodb_current_object'];
  13. $conn = $_SESSION['adodb_current_object'];
  14. $migrationlog->debug("\n\nDB Changes from 5.1.0 RC to 5.1.0 -------- Starts \n\n");
  15. ExecuteQuery("DELETE vtiger_cvcolumnlist FROM vtiger_cvcolumnlist INNER JOIN vtiger_customview WHERE vtiger_cvcolumnlist.columnname LIKE '%vtiger_notes:filename%' AND vtiger_customview.cvid = vtiger_cvcolumnlist.cvid AND vtiger_customview.entitytype='HelpDesk'");
  16. ExecuteQuery("DELETE vtiger_cvcolumnlist FROM vtiger_cvcolumnlist INNER JOIN vtiger_customview WHERE (vtiger_cvcolumnlist.columnname LIKE '%parent_id%' OR vtiger_cvcolumnlist.columnname LIKE '%vtiger_contactdetails%') AND vtiger_customview.cvid = vtiger_cvcolumnlist.cvid AND vtiger_customview.entitytype='Documents'");
  17. ExecuteQuery("DELETE vtiger_cvadvfilter FROM vtiger_cvadvfilter INNER JOIN vtiger_customview WHERE vtiger_cvadvfilter.columnname LIKE '%vtiger_notes:filename%' AND vtiger_customview.cvid = vtiger_cvadvfilter.cvid AND vtiger_customview.entitytype='HelpDesk'");
  18. ExecuteQuery("DELETE vtiger_cvadvfilter FROM vtiger_cvadvfilter INNER JOIN vtiger_customview WHERE (vtiger_cvadvfilter.columnname LIKE '%parent_id%' OR vtiger_cvadvfilter.columnname LIKE '%vtiger_contactdetails%') AND vtiger_customview.cvid = vtiger_cvadvfilter.cvid AND vtiger_customview.entitytype='Documents'");
  19. // Fixed issue with Calendar duration calculation
  20. ExecuteQuery("ALTER TABLE vtiger_activity MODIFY duration_hours VARCHAR(200)");
  21. $result = $adb->query("SELECT activityid,date_start,due_date, time_start,time_end FROM vtiger_activity WHERE activitytype NOT IN ('Task','Emails')");
  22. $noofrows = $adb->num_rows($result);
  23. for($index=0;$index<$noofrows;$index++){
  24. $activityid = $adb->query_result($result,$index,'activityid');
  25. $date_start = $adb->query_result($result,$index,'date_start');
  26. $time_start = $adb->query_result($result,$index,'time_start');
  27. $due_date = $adb->query_result($result,$index,'due_date');
  28. $time_end = $adb->query_result($result,$index,'time_end');
  29. $start_date = split("-",$date_start);
  30. $end_date = split("-",$due_date);
  31. $start_time = split(":",$time_start);
  32. $end_time = split(":",$time_end);
  33. $start = mktime(intval($start_time[0]),intval($start_time[1]),0,intval($start_date[1]),intval($start_date[2]),intval($start_date[0]));
  34. $end = mktime(intval($end_time[0]),intval($end_time[1]),0,intval($end_date[1]),intval($end_date[2]),intval($end_date[0]));
  35. $duration_in_minutes = floor(($end-$start)/(60));//get the difference between start time and end time in minutes
  36. $hours = floor($duration_in_minutes/60);
  37. $minutes = $duration_in_minutes%60;
  38. $adb->pquery("UPDATE vtiger_activity SET duration_hours=?, duration_minutes=? WHERE activityid=?",array($hours, $minutes,$activityid));
  39. }
  40. $migrationlog->debug("\n\nDB Changes from 5.1.0 RC to 5.1.0 -------- Ends \n\n");
  41. ?>