@@ -72,18 +72,18 @@ |
||
| 72 | 72 | } |
| 73 | 73 | */ |
| 74 | 74 | |
| 75 | - $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime']; |
|
| 76 | - $response = $_SESSION['totalUpgradeTime']; |
|
| 75 | + $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime']; |
|
| 76 | + $response = $_SESSION['totalUpgradeTime']; |
|
| 77 | 77 | |
| 78 | 78 | $GLOBALS['log']->fatal('TOTAL TIME .....'.$_SESSION['totalUpgradeTime']); |
| 79 | - //$uptime = $uptime+$_REQUEST['upgradeStepTime']; |
|
| 80 | - $GLOBALS['log']->fatal($response); |
|
| 79 | + //$uptime = $uptime+$_REQUEST['upgradeStepTime']; |
|
| 80 | + $GLOBALS['log']->fatal($response); |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - if (!empty($response)) { |
|
| 83 | + if (!empty($response)) { |
|
| 84 | 84 | $json = getJSONobj(); |
| 85 | - print $json->encode($response); |
|
| 86 | - } |
|
| 85 | + print $json->encode($response); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | sugar_cleanup(); |
| 89 | 89 | exit(); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | */ |
| 74 | 74 | |
| 75 | - $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime']+$_REQUEST['upgradeStepTime']; |
|
| 75 | + $_SESSION['totalUpgradeTime'] = $_SESSION['totalUpgradeTime'] + $_REQUEST['upgradeStepTime']; |
|
| 76 | 76 | $response = $_SESSION['totalUpgradeTime']; |
| 77 | 77 | |
| 78 | 78 | $GLOBALS['log']->fatal('TOTAL TIME .....'.$_SESSION['totalUpgradeTime']); |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getFilesToRemove($version) |
| 70 | 70 | { |
| 71 | - return array(); |
|
| 71 | + return array(); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -79,31 +79,31 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function processFilesToRemove($files=array()) |
| 81 | 81 | { |
| 82 | - if(empty($files) || !is_array($files)) |
|
| 83 | - { |
|
| 84 | - return; |
|
| 85 | - } |
|
| 82 | + if(empty($files) || !is_array($files)) |
|
| 83 | + { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - require_once('include/dir_inc.php'); |
|
| 87 | + require_once('include/dir_inc.php'); |
|
| 88 | 88 | |
| 89 | - if(!file_exists('custom/backup')) |
|
| 90 | - { |
|
| 91 | - mkdir_recursive('custom/backup'); |
|
| 92 | - } |
|
| 89 | + if(!file_exists('custom/backup')) |
|
| 90 | + { |
|
| 91 | + mkdir_recursive('custom/backup'); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - foreach($files as $file) |
|
| 95 | - { |
|
| 96 | - if(file_exists($file)) |
|
| 97 | - { |
|
| 98 | - $this->backup($file); |
|
| 99 | - if(is_dir($file)) |
|
| 100 | - { |
|
| 101 | - rmdir_recursive($file); |
|
| 102 | - } else { |
|
| 103 | - unlink($file); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 94 | + foreach($files as $file) |
|
| 95 | + { |
|
| 96 | + if(file_exists($file)) |
|
| 97 | + { |
|
| 98 | + $this->backup($file); |
|
| 99 | + if(is_dir($file)) |
|
| 100 | + { |
|
| 101 | + rmdir_recursive($file); |
|
| 102 | + } else { |
|
| 103 | + unlink($file); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
@@ -115,20 +115,20 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | protected function backup($file) |
| 117 | 117 | { |
| 118 | - $basename = basename($file); |
|
| 119 | - $basepath = str_replace($basename, '', $file); |
|
| 118 | + $basename = basename($file); |
|
| 119 | + $basepath = str_replace($basename, '', $file); |
|
| 120 | 120 | |
| 121 | - if(!empty($basepath) && !file_exists('custom/backup/' . $basepath)) |
|
| 122 | - { |
|
| 123 | - mkdir_recursive('custom/backup/' . $basepath); |
|
| 124 | - } |
|
| 121 | + if(!empty($basepath) && !file_exists('custom/backup/' . $basepath)) |
|
| 122 | + { |
|
| 123 | + mkdir_recursive('custom/backup/' . $basepath); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - if(is_dir($file)) |
|
| 127 | - { |
|
| 128 | - copy_recursive($file, 'custom/backup/' . $file); |
|
| 129 | - } else { |
|
| 130 | - copy($file, 'custom/backup/' . $file); |
|
| 131 | - } |
|
| 126 | + if(is_dir($file)) |
|
| 127 | + { |
|
| 128 | + copy_recursive($file, 'custom/backup/' . $file); |
|
| 129 | + } else { |
|
| 130 | + copy($file, 'custom/backup/' . $file); |
|
| 131 | + } |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -77,26 +77,26 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @param mixed $files |
| 79 | 79 | */ |
| 80 | -public function processFilesToRemove($files=array()) |
|
| 80 | +public function processFilesToRemove($files = array()) |
|
| 81 | 81 | { |
| 82 | - if(empty($files) || !is_array($files)) |
|
| 82 | + if (empty($files) || !is_array($files)) |
|
| 83 | 83 | { |
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | require_once('include/dir_inc.php'); |
| 88 | 88 | |
| 89 | - if(!file_exists('custom/backup')) |
|
| 89 | + if (!file_exists('custom/backup')) |
|
| 90 | 90 | { |
| 91 | 91 | mkdir_recursive('custom/backup'); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - foreach($files as $file) |
|
| 94 | + foreach ($files as $file) |
|
| 95 | 95 | { |
| 96 | - if(file_exists($file)) |
|
| 96 | + if (file_exists($file)) |
|
| 97 | 97 | { |
| 98 | 98 | $this->backup($file); |
| 99 | - if(is_dir($file)) |
|
| 99 | + if (is_dir($file)) |
|
| 100 | 100 | { |
| 101 | 101 | rmdir_recursive($file); |
| 102 | 102 | } else { |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | $basename = basename($file); |
| 119 | 119 | $basepath = str_replace($basename, '', $file); |
| 120 | 120 | |
| 121 | - if(!empty($basepath) && !file_exists('custom/backup/' . $basepath)) |
|
| 121 | + if (!empty($basepath) && !file_exists('custom/backup/'.$basepath)) |
|
| 122 | 122 | { |
| 123 | - mkdir_recursive('custom/backup/' . $basepath); |
|
| 123 | + mkdir_recursive('custom/backup/'.$basepath); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if(is_dir($file)) |
|
| 126 | + if (is_dir($file)) |
|
| 127 | 127 | { |
| 128 | - copy_recursive($file, 'custom/backup/' . $file); |
|
| 128 | + copy_recursive($file, 'custom/backup/'.$file); |
|
| 129 | 129 | } else { |
| 130 | - copy($file, 'custom/backup/' . $file); |
|
| 130 | + copy($file, 'custom/backup/'.$file); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
| 39 | 39 | ********************************************************************************/ |
| 40 | 40 | |
| 41 | - //Request object must have these property values: |
|
| 42 | - // Module: module name, this module should have a file called TreeData.php |
|
| 43 | - // Function: name of the function to be called in TreeData.php, the function will be called statically. |
|
| 44 | - // PARAM prefixed properties: array of these property/values will be passed to the function as parameter. |
|
| 41 | + //Request object must have these property values: |
|
| 42 | + // Module: module name, this module should have a file called TreeData.php |
|
| 43 | + // Function: name of the function to be called in TreeData.php, the function will be called statically. |
|
| 44 | + // PARAM prefixed properties: array of these property/values will be passed to the function as parameter. |
|
| 45 | 45 | |
| 46 | 46 | require_once('include/JSON.php'); |
| 47 | 47 | require_once('include/entryPoint.php'); |
@@ -52,25 +52,25 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $json = getJSONobj(); |
| 54 | 54 | $selectedTable = $json->decode(html_entity_decode($_REQUEST['selectedTable'])); |
| 55 | - if(isset($tagArticleIds['jsonObject']) && $tagArticleIds['jsonObject'] != null){ |
|
| 56 | - $selectedTable = $selectedTable['jsonObject']; |
|
| 57 | - } |
|
| 55 | + if(isset($tagArticleIds['jsonObject']) && $tagArticleIds['jsonObject'] != null){ |
|
| 56 | + $selectedTable = $selectedTable['jsonObject']; |
|
| 57 | + } |
|
| 58 | 58 | $GLOBALS['log']->fatal('************ comes here *********'); |
| 59 | 59 | //$GLOBALS['log']->fatal($_REQUEST['selectedTable']); |
| 60 | 60 | function tableColumns($table_name){ |
| 61 | - $GLOBALS['log']->fatal('********TABLE PASSED******* '.$table_name); |
|
| 62 | - global $sugar_config; |
|
| 63 | - global $setup_db_database_name; |
|
| 61 | + $GLOBALS['log']->fatal('********TABLE PASSED******* '.$table_name); |
|
| 62 | + global $sugar_config; |
|
| 63 | + global $setup_db_database_name; |
|
| 64 | 64 | global $setup_db_host_name; |
| 65 | 65 | global $setup_db_host_instance; |
| 66 | 66 | global $setup_db_admin_user_name; |
| 67 | 67 | global $setup_db_admin_password; |
| 68 | 68 | |
| 69 | - //$db = &DBManagerFactory::getInstance('information_schema'); |
|
| 69 | + //$db = &DBManagerFactory::getInstance('information_schema'); |
|
| 70 | 70 | |
| 71 | - $db_name= $sugar_config['dbconfig']['db_name']; |
|
| 72 | - $setup_db_host_name = $sugar_config['dbconfig']['db_host_name']; |
|
| 73 | - $setup_db_admin_user_name = $sugar_config['dbconfig']['db_user_name']; |
|
| 71 | + $db_name= $sugar_config['dbconfig']['db_name']; |
|
| 72 | + $setup_db_host_name = $sugar_config['dbconfig']['db_host_name']; |
|
| 73 | + $setup_db_admin_user_name = $sugar_config['dbconfig']['db_user_name']; |
|
| 74 | 74 | $setup_db_host_instance = $sugar_config['dbconfig']['db_host_instance']; |
| 75 | 75 | $setup_db_admin_password = $sugar_config['dbconfig']['db_password']; |
| 76 | 76 | |
@@ -78,27 +78,27 @@ discard block |
||
| 78 | 78 | mysql_select_db('information_schema'); |
| 79 | 79 | |
| 80 | 80 | $qu="SELECT column_name FROM information_schema.columns WHERE table_schema = '".$db_name."' AND table_name = '".$table_name."'"; |
| 81 | - $ct =mysql_query($qu,$link); |
|
| 81 | + $ct =mysql_query($qu,$link); |
|
| 82 | 82 | //$cols= ''; |
| 83 | 83 | $colsDrop = array(); |
| 84 | 84 | while($row = mysql_fetch_assoc($ct)){ |
| 85 | - $colsDrop[] =$row['column_name']; |
|
| 85 | + $colsDrop[] =$row['column_name']; |
|
| 86 | 86 | } |
| 87 | 87 | return $colsDrop; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $colsDrop = tableColumns($_REQUEST['selectedTable']); |
| 91 | 91 | if($colsDrop != null){ |
| 92 | - $colsDropDown = "<option value=".$_REQUEST['selectedTable']." Columns>".$_REQUEST['selectedTable']." Columns</option>"; |
|
| 93 | - foreach($colsDrop as $col){ |
|
| 94 | - $colsDropDown .="<option value={$col}>{$col}</option>"; |
|
| 95 | - } |
|
| 92 | + $colsDropDown = "<option value=".$_REQUEST['selectedTable']." Columns>".$_REQUEST['selectedTable']." Columns</option>"; |
|
| 93 | + foreach($colsDrop as $col){ |
|
| 94 | + $colsDropDown .="<option value={$col}>{$col}</option>"; |
|
| 95 | + } |
|
| 96 | 96 | } |
| 97 | 97 | //$response = "<script>document.getElementById('select_column').innerHTML=$colsDropDown</script>"; |
| 98 | 98 | $response = $colsDropDown; |
| 99 | 99 | |
| 100 | 100 | if (!empty($response)) { |
| 101 | - echo $response; |
|
| 101 | + echo $response; |
|
| 102 | 102 | } |
| 103 | 103 | sugar_cleanup(); |
| 104 | 104 | exit(); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $json = getJSONobj(); |
| 54 | 54 | $selectedTable = $json->decode(html_entity_decode($_REQUEST['selectedTable'])); |
| 55 | - if(isset($tagArticleIds['jsonObject']) && $tagArticleIds['jsonObject'] != null){ |
|
| 55 | + if (isset($tagArticleIds['jsonObject']) && $tagArticleIds['jsonObject'] != null) { |
|
| 56 | 56 | $selectedTable = $selectedTable['jsonObject']; |
| 57 | 57 | } |
| 58 | 58 | $GLOBALS['log']->fatal('************ comes here *********'); |
| 59 | 59 | //$GLOBALS['log']->fatal($_REQUEST['selectedTable']); |
| 60 | -function tableColumns($table_name){ |
|
| 60 | +function tableColumns($table_name) { |
|
| 61 | 61 | $GLOBALS['log']->fatal('********TABLE PASSED******* '.$table_name); |
| 62 | 62 | global $sugar_config; |
| 63 | 63 | global $setup_db_database_name; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | //$db = &DBManagerFactory::getInstance('information_schema'); |
| 70 | 70 | |
| 71 | - $db_name= $sugar_config['dbconfig']['db_name']; |
|
| 71 | + $db_name = $sugar_config['dbconfig']['db_name']; |
|
| 72 | 72 | $setup_db_host_name = $sugar_config['dbconfig']['db_host_name']; |
| 73 | 73 | $setup_db_admin_user_name = $sugar_config['dbconfig']['db_user_name']; |
| 74 | 74 | $setup_db_host_instance = $sugar_config['dbconfig']['db_host_instance']; |
@@ -77,21 +77,21 @@ discard block |
||
| 77 | 77 | $link = @mysql_connect($setup_db_host_name, $setup_db_admin_user_name, $setup_db_admin_password); |
| 78 | 78 | mysql_select_db('information_schema'); |
| 79 | 79 | |
| 80 | - $qu="SELECT column_name FROM information_schema.columns WHERE table_schema = '".$db_name."' AND table_name = '".$table_name."'"; |
|
| 81 | - $ct =mysql_query($qu,$link); |
|
| 80 | + $qu = "SELECT column_name FROM information_schema.columns WHERE table_schema = '".$db_name."' AND table_name = '".$table_name."'"; |
|
| 81 | + $ct = mysql_query($qu, $link); |
|
| 82 | 82 | //$cols= ''; |
| 83 | 83 | $colsDrop = array(); |
| 84 | - while($row = mysql_fetch_assoc($ct)){ |
|
| 85 | - $colsDrop[] =$row['column_name']; |
|
| 84 | + while ($row = mysql_fetch_assoc($ct)) { |
|
| 85 | + $colsDrop[] = $row['column_name']; |
|
| 86 | 86 | } |
| 87 | 87 | return $colsDrop; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $colsDrop = tableColumns($_REQUEST['selectedTable']); |
| 91 | -if($colsDrop != null){ |
|
| 91 | +if ($colsDrop != null) { |
|
| 92 | 92 | $colsDropDown = "<option value=".$_REQUEST['selectedTable']." Columns>".$_REQUEST['selectedTable']." Columns</option>"; |
| 93 | - foreach($colsDrop as $col){ |
|
| 94 | - $colsDropDown .="<option value={$col}>{$col}</option>"; |
|
| 93 | + foreach ($colsDrop as $col) { |
|
| 94 | + $colsDropDown .= "<option value={$col}>{$col}</option>"; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | //$response = "<script>document.getElementById('select_column').innerHTML=$colsDropDown</script>"; |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
| 3 | + die('Not A Valid Entry Point'); |
|
| 4 | +} |
|
| 3 | 5 | /********************************************************************************* |
| 4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -35,29 +35,29 @@ discard block |
||
| 35 | 35 | ********************************************************************************/ |
| 36 | 36 | |
| 37 | 37 | function build_argument_string($arguments=array()) { |
| 38 | - if(!is_array($arguments)) { |
|
| 39 | - return ''; |
|
| 40 | - } |
|
| 38 | + if(!is_array($arguments)) { |
|
| 39 | + return ''; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $argument_string = ''; |
|
| 43 | - $count = 0; |
|
| 44 | - foreach($arguments as $arg) { |
|
| 45 | - if($count != 0) |
|
| 46 | - { |
|
| 47 | - //If current directory or parent directory is specified, substitute with full path |
|
| 48 | - if($arg == '.') |
|
| 49 | - { |
|
| 50 | - $arg = getcwd(); |
|
| 51 | - } else if ($arg == '..') { |
|
| 52 | - $dir = getcwd(); |
|
| 53 | - $arg = substr($dir, 0, strrpos($dir, DIRECTORY_SEPARATOR)); |
|
| 54 | - } |
|
| 55 | - $argument_string .= ' ' . escapeshellarg($arg); |
|
| 56 | - } |
|
| 57 | - $count++; |
|
| 58 | - } |
|
| 42 | + $argument_string = ''; |
|
| 43 | + $count = 0; |
|
| 44 | + foreach($arguments as $arg) { |
|
| 45 | + if($count != 0) |
|
| 46 | + { |
|
| 47 | + //If current directory or parent directory is specified, substitute with full path |
|
| 48 | + if($arg == '.') |
|
| 49 | + { |
|
| 50 | + $arg = getcwd(); |
|
| 51 | + } else if ($arg == '..') { |
|
| 52 | + $dir = getcwd(); |
|
| 53 | + $arg = substr($dir, 0, strrpos($dir, DIRECTORY_SEPARATOR)); |
|
| 54 | + } |
|
| 55 | + $argument_string .= ' ' . escapeshellarg($arg); |
|
| 56 | + } |
|
| 57 | + $count++; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - return $argument_string; |
|
| 60 | + return $argument_string; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | //Bug 52872. Dies if the request does not come from CLI. |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | $run_dce_upgrade = true; |
| 76 | 76 | //set the php path if found |
| 77 | 77 | if(is_file($argv[7].'dce_config.php')){ |
| 78 | - include($argv[7].'dce_config.php'); |
|
| 79 | - $php_path = $dce_config['client_php_path'].'/'; |
|
| 78 | + include($argv[7].'dce_config.php'); |
|
| 79 | + $php_path = $dce_config['client_php_path'].'/'; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -92,25 +92,25 @@ discard block |
||
| 92 | 92 | $has_error = $output == 0 ? false : true; |
| 93 | 93 | |
| 94 | 94 | if(!$has_error) { |
| 95 | - if($run_dce_upgrade) { |
|
| 96 | - $step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php " . build_argument_string($argv); |
|
| 97 | - passthru($step2, $output); |
|
| 98 | - } else { |
|
| 99 | - $step2 = "php -f {$php_dir}silentUpgrade_step2.php " . build_argument_string($argv); |
|
| 100 | - passthru($step2, $output); |
|
| 101 | - } |
|
| 95 | + if($run_dce_upgrade) { |
|
| 96 | + $step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php " . build_argument_string($argv); |
|
| 97 | + passthru($step2, $output); |
|
| 98 | + } else { |
|
| 99 | + $step2 = "php -f {$php_dir}silentUpgrade_step2.php " . build_argument_string($argv); |
|
| 100 | + passthru($step2, $output); |
|
| 101 | + } |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | if($run_dce_upgrade) { |
| 105 | - $has_error = $output == 0 ? false : true; |
|
| 106 | - if(!$has_error) { |
|
| 107 | - $step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php " . build_argument_string($argv); |
|
| 108 | - passthru($step3, $output); |
|
| 109 | - } |
|
| 105 | + $has_error = $output == 0 ? false : true; |
|
| 106 | + if(!$has_error) { |
|
| 107 | + $step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php " . build_argument_string($argv); |
|
| 108 | + passthru($step3, $output); |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if($output != 0) { |
| 113 | - echo "*************** silentupgrade failed ***************: $output\n"; |
|
| 113 | + echo "*************** silentupgrade failed ***************: $output\n"; |
|
| 114 | 114 | } |
| 115 | 115 | exit($output); |
| 116 | 116 | ?> |
@@ -34,25 +34,25 @@ discard block |
||
| 34 | 34 | * "Powered by SugarCRM". |
| 35 | 35 | ********************************************************************************/ |
| 36 | 36 | |
| 37 | -function build_argument_string($arguments=array()) { |
|
| 38 | - if(!is_array($arguments)) { |
|
| 37 | +function build_argument_string($arguments = array()) { |
|
| 38 | + if (!is_array($arguments)) { |
|
| 39 | 39 | return ''; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $argument_string = ''; |
| 43 | 43 | $count = 0; |
| 44 | - foreach($arguments as $arg) { |
|
| 45 | - if($count != 0) |
|
| 44 | + foreach ($arguments as $arg) { |
|
| 45 | + if ($count != 0) |
|
| 46 | 46 | { |
| 47 | 47 | //If current directory or parent directory is specified, substitute with full path |
| 48 | - if($arg == '.') |
|
| 48 | + if ($arg == '.') |
|
| 49 | 49 | { |
| 50 | 50 | $arg = getcwd(); |
| 51 | 51 | } else if ($arg == '..') { |
| 52 | 52 | $dir = getcwd(); |
| 53 | 53 | $arg = substr($dir, 0, strrpos($dir, DIRECTORY_SEPARATOR)); |
| 54 | 54 | } |
| 55 | - $argument_string .= ' ' . escapeshellarg($arg); |
|
| 55 | + $argument_string .= ' '.escapeshellarg($arg); |
|
| 56 | 56 | } |
| 57 | 57 | $count++; |
| 58 | 58 | } |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $php_path = ''; |
| 71 | 71 | $run_dce_upgrade = false; |
| 72 | -if(isset($argv[3]) && is_dir($argv[3]) && file_exists($argv[3]."/ini_setup.php")) { |
|
| 72 | +if (isset($argv[3]) && is_dir($argv[3]) && file_exists($argv[3]."/ini_setup.php")) { |
|
| 73 | 73 | //this is a dce call, set the dce flag |
| 74 | 74 | chdir($argv[3]); |
| 75 | 75 | $run_dce_upgrade = true; |
| 76 | 76 | //set the php path if found |
| 77 | - if(is_file($argv[7].'dce_config.php')){ |
|
| 77 | + if (is_file($argv[7].'dce_config.php')) { |
|
| 78 | 78 | include($argv[7].'dce_config.php'); |
| 79 | 79 | $php_path = $dce_config['client_php_path'].'/'; |
| 80 | 80 | } |
@@ -82,34 +82,34 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $php_file = $argv[0]; |
| 84 | 84 | $p_info = pathinfo($php_file); |
| 85 | -$php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ? $p_info['dirname'] . '/' : ''; |
|
| 85 | +$php_dir = (isset($p_info['dirname']) && $p_info['dirname'] != '.') ? $p_info['dirname'].'/' : ''; |
|
| 86 | 86 | |
| 87 | -$step1 = $php_path."php -f {$php_dir}silentUpgrade_step1.php " . build_argument_string($argv); |
|
| 87 | +$step1 = $php_path."php -f {$php_dir}silentUpgrade_step1.php ".build_argument_string($argv); |
|
| 88 | 88 | passthru($step1, $output); |
| 89 | -if($output != 0) { |
|
| 89 | +if ($output != 0) { |
|
| 90 | 90 | echo "*************** step1 failed ***************: $output\n"; |
| 91 | 91 | } |
| 92 | 92 | $has_error = $output == 0 ? false : true; |
| 93 | 93 | |
| 94 | -if(!$has_error) { |
|
| 95 | - if($run_dce_upgrade) { |
|
| 96 | - $step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php " . build_argument_string($argv); |
|
| 94 | +if (!$has_error) { |
|
| 95 | + if ($run_dce_upgrade) { |
|
| 96 | + $step2 = $php_path."php -f {$php_dir}silentUpgrade_dce_step1.php ".build_argument_string($argv); |
|
| 97 | 97 | passthru($step2, $output); |
| 98 | 98 | } else { |
| 99 | - $step2 = "php -f {$php_dir}silentUpgrade_step2.php " . build_argument_string($argv); |
|
| 99 | + $step2 = "php -f {$php_dir}silentUpgrade_step2.php ".build_argument_string($argv); |
|
| 100 | 100 | passthru($step2, $output); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -if($run_dce_upgrade) { |
|
| 104 | +if ($run_dce_upgrade) { |
|
| 105 | 105 | $has_error = $output == 0 ? false : true; |
| 106 | - if(!$has_error) { |
|
| 107 | - $step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php " . build_argument_string($argv); |
|
| 106 | + if (!$has_error) { |
|
| 107 | + $step3 = $php_path."php -f {$php_dir}silentUpgrade_dce_step2.php ".build_argument_string($argv); |
|
| 108 | 108 | passthru($step3, $output); |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | -if($output != 0) { |
|
| 112 | +if ($output != 0) { |
|
| 113 | 113 | echo "*************** silentupgrade failed ***************: $output\n"; |
| 114 | 114 | } |
| 115 | 115 | exit($output); |
@@ -38,45 +38,45 @@ discard block |
||
| 38 | 38 | ********************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | $dictionary['AOR_Report'] = array( |
| 41 | - 'table'=>'aor_reports', |
|
| 42 | - 'audited'=>true, |
|
| 43 | - 'duplicate_merge'=>true, |
|
| 44 | - 'fields'=>array ( |
|
| 45 | - 'report_module' => |
|
| 46 | - array ( |
|
| 47 | - 'required' => true, |
|
| 48 | - 'name' => 'report_module', |
|
| 49 | - 'vname' => 'LBL_REPORT_MODULE', |
|
| 50 | - 'type' => 'enum', |
|
| 51 | - 'massupdate' => 0, |
|
| 52 | - 'default' => '', |
|
| 53 | - 'no_default' => false, |
|
| 54 | - 'comments' => '', |
|
| 55 | - 'help' => '', |
|
| 56 | - 'importable' => 'true', |
|
| 57 | - 'duplicate_merge' => 'disabled', |
|
| 58 | - 'duplicate_merge_dom_value' => '0', |
|
| 59 | - 'audited' => true, |
|
| 60 | - 'reportable' => true, |
|
| 61 | - 'unified_search' => false, |
|
| 62 | - 'merge_filter' => 'disabled', |
|
| 63 | - 'len' => 100, |
|
| 64 | - 'size' => '20', |
|
| 65 | - 'options' => 'aor_moduleList', |
|
| 66 | - 'studio' => 'visible', |
|
| 67 | - 'dependency' => false, |
|
| 68 | - ), |
|
| 41 | + 'table'=>'aor_reports', |
|
| 42 | + 'audited'=>true, |
|
| 43 | + 'duplicate_merge'=>true, |
|
| 44 | + 'fields'=>array ( |
|
| 45 | + 'report_module' => |
|
| 46 | + array ( |
|
| 47 | + 'required' => true, |
|
| 48 | + 'name' => 'report_module', |
|
| 49 | + 'vname' => 'LBL_REPORT_MODULE', |
|
| 50 | + 'type' => 'enum', |
|
| 51 | + 'massupdate' => 0, |
|
| 52 | + 'default' => '', |
|
| 53 | + 'no_default' => false, |
|
| 54 | + 'comments' => '', |
|
| 55 | + 'help' => '', |
|
| 56 | + 'importable' => 'true', |
|
| 57 | + 'duplicate_merge' => 'disabled', |
|
| 58 | + 'duplicate_merge_dom_value' => '0', |
|
| 59 | + 'audited' => true, |
|
| 60 | + 'reportable' => true, |
|
| 61 | + 'unified_search' => false, |
|
| 62 | + 'merge_filter' => 'disabled', |
|
| 63 | + 'len' => 100, |
|
| 64 | + 'size' => '20', |
|
| 65 | + 'options' => 'aor_moduleList', |
|
| 66 | + 'studio' => 'visible', |
|
| 67 | + 'dependency' => false, |
|
| 68 | + ), |
|
| 69 | 69 | |
| 70 | - 'graphs_per_row' => |
|
| 71 | - array ( |
|
| 72 | - 'required' => true, |
|
| 73 | - 'name' => 'graphs_per_row', |
|
| 74 | - 'vname' => 'LBL_GRAPHS_PER_ROW', |
|
| 75 | - 'type' => 'int', |
|
| 76 | - 'massupdate' => 0, |
|
| 77 | - 'default' => 2, |
|
| 78 | - 'no_default' => false, |
|
| 79 | - ), |
|
| 70 | + 'graphs_per_row' => |
|
| 71 | + array ( |
|
| 72 | + 'required' => true, |
|
| 73 | + 'name' => 'graphs_per_row', |
|
| 74 | + 'vname' => 'LBL_GRAPHS_PER_ROW', |
|
| 75 | + 'type' => 'int', |
|
| 76 | + 'massupdate' => 0, |
|
| 77 | + 'default' => 2, |
|
| 78 | + 'no_default' => false, |
|
| 79 | + ), |
|
| 80 | 80 | |
| 81 | 81 | 'field_lines' => |
| 82 | 82 | array ( |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | 'include' => 'modules/AOR_Conditions/conditionLines.php' |
| 119 | 119 | ), |
| 120 | 120 | ), |
| 121 | - 'aor_fields' => |
|
| 122 | - array ( |
|
| 121 | + 'aor_fields' => |
|
| 122 | + array ( |
|
| 123 | 123 | 'name' => 'aor_fields', |
| 124 | 124 | 'type' => 'link', |
| 125 | 125 | 'relationship' => 'aor_reports_aor_fields', |
@@ -127,26 +127,26 @@ discard block |
||
| 127 | 127 | 'bean_name'=>'AOR_Field', |
| 128 | 128 | 'source'=>'non-db', |
| 129 | 129 | 'id_name' => 'aor_report_id', |
| 130 | - ), |
|
| 131 | - 'aor_conditions' => |
|
| 132 | - array ( |
|
| 133 | - 'name' => 'aor_conditions', |
|
| 134 | - 'type' => 'link', |
|
| 135 | - 'relationship' => 'aor_reports_aor_conditions', |
|
| 136 | - 'module'=>'AOR_Conditions', |
|
| 137 | - 'bean_name'=>'AOR_Condition', |
|
| 138 | - 'source'=>'non-db', |
|
| 139 | - ), |
|
| 140 | - 'aor_charts' => |
|
| 141 | - array ( |
|
| 130 | + ), |
|
| 131 | + 'aor_conditions' => |
|
| 132 | + array ( |
|
| 133 | + 'name' => 'aor_conditions', |
|
| 134 | + 'type' => 'link', |
|
| 135 | + 'relationship' => 'aor_reports_aor_conditions', |
|
| 136 | + 'module'=>'AOR_Conditions', |
|
| 137 | + 'bean_name'=>'AOR_Condition', |
|
| 138 | + 'source'=>'non-db', |
|
| 139 | + ), |
|
| 140 | + 'aor_charts' => |
|
| 141 | + array ( |
|
| 142 | 142 | 'name' => 'aor_charts', |
| 143 | 143 | 'type' => 'link', |
| 144 | 144 | 'relationship' => 'aor_charts_aor_reports', |
| 145 | 145 | 'source' => 'non-db', |
| 146 | 146 | 'id_name' => 'aor_report_id', |
| 147 | 147 | 'vname' => 'LBL_AOR_CHARTS', |
| 148 | - ), |
|
| 149 | - 'aor_scheduled_reports' => |
|
| 148 | + ), |
|
| 149 | + 'aor_scheduled_reports' => |
|
| 150 | 150 | array ( |
| 151 | 151 | 'name' => 'aor_scheduled_reports', |
| 152 | 152 | 'type' => 'link', |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | 'relationship_type'=>'one-to-many', |
| 189 | 189 | ), |
| 190 | 190 | ), |
| 191 | - 'optimistic_locking'=>true, |
|
| 192 | - 'unified_search'=>true, |
|
| 191 | + 'optimistic_locking'=>true, |
|
| 192 | + 'unified_search'=>true, |
|
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | if (!class_exists('VardefManager')){ |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | 'table'=>'aor_reports', |
| 42 | 42 | 'audited'=>true, |
| 43 | 43 | 'duplicate_merge'=>true, |
| 44 | - 'fields'=>array ( |
|
| 44 | + 'fields'=>array( |
|
| 45 | 45 | 'report_module' => |
| 46 | - array ( |
|
| 46 | + array( |
|
| 47 | 47 | 'required' => true, |
| 48 | 48 | 'name' => 'report_module', |
| 49 | 49 | 'vname' => 'LBL_REPORT_MODULE', |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | ), |
| 69 | 69 | |
| 70 | 70 | 'graphs_per_row' => |
| 71 | - array ( |
|
| 71 | + array( |
|
| 72 | 72 | 'required' => true, |
| 73 | 73 | 'name' => 'graphs_per_row', |
| 74 | 74 | 'vname' => 'LBL_GRAPHS_PER_ROW', |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ), |
| 80 | 80 | |
| 81 | 81 | 'field_lines' => |
| 82 | - array ( |
|
| 82 | + array( |
|
| 83 | 83 | 'required' => false, |
| 84 | 84 | 'name' => 'field_lines', |
| 85 | 85 | 'vname' => 'LBL_FIELD_LINES', |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | 'audited' => false, |
| 93 | 93 | 'reportable' => false, |
| 94 | 94 | 'function' => |
| 95 | - array ( |
|
| 95 | + array( |
|
| 96 | 96 | 'name' => 'display_field_lines', |
| 97 | 97 | 'returns' => 'html', |
| 98 | 98 | 'include' => 'modules/AOR_Fields/fieldLines.php' |
| 99 | 99 | ), |
| 100 | 100 | ), |
| 101 | 101 | 'condition_lines' => |
| 102 | - array ( |
|
| 102 | + array( |
|
| 103 | 103 | 'required' => false, |
| 104 | 104 | 'name' => 'condition_lines', |
| 105 | 105 | 'vname' => 'LBL_CONDITION_LINES', |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | 'audited' => false, |
| 113 | 113 | 'reportable' => false, |
| 114 | 114 | 'function' => |
| 115 | - array ( |
|
| 115 | + array( |
|
| 116 | 116 | 'name' => 'display_condition_lines', |
| 117 | 117 | 'returns' => 'html', |
| 118 | 118 | 'include' => 'modules/AOR_Conditions/conditionLines.php' |
| 119 | 119 | ), |
| 120 | 120 | ), |
| 121 | 121 | 'aor_fields' => |
| 122 | - array ( |
|
| 122 | + array( |
|
| 123 | 123 | 'name' => 'aor_fields', |
| 124 | 124 | 'type' => 'link', |
| 125 | 125 | 'relationship' => 'aor_reports_aor_fields', |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'id_name' => 'aor_report_id', |
| 130 | 130 | ), |
| 131 | 131 | 'aor_conditions' => |
| 132 | - array ( |
|
| 132 | + array( |
|
| 133 | 133 | 'name' => 'aor_conditions', |
| 134 | 134 | 'type' => 'link', |
| 135 | 135 | 'relationship' => 'aor_reports_aor_conditions', |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | 'source'=>'non-db', |
| 139 | 139 | ), |
| 140 | 140 | 'aor_charts' => |
| 141 | - array ( |
|
| 141 | + array( |
|
| 142 | 142 | 'name' => 'aor_charts', |
| 143 | 143 | 'type' => 'link', |
| 144 | 144 | 'relationship' => 'aor_charts_aor_reports', |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | 'vname' => 'LBL_AOR_CHARTS', |
| 148 | 148 | ), |
| 149 | 149 | 'aor_scheduled_reports' => |
| 150 | - array ( |
|
| 150 | + array( |
|
| 151 | 151 | 'name' => 'aor_scheduled_reports', |
| 152 | 152 | 'type' => 'link', |
| 153 | 153 | 'relationship' => 'aor_scheduled_reports_aor_reports', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | ), |
| 158 | 158 | |
| 159 | 159 | ), |
| 160 | -'relationships'=>array ( |
|
| 160 | +'relationships'=>array( |
|
| 161 | 161 | 'aor_reports_aor_fields' => |
| 162 | 162 | array( |
| 163 | 163 | 'lhs_module'=> 'AOR_Reports', |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | 'rhs_key' => 'aor_report_id', |
| 179 | 179 | 'relationship_type'=>'one-to-many', |
| 180 | 180 | ), |
| 181 | - "aor_scheduled_reports_aor_reports" => array ( |
|
| 181 | + "aor_scheduled_reports_aor_reports" => array( |
|
| 182 | 182 | 'lhs_module'=> 'AOR_Reports', |
| 183 | 183 | 'lhs_table'=> 'aor_reports', |
| 184 | 184 | 'lhs_key' => 'id', |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | 'unified_search'=>true, |
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | -if (!class_exists('VardefManager')){ |
|
| 195 | +if (!class_exists('VardefManager')) { |
|
| 196 | 196 | require_once('include/SugarObjects/VardefManager.php'); |
| 197 | 197 | } |
| 198 | -VardefManager::createVardef('AOR_Reports','AOR_Report', array('basic','assignable','security_groups')); |
|
| 198 | +VardefManager::createVardef('AOR_Reports', 'AOR_Report', array('basic', 'assignable', 'security_groups')); |
|
| 199 | 199 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $fieldDisplay = $currentBean->field_name_map[$field]['vname']; |
| 63 | 63 | $fieldDisplay = translate($fieldDisplay, $currentBean->module_dir); |
| 64 | 64 | $fieldDisplay = trim($fieldDisplay, ':'); |
| 65 | - foreach($modulePathDisplay as &$module) { |
|
| 65 | + foreach ($modulePathDisplay as &$module) { |
|
| 66 | 66 | $module = isset($app_list_strings['aor_moduleList'][$module]) ? $app_list_strings['aor_moduleList'][$module] : ( |
| 67 | 67 | isset($app_list_strings['moduleList'][$module]) ? $app_list_strings['moduleList'][$module] : $module |
| 68 | 68 | ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | function requestToUserParameters() |
| 74 | 74 | { |
| 75 | 75 | $params = array(); |
| 76 | - if(isset($_REQUEST['parameter_id']) && $_REQUEST['parameter_id']) { |
|
| 76 | + if (isset($_REQUEST['parameter_id']) && $_REQUEST['parameter_id']) { |
|
| 77 | 77 | foreach ($_REQUEST['parameter_id'] as $key => $parameterId) { |
| 78 | 78 | if ($_REQUEST['parameter_type'][$key] === 'Multi') { |
| 79 | 79 | $_REQUEST['parameter_value'][$key] = encodeMultienumValue(explode(',', $_REQUEST['parameter_value'][$key])); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $offsetMonths -= 1; |
| 229 | 229 | // Offset months |
| 230 | 230 | if ($offsetMonths > 0) { |
| 231 | - $q1start->add(new DateInterval('P' . $offsetMonths . 'M')); |
|
| 231 | + $q1start->add(new DateInterval('P'.$offsetMonths.'M')); |
|
| 232 | 232 | } |
| 233 | 233 | $q1end = DateTime::createFromFormat(DATE_ISO8601, $q1start->format(DATE_ISO8601)); |
| 234 | 234 | $q1end->add(new DateInterval('P2M')); |
@@ -88,6 +88,9 @@ |
||
| 88 | 88 | return $params; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | +/** |
|
| 92 | + * @param SugarBean $report |
|
| 93 | + */ |
|
| 91 | 94 | function getConditionsAsParameters($report, $override = array()) |
| 92 | 95 | { |
| 93 | 96 | if (empty($report)) { |
@@ -1,88 +1,88 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Advanced OpenReports, SugarCRM Reporting. |
|
| 4 | - * @package Advanced OpenReports for SugarCRM |
|
| 5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
| 6 | - * |
|
| 7 | - * This program is free software; you can redistribute it and/or modify |
|
| 8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
| 9 | - * the Free Software Foundation; either version 3 of the License, or |
|
| 10 | - * (at your option) any later version. |
|
| 11 | - * |
|
| 12 | - * This program is distributed in the hope that it will be useful, |
|
| 13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 | - * GNU General Public License for more details. |
|
| 16 | - * |
|
| 17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
| 19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
| 20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
| 21 | - * |
|
| 22 | - * @author SalesAgility <[email protected]> |
|
| 23 | - */ |
|
| 3 | + * Advanced OpenReports, SugarCRM Reporting. |
|
| 4 | + * @package Advanced OpenReports for SugarCRM |
|
| 5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
| 6 | + * |
|
| 7 | + * This program is free software; you can redistribute it and/or modify |
|
| 8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
| 9 | + * the Free Software Foundation; either version 3 of the License, or |
|
| 10 | + * (at your option) any later version. |
|
| 11 | + * |
|
| 12 | + * This program is distributed in the hope that it will be useful, |
|
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 | + * GNU General Public License for more details. |
|
| 16 | + * |
|
| 17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
| 19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
| 20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
| 21 | + * |
|
| 22 | + * @author SalesAgility <[email protected]> |
|
| 23 | + */ |
|
| 24 | 24 | |
| 25 | 25 | $mod_strings = array ( |
| 26 | - 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
|
| 27 | - 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
|
| 28 | - 'LBL_ID' => 'ID', |
|
| 29 | - 'LBL_DATE_ENTERED' => 'Date Created', |
|
| 30 | - 'LBL_DATE_MODIFIED' => 'Date Modified', |
|
| 31 | - 'LBL_MODIFIED' => 'Modified By', |
|
| 32 | - 'LBL_MODIFIED_ID' => 'Modified By Id', |
|
| 33 | - 'LBL_MODIFIED_NAME' => 'Modified By Name', |
|
| 34 | - 'LBL_CREATED' => 'Created By', |
|
| 35 | - 'LBL_CREATED_ID' => 'Created By Id', |
|
| 36 | - 'LBL_DESCRIPTION' => 'Description', |
|
| 37 | - 'LBL_DELETED' => 'Deleted', |
|
| 38 | - 'LBL_NAME' => 'Name', |
|
| 39 | - 'LBL_CREATED_USER' => 'Created by User', |
|
| 40 | - 'LBL_MODIFIED_USER' => 'Modified by User', |
|
| 41 | - 'LBL_LIST_NAME' => 'Name', |
|
| 42 | - 'LBL_EDIT_BUTTON' => 'Edit', |
|
| 43 | - 'LBL_REMOVE' => 'Remove', |
|
| 44 | - 'LBL_LIST_FORM_TITLE' => 'Reports List', |
|
| 45 | - 'LBL_MODULE_NAME' => 'Reports', |
|
| 46 | - 'LBL_MODULE_TITLE' => 'Reports', |
|
| 47 | - 'LBL_HOMEPAGE_TITLE' => 'My Reports', |
|
| 48 | - 'LNK_NEW_RECORD' => 'Create Report', |
|
| 49 | - 'LNK_LIST' => 'View Reports', |
|
| 50 | - 'LNK_IMPORT_AOR_REPORTS' => 'Import Reports', |
|
| 51 | - 'LBL_SEARCH_FORM_TITLE' => 'Search Reports', |
|
| 52 | - 'LBL_HISTORY_SUBPANEL_TITLE' => 'View History', |
|
| 53 | - 'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities', |
|
| 54 | - 'LBL_AOR_REPORTS_SUBPANEL_TITLE' => 'Reports', |
|
| 55 | - 'LBL_NEW_FORM_TITLE' => 'New Reports', |
|
| 56 | - 'LBL_REPORT_MODULE' => 'Report Module', |
|
| 26 | + 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
|
| 27 | + 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
|
| 28 | + 'LBL_ID' => 'ID', |
|
| 29 | + 'LBL_DATE_ENTERED' => 'Date Created', |
|
| 30 | + 'LBL_DATE_MODIFIED' => 'Date Modified', |
|
| 31 | + 'LBL_MODIFIED' => 'Modified By', |
|
| 32 | + 'LBL_MODIFIED_ID' => 'Modified By Id', |
|
| 33 | + 'LBL_MODIFIED_NAME' => 'Modified By Name', |
|
| 34 | + 'LBL_CREATED' => 'Created By', |
|
| 35 | + 'LBL_CREATED_ID' => 'Created By Id', |
|
| 36 | + 'LBL_DESCRIPTION' => 'Description', |
|
| 37 | + 'LBL_DELETED' => 'Deleted', |
|
| 38 | + 'LBL_NAME' => 'Name', |
|
| 39 | + 'LBL_CREATED_USER' => 'Created by User', |
|
| 40 | + 'LBL_MODIFIED_USER' => 'Modified by User', |
|
| 41 | + 'LBL_LIST_NAME' => 'Name', |
|
| 42 | + 'LBL_EDIT_BUTTON' => 'Edit', |
|
| 43 | + 'LBL_REMOVE' => 'Remove', |
|
| 44 | + 'LBL_LIST_FORM_TITLE' => 'Reports List', |
|
| 45 | + 'LBL_MODULE_NAME' => 'Reports', |
|
| 46 | + 'LBL_MODULE_TITLE' => 'Reports', |
|
| 47 | + 'LBL_HOMEPAGE_TITLE' => 'My Reports', |
|
| 48 | + 'LNK_NEW_RECORD' => 'Create Report', |
|
| 49 | + 'LNK_LIST' => 'View Reports', |
|
| 50 | + 'LNK_IMPORT_AOR_REPORTS' => 'Import Reports', |
|
| 51 | + 'LBL_SEARCH_FORM_TITLE' => 'Search Reports', |
|
| 52 | + 'LBL_HISTORY_SUBPANEL_TITLE' => 'View History', |
|
| 53 | + 'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities', |
|
| 54 | + 'LBL_AOR_REPORTS_SUBPANEL_TITLE' => 'Reports', |
|
| 55 | + 'LBL_NEW_FORM_TITLE' => 'New Reports', |
|
| 56 | + 'LBL_REPORT_MODULE' => 'Report Module', |
|
| 57 | 57 | 'LBL_GRAPHS_PER_ROW' => 'Charts per row', |
| 58 | - 'LBL_FIELD_LINES' => 'Display Fields', |
|
| 59 | - 'LBL_ADD_FIELD' => 'Add Field', |
|
| 60 | - 'LBL_CONDITION_LINES' => 'Conditions', |
|
| 61 | - 'LBL_ADD_CONDITION' => 'Add Condition', |
|
| 62 | - 'LBL_EXPORT' => 'Export', |
|
| 63 | - 'LBL_DOWNLOAD_PDF' => 'Download PDF', |
|
| 64 | - 'LBL_ADD_TO_PROSPECT_LIST' => 'Add To Target List', |
|
| 65 | - 'LBL_AOR_MODULETREE_SUBPANEL_TITLE' => 'Module tree', |
|
| 66 | - 'LBL_AOR_FIELDS_SUBPANEL_TITLE' => 'Fields', |
|
| 67 | - 'LBL_AOR_CONDITIONS_SUBPANEL_TITLE' => 'Conditions', |
|
| 68 | - 'LBL_TOTAL' => 'Total', |
|
| 69 | - 'LBL_AOR_CHARTS_SUBPANEL_TITLE' => 'Charts', |
|
| 70 | - 'LBL_ADD_CHART' => 'Add chart', |
|
| 58 | + 'LBL_FIELD_LINES' => 'Display Fields', |
|
| 59 | + 'LBL_ADD_FIELD' => 'Add Field', |
|
| 60 | + 'LBL_CONDITION_LINES' => 'Conditions', |
|
| 61 | + 'LBL_ADD_CONDITION' => 'Add Condition', |
|
| 62 | + 'LBL_EXPORT' => 'Export', |
|
| 63 | + 'LBL_DOWNLOAD_PDF' => 'Download PDF', |
|
| 64 | + 'LBL_ADD_TO_PROSPECT_LIST' => 'Add To Target List', |
|
| 65 | + 'LBL_AOR_MODULETREE_SUBPANEL_TITLE' => 'Module tree', |
|
| 66 | + 'LBL_AOR_FIELDS_SUBPANEL_TITLE' => 'Fields', |
|
| 67 | + 'LBL_AOR_CONDITIONS_SUBPANEL_TITLE' => 'Conditions', |
|
| 68 | + 'LBL_TOTAL' => 'Total', |
|
| 69 | + 'LBL_AOR_CHARTS_SUBPANEL_TITLE' => 'Charts', |
|
| 70 | + 'LBL_ADD_CHART' => 'Add chart', |
|
| 71 | 71 | 'LBL_ADD_PARENTHESIS' => 'Drop parenthesis', |
| 72 | - 'LBL_CHART_TITLE' => 'Title', |
|
| 73 | - 'LBL_CHART_TYPE' => 'Type', |
|
| 74 | - 'LBL_CHART_X_FIELD' => 'X Axis', |
|
| 75 | - 'LBL_CHART_Y_FIELD' => 'Y Axis', |
|
| 76 | - 'LBL_AOR_REPORTS_DASHLET' => 'Reports', |
|
| 77 | - 'LBL_DASHLET_TITLE' => 'Title', |
|
| 78 | - 'LBL_DASHLET_REPORT' => 'Report', |
|
| 79 | - 'LBL_DASHLET_CHOOSE_REPORT' => 'Please choose a report', |
|
| 80 | - 'LBL_DASHLET_SAVE' => 'Save', |
|
| 81 | - 'LBL_DASHLET_CHARTS' => 'Charts', |
|
| 82 | - 'LBL_DASHLET_ONLY_CHARTS' => 'Only show charts', |
|
| 83 | - 'LBL_AOR_SCHEDULED_REPORTS_AOR_REPORTS_FROM_AOR_SCHEDULED_REPORTS_TITLE' => 'Scheduled Reports', |
|
| 84 | - 'LBL_UPDATE_PARAMETERS' => 'Update', |
|
| 85 | - 'LBL_PARAMETERS' => 'Parameters', |
|
| 72 | + 'LBL_CHART_TITLE' => 'Title', |
|
| 73 | + 'LBL_CHART_TYPE' => 'Type', |
|
| 74 | + 'LBL_CHART_X_FIELD' => 'X Axis', |
|
| 75 | + 'LBL_CHART_Y_FIELD' => 'Y Axis', |
|
| 76 | + 'LBL_AOR_REPORTS_DASHLET' => 'Reports', |
|
| 77 | + 'LBL_DASHLET_TITLE' => 'Title', |
|
| 78 | + 'LBL_DASHLET_REPORT' => 'Report', |
|
| 79 | + 'LBL_DASHLET_CHOOSE_REPORT' => 'Please choose a report', |
|
| 80 | + 'LBL_DASHLET_SAVE' => 'Save', |
|
| 81 | + 'LBL_DASHLET_CHARTS' => 'Charts', |
|
| 82 | + 'LBL_DASHLET_ONLY_CHARTS' => 'Only show charts', |
|
| 83 | + 'LBL_AOR_SCHEDULED_REPORTS_AOR_REPORTS_FROM_AOR_SCHEDULED_REPORTS_TITLE' => 'Scheduled Reports', |
|
| 84 | + 'LBL_UPDATE_PARAMETERS' => 'Update', |
|
| 85 | + 'LBL_PARAMETERS' => 'Parameters', |
|
| 86 | 86 | 'LBL_TOOLTIP_DRAG_DROP_ELEMS' => 'Drag and drop elements into field or condition area', |
| 87 | 87 | 'LBL_MAIN_GROUPS' => 'Main Group:', |
| 88 | 88 | ); |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * @author SalesAgility <[email protected]> |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | -$mod_strings = array ( |
|
| 25 | +$mod_strings = array( |
|
| 26 | 26 | 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
| 27 | 27 | 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
| 28 | 28 | 'LBL_ID' => 'ID', |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | var $object_name = 'AOR_Report'; |
| 29 | 29 | var $table_name = 'aor_reports'; |
| 30 | 30 | var $importable = true; |
| 31 | - var $disable_row_level_security = true ; |
|
| 31 | + var $disable_row_level_security = true; |
|
| 32 | 32 | |
| 33 | 33 | var $id; |
| 34 | 34 | var $name; |
@@ -47,25 +47,25 @@ discard block |
||
| 47 | 47 | var $assigned_user_link; |
| 48 | 48 | var $report_module; |
| 49 | 49 | |
| 50 | - function AOR_Report(){ |
|
| 50 | + function AOR_Report() { |
|
| 51 | 51 | parent::Basic(); |
| 52 | 52 | $this->load_report_beans(); |
| 53 | 53 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - function bean_implements($interface){ |
|
| 57 | - switch($interface){ |
|
| 56 | + function bean_implements($interface) { |
|
| 57 | + switch ($interface) { |
|
| 58 | 58 | case 'ACL': return true; |
| 59 | 59 | } |
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - function save($check_notify = FALSE){ |
|
| 63 | + function save($check_notify = FALSE) { |
|
| 64 | 64 | |
| 65 | 65 | // TODO: process of saveing the fields and conditions is too long so we will have to make some optimization on save_lines functions |
| 66 | 66 | set_time_limit(3600); |
| 67 | 67 | |
| 68 | - if (empty($this->id)){ |
|
| 68 | + if (empty($this->id)) { |
|
| 69 | 69 | unset($_POST['aor_conditions_id']); |
| 70 | 70 | unset($_POST['aor_fields_id']); |
| 71 | 71 | } |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | $chart->save_lines($_POST, $this, 'aor_chart_'); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - function load_report_beans(){ |
|
| 88 | + function load_report_beans() { |
|
| 89 | 89 | global $beanList, $app_list_strings; |
| 90 | 90 | |
| 91 | 91 | $app_list_strings['aor_moduleList'] = $app_list_strings['moduleList']; |
| 92 | 92 | |
| 93 | - foreach($app_list_strings['aor_moduleList'] as $mkey => $mvalue){ |
|
| 94 | - if(!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')){ |
|
| 93 | + foreach ($app_list_strings['aor_moduleList'] as $mkey => $mvalue) { |
|
| 94 | + if (!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')) { |
|
| 95 | 95 | unset($app_list_strings['aor_moduleList'][$mkey]); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | - function getReportFields(){ |
|
| 105 | + function getReportFields() { |
|
| 106 | 106 | $fields = array(); |
| 107 | - foreach($this->get_linked_beans('aor_fields','AOR_Fields') as $field){ |
|
| 107 | + foreach ($this->get_linked_beans('aor_fields', 'AOR_Fields') as $field) { |
|
| 108 | 108 | $fields[] = $field; |
| 109 | 109 | } |
| 110 | - usort($fields,function($a,$b){ |
|
| 110 | + usort($fields, function($a, $b) { |
|
| 111 | 111 | return $a->field_order - $b->field_order; |
| 112 | 112 | }); |
| 113 | 113 | return $fields; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | const CHART_TYPE_RGRAPH = 'rgraph'; |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART){ |
|
| 121 | + function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART) { |
|
| 122 | 122 | global $beanList; |
| 123 | 123 | |
| 124 | 124 | |
@@ -141,16 +141,16 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $field_module = $this->report_module; |
| 143 | 143 | $field_alias = $field_bean->table_name; |
| 144 | - if($path[0] != $this->report_module){ |
|
| 145 | - foreach($path as $rel){ |
|
| 146 | - if(empty($rel)){ |
|
| 144 | + if ($path[0] != $this->report_module) { |
|
| 145 | + foreach ($path as $rel) { |
|
| 146 | + if (empty($rel)) { |
|
| 147 | 147 | continue; |
| 148 | 148 | } |
| 149 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 150 | - $field_alias = $field_alias . ':'.$rel; |
|
| 149 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 150 | + $field_alias = $field_alias.':'.$rel; |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - $label = str_replace(' ','_',$field->label).$i; |
|
| 153 | + $label = str_replace(' ', '_', $field->label).$i; |
|
| 154 | 154 | $fields[$label]['field'] = $field->field; |
| 155 | 155 | $fields[$label]['label'] = $field->label; |
| 156 | 156 | $fields[$label]['display'] = $field->display; |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | // get the main group |
| 165 | 165 | |
| 166 | - if($field->group_display) { |
|
| 166 | + if ($field->group_display) { |
|
| 167 | 167 | |
| 168 | 168 | // if we have a main group already thats wrong cause only one main grouping field possible |
| 169 | - if(!is_null($mainGroupField)) { |
|
| 169 | + if (!is_null($mainGroupField)) { |
|
| 170 | 170 | $GLOBALS['log']->fatal('main group already found'); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -181,17 +181,17 @@ discard block |
||
| 181 | 181 | $query = $this->build_report_query(); |
| 182 | 182 | $result = $this->db->query($query); |
| 183 | 183 | $data = array(); |
| 184 | - while($row = $this->db->fetchByAssoc($result, false)) |
|
| 184 | + while ($row = $this->db->fetchByAssoc($result, false)) |
|
| 185 | 185 | { |
| 186 | - foreach($fields as $name => $att){ |
|
| 186 | + foreach ($fields as $name => $att) { |
|
| 187 | 187 | |
| 188 | 188 | $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : ''; |
| 189 | 189 | |
| 190 | - switch ($att['function']){ |
|
| 190 | + switch ($att['function']) { |
|
| 191 | 191 | case 'COUNT': |
| 192 | 192 | break; |
| 193 | 193 | default: |
| 194 | - if(!is_numeric($row[$name])) { |
|
| 194 | + if (!is_numeric($row[$name])) { |
|
| 195 | 195 | $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id))); |
| 196 | 196 | } |
| 197 | 197 | break; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | $fields = $this->getReportFields(); |
| 205 | 205 | |
| 206 | - switch($chartType) { |
|
| 206 | + switch ($chartType) { |
|
| 207 | 207 | case self::CHART_TYPE_PCHART: |
| 208 | 208 | $html = '<script src="modules/AOR_Charts/lib/pChart/imagemap.js"></script>'; |
| 209 | 209 | break; |
@@ -211,17 +211,17 @@ discard block |
||
| 211 | 211 | $html = '<script src="modules/AOR_Reports/js/Chart.js"></script>'; |
| 212 | 212 | break; |
| 213 | 213 | case self::CHART_TYPE_RGRAPH: |
| 214 | - if($_REQUEST['module']!= 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 214 | + if ($_REQUEST['module'] != 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 215 | 215 | require_once('include/SuiteGraphs/RGraphIncludes.php'); |
| 216 | 216 | |
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | $x = 0; |
| 220 | - foreach($this->get_linked_beans('aor_charts','AOR_Charts') as $chart){ |
|
| 221 | - if($chartIds !== null && !in_array($chart->id,$chartIds)){ |
|
| 220 | + foreach ($this->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) { |
|
| 221 | + if ($chartIds !== null && !in_array($chart->id, $chartIds)) { |
|
| 222 | 222 | continue; |
| 223 | 223 | } |
| 224 | - $html .= $chart->buildChartHTML($data,$fields,$x, $chartType, $mainGroupField); |
|
| 224 | + $html .= $chart->buildChartHTML($data, $fields, $x, $chartType, $mainGroupField); |
|
| 225 | 225 | $x++; |
| 226 | 226 | } |
| 227 | 227 | return $html; |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $rows = $this->getGroupDisplayFieldByReportId($this->id, $level); |
| 235 | 235 | |
| 236 | - if(count($rows) > 1) { |
|
| 237 | - $GLOBALS['log']->fatal('ambiguous group display for report ' . $this->id); |
|
| 236 | + if (count($rows) > 1) { |
|
| 237 | + $GLOBALS['log']->fatal('ambiguous group display for report '.$this->id); |
|
| 238 | 238 | } |
| 239 | - else if(count($rows) == 1){ |
|
| 239 | + else if (count($rows) == 1) { |
|
| 240 | 240 | $rows[0]['module_path'] = unserialize(base64_decode($rows[0]['module_path'])); |
| 241 | - if(!$rows[0]['module_path'][0]) { |
|
| 241 | + if (!$rows[0]['module_path'][0]) { |
|
| 242 | 242 | $module = new $beanList[$this->report_module](); |
| 243 | 243 | $rows[0]['field_id_name'] = $module->field_defs[$rows[0]['field']]['id_name'] ? $module->field_defs[$rows[0]['field']]['id_name'] : $module->field_defs[$rows[0]['field']]['name']; |
| 244 | 244 | $rows[0]['module_path'][0] = $module->table_name; |
@@ -248,23 +248,23 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | $path[] = $rows[0]; |
| 250 | 250 | |
| 251 | - if($level>10) { |
|
| 251 | + if ($level > 10) { |
|
| 252 | 252 | $msg = 'Too many nested groups'; |
| 253 | 253 | $GLOBALS['log']->fatal($msg); |
| 254 | 254 | return null; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - return $this->buildMultiGroupReport($offset, $links, $level+1, $path); |
|
| 257 | + return $this->buildMultiGroupReport($offset, $links, $level + 1, $path); |
|
| 258 | 258 | } |
| 259 | - else if(!$rows) { |
|
| 260 | - if($path) { |
|
| 259 | + else if (!$rows) { |
|
| 260 | + if ($path) { |
|
| 261 | 261 | $html = ''; |
| 262 | 262 | foreach ($path as $pth) { |
| 263 | 263 | $_fieldIdName = $this->db->quoteIdentifier($pth['field_id_name']); |
| 264 | - $query = "SELECT $_fieldIdName FROM " . $this->db->quoteIdentifier($pth['module_path'][0]) . " GROUP BY $_fieldIdName;"; |
|
| 264 | + $query = "SELECT $_fieldIdName FROM ".$this->db->quoteIdentifier($pth['module_path'][0])." GROUP BY $_fieldIdName;"; |
|
| 265 | 265 | $values = $this->dbSelect($query); |
| 266 | 266 | |
| 267 | - foreach($values as $value) { |
|
| 267 | + foreach ($values as $value) { |
|
| 268 | 268 | |
| 269 | 269 | //$where = [ $this->db->quote($pth['module_path'][0]) . '.' . $_fieldIdName . ' = \'' . $this->db->quote($value[$pth['field_id_name']]) . '\'' ]; |
| 270 | 270 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | // escape values for query |
| 301 | 301 | |
| 302 | 302 | $_id = $this->db->quote($reportId); |
| 303 | - $_level = (int) $level; |
|
| 303 | + $_level = (int)$level; |
|
| 304 | 304 | |
| 305 | 305 | // get results array |
| 306 | 306 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $results = $this->db->query($query); |
| 316 | 316 | |
| 317 | 317 | $rows = array(); |
| 318 | - while($row = $this->db->fetchByAssoc($results)) { |
|
| 318 | + while ($row = $this->db->fetchByAssoc($results)) { |
|
| 319 | 319 | $rows[] = $row; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -324,20 +324,20 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | private function getMultiGroupFrameHTML($header, $body) { |
| 326 | 326 | $html = '<div class="multi-group-list" style="border: 1px solid black; padding: 10px;"> |
| 327 | - <h3>' . $header . '</h3> |
|
| 328 | - <div class="multi-group-list-inner">' . $body . '</div> |
|
| 327 | + <h3>' . $header.'</h3> |
|
| 328 | + <div class="multi-group-list-inner">' . $body.'</div> |
|
| 329 | 329 | </div>'; |
| 330 | 330 | return $html; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | private function addDataIdValueToInnertext($html) { |
| 334 | 334 | preg_match('/\sdata-id-value\s*=\s*"([^"]*)"/', $html, $match); |
| 335 | - $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2' . $match[1] . '$3', $html); |
|
| 335 | + $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2'.$match[1].'$3', $html); |
|
| 336 | 336 | return $html; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | |
| 340 | - function build_group_report($offset = -1, $links = true, $extra = array()){ |
|
| 340 | + function build_group_report($offset = -1, $links = true, $extra = array()) { |
|
| 341 | 341 | global $beanList; |
| 342 | 342 | |
| 343 | 343 | $html = ''; |
@@ -348,23 +348,23 @@ discard block |
||
| 348 | 348 | $sql = "SELECT id FROM aor_fields WHERE aor_report_id = '".$this->id."' AND group_display = 1 AND deleted = 0 ORDER BY field_order ASC"; |
| 349 | 349 | $field_id = $this->db->getOne($sql); |
| 350 | 350 | |
| 351 | - if(!$field_id) { |
|
| 352 | - $query_array['select'][] = $module->table_name . ".id AS '" . $module->table_name . "_id'"; |
|
| 351 | + if (!$field_id) { |
|
| 352 | + $query_array['select'][] = $module->table_name.".id AS '".$module->table_name."_id'"; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if($field_id != ''){ |
|
| 355 | + if ($field_id != '') { |
|
| 356 | 356 | $field = new AOR_Field(); |
| 357 | 357 | $field->retrieve($field_id); |
| 358 | 358 | |
| 359 | - $field_label = str_replace(' ','_',$field->label); |
|
| 359 | + $field_label = str_replace(' ', '_', $field->label); |
|
| 360 | 360 | |
| 361 | 361 | $path = unserialize(base64_decode($field->module_path)); |
| 362 | 362 | |
| 363 | 363 | $field_module = $module; |
| 364 | 364 | $table_alias = $field_module->table_name; |
| 365 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
| 366 | - foreach($path as $rel){ |
|
| 367 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)]; |
|
| 365 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
| 366 | + foreach ($path as $rel) { |
|
| 367 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)]; |
|
| 368 | 368 | $oldAlias = $table_alias; |
| 369 | 369 | $table_alias = $table_alias.":".$rel; |
| 370 | 370 | |
@@ -378,71 +378,71 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | $data = $field_module->field_defs[$field->field]; |
| 380 | 380 | |
| 381 | - if($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 381 | + if ($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 382 | 382 | $field->field = $data['id_name']; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) { |
|
| 386 | - if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 385 | + if ($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) { |
|
| 386 | + if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 387 | 387 | $query['select'][$table_alias.'_currency_id'] = $table_alias.'_cstm'.".currency_id AS '".$table_alias."_currency_id'"; |
| 388 | 388 | } else { |
| 389 | - $query_array['select'][$table_alias . '_currency_id'] = $table_alias . ".currency_id AS '" . $table_alias . "_currency_id'"; |
|
| 389 | + $query_array['select'][$table_alias.'_currency_id'] = $table_alias.".currency_id AS '".$table_alias."_currency_id'"; |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if( (isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 393 | + if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 394 | 394 | $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field; |
| 395 | 395 | // ? $query_array = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm',$table_alias, $field_module, 'custom', $query); |
| 396 | 396 | $query_array = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $field_module, 'custom', $query); |
| 397 | 397 | } else { |
| 398 | - $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 398 | + $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if($field->sort_by != ''){ |
|
| 401 | + if ($field->sort_by != '') { |
|
| 402 | 402 | $query_array['sort_by'][] = $field_label.' '.$field->sort_by; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if($field->group_by == 1){ |
|
| 405 | + if ($field->group_by == 1) { |
|
| 406 | 406 | $query_array['group_by'][] = $select_field; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if($field->field_function != null){ |
|
| 409 | + if ($field->field_function != null) { |
|
| 410 | 410 | $select_field = $field->field_function.'('.$select_field.')'; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $query_array['select'][] = $select_field ." AS '".$field_label."'"; |
|
| 414 | - if(isset($extra['select']) && $extra['select']) { |
|
| 415 | - foreach($extra['select'] as $selectField => $selectAlias) { |
|
| 416 | - if($selectAlias) { |
|
| 417 | - $query_array['select'][] = $selectField . " AS " . $selectAlias; |
|
| 413 | + $query_array['select'][] = $select_field." AS '".$field_label."'"; |
|
| 414 | + if (isset($extra['select']) && $extra['select']) { |
|
| 415 | + foreach ($extra['select'] as $selectField => $selectAlias) { |
|
| 416 | + if ($selectAlias) { |
|
| 417 | + $query_array['select'][] = $selectField." AS ".$selectAlias; |
|
| 418 | 418 | } |
| 419 | 419 | else { |
| 420 | 420 | $query_array['select'][] = $selectField; |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | - $query_array['where'][] = $select_field ." IS NOT NULL AND "; |
|
| 425 | - if(isset($extra['where']) && $extra['where']) { |
|
| 426 | - $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND '; |
|
| 424 | + $query_array['where'][] = $select_field." IS NOT NULL AND "; |
|
| 425 | + if (isset($extra['where']) && $extra['where']) { |
|
| 426 | + $query_array['where'][] = implode(' AND ', $extra['where']).' AND '; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $query_array = $this->build_report_query_where($query_array); |
| 430 | 430 | |
| 431 | - foreach ($query_array['select'] as $select){ |
|
| 432 | - $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 431 | + foreach ($query_array['select'] as $select) { |
|
| 432 | + $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | $query .= ' FROM '.$module->table_name.' '; |
| 436 | 436 | |
| 437 | - if(isset($query_array['join'])){ |
|
| 438 | - foreach ($query_array['join'] as $join){ |
|
| 437 | + if (isset($query_array['join'])) { |
|
| 438 | + foreach ($query_array['join'] as $join) { |
|
| 439 | 439 | $query .= $join; |
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | - if(isset($query_array['where'])){ |
|
| 442 | + if (isset($query_array['where'])) { |
|
| 443 | 443 | $query_where = ''; |
| 444 | - foreach ($query_array['where'] as $where){ |
|
| 445 | - $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 444 | + foreach ($query_array['where'] as $where) { |
|
| 445 | + $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | $query_where = $this->queryWhereRepair($query_where); |
@@ -450,41 +450,41 @@ discard block |
||
| 450 | 450 | $query .= ' '.$query_where; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if(isset($query_array['group_by'])){ |
|
| 453 | + if (isset($query_array['group_by'])) { |
|
| 454 | 454 | $query_group_by = ''; |
| 455 | - foreach ($query_array['group_by'] as $group_by){ |
|
| 456 | - $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 455 | + foreach ($query_array['group_by'] as $group_by) { |
|
| 456 | + $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 457 | 457 | } |
| 458 | 458 | $query .= ' '.$query_group_by; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if(isset($query_array['sort_by'])){ |
|
| 461 | + if (isset($query_array['sort_by'])) { |
|
| 462 | 462 | $query_sort_by = ''; |
| 463 | - foreach ($query_array['sort_by'] as $sort_by){ |
|
| 464 | - $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 463 | + foreach ($query_array['sort_by'] as $sort_by) { |
|
| 464 | + $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 465 | 465 | } |
| 466 | 466 | $query .= ' '.$query_sort_by; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - $query .= ' group by ' . $field_label; |
|
| 469 | + $query .= ' group by '.$field_label; |
|
| 470 | 470 | |
| 471 | 471 | $result = $this->db->query($query); |
| 472 | 472 | |
| 473 | 473 | while ($row = $this->db->fetchByAssoc($result)) { |
| 474 | - if($html != '') $html .= '<br />'; |
|
| 474 | + if ($html != '') $html .= '<br />'; |
|
| 475 | 475 | |
| 476 | 476 | $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
| 477 | 477 | |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if($html == '') $html = $this->build_report_html($offset, $links); |
|
| 481 | + if ($html == '') $html = $this->build_report_html($offset, $links); |
|
| 482 | 482 | return $html; |
| 483 | 483 | |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | |
| 487 | - function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()){ |
|
| 487 | + function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()) { |
|
| 488 | 488 | |
| 489 | 489 | global $beanList, $sugar_config; |
| 490 | 490 | |
@@ -497,22 +497,22 @@ discard block |
||
| 497 | 497 | // We have a count query. Run it and get the results. |
| 498 | 498 | $result = $this->db->query($count_query); |
| 499 | 499 | $assoc = $this->db->fetchByAssoc($result); |
| 500 | - if(!empty($assoc['c'])) |
|
| 500 | + if (!empty($assoc['c'])) |
|
| 501 | 501 | { |
| 502 | 502 | $total_rows = $assoc['c']; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | $html = "<table class='list' id='report_table".$group_value."' width='100%' cellspacing='0' cellpadding='0' border='0' repeat_header='1'>"; |
| 506 | 506 | |
| 507 | - if($offset >= 0){ |
|
| 507 | + if ($offset >= 0) { |
|
| 508 | 508 | $start = 0; |
| 509 | 509 | $end = 0; |
| 510 | 510 | $previous_offset = 0; |
| 511 | 511 | $next_offset = 0; |
| 512 | 512 | $last_offset = 0; |
| 513 | 513 | |
| 514 | - if($total_rows > 0){ |
|
| 515 | - $start = $offset +1; |
|
| 514 | + if ($total_rows > 0) { |
|
| 515 | + $start = $offset + 1; |
|
| 516 | 516 | $end = (($offset + $max_rows) < $total_rows) ? $offset + $max_rows : $total_rows; |
| 517 | 517 | $previous_offset = ($offset - $max_rows) < 0 ? 0 : $offset - $max_rows; |
| 518 | 518 | $next_offset = $offset + $max_rows; |
@@ -524,36 +524,36 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value); |
| 526 | 526 | |
| 527 | - $html .="<td colspan='18'> |
|
| 527 | + $html .= "<td colspan='18'> |
|
| 528 | 528 | <table class='paginationTable' border='0' cellpadding='0' cellspacing='0' width='100%'> |
| 529 | 529 | <td style='text-align:left' ><H3><a href=\"javascript:void(0)\" class=\"collapseLink\" onclick=\"groupedReportToggler.toggleList(this);\"><img border=\"0\" id=\"detailpanel_1_img_hide\" src=\"themes/SuiteR/images/basic_search.gif\"></a>$moduleFieldByGroupValue</H3></td> |
| 530 | 530 | <td class='paginationChangeButtons' align='right' nowrap='nowrap' width='1%'>"; |
| 531 | 531 | |
| 532 | - if($offset == 0){ |
|
| 533 | - $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'> |
|
| 532 | + if ($offset == 0) { |
|
| 533 | + $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'> |
|
| 534 | 534 | <img src='".SugarThemeRegistry::current()->getImageURL('start_off.gif')."' alt='Start' align='absmiddle' border='0'> |
| 535 | 535 | </button> |
| 536 | 536 | <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' disabled='disabled'> |
| 537 | 537 | <img src='".SugarThemeRegistry::current()->getImageURL('previous_off.gif')."' alt='Previous' align='absmiddle' border='0'> |
| 538 | 538 | </button>"; |
| 539 | 539 | } else { |
| 540 | - $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 540 | + $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 541 | 541 | <img src='".SugarThemeRegistry::current()->getImageURL('start.gif')."' alt='Start' align='absmiddle' border='0'> |
| 542 | 542 | </button> |
| 543 | 543 | <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' onclick='changeReportPage(\"".$this->id."\",".$previous_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
| 544 | 544 | <img src='".SugarThemeRegistry::current()->getImageURL('previous.gif')."' alt='Previous' align='absmiddle' border='0'> |
| 545 | 545 | </button>"; |
| 546 | 546 | } |
| 547 | - $html .=" <span class='pageNumbers'>(".$start ." - ".$end ." of ". $total_rows .")</span>"; |
|
| 548 | - if($next_offset < $total_rows){ |
|
| 549 | - $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 547 | + $html .= " <span class='pageNumbers'>(".$start." - ".$end." of ".$total_rows.")</span>"; |
|
| 548 | + if ($next_offset < $total_rows) { |
|
| 549 | + $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
|
| 550 | 550 | <img src='".SugarThemeRegistry::current()->getImageURL('next.gif')."' alt='Next' align='absmiddle' border='0'> |
| 551 | 551 | </button> |
| 552 | 552 | <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' onclick='changeReportPage(\"".$this->id."\",".$last_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'> |
| 553 | 553 | <img src='".SugarThemeRegistry::current()->getImageURL('end.gif')."' alt='End' align='absmiddle' border='0'> |
| 554 | 554 | </button>"; |
| 555 | 555 | } else { |
| 556 | - $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' disabled='disabled'> |
|
| 556 | + $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' disabled='disabled'> |
|
| 557 | 557 | <img src='".SugarThemeRegistry::current()->getImageURL('next_off.gif')."' alt='Next' align='absmiddle' border='0'> |
| 558 | 558 | </button> |
| 559 | 559 | <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' disabled='disabled'> |
@@ -562,12 +562,12 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $html .="</td> |
|
| 565 | + $html .= "</td> |
|
| 566 | 566 | </table> |
| 567 | 567 | </td>"; |
| 568 | 568 | |
| 569 | - $html .="</tr></thead>"; |
|
| 570 | - } else{ |
|
| 569 | + $html .= "</tr></thead>"; |
|
| 570 | + } else { |
|
| 571 | 571 | |
| 572 | 572 | $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value); |
| 573 | 573 | |
@@ -593,16 +593,16 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | $field_module = $this->report_module; |
| 595 | 595 | $field_alias = $field_bean->table_name; |
| 596 | - if($path[0] != $this->report_module){ |
|
| 597 | - foreach($path as $rel){ |
|
| 598 | - if(empty($rel)){ |
|
| 596 | + if ($path[0] != $this->report_module) { |
|
| 597 | + foreach ($path as $rel) { |
|
| 598 | + if (empty($rel)) { |
|
| 599 | 599 | continue; |
| 600 | 600 | } |
| 601 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 602 | - $field_alias = $field_alias . ':'.$rel; |
|
| 601 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 602 | + $field_alias = $field_alias.':'.$rel; |
|
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | - $label = str_replace(' ','_',$field->label).$i; |
|
| 605 | + $label = str_replace(' ', '_', $field->label).$i; |
|
| 606 | 606 | $fields[$label]['field'] = $field->field; |
| 607 | 607 | $fields[$label]['label'] = $field->label; |
| 608 | 608 | $fields[$label]['display'] = $field->display; |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | $fields[$label]['params'] = array("date_format" => $field->format); |
| 616 | 616 | |
| 617 | 617 | |
| 618 | - if($fields[$label]['display']){ |
|
| 618 | + if ($fields[$label]['display']) { |
|
| 619 | 619 | $html .= "<th scope='col'>"; |
| 620 | 620 | $html .= "<div style='white-space: normal;' width='100%' align='left'>"; |
| 621 | 621 | $html .= $field->label; |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $html .= "</thead>"; |
| 629 | 629 | $html .= "<tbody>"; |
| 630 | 630 | |
| 631 | - if($offset >= 0){ |
|
| 631 | + if ($offset >= 0) { |
|
| 632 | 632 | $result = $this->db->limitQuery($report_sql, $offset, $max_rows); |
| 633 | 633 | } else { |
| 634 | 634 | $result = $this->db->query($report_sql); |
@@ -641,39 +641,39 @@ discard block |
||
| 641 | 641 | while ($row = $this->db->fetchByAssoc($result)) { |
| 642 | 642 | $html .= "<tr class='".$row_class."' height='20'>"; |
| 643 | 643 | |
| 644 | - foreach($fields as $name => $att){ |
|
| 645 | - if($att['display']){ |
|
| 644 | + foreach ($fields as $name => $att) { |
|
| 645 | + if ($att['display']) { |
|
| 646 | 646 | $html .= "<td class='' valign='top' align='left'>"; |
| 647 | - if($att['link'] && $links){ |
|
| 648 | - $html .= "<a href='" . $sugar_config['site_url'] . "/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>"; |
|
| 647 | + if ($att['link'] && $links) { |
|
| 648 | + $html .= "<a href='".$sugar_config['site_url']."/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>"; |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : ''; |
| 652 | 652 | |
| 653 | - switch ($att['function']){ |
|
| 653 | + switch ($att['function']) { |
|
| 654 | 654 | case 'COUNT': |
| 655 | 655 | //case 'SUM': |
| 656 | 656 | $html .= $row[$name]; |
| 657 | 657 | break; |
| 658 | 658 | default: |
| 659 | 659 | |
| 660 | - $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name],'',$currency_id, $att['params']); |
|
| 660 | + $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params']); |
|
| 661 | 661 | break; |
| 662 | 662 | } |
| 663 | - if($att['total']){ |
|
| 663 | + if ($att['total']) { |
|
| 664 | 664 | $totals[$name][] = $row[$name]; |
| 665 | 665 | } |
| 666 | - if($att['link'] && $links) $html .= "</a>"; |
|
| 666 | + if ($att['link'] && $links) $html .= "</a>"; |
|
| 667 | 667 | $html .= "</td>"; |
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | $html .= "</tr>"; |
| 671 | 671 | |
| 672 | - $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1':'oddListRowS1'; |
|
| 672 | + $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1' : 'oddListRowS1'; |
|
| 673 | 673 | } |
| 674 | 674 | $html .= "</tbody>"; |
| 675 | 675 | |
| 676 | - $html .= $this->getTotalHtml($fields,$totals); |
|
| 676 | + $html .= $this->getTotalHtml($fields, $totals); |
|
| 677 | 677 | |
| 678 | 678 | $html .= "</table>"; |
| 679 | 679 | |
@@ -716,13 +716,13 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $field_module = $this->report_module; |
| 718 | 718 | $field_alias = $field_bean->table_name; |
| 719 | - if($path[0] != $this->report_module){ |
|
| 720 | - foreach($path as $rel){ |
|
| 721 | - if(empty($rel)){ |
|
| 719 | + if ($path[0] != $this->report_module) { |
|
| 720 | + foreach ($path as $rel) { |
|
| 721 | + if (empty($rel)) { |
|
| 722 | 722 | continue; |
| 723 | 723 | } |
| 724 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 725 | - $field_alias = $field_alias . ':'.$rel; |
|
| 724 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 725 | + $field_alias = $field_alias.':'.$rel; |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | |
@@ -735,31 +735,31 @@ discard block |
||
| 735 | 735 | return $moduleFieldByGroupValue; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - function getTotalHTML($fields,$totals){ |
|
| 738 | + function getTotalHTML($fields, $totals) { |
|
| 739 | 739 | global $app_list_strings; |
| 740 | 740 | $html = ''; |
| 741 | 741 | $html .= "<tbody>"; |
| 742 | 742 | $html .= "<tr>"; |
| 743 | - foreach($fields as $label => $field){ |
|
| 744 | - if(!$field['display']){ |
|
| 743 | + foreach ($fields as $label => $field) { |
|
| 744 | + if (!$field['display']) { |
|
| 745 | 745 | continue; |
| 746 | 746 | } |
| 747 | - if($field['total']){ |
|
| 748 | - $totalLabel = $field['label'] ." ".$app_list_strings['aor_total_options'][$field['total']]; |
|
| 747 | + if ($field['total']) { |
|
| 748 | + $totalLabel = $field['label']." ".$app_list_strings['aor_total_options'][$field['total']]; |
|
| 749 | 749 | $html .= "<th>{$totalLabel}</th>"; |
| 750 | - }else{ |
|
| 750 | + } else { |
|
| 751 | 751 | $html .= "<th></th>"; |
| 752 | 752 | } |
| 753 | 753 | } |
| 754 | 754 | $html .= "</tr>"; |
| 755 | 755 | $html .= "<tr>"; |
| 756 | - foreach($fields as $label => $field){ |
|
| 757 | - if(!$field['display']){ |
|
| 756 | + foreach ($fields as $label => $field) { |
|
| 757 | + if (!$field['display']) { |
|
| 758 | 758 | continue; |
| 759 | 759 | } |
| 760 | - if($field['total'] && isset($totals[$label])){ |
|
| 761 | - $html .= "<td>".$this->calculateTotal($field['total'],$totals[$label])."</td>"; |
|
| 762 | - }else{ |
|
| 760 | + if ($field['total'] && isset($totals[$label])) { |
|
| 761 | + $html .= "<td>".$this->calculateTotal($field['total'], $totals[$label])."</td>"; |
|
| 762 | + } else { |
|
| 763 | 763 | $html .= "<td></td>"; |
| 764 | 764 | } |
| 765 | 765 | } |
@@ -768,24 +768,24 @@ discard block |
||
| 768 | 768 | return $html; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - function calculateTotal($type, $totals){ |
|
| 772 | - switch($type){ |
|
| 771 | + function calculateTotal($type, $totals) { |
|
| 772 | + switch ($type) { |
|
| 773 | 773 | case 'SUM': |
| 774 | 774 | return array_sum($totals); |
| 775 | 775 | case 'COUNT': |
| 776 | 776 | return count($totals); |
| 777 | 777 | case 'AVG': |
| 778 | - return array_sum($totals)/count($totals); |
|
| 778 | + return array_sum($totals) / count($totals); |
|
| 779 | 779 | default: |
| 780 | 780 | return ''; |
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - private function encloseForCSV($field){ |
|
| 784 | + private function encloseForCSV($field) { |
|
| 785 | 785 | return '"'.$field.'"'; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - function build_report_csv(){ |
|
| 788 | + function build_report_csv() { |
|
| 789 | 789 | |
| 790 | 790 | ini_set('zlib.output_compression', 'Off'); |
| 791 | 791 | |
@@ -809,20 +809,20 @@ discard block |
||
| 809 | 809 | $path = unserialize(base64_decode($field->module_path)); |
| 810 | 810 | |
| 811 | 811 | $field_module = $this->report_module; |
| 812 | - if($path[0] != $this->report_module){ |
|
| 813 | - foreach($path as $rel){ |
|
| 814 | - $field_module = getRelatedModule($field_module,$rel); |
|
| 812 | + if ($path[0] != $this->report_module) { |
|
| 813 | + foreach ($path as $rel) { |
|
| 814 | + $field_module = getRelatedModule($field_module, $rel); |
|
| 815 | 815 | } |
| 816 | 816 | } |
| 817 | - $label = str_replace(' ','_',$field->label).$i; |
|
| 817 | + $label = str_replace(' ', '_', $field->label).$i; |
|
| 818 | 818 | $fields[$label]['field'] = $field->field; |
| 819 | 819 | $fields[$label]['display'] = $field->display; |
| 820 | 820 | $fields[$label]['function'] = $field->field_function; |
| 821 | 821 | $fields[$label]['module'] = $field_module; |
| 822 | 822 | |
| 823 | 823 | |
| 824 | - if($field->display){ |
|
| 825 | - $csv.= $this->encloseForCSV($field->label); |
|
| 824 | + if ($field->display) { |
|
| 825 | + $csv .= $this->encloseForCSV($field->label); |
|
| 826 | 826 | $csv .= $delimiter; |
| 827 | 827 | } |
| 828 | 828 | ++$i; |
@@ -833,30 +833,30 @@ discard block |
||
| 833 | 833 | |
| 834 | 834 | while ($row = $this->db->fetchByAssoc($result)) { |
| 835 | 835 | $csv .= "\r\n"; |
| 836 | - foreach($fields as $name => $att){ |
|
| 837 | - if($att['display']){ |
|
| 838 | - if($att['function'] != '' ) |
|
| 836 | + foreach ($fields as $name => $att) { |
|
| 837 | + if ($att['display']) { |
|
| 838 | + if ($att['function'] != '') |
|
| 839 | 839 | $csv .= $this->encloseForCSV($row[$name]); |
| 840 | 840 | else |
| 841 | - $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
| 841 | + $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name])))); |
|
| 842 | 842 | $csv .= $delimiter; |
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $csv= $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
|
| 847 | + $csv = $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
|
| 848 | 848 | |
| 849 | 849 | ob_clean(); |
| 850 | 850 | header("Pragma: cache"); |
| 851 | 851 | header("Content-type: text/comma-separated-values; charset=".$GLOBALS['locale']->getExportCharset()); |
| 852 | 852 | header("Content-Disposition: attachment; filename=\"{$this->name}.csv\""); |
| 853 | 853 | header("Content-transfer-encoding: binary"); |
| 854 | - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); |
|
| 855 | - header("Last-Modified: " . TimeDate::httpTime() ); |
|
| 856 | - header("Cache-Control: post-check=0, pre-check=0", false ); |
|
| 854 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
| 855 | + header("Last-Modified: ".TimeDate::httpTime()); |
|
| 856 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
| 857 | 857 | header("Content-Length: ".mb_strlen($csv, '8bit')); |
| 858 | 858 | if (!empty($sugar_config['export_excel_compatible'])) { |
| 859 | - $csv==chr(255) . chr(254) . mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); |
|
| 859 | + $csv == chr(255).chr(254).mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8'); |
|
| 860 | 860 | } |
| 861 | 861 | print $csv; |
| 862 | 862 | |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | |
| 867 | 867 | |
| 868 | - function build_report_query($group_value ='', $extra = array()){ |
|
| 868 | + function build_report_query($group_value = '', $extra = array()) { |
|
| 869 | 869 | global $beanList; |
| 870 | 870 | |
| 871 | 871 | $module = new $beanList[$this->report_module](); |
@@ -874,26 +874,26 @@ discard block |
||
| 874 | 874 | $query_array = array(); |
| 875 | 875 | |
| 876 | 876 | $query_array = $this->build_report_query_select($query_array, $group_value); |
| 877 | - if(isset($extra['where']) && $extra['where']) { |
|
| 878 | - $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND '; |
|
| 877 | + if (isset($extra['where']) && $extra['where']) { |
|
| 878 | + $query_array['where'][] = implode(' AND ', $extra['where']).' AND '; |
|
| 879 | 879 | } |
| 880 | 880 | $query_array = $this->build_report_query_where($query_array); |
| 881 | 881 | |
| 882 | - foreach ($query_array['select'] as $select){ |
|
| 883 | - $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 882 | + foreach ($query_array['select'] as $select) { |
|
| 883 | + $query .= ($query == '' ? 'SELECT ' : ', ').$select; |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | $query .= ' FROM '.$this->db->quoteIdentifier($module->table_name).' '; |
| 887 | 887 | |
| 888 | - if(isset($query_array['join'])){ |
|
| 889 | - foreach ($query_array['join'] as $join){ |
|
| 888 | + if (isset($query_array['join'])) { |
|
| 889 | + foreach ($query_array['join'] as $join) { |
|
| 890 | 890 | $query .= $join; |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | - if(isset($query_array['where'])){ |
|
| 893 | + if (isset($query_array['where'])) { |
|
| 894 | 894 | $query_where = ''; |
| 895 | - foreach ($query_array['where'] as $where){ |
|
| 896 | - $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 895 | + foreach ($query_array['where'] as $where) { |
|
| 896 | + $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where; |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | $query_where = $this->queryWhereRepair($query_where); |
@@ -901,18 +901,18 @@ discard block |
||
| 901 | 901 | $query .= ' '.$query_where; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if(isset($query_array['group_by'])){ |
|
| 904 | + if (isset($query_array['group_by'])) { |
|
| 905 | 905 | $query_group_by = ''; |
| 906 | - foreach ($query_array['group_by'] as $group_by){ |
|
| 907 | - $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 906 | + foreach ($query_array['group_by'] as $group_by) { |
|
| 907 | + $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by; |
|
| 908 | 908 | } |
| 909 | 909 | $query .= ' '.$query_group_by; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - if(isset($query_array['sort_by'])){ |
|
| 912 | + if (isset($query_array['sort_by'])) { |
|
| 913 | 913 | $query_sort_by = ''; |
| 914 | - foreach ($query_array['sort_by'] as $sort_by){ |
|
| 915 | - $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 914 | + foreach ($query_array['sort_by'] as $sort_by) { |
|
| 915 | + $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by; |
|
| 916 | 916 | } |
| 917 | 917 | $query .= ' '.$query_sort_by; |
| 918 | 918 | } |
@@ -926,11 +926,11 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | $safe = 0; |
| 928 | 928 | $query_where_clean = ''; |
| 929 | - while($query_where_clean != $query_where) { |
|
| 929 | + while ($query_where_clean != $query_where) { |
|
| 930 | 930 | $query_where_clean = $query_where; |
| 931 | 931 | $query_where = preg_replace('/\b(AND|OR)\s*\(\s*\)|\(\s*\)/i', '', $query_where_clean); |
| 932 | 932 | $safe++; |
| 933 | - if($safe>100){ |
|
| 933 | + if ($safe > 100) { |
|
| 934 | 934 | $GLOBALS['log']->fatal('Invalid report query conditions'); |
| 935 | 935 | break; |
| 936 | 936 | } |
@@ -939,10 +939,10 @@ discard block |
||
| 939 | 939 | return $query_where; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - function build_report_query_select($query = array(), $group_value =''){ |
|
| 942 | + function build_report_query_select($query = array(), $group_value = '') { |
|
| 943 | 943 | global $beanList; |
| 944 | 944 | |
| 945 | - if($beanList[$this->report_module]){ |
|
| 945 | + if ($beanList[$this->report_module]) { |
|
| 946 | 946 | $module = new $beanList[$this->report_module](); |
| 947 | 947 | |
| 948 | 948 | $query['select'][] = $this->db->quoteIdentifier($module->table_name).".id AS '".$module->table_name."_id'"; |
@@ -955,16 +955,16 @@ discard block |
||
| 955 | 955 | $field = new AOR_Field(); |
| 956 | 956 | $field->retrieve($row['id']); |
| 957 | 957 | |
| 958 | - $field->label = str_replace(' ','_',$field->label).$i; |
|
| 958 | + $field->label = str_replace(' ', '_', $field->label).$i; |
|
| 959 | 959 | |
| 960 | 960 | $path = unserialize(base64_decode($field->module_path)); |
| 961 | 961 | |
| 962 | 962 | $field_module = $module; |
| 963 | 963 | $table_alias = $field_module->table_name; |
| 964 | 964 | $oldAlias = $table_alias; |
| 965 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
| 966 | - foreach($path as $rel){ |
|
| 967 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)]; |
|
| 965 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
| 966 | + foreach ($path as $rel) { |
|
| 967 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)]; |
|
| 968 | 968 | $oldAlias = $table_alias; |
| 969 | 969 | $table_alias = $table_alias.":".$rel; |
| 970 | 970 | $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
@@ -975,54 +975,54 @@ discard block |
||
| 975 | 975 | |
| 976 | 976 | $data = $field_module->field_defs[$field->field]; |
| 977 | 977 | |
| 978 | - if($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 978 | + if ($data['type'] == 'relate' && isset($data['id_name'])) { |
|
| 979 | 979 | $field->field = $data['id_name']; |
| 980 | 980 | $data_new = $field_module->field_defs[$field->field]; |
| 981 | - if(isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])){ |
|
| 981 | + if (isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) { |
|
| 982 | 982 | $data_new['type'] = 'link'; |
| 983 | 983 | $data_new['relationship'] = $data['link']; |
| 984 | 984 | } |
| 985 | 985 | $data = $data_new; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - if($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 989 | - $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$data['relationship'])]; |
|
| 988 | + if ($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 989 | + $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $data['relationship'])]; |
|
| 990 | 990 | $table_alias = $data['relationship']; |
| 991 | - $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
|
| 991 | + $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module); |
|
| 992 | 992 | $field_module = $new_field_module; |
| 993 | 993 | $field->field = 'id'; |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | - if($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) { |
|
| 997 | - if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 996 | + if ($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) { |
|
| 997 | + if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) { |
|
| 998 | 998 | $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias.'_cstm').".currency_id AS '".$table_alias."_currency_id'"; |
| 999 | 999 | } else { |
| 1000 | 1000 | $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias).".currency_id AS '".$table_alias."_currency_id'"; |
| 1001 | 1001 | } |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | - if((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 1004 | + if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
|
| 1005 | 1005 | $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field; |
| 1006 | - $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm',$table_alias, $field_module, 'custom', $query); |
|
| 1006 | + $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $table_alias, $field_module, 'custom', $query); |
|
| 1007 | 1007 | } else { |
| 1008 | - $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 1008 | + $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field; |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - if($field->sort_by != ''){ |
|
| 1011 | + if ($field->sort_by != '') { |
|
| 1012 | 1012 | $query['sort_by'][] = $select_field." ".$field->sort_by; |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - if($field->group_by == 1){ |
|
| 1016 | - $query['group_by'][] = $field->format ? str_replace('(%1)', '(' . $select_field . ')', preg_replace(array('/\s+/', '/Y/', '/m/', '/d/'), array(', ', 'YEAR(%1)', 'MONTH(%1)', 'DAY(%1)'), trim(preg_replace('/[^Ymd]/', ' ', $field->format)))) : $select_field; |
|
| 1015 | + if ($field->group_by == 1) { |
|
| 1016 | + $query['group_by'][] = $field->format ? str_replace('(%1)', '('.$select_field.')', preg_replace(array('/\s+/', '/Y/', '/m/', '/d/'), array(', ', 'YEAR(%1)', 'MONTH(%1)', 'DAY(%1)'), trim(preg_replace('/[^Ymd]/', ' ', $field->format)))) : $select_field; |
|
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | - if($field->field_function != null){ |
|
| 1019 | + if ($field->field_function != null) { |
|
| 1020 | 1020 | $select_field = $field->field_function.'('.$select_field.')'; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - $query['select'][] = $select_field ." AS '".$field->label."'"; |
|
| 1023 | + $query['select'][] = $select_field." AS '".$field->label."'"; |
|
| 1024 | 1024 | |
| 1025 | - if($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1025 | + if ($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1026 | 1026 | ++$i; |
| 1027 | 1027 | } |
| 1028 | 1028 | } |
@@ -1030,30 +1030,30 @@ discard block |
||
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | |
| 1033 | - function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(),SugarBean $rel_module = null ){ |
|
| 1033 | + function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(), SugarBean $rel_module = null) { |
|
| 1034 | 1034 | |
| 1035 | - if(!isset($query['join'][$alias])){ |
|
| 1035 | + if (!isset($query['join'][$alias])) { |
|
| 1036 | 1036 | |
| 1037 | - switch ($type){ |
|
| 1037 | + switch ($type) { |
|
| 1038 | 1038 | case 'custom': |
| 1039 | - $query['join'][$alias] = 'LEFT JOIN '.$this->db->quoteIdentifier($module->get_custom_table_name()).' '.$this->db->quoteIdentifier($name).' ON '.$this->db->quoteIdentifier($parentAlias).'.id = '. $this->db->quoteIdentifier($name).'.id_c '; |
|
| 1039 | + $query['join'][$alias] = 'LEFT JOIN '.$this->db->quoteIdentifier($module->get_custom_table_name()).' '.$this->db->quoteIdentifier($name).' ON '.$this->db->quoteIdentifier($parentAlias).'.id = '.$this->db->quoteIdentifier($name).'.id_c '; |
|
| 1040 | 1040 | break; |
| 1041 | 1041 | |
| 1042 | 1042 | case 'relationship': |
| 1043 | - if($module->load_relationship($name)){ |
|
| 1043 | + if ($module->load_relationship($name)) { |
|
| 1044 | 1044 | $params['join_type'] = 'LEFT JOIN'; |
| 1045 | - if($module->$name->relationship_type != 'one-to-many'){ |
|
| 1046 | - if($module->$name->getSide() == REL_LHS){ |
|
| 1045 | + if ($module->$name->relationship_type != 'one-to-many') { |
|
| 1046 | + if ($module->$name->getSide() == REL_LHS) { |
|
| 1047 | 1047 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1048 | 1048 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1049 | 1049 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1050 | - }else{ |
|
| 1050 | + } else { |
|
| 1051 | 1051 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1052 | 1052 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1053 | 1053 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | - }else{ |
|
| 1056 | + } else { |
|
| 1057 | 1057 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1058 | 1058 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1059 | 1059 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | $params['join_table_link_alias'] = $this->db->quoteIdentifier($linkAlias); |
| 1063 | 1063 | $join = $module->$name->getJoin($params, true); |
| 1064 | 1064 | $query['join'][$alias] = $join['join']; |
| 1065 | - if($rel_module != null) { |
|
| 1065 | + if ($rel_module != null) { |
|
| 1066 | 1066 | $query['join'][$alias] .= $this->build_report_access_query($rel_module, $name); |
| 1067 | 1067 | } |
| 1068 | 1068 | $query['select'][] = $join['select']." AS '".$alias."_id'"; |
@@ -1077,11 +1077,11 @@ discard block |
||
| 1077 | 1077 | return $query; |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | - function build_report_access_query(SugarBean $module, $alias){ |
|
| 1080 | + function build_report_access_query(SugarBean $module, $alias) { |
|
| 1081 | 1081 | |
| 1082 | 1082 | $module->table_name = $alias; |
| 1083 | 1083 | $where = ''; |
| 1084 | - if($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list') ) |
|
| 1084 | + if ($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list')) |
|
| 1085 | 1085 | { |
| 1086 | 1086 | global $current_user; |
| 1087 | 1087 | $owner_where = $module->getOwnerWhere($current_user->id); |
@@ -1089,18 +1089,18 @@ discard block |
||
| 1089 | 1089 | |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - if(file_exists('modules/SecurityGroups/SecurityGroup.php')){ |
|
| 1092 | + if (file_exists('modules/SecurityGroups/SecurityGroup.php')) { |
|
| 1093 | 1093 | /* BEGIN - SECURITY GROUPS */ |
| 1094 | - if($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list') ) |
|
| 1094 | + if ($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list')) |
|
| 1095 | 1095 | { |
| 1096 | 1096 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
| 1097 | 1097 | global $current_user; |
| 1098 | 1098 | $owner_where = $module->getOwnerWhere($current_user->id); |
| 1099 | - $group_where = SecurityGroup::getGroupWhere($alias,$module->module_dir,$current_user->id); |
|
| 1100 | - if(!empty($owner_where)){ |
|
| 1101 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 1099 | + $group_where = SecurityGroup::getGroupWhere($alias, $module->module_dir, $current_user->id); |
|
| 1100 | + if (!empty($owner_where)) { |
|
| 1101 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
| 1102 | 1102 | } else { |
| 1103 | - $where .= ' AND '. $group_where; |
|
| 1103 | + $where .= ' AND '.$group_where; |
|
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | /* END - SECURITY GROUPS */ |
@@ -1113,16 +1113,16 @@ discard block |
||
| 1113 | 1113 | * @param array $query |
| 1114 | 1114 | * @return array |
| 1115 | 1115 | */ |
| 1116 | - function build_report_query_where($query = array()){ |
|
| 1116 | + function build_report_query_where($query = array()) { |
|
| 1117 | 1117 | global $beanList, $app_list_strings, $sugar_config; |
| 1118 | 1118 | |
| 1119 | 1119 | $closure = false; |
| 1120 | - if(!empty($query['where'])) { |
|
| 1120 | + if (!empty($query['where'])) { |
|
| 1121 | 1121 | $query['where'][] = '('; |
| 1122 | 1122 | $closure = true; |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | - if($beanList[$this->report_module]){ |
|
| 1125 | + if ($beanList[$this->report_module]) { |
|
| 1126 | 1126 | $module = new $beanList[$this->report_module](); |
| 1127 | 1127 | |
| 1128 | 1128 | $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC"; |
@@ -1139,21 +1139,21 @@ discard block |
||
| 1139 | 1139 | $condition_module = $module; |
| 1140 | 1140 | $table_alias = $condition_module->table_name; |
| 1141 | 1141 | $oldAlias = $table_alias; |
| 1142 | - if(!empty($path[0]) && $path[0] != $module->module_dir){ |
|
| 1143 | - foreach($path as $rel){ |
|
| 1144 | - if(empty($rel)){ |
|
| 1142 | + if (!empty($path[0]) && $path[0] != $module->module_dir) { |
|
| 1143 | + foreach ($path as $rel) { |
|
| 1144 | + if (empty($rel)) { |
|
| 1145 | 1145 | continue; |
| 1146 | 1146 | } |
| 1147 | 1147 | // Bug: Prevents relationships from loading. |
| 1148 | 1148 | //$rel = strtolower($rel); |
| 1149 | - $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir,$rel)]; |
|
| 1149 | + $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)]; |
|
| 1150 | 1150 | $oldAlias = $table_alias; |
| 1151 | 1151 | $table_alias = $table_alias.":".$rel; |
| 1152 | 1152 | $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_condition_module); |
| 1153 | 1153 | $condition_module = $new_condition_module; |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
| 1156 | - if(isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { |
|
| 1156 | + if (isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) { |
|
| 1157 | 1157 | $where_set = false; |
| 1158 | 1158 | |
| 1159 | 1159 | $data = $condition_module->field_defs[$condition->field]; |
@@ -1168,24 +1168,24 @@ discard block |
||
| 1168 | 1168 | $data = $data_new; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | - if($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 1172 | - $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir,$data['relationship'])]; |
|
| 1171 | + if ($data['type'] == 'link' && $data['source'] == 'non-db') { |
|
| 1172 | + $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir, $data['relationship'])]; |
|
| 1173 | 1173 | $table_alias = $data['relationship']; |
| 1174 | - $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); |
|
| 1174 | + $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module); |
|
| 1175 | 1175 | $condition_module = $new_field_module; |
| 1176 | 1176 | |
| 1177 | 1177 | // Debugging: security groups conditions - It's a hack to just get the query working |
| 1178 | - if($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { |
|
| 1178 | + if ($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) { |
|
| 1179 | 1179 | // $table_alias = 'opportunities:assigned_user_link:SecurityGroups' ; |
| 1180 | - $table_alias = $oldAlias. ':' .$rel; |
|
| 1180 | + $table_alias = $oldAlias.':'.$rel; |
|
| 1181 | 1181 | } |
| 1182 | 1182 | $condition->field = 'id'; |
| 1183 | 1183 | } |
| 1184 | 1184 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
| 1185 | - $field = $this->db->quoteIdentifier($table_alias . '_cstm') . '.' . $condition->field; |
|
| 1186 | - $query = $this->build_report_query_join($table_alias . '_cstm', $table_alias . '_cstm', $oldAlias, $condition_module, 'custom', $query); |
|
| 1185 | + $field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$condition->field; |
|
| 1186 | + $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $oldAlias, $condition_module, 'custom', $query); |
|
| 1187 | 1187 | } else { |
| 1188 | - $field = $this->db->quoteIdentifier($table_alias) . '.' . $condition->field; |
|
| 1188 | + $field = $this->db->quoteIdentifier($table_alias).'.'.$condition->field; |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | if (!empty($this->user_parameters[$condition->id]) && $condition->parameter) { |
@@ -1217,10 +1217,10 @@ discard block |
||
| 1217 | 1217 | $condition->field = 'id'; |
| 1218 | 1218 | } |
| 1219 | 1219 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
| 1220 | - $value = $condition_module->table_name . '_cstm.' . $condition->value; |
|
| 1221 | - $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1220 | + $value = $condition_module->table_name.'_cstm.'.$condition->value; |
|
| 1221 | + $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1222 | 1222 | } else { |
| 1223 | - $value = $condition_module->table_name . '.' . $condition->value; |
|
| 1223 | + $value = $condition_module->table_name.'.'.$condition->value; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | break; |
| 1226 | 1226 | |
@@ -1232,10 +1232,10 @@ discard block |
||
| 1232 | 1232 | } else { |
| 1233 | 1233 | $value = 'NOW()'; |
| 1234 | 1234 | } |
| 1235 | - } else if($params[0] == 'today'){ |
|
| 1236 | - if($sugar_config['dbconfig']['db_type'] == 'mssql'){ |
|
| 1235 | + } else if ($params[0] == 'today') { |
|
| 1236 | + if ($sugar_config['dbconfig']['db_type'] == 'mssql') { |
|
| 1237 | 1237 | //$field = |
| 1238 | - $value = 'CAST(GETDATE() AS DATE)'; |
|
| 1238 | + $value = 'CAST(GETDATE() AS DATE)'; |
|
| 1239 | 1239 | } else { |
| 1240 | 1240 | $field = 'DATE('.$field.')'; |
| 1241 | 1241 | $value = 'Curdate()'; |
@@ -1243,10 +1243,10 @@ discard block |
||
| 1243 | 1243 | } else { |
| 1244 | 1244 | $data = $condition_module->field_defs[$params[0]]; |
| 1245 | 1245 | if ((isset($data['source']) && $data['source'] == 'custom_fields')) { |
| 1246 | - $value = $condition_module->table_name . '_cstm.' . $params[0]; |
|
| 1247 | - $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1246 | + $value = $condition_module->table_name.'_cstm.'.$params[0]; |
|
| 1247 | + $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query); |
|
| 1248 | 1248 | } else { |
| 1249 | - $value = $condition_module->table_name . '.' . $params[0]; |
|
| 1249 | + $value = $condition_module->table_name.'.'.$params[0]; |
|
| 1250 | 1250 | } |
| 1251 | 1251 | } |
| 1252 | 1252 | |
@@ -1257,9 +1257,9 @@ discard block |
||
| 1257 | 1257 | $params[3] = 'hours'; |
| 1258 | 1258 | default: |
| 1259 | 1259 | if ($sugar_config['dbconfig']['db_type'] == 'mssql') { |
| 1260 | - $value = "DATEADD(" . $params[3] . ", " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2], $value)"; |
|
| 1260 | + $value = "DATEADD(".$params[3].", ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2], $value)"; |
|
| 1261 | 1261 | } else { |
| 1262 | - $value = "DATE_ADD($value, INTERVAL " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2] " . $params[3] . ")"; |
|
| 1262 | + $value = "DATE_ADD($value, INTERVAL ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2] ".$params[3].")"; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | break; |
| 1265 | 1265 | } |
@@ -1274,7 +1274,7 @@ discard block |
||
| 1274 | 1274 | $value = '('; |
| 1275 | 1275 | foreach ($multi_values as $multi_value) { |
| 1276 | 1276 | if ($value != '(') $value .= $sep; |
| 1277 | - $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; |
|
| 1277 | + $value .= $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator]." '".$multi_value."'"; |
|
| 1278 | 1278 | } |
| 1279 | 1279 | $value .= ')'; |
| 1280 | 1280 | } |
@@ -1287,20 +1287,20 @@ discard block |
||
| 1287 | 1287 | } else { |
| 1288 | 1288 | $params = base64_decode($condition->value); |
| 1289 | 1289 | } |
| 1290 | - $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"'; |
|
| 1290 | + $value = '"'.getPeriodDate($params)->format('Y-m-d H:i:s').'"'; |
|
| 1291 | 1291 | break; |
| 1292 | 1292 | case "CurrentUserID": |
| 1293 | 1293 | global $current_user; |
| 1294 | - $value = '"' . $current_user->id . '"'; |
|
| 1294 | + $value = '"'.$current_user->id.'"'; |
|
| 1295 | 1295 | break; |
| 1296 | 1296 | case 'Value': |
| 1297 | 1297 | default: |
| 1298 | - $value = "'" . $this->db->quote($condition->value) . "'"; |
|
| 1298 | + $value = "'".$this->db->quote($condition->value)."'"; |
|
| 1299 | 1299 | break; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | 1302 | //handle like conditions |
| 1303 | - Switch($condition->operator) { |
|
| 1303 | + Switch ($condition->operator) { |
|
| 1304 | 1304 | case 'Contains': |
| 1305 | 1305 | $value = "CONCAT('%', ".$value." ,'%')"; |
| 1306 | 1306 | break; |
@@ -1313,13 +1313,13 @@ discard block |
||
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | |
| 1316 | - if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; |
|
| 1316 | + if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator].' '.$value; |
|
| 1317 | 1317 | |
| 1318 | 1318 | $tiltLogicOp = false; |
| 1319 | 1319 | } |
| 1320 | - else if($condition->parenthesis) { |
|
| 1321 | - if($condition->parenthesis == 'START') { |
|
| 1322 | - $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . '('; |
|
| 1320 | + else if ($condition->parenthesis) { |
|
| 1321 | + if ($condition->parenthesis == 'START') { |
|
| 1322 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).'('; |
|
| 1323 | 1323 | $tiltLogicOp = true; |
| 1324 | 1324 | } |
| 1325 | 1325 | else { |
@@ -1333,7 +1333,7 @@ discard block |
||
| 1333 | 1333 | |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | - if(isset($query['where']) && $query['where']) { |
|
| 1336 | + if (isset($query['where']) && $query['where']) { |
|
| 1337 | 1337 | array_unshift($query['where'], '('); |
| 1338 | 1338 | $query['where'][] = ') AND '; |
| 1339 | 1339 | } |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | - if($closure) { |
|
| 1344 | + if ($closure) { |
|
| 1345 | 1345 | $query['where'][] = ')'; |
| 1346 | 1346 | } |
| 1347 | 1347 | |
@@ -211,8 +211,10 @@ discard block |
||
| 211 | 211 | $html = '<script src="modules/AOR_Reports/js/Chart.js"></script>'; |
| 212 | 212 | break; |
| 213 | 213 | case self::CHART_TYPE_RGRAPH: |
| 214 | - if($_REQUEST['module']!= 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 214 | + if($_REQUEST['module']!= 'Home') { |
|
| 215 | + //Need the require_once for the rgraphincludes as they are only loaded when the home page is hit |
|
| 215 | 216 | require_once('include/SuiteGraphs/RGraphIncludes.php'); |
| 217 | + } |
|
| 216 | 218 | |
| 217 | 219 | break; |
| 218 | 220 | } |
@@ -235,15 +237,13 @@ discard block |
||
| 235 | 237 | |
| 236 | 238 | if(count($rows) > 1) { |
| 237 | 239 | $GLOBALS['log']->fatal('ambiguous group display for report ' . $this->id); |
| 238 | - } |
|
| 239 | - else if(count($rows) == 1){ |
|
| 240 | + } else if(count($rows) == 1){ |
|
| 240 | 241 | $rows[0]['module_path'] = unserialize(base64_decode($rows[0]['module_path'])); |
| 241 | 242 | if(!$rows[0]['module_path'][0]) { |
| 242 | 243 | $module = new $beanList[$this->report_module](); |
| 243 | 244 | $rows[0]['field_id_name'] = $module->field_defs[$rows[0]['field']]['id_name'] ? $module->field_defs[$rows[0]['field']]['id_name'] : $module->field_defs[$rows[0]['field']]['name']; |
| 244 | 245 | $rows[0]['module_path'][0] = $module->table_name; |
| 245 | - } |
|
| 246 | - else { |
|
| 246 | + } else { |
|
| 247 | 247 | $rows[0]['field_id_name'] = $rows[0]['field']; |
| 248 | 248 | } |
| 249 | 249 | $path[] = $rows[0]; |
@@ -255,8 +255,7 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | return $this->buildMultiGroupReport($offset, $links, $level+1, $path); |
| 258 | - } |
|
| 259 | - else if(!$rows) { |
|
| 258 | + } else if(!$rows) { |
|
| 260 | 259 | if($path) { |
| 261 | 260 | $html = ''; |
| 262 | 261 | foreach ($path as $pth) { |
@@ -274,12 +273,10 @@ discard block |
||
| 274 | 273 | } |
| 275 | 274 | } |
| 276 | 275 | return $html; |
| 277 | - } |
|
| 278 | - else { |
|
| 276 | + } else { |
|
| 279 | 277 | return $this->build_group_report($offset, $links); |
| 280 | 278 | } |
| 281 | - } |
|
| 282 | - else { |
|
| 279 | + } else { |
|
| 283 | 280 | throw new Exception('incorrect results'); |
| 284 | 281 | } |
| 285 | 282 | throw new Exception('incorrect state'); |
@@ -415,8 +412,7 @@ discard block |
||
| 415 | 412 | foreach($extra['select'] as $selectField => $selectAlias) { |
| 416 | 413 | if($selectAlias) { |
| 417 | 414 | $query_array['select'][] = $selectField . " AS " . $selectAlias; |
| 418 | - } |
|
| 419 | - else { |
|
| 415 | + } else { |
|
| 420 | 416 | $query_array['select'][] = $selectField; |
| 421 | 417 | } |
| 422 | 418 | } |
@@ -471,14 +467,18 @@ discard block |
||
| 471 | 467 | $result = $this->db->query($query); |
| 472 | 468 | |
| 473 | 469 | while ($row = $this->db->fetchByAssoc($result)) { |
| 474 | - if($html != '') $html .= '<br />'; |
|
| 470 | + if($html != '') { |
|
| 471 | + $html .= '<br />'; |
|
| 472 | + } |
|
| 475 | 473 | |
| 476 | 474 | $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
| 477 | 475 | |
| 478 | 476 | } |
| 479 | 477 | } |
| 480 | 478 | |
| 481 | - if($html == '') $html = $this->build_report_html($offset, $links); |
|
| 479 | + if($html == '') { |
|
| 480 | + $html = $this->build_report_html($offset, $links); |
|
| 481 | + } |
|
| 482 | 482 | return $html; |
| 483 | 483 | |
| 484 | 484 | } |
@@ -663,7 +663,9 @@ discard block |
||
| 663 | 663 | if($att['total']){ |
| 664 | 664 | $totals[$name][] = $row[$name]; |
| 665 | 665 | } |
| 666 | - if($att['link'] && $links) $html .= "</a>"; |
|
| 666 | + if($att['link'] && $links) { |
|
| 667 | + $html .= "</a>"; |
|
| 668 | + } |
|
| 667 | 669 | $html .= "</td>"; |
| 668 | 670 | } |
| 669 | 671 | } |
@@ -747,7 +749,7 @@ discard block |
||
| 747 | 749 | if($field['total']){ |
| 748 | 750 | $totalLabel = $field['label'] ." ".$app_list_strings['aor_total_options'][$field['total']]; |
| 749 | 751 | $html .= "<th>{$totalLabel}</th>"; |
| 750 | - }else{ |
|
| 752 | + } else{ |
|
| 751 | 753 | $html .= "<th></th>"; |
| 752 | 754 | } |
| 753 | 755 | } |
@@ -759,7 +761,7 @@ discard block |
||
| 759 | 761 | } |
| 760 | 762 | if($field['total'] && isset($totals[$label])){ |
| 761 | 763 | $html .= "<td>".$this->calculateTotal($field['total'],$totals[$label])."</td>"; |
| 762 | - }else{ |
|
| 764 | + } else{ |
|
| 763 | 765 | $html .= "<td></td>"; |
| 764 | 766 | } |
| 765 | 767 | } |
@@ -835,10 +837,11 @@ discard block |
||
| 835 | 837 | $csv .= "\r\n"; |
| 836 | 838 | foreach($fields as $name => $att){ |
| 837 | 839 | if($att['display']){ |
| 838 | - if($att['function'] != '' ) |
|
| 839 | - $csv .= $this->encloseForCSV($row[$name]); |
|
| 840 | - else |
|
| 841 | - $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
| 840 | + if($att['function'] != '' ) { |
|
| 841 | + $csv .= $this->encloseForCSV($row[$name]); |
|
| 842 | + } else { |
|
| 843 | + $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name])))); |
|
| 844 | + } |
|
| 842 | 845 | $csv .= $delimiter; |
| 843 | 846 | } |
| 844 | 847 | } |
@@ -1022,7 +1025,9 @@ discard block |
||
| 1022 | 1025 | |
| 1023 | 1026 | $query['select'][] = $select_field ." AS '".$field->label."'"; |
| 1024 | 1027 | |
| 1025 | - if($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1028 | + if($field->group_display == 1 && $group_value) { |
|
| 1029 | + $query['where'][] = $select_field." = '".$group_value."' AND "; |
|
| 1030 | + } |
|
| 1026 | 1031 | ++$i; |
| 1027 | 1032 | } |
| 1028 | 1033 | } |
@@ -1047,13 +1052,13 @@ discard block |
||
| 1047 | 1052 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1048 | 1053 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1049 | 1054 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1050 | - }else{ |
|
| 1055 | + } else{ |
|
| 1051 | 1056 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1052 | 1057 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1053 | 1058 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1054 | 1059 | } |
| 1055 | 1060 | |
| 1056 | - }else{ |
|
| 1061 | + } else{ |
|
| 1057 | 1062 | $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
| 1058 | 1063 | $params['join_table_alias'] = $this->db->quoteIdentifier($alias); |
| 1059 | 1064 | $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias); |
@@ -1268,12 +1273,16 @@ discard block |
||
| 1268 | 1273 | |
| 1269 | 1274 | case 'Multi': |
| 1270 | 1275 | $sep = ' AND '; |
| 1271 | - if ($condition->operator == 'Equal_To') $sep = ' OR '; |
|
| 1276 | + if ($condition->operator == 'Equal_To') { |
|
| 1277 | + $sep = ' OR '; |
|
| 1278 | + } |
|
| 1272 | 1279 | $multi_values = unencodeMultienum($condition->value); |
| 1273 | 1280 | if (!empty($multi_values)) { |
| 1274 | 1281 | $value = '('; |
| 1275 | 1282 | foreach ($multi_values as $multi_value) { |
| 1276 | - if ($value != '(') $value .= $sep; |
|
| 1283 | + if ($value != '(') { |
|
| 1284 | + $value .= $sep; |
|
| 1285 | + } |
|
| 1277 | 1286 | $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'"; |
| 1278 | 1287 | } |
| 1279 | 1288 | $value .= ')'; |
@@ -1313,21 +1322,20 @@ discard block |
||
| 1313 | 1322 | } |
| 1314 | 1323 | |
| 1315 | 1324 | |
| 1316 | - if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; |
|
| 1325 | + if (!$where_set) { |
|
| 1326 | + $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value; |
|
| 1327 | + } |
|
| 1317 | 1328 | |
| 1318 | 1329 | $tiltLogicOp = false; |
| 1319 | - } |
|
| 1320 | - else if($condition->parenthesis) { |
|
| 1330 | + } else if($condition->parenthesis) { |
|
| 1321 | 1331 | if($condition->parenthesis == 'START') { |
| 1322 | 1332 | $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) . '('; |
| 1323 | 1333 | $tiltLogicOp = true; |
| 1324 | - } |
|
| 1325 | - else { |
|
| 1334 | + } else { |
|
| 1326 | 1335 | $query['where'][] = ')'; |
| 1327 | 1336 | $tiltLogicOp = false; |
| 1328 | 1337 | } |
| 1329 | - } |
|
| 1330 | - else { |
|
| 1338 | + } else { |
|
| 1331 | 1339 | $GLOBALS['log']->debug('illegal condition'); |
| 1332 | 1340 | } |
| 1333 | 1341 | |
@@ -322,6 +322,9 @@ discard block |
||
| 322 | 322 | return $rows; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | + /** |
|
| 326 | + * @param string $body |
|
| 327 | + */ |
|
| 325 | 328 | private function getMultiGroupFrameHTML($header, $body) { |
| 326 | 329 | $html = '<div class="multi-group-list" style="border: 1px solid black; padding: 10px;"> |
| 327 | 330 | <h3>' . $header . '</h3> |
@@ -330,6 +333,9 @@ discard block |
||
| 330 | 333 | return $html; |
| 331 | 334 | } |
| 332 | 335 | |
| 336 | + /** |
|
| 337 | + * @param string $html |
|
| 338 | + */ |
|
| 333 | 339 | private function addDataIdValueToInnertext($html) { |
| 334 | 340 | preg_match('/\sdata-id-value\s*=\s*"([^"]*)"/', $html, $match); |
| 335 | 341 | $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2' . $match[1] . '$3', $html); |
@@ -920,6 +926,9 @@ discard block |
||
| 920 | 926 | |
| 921 | 927 | } |
| 922 | 928 | |
| 929 | + /** |
|
| 930 | + * @param string $query_where |
|
| 931 | + */ |
|
| 923 | 932 | private function queryWhereRepair($query_where) { |
| 924 | 933 | |
| 925 | 934 | // remove empty parenthesis and fix query syntax |
@@ -1030,6 +1039,9 @@ discard block |
||
| 1030 | 1039 | } |
| 1031 | 1040 | |
| 1032 | 1041 | |
| 1042 | + /** |
|
| 1043 | + * @param string $type |
|
| 1044 | + */ |
|
| 1033 | 1045 | function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(),SugarBean $rel_module = null ){ |
| 1034 | 1046 | |
| 1035 | 1047 | if(!isset($query['join'][$alias])){ |
@@ -23,42 +23,42 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | class AOR_Report extends Basic { |
| 26 | - var $new_schema = true; |
|
| 27 | - var $module_dir = 'AOR_Reports'; |
|
| 28 | - var $object_name = 'AOR_Report'; |
|
| 29 | - var $table_name = 'aor_reports'; |
|
| 30 | - var $importable = true; |
|
| 31 | - var $disable_row_level_security = true ; |
|
| 32 | - |
|
| 33 | - var $id; |
|
| 34 | - var $name; |
|
| 35 | - var $date_entered; |
|
| 36 | - var $date_modified; |
|
| 37 | - var $modified_user_id; |
|
| 38 | - var $modified_by_name; |
|
| 39 | - var $created_by; |
|
| 40 | - var $created_by_name; |
|
| 41 | - var $description; |
|
| 42 | - var $deleted; |
|
| 43 | - var $created_by_link; |
|
| 44 | - var $modified_user_link; |
|
| 45 | - var $assigned_user_id; |
|
| 46 | - var $assigned_user_name; |
|
| 47 | - var $assigned_user_link; |
|
| 48 | - var $report_module; |
|
| 49 | - |
|
| 50 | - function AOR_Report(){ |
|
| 51 | - parent::Basic(); |
|
| 26 | + var $new_schema = true; |
|
| 27 | + var $module_dir = 'AOR_Reports'; |
|
| 28 | + var $object_name = 'AOR_Report'; |
|
| 29 | + var $table_name = 'aor_reports'; |
|
| 30 | + var $importable = true; |
|
| 31 | + var $disable_row_level_security = true ; |
|
| 32 | + |
|
| 33 | + var $id; |
|
| 34 | + var $name; |
|
| 35 | + var $date_entered; |
|
| 36 | + var $date_modified; |
|
| 37 | + var $modified_user_id; |
|
| 38 | + var $modified_by_name; |
|
| 39 | + var $created_by; |
|
| 40 | + var $created_by_name; |
|
| 41 | + var $description; |
|
| 42 | + var $deleted; |
|
| 43 | + var $created_by_link; |
|
| 44 | + var $modified_user_link; |
|
| 45 | + var $assigned_user_id; |
|
| 46 | + var $assigned_user_name; |
|
| 47 | + var $assigned_user_link; |
|
| 48 | + var $report_module; |
|
| 49 | + |
|
| 50 | + function AOR_Report(){ |
|
| 51 | + parent::Basic(); |
|
| 52 | 52 | $this->load_report_beans(); |
| 53 | 53 | require_once('modules/AOW_WorkFlow/aow_utils.php'); |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - function bean_implements($interface){ |
|
| 57 | - switch($interface){ |
|
| 58 | - case 'ACL': return true; |
|
| 59 | - } |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 56 | + function bean_implements($interface){ |
|
| 57 | + switch($interface){ |
|
| 58 | + case 'ACL': return true; |
|
| 59 | + } |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | function save($check_notify = FALSE){ |
| 64 | 64 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | while ($row = $this->db->fetchByAssoc($result)) { |
| 474 | 474 | if($html != '') $html .= '<br />'; |
| 475 | 475 | |
| 476 | - $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
|
| 476 | + $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra); |
|
| 477 | 477 | |
| 478 | 478 | } |
| 479 | 479 | } |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | $viewdefs ['AOR_Reports'] = |
| 26 | -array ( |
|
| 26 | +array( |
|
| 27 | 27 | 'EditView' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | 'templateMeta' => |
| 30 | - array ( |
|
| 30 | + array( |
|
| 31 | 31 | 'maxColumns' => '2', |
| 32 | 32 | 'widths' => |
| 33 | - array ( |
|
| 33 | + array( |
|
| 34 | 34 | 0 => |
| 35 | - array ( |
|
| 35 | + array( |
|
| 36 | 36 | 'label' => '10', |
| 37 | 37 | 'field' => '30', |
| 38 | 38 | ), |
| 39 | 39 | 1 => |
| 40 | - array ( |
|
| 40 | + array( |
|
| 41 | 41 | 'label' => '10', |
| 42 | 42 | 'field' => '30', |
| 43 | 43 | ), |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | ), |
| 50 | 50 | ), |
| 51 | 51 | 'panels' => |
| 52 | - array ( |
|
| 52 | + array( |
|
| 53 | 53 | 'default' => |
| 54 | - array ( |
|
| 54 | + array( |
|
| 55 | 55 | 0 => |
| 56 | - array ( |
|
| 56 | + array( |
|
| 57 | 57 | 0 => 'name', |
| 58 | 58 | 1 => 'assigned_user_name', |
| 59 | 59 | ), |
| 60 | 60 | 1 => |
| 61 | - array ( |
|
| 61 | + array( |
|
| 62 | 62 | 0 => |
| 63 | - array ( |
|
| 63 | + array( |
|
| 64 | 64 | 'name' => 'report_module', |
| 65 | 65 | 'studio' => 'visible', |
| 66 | 66 | 'label' => 'LBL_REPORT_MODULE', |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | 1 => '', |
| 69 | 69 | ), |
| 70 | 70 | 2 => |
| 71 | - array ( |
|
| 71 | + array( |
|
| 72 | 72 | 0 => |
| 73 | - array ( |
|
| 73 | + array( |
|
| 74 | 74 | 'name' => 'graphs_per_row', |
| 75 | 75 | 'label' => 'LBL_GRAPHS_PER_ROW', |
| 76 | 76 | ), |
@@ -24,25 +24,25 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $viewdefs ['AOR_Reports'] = |
| 26 | 26 | array ( |
| 27 | - 'EditView' => |
|
| 28 | - array ( |
|
| 27 | + 'EditView' => |
|
| 28 | + array ( |
|
| 29 | 29 | 'templateMeta' => |
| 30 | 30 | array ( |
| 31 | - 'maxColumns' => '2', |
|
| 32 | - 'widths' => |
|
| 33 | - array ( |
|
| 31 | + 'maxColumns' => '2', |
|
| 32 | + 'widths' => |
|
| 33 | + array ( |
|
| 34 | 34 | 0 => |
| 35 | 35 | array ( |
| 36 | - 'label' => '10', |
|
| 37 | - 'field' => '30', |
|
| 36 | + 'label' => '10', |
|
| 37 | + 'field' => '30', |
|
| 38 | 38 | ), |
| 39 | 39 | 1 => |
| 40 | 40 | array ( |
| 41 | - 'label' => '10', |
|
| 42 | - 'field' => '30', |
|
| 41 | + 'label' => '10', |
|
| 42 | + 'field' => '30', |
|
| 43 | + ), |
|
| 43 | 44 | ), |
| 44 | - ), |
|
| 45 | - 'useTabs' => false, |
|
| 45 | + 'useTabs' => false, |
|
| 46 | 46 | 'form' => array( |
| 47 | 47 | 'headerTpl' => 'modules/AOR_Reports/tpls/EditViewHeader.tpl', |
| 48 | 48 | 'footerTpl' => 'modules/AOR_Reports/tpls/EditViewFooter.tpl', |
@@ -50,38 +50,38 @@ discard block |
||
| 50 | 50 | ), |
| 51 | 51 | 'panels' => |
| 52 | 52 | array ( |
| 53 | - 'default' => |
|
| 54 | - array ( |
|
| 53 | + 'default' => |
|
| 54 | + array ( |
|
| 55 | 55 | 0 => |
| 56 | 56 | array ( |
| 57 | - 0 => 'name', |
|
| 58 | - 1 => 'assigned_user_name', |
|
| 57 | + 0 => 'name', |
|
| 58 | + 1 => 'assigned_user_name', |
|
| 59 | 59 | ), |
| 60 | 60 | 1 => |
| 61 | 61 | array ( |
| 62 | - 0 => |
|
| 63 | - array ( |
|
| 62 | + 0 => |
|
| 63 | + array ( |
|
| 64 | 64 | 'name' => 'report_module', |
| 65 | 65 | 'studio' => 'visible', |
| 66 | 66 | 'label' => 'LBL_REPORT_MODULE', |
| 67 | - ), |
|
| 68 | - 1 => '', |
|
| 67 | + ), |
|
| 68 | + 1 => '', |
|
| 69 | 69 | ), |
| 70 | - 2 => |
|
| 71 | - array ( |
|
| 72 | - 0 => |
|
| 73 | - array ( |
|
| 74 | - 'name' => 'graphs_per_row', |
|
| 75 | - 'label' => 'LBL_GRAPHS_PER_ROW', |
|
| 76 | - ), |
|
| 77 | - 1 => '', |
|
| 78 | - ), |
|
| 70 | + 2 => |
|
| 71 | + array ( |
|
| 72 | + 0 => |
|
| 73 | + array ( |
|
| 74 | + 'name' => 'graphs_per_row', |
|
| 75 | + 'label' => 'LBL_GRAPHS_PER_ROW', |
|
| 76 | + ), |
|
| 77 | + 1 => '', |
|
| 78 | + ), |
|
| 79 | 79 | // 2 => |
| 80 | 80 | // array ( |
| 81 | 81 | // 0 => 'description', |
| 82 | 82 | // ), |
| 83 | - ), |
|
| 83 | + ), |
|
| 84 | + ), |
|
| 84 | 85 | ), |
| 85 | - ), |
|
| 86 | 86 | ); |
| 87 | 87 | ?> |