Completed
Push — console-installer ( e2b50d...6ce748 )
by Adam
22:30
created
modules/DynamicFields/DynamicField.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         global $sugar_config;
65 65
         $this->module = (!empty($module)) ? $module : ((isset($_REQUEST['module']) && !empty($_REQUEST['module'])) ? $_REQUEST ['module'] : '');
66 66
         $this->base_path = "custom/Extension/modules/{$this->module}/Ext/Vardefs";
67
-        if(isset($sugar_config['dbconfig'])) {
67
+        if (isset($sugar_config['dbconfig'])) {
68 68
             $this->db = DBManagerFactory::getInstance();
69 69
         }
70 70
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function setLabel($language = 'en_us', $key, $value)
135 135
     {
136
-        $params ['label_' . $key] = $value;
136
+        $params ['label_'.$key] = $value;
137 137
         require_once 'modules/ModuleBuilder/parsers/parser.label.php';
138 138
         $parser = new ParserLabel($this->module);
139 139
         $parser->handleSave($params, $language);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             return false;
169 169
         }
170 170
 
171
-        $GLOBALS['log']->debug('rebuilding cache for ' . $module);
171
+        $GLOBALS['log']->debug('rebuilding cache for '.$module);
172 172
         $query = "SELECT * FROM fields_meta_data WHERE $where deleted = 0";
173 173
 
174 174
         $result = $this->db->query($query);
@@ -336,20 +336,20 @@  discard block
 block discarded – undo
336 336
                 }
337 337
             }
338 338
         }
339
-        $join = ' LEFT JOIN ' . $this->bean->table_name . '_cstm ON ' . $this->bean->table_name . '.id = ' . $this->bean->table_name . '_cstm.id_c ';
339
+        $join = ' LEFT JOIN '.$this->bean->table_name.'_cstm ON '.$this->bean->table_name.'.id = '.$this->bean->table_name.'_cstm.id_c ';
340 340
 
341 341
         if ($includeRelates) {
342 342
             $jtAlias = 'relJoin';
343 343
             $jtCount = 1;
344 344
             foreach ($this->bean->field_defs as $name => $field) {
345 345
                 if ($field['type'] == 'relate' && isset($field['custom_module'])) {
346
-                    $relateJoinInfo = $this->getRelateJoin($field, $jtAlias . $jtCount);
346
+                    $relateJoinInfo = $this->getRelateJoin($field, $jtAlias.$jtCount);
347 347
                     $select .= $relateJoinInfo['select'];
348 348
                     $join .= $relateJoinInfo['from'];
349 349
                     //bug 27654 martin
350 350
                     if ($where) {
351
-                        $pattern = '/' . $field['name'] . '\slike/i';
352
-                        $replacement = $relateJoinInfo['name_field'] . ' like';
351
+                        $pattern = '/'.$field['name'].'\slike/i';
352
+                        $replacement = $relateJoinInfo['name_field'].' like';
353 353
                         $where = preg_replace($pattern, $replacement, $where);
354 354
                     }
355 355
                     ++$jtCount;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                 $name_field = $this->db->concat($joinTableAlias, $name_field_def['db_concat_fields']);
386 386
             } //If the name field is non-db, we need to find another field to display
387 387
             elseif (!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == 'non-db' && !empty($field_def['rname'])) {
388
-                $name_field = "$joinTableAlias." . $field_def['rname'];
388
+                $name_field = "$joinTableAlias.".$field_def['rname'];
389 389
             } else {
390 390
                 $name_field = "$joinTableAlias.name";
391 391
             }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
         $relID = $field_def['id_name'];
395 395
         $ret_array['rel_table'] = $rel_table;
396 396
         $ret_array['name_field'] = $name_field;
397
-        $ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : '') . ", {$name_field} {$field_def['name']} ";
397
+        $ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : '').", {$name_field} {$field_def['name']} ";
398 398
         $ret_array['from'] = " LEFT JOIN $rel_table $joinTableAlias ON $tableName.$relID = $joinTableAlias.id"
399 399
             . " AND $joinTableAlias.deleted=0 ";
400 400
 
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
         if ($this->bean->hasCustomFields() && isset($this->bean->id)) {
444 444
             $query = '';
445 445
             if ($isUpdate) {
446
-                $query = 'UPDATE ' . $this->bean->table_name . '_cstm SET ';
446
+                $query = 'UPDATE '.$this->bean->table_name.'_cstm SET ';
447 447
             }
448
-            $queryInsert = 'INSERT INTO ' . $this->bean->table_name . '_cstm (id_c';
449
-            $values = "('" . $this->bean->id . "'";
448
+            $queryInsert = 'INSERT INTO '.$this->bean->table_name.'_cstm (id_c';
449
+            $values = "('".$this->bean->id."'";
450 450
             $first = true;
451 451
             foreach ($this->bean->field_defs as $name => $field) {
452 452
                 if (empty($field['source']) || $field['source'] != 'custom_fields') {
@@ -484,18 +484,18 @@  discard block
 block discarded – undo
484 484
                     }
485 485
                     if ($isUpdate) {
486 486
                         if ($first) {
487
-                            $query .= " $name=$quote" . $this->db->quote($val) . "$quote";
487
+                            $query .= " $name=$quote".$this->db->quote($val)."$quote";
488 488
                         } else {
489
-                            $query .= " ,$name=$quote" . $this->db->quote($val) . "$quote";
489
+                            $query .= " ,$name=$quote".$this->db->quote($val)."$quote";
490 490
                         }
491 491
                     }
492 492
                     $first = false;
493 493
                     $queryInsert .= " ,$name";
494
-                    $values .= " ,$quote" . $this->db->quote($val) . "$quote";
494
+                    $values .= " ,$quote".$this->db->quote($val)."$quote";
495 495
                 }
496 496
             }
497 497
             if ($isUpdate) {
498
-                $query .= " WHERE id_c='" . $this->bean->id . "'";
498
+                $query .= " WHERE id_c='".$this->bean->id."'";
499 499
             }
500 500
 
501 501
             $queryInsert .= " ) VALUES $values )";
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
             $object_name = $newName != false ? $newName : $object_name;
539 539
         }
540 540
 
541
-        $this->db->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'");
542
-        $sql = $widget->get_db_delete_alter_table($this->bean->table_name . '_cstm');
541
+        $this->db->query("DELETE FROM fields_meta_data WHERE id='".$this->module.$widget->name."'");
542
+        $sql = $widget->get_db_delete_alter_table($this->bean->table_name.'_cstm');
543 543
         if (!empty($sql)) {
544 544
             $this->db->query($sql);
545 545
         }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
         $db_name = $field->name;
600 600
 
601 601
         $fmd = new FieldsMetaData();
602
-        $id = $fmd->retrieve($object_name . $db_name, true, false);
602
+        $id = $fmd->retrieve($object_name.$db_name, true, false);
603 603
         $is_update = false;
604 604
         $label = strtoupper($field->label);
605 605
         if (!empty($id)) {
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
             $field->name = $db_name;
610 610
         }
611 611
         $this->createCustomTable();
612
-        $fmd->id = $object_name . $db_name;
612
+        $fmd->id = $object_name.$db_name;
613 613
         $fmd->custom_module = $object_name;
614 614
         $fmd->name = $db_name;
615 615
         $fmd->vname = $label;
@@ -645,20 +645,20 @@  discard block
 block discarded – undo
645 645
                 // resetting default and default_value does not work for multienum and causes trouble for MsSQL
646 646
                 // so using a temporary variable here to indicate that we don't want default for this query
647 647
                 $field->no_default = 1;
648
-                $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
648
+                $query = $field->get_db_add_alter_table($this->bean->table_name.'_cstm');
649 649
                 // unset temporary member variable
650 650
                 unset($field->no_default);
651 651
                 if (!empty($query)) {
652 652
                     $this->db->query($query, true, 'Cannot create column');
653 653
                     $field->default = $fmd->default_value;
654 654
                     $field->default_value = $fmd->default_value;
655
-                    $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
655
+                    $query = $field->get_db_modify_alter_table($this->bean->table_name.'_cstm');
656 656
                     if (!empty($query)) {
657 657
                         $this->db->query($query, true, 'Cannot set default');
658 658
                     }
659 659
                 }
660 660
             } else {
661
-                $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
661
+                $query = $field->get_db_modify_alter_table($this->bean->table_name.'_cstm');
662 662
                 if (!empty($query)) {
663 663
                     $this->db->query($query, true, 'Cannot modify field');
664 664
                 }
@@ -747,9 +747,9 @@  discard block
 block discarded – undo
747 747
         $vBean = $bean_name == 'aCase' ? 'Case' : $bean_name;
748 748
         $file_loc = "$this->base_path/sugarfield_{$field->name}.php";
749 749
 
750
-        $out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n";
750
+        $out = "<?php\n // created: ".date('Y-m-d H:i:s')."\n";
751 751
         foreach ($def_override as $property => $val) {
752
-            $out .= override_value_to_string_recursive(array($vBean, 'fields', $field->name, $property), 'dictionary', $val) . "\n";
752
+            $out .= override_value_to_string_recursive(array($vBean, 'fields', $field->name, $property), 'dictionary', $val)."\n";
753 753
         }
754 754
 
755 755
         $out .= "\n ?>";
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
     public function createCustomTable($execute = true)
841 841
     {
842 842
         $out = '';
843
-        if (!$this->db->tableExists($this->bean->table_name . '_cstm')) {
844
-            $GLOBALS['log']->debug('creating custom table for ' . $this->bean->table_name);
843
+        if (!$this->db->tableExists($this->bean->table_name.'_cstm')) {
844
+            $GLOBALS['log']->debug('creating custom table for '.$this->bean->table_name);
845 845
             $idDef = array(
846 846
                 'id_c' => array(
847 847
                     'name' => 'id_c',
@@ -851,15 +851,15 @@  discard block
 block discarded – undo
851 851
             );
852 852
             $idIdx = array(
853 853
                 'id' => array(
854
-                    'name' => $this->bean->table_name . '_cstm_pk',
854
+                    'name' => $this->bean->table_name.'_cstm_pk',
855 855
                     'type' => 'primary',
856 856
                     'fields' => array('id_c'),
857 857
                 ),
858 858
             );
859 859
 
860
-            $query = $this->db->createTableSQLParams($this->bean->table_name . '_cstm', $idDef, $idIdx);
860
+            $query = $this->db->createTableSQLParams($this->bean->table_name.'_cstm', $idDef, $idIdx);
861 861
             if (!$this->db->supports('inline_keys')) {
862
-                $indicesArr = $this->db->getConstraintSql($idIdx, $this->bean->table_name . '_cstm');
862
+                $indicesArr = $this->db->getConstraintSql($idIdx, $this->bean->table_name.'_cstm');
863 863
             } else {
864 864
                 $indicesArr = array();
865 865
             }
@@ -871,9 +871,9 @@  discard block
 block discarded – undo
871 871
                     }
872 872
                 }
873 873
             }
874
-            $out = $query . "\n";
874
+            $out = $query."\n";
875 875
             if (!empty($indicesArr)) {
876
-                $out .= implode("\n", $indicesArr) . "\n";
876
+                $out .= implode("\n", $indicesArr)."\n";
877 877
             }
878 878
 
879 879
             $out .= $this->add_existing_custom_fields($execute);
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
         $field = get_widget($data ['type']);
915 915
         $field->populateFromRow($data);
916 916
         $query = "/*MISSING IN DATABASE - {$data['name']} -  ROW*/\n"
917
-            . $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
918
-        $out = $query . "\n";
917
+            . $field->get_db_add_alter_table($this->bean->table_name.'_cstm');
918
+        $out = $query."\n";
919 919
         if ($execute) {
920 920
             $this->db->query($query);
921 921
         }
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
         //Otherwise make sure all the custom fields defined in the vardefs exist in the custom table.
938 938
         //We aren't checking for data types, just that the column exists.
939 939
         $db = $this->db;
940
-        $tablename = $this->bean->table_name . '_cstm';
940
+        $tablename = $this->bean->table_name.'_cstm';
941 941
         $compareFieldDefs = $db->get_columns($tablename);
942 942
         foreach ($this->bean->field_defs as $name => $data) {
943 943
             if (empty($data['source']) || $data['source'] != 'custom_fields') {
@@ -981,14 +981,14 @@  discard block
 block discarded – undo
981 981
         $systemLabel = $field_key;
982 982
         if (!$this->use_existing_labels) { // use_existing_labels defaults to false in this module; as of today, only set to true by ModuleInstaller.php
983 983
             while (isset($mod_strings [$systemLabel]) && $count <= $limit) {
984
-                $systemLabel = $field_key . "_$count";
984
+                $systemLabel = $field_key."_$count";
985 985
                 ++$count;
986 986
             }
987 987
         }
988 988
         $selMod = (!empty($_REQUEST['view_module'])) ? $_REQUEST['view_module'] : $this->module;
989 989
         require_once 'modules/ModuleBuilder/parsers/parser.label.php';
990 990
         $parser = new ParserLabel($selMod, isset($_REQUEST ['view_package']) ? $_REQUEST ['view_package'] : null);
991
-        $parser->handleSave(array('label_' . $systemLabel => $displayLabel), $GLOBALS ['current_language']);
991
+        $parser->handleSave(array('label_'.$systemLabel => $displayLabel), $GLOBALS ['current_language']);
992 992
 
993 993
         return $systemLabel;
994 994
     }
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
         if (isset($this->avail_fields)) {
1027 1027
             foreach ($this->avail_fields as $name => $value) {
1028 1028
                 if (!empty($_REQUEST[$name])) {
1029
-                    $where_clauses[] = $this->bean->table_name . "_cstm.$name LIKE '" . $this->db->quote($_REQUEST[$name]) . "%'";
1029
+                    $where_clauses[] = $this->bean->table_name."_cstm.$name LIKE '".$this->db->quote($_REQUEST[$name])."%'";
1030 1030
                 }
1031 1031
             }
1032 1032
         }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
             return false;
1051 1051
         }
1052 1052
 
1053
-        $query = 'SELECT * FROM ' . $this->bean->table_name . "_cstm WHERE id_c='" . $this->bean->id . "'";
1053
+        $query = 'SELECT * FROM '.$this->bean->table_name."_cstm WHERE id_c='".$this->bean->id."'";
1054 1054
         $result = $this->db->query($query);
1055 1055
         $row = $this->db->fetchByAssoc($result);
1056 1056
 
Please login to merge, or discard this patch.
modules/ModuleBuilder/parsers/parser.label.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $labels = array();
81 81
         foreach ($params as $key => $value) {
82 82
             if (preg_match('/^label_/', $key) && strcmp($value, 'no_change') != 0) {
83
-                $labels [ strtoupper(substr($key, 6)) ] = SugarCleaner::cleanHtml(from_html($value), false);
83
+                $labels [strtoupper(substr($key, 6))] = SugarCleaner::cleanHtml(from_html($value), false);
84 84
             }
85 85
         }
86 86
         if (!empty($this->packageName)) {
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public static function removeLabel($language, $label, $labelvalue, $moduleName, $basepath = null, $forRelationshipLabel = false)
105 105
     {
106
-        $GLOBALS [ 'log' ]->debug("ParserLabel->removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );");
106
+        $GLOBALS ['log']->debug("ParserLabel->removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );");
107 107
         if (is_null($basepath)) {
108 108
             $deployedModule = true;
109 109
             $basepath = "custom/modules/$moduleName/language";
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
         if ($changed) {
152 152
             if (!write_array_to_file('mod_strings', $mod_strings, $filename)) {
153
-                $GLOBALS [ 'log' ]->fatal("Could not write $filename");
153
+                $GLOBALS ['log']->fatal("Could not write $filename");
154 154
             } else {
155 155
                 // if we have a cache to worry about, then clear it now
156 156
                 if ($deployedModule) {
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public static function addLabels($language, $labels, $moduleName, $basepath = null, $forRelationshipLabel = false)
176 176
     {
177
-        $GLOBALS [ 'log' ]->debug("ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );");
178
-        $GLOBALS [ 'log' ]->debug('$labels:'.print_r($labels, true));
177
+        $GLOBALS ['log']->debug("ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );");
178
+        $GLOBALS ['log']->debug('$labels:'.print_r($labels, true));
179 179
 
180 180
         $deployedModule = false;
181 181
         if (is_null($basepath)) {
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
         //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;
215 215
 
216 216
             foreach ($labels as $key => $value) {
217
-                if (!isset($mod_strings [ $key ]) || strcmp($value, $mod_strings [ $key ]) != 0) {
217
+                if (!isset($mod_strings [$key]) || strcmp($value, $mod_strings [$key]) != 0) {
218 218
                     $mod_strings [$key] = to_html(strip_tags(from_html($value))); // must match encoding used in view.labels.php
219 219
                     $changed = true;
220 220
                 }
221 221
             }
222 222
 
223 223
         if ($changed) {
224
-            $GLOBALS [ 'log' ]->debug("ParserLabel->addLabels: writing new mod_strings to $filename");
225
-            $GLOBALS [ 'log' ]->debug('ParserLabel->addLabels: mod_strings='.print_r($mod_strings, true));
224
+            $GLOBALS ['log']->debug("ParserLabel->addLabels: writing new mod_strings to $filename");
225
+            $GLOBALS ['log']->debug('ParserLabel->addLabels: mod_strings='.print_r($mod_strings, true));
226 226
             if (!write_array_to_file('mod_strings', $mod_strings, $filename)) {
227
-                $GLOBALS [ 'log' ]->fatal("Could not write $filename");
227
+                $GLOBALS ['log']->fatal("Could not write $filename");
228 228
             } else {
229 229
                 // if we have a cache to worry about, then clear it now
230 230
                 if ($deployedModule) {
231 231
                     SugarCache::cleanOpcodes();
232
-                    $GLOBALS [ 'log' ]->debug('PaserLabel->addLabels: clearing language cache');
232
+                    $GLOBALS ['log']->debug('PaserLabel->addLabels: clearing language cache');
233 233
                     $cache_key = 'module_language.'.$language.$moduleName;
234 234
                     sugar_cache_clear($cache_key);
235 235
                     LanguageManager::clearLanguageCache($moduleName, $language);
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                     $file_contents = fopen($extension_filename, 'w');
280 280
                     fputs($file_contents, $out, strlen($out));
281 281
                     fclose($file_contents);
282
-                } catch (Exception $e) {
282
+                }catch (Exception $e) {
283 283
                     $GLOBALS ['log']->fatal("Could not write $filename");
284 284
                     $GLOBALS ['log']->fatal('Exception '.$e->getMessage());
285 285
                 }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                     $file_contents = fopen($relationships_filename, 'w');
322 322
                     fputs($file_contents, $out, strlen($out));
323 323
                     fclose($file_contents);
324
-                } catch (Exception $e) {
324
+                }catch (Exception $e) {
325 325
                     $GLOBALS ['log']->fatal("Could not write $filename");
326 326
                     $GLOBALS ['log']->fatal('Exception '.$e->getMessage());
327 327
                     $failed_to_write = true;
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
     {
357 357
         foreach ($metadata as $definition) {
358 358
             $labels = array();
359
-            $labels[$definition [ 'system_label' ]] = $definition [ 'display_label' ];
360
-            self::addLabels($language, $labels, $definition [ 'module' ], null, true);
359
+            $labels[$definition ['system_label']] = $definition ['display_label'];
360
+            self::addLabels($language, $labels, $definition ['module'], null, true);
361 361
         }
362 362
     }
363 363
 
Please login to merge, or discard this patch.
modules/AOR_Reports/AOR_Report.php 1 patch
Spacing   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	var $object_name = 'AOR_Report';
45 45
 	var $table_name = 'aor_reports';
46 46
 	var $importable = true;
47
-	var $disable_row_level_security = true ;
47
+	var $disable_row_level_security = true;
48 48
 
49 49
 	var $id;
50 50
 	var $name;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	var $assigned_user_link;
64 64
 	var $report_module;
65 65
 
66
-	function __construct(){
66
+	function __construct() {
67 67
 		parent::__construct();
68 68
         $this->load_report_beans();
69 69
         require_once('modules/AOW_WorkFlow/aow_utils.php');
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
     /**
74 74
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
75 75
      */
76
-    function AOR_Report(){
76
+    function AOR_Report() {
77 77
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
78
-        if(isset($GLOBALS['log'])) {
78
+        if (isset($GLOBALS['log'])) {
79 79
             $GLOBALS['log']->deprecated($deprecatedMessage);
80 80
         }
81 81
         else {
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
 
88
-	function bean_implements($interface){
89
-		switch($interface){
88
+	function bean_implements($interface) {
89
+		switch ($interface) {
90 90
 			case 'ACL': return true;
91 91
 		}
92 92
 		return false;
93 93
 	}
94 94
 
95
-    function save($check_notify = FALSE){
95
+    function save($check_notify = FALSE) {
96 96
 
97 97
         // TODO: process of saveing the fields and conditions is too long so we will have to make some optimization on save_lines functions
98 98
         set_time_limit(3600);
99 99
 
100
-        if (empty($this->id)){
100
+        if (empty($this->id)) {
101 101
             unset($_POST['aor_conditions_id']);
102 102
             unset($_POST['aor_fields_id']);
103 103
         }
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
         $chart->save_lines($_POST, $this, 'aor_chart_');
118 118
     }
119 119
 
120
-    function load_report_beans(){
120
+    function load_report_beans() {
121 121
         global $beanList, $app_list_strings;
122 122
 
123 123
         $app_list_strings['aor_moduleList'] = $app_list_strings['moduleList'];
124 124
 
125
-        foreach($app_list_strings['aor_moduleList'] as $mkey => $mvalue){
126
-            if(!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')){
125
+        foreach ($app_list_strings['aor_moduleList'] as $mkey => $mvalue) {
126
+            if (!isset($beanList[$mkey]) || str_begin($mkey, 'AOR_') || str_begin($mkey, 'AOW_')) {
127 127
                 unset($app_list_strings['aor_moduleList'][$mkey]);
128 128
             }
129 129
         }
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
     }
135 135
 
136 136
 
137
-    function getReportFields(){
137
+    function getReportFields() {
138 138
         $fields = array();
139
-        foreach($this->get_linked_beans('aor_fields','AOR_Fields') as $field){
139
+        foreach ($this->get_linked_beans('aor_fields', 'AOR_Fields') as $field) {
140 140
             $fields[] = $field;
141 141
         }
142
-        usort($fields,function($a,$b){
142
+        usort($fields, function($a, $b) {
143 143
             return $a->field_order - $b->field_order;
144 144
         });
145 145
         return $fields;
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
     const CHART_TYPE_RGRAPH = 'rgraph';
151 151
 
152 152
 
153
-    function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART){
153
+    function build_report_chart($chartIds = null, $chartType = self::CHART_TYPE_PCHART) {
154 154
         global $beanList;
155
-        $linkedCharts = $this->get_linked_beans('aor_charts','AOR_Charts');
156
-	if(!$linkedCharts){
155
+        $linkedCharts = $this->get_linked_beans('aor_charts', 'AOR_Charts');
156
+	if (!$linkedCharts) {
157 157
             //No charts to display
158 158
             return '';
159 159
         }
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 
178 178
             $field_module = $this->report_module;
179 179
             $field_alias = $field_bean->table_name;
180
-            if($path[0] != $this->report_module){
181
-                foreach($path as $rel){
182
-                    if(empty($rel)){
180
+            if ($path[0] != $this->report_module) {
181
+                foreach ($path as $rel) {
182
+                    if (empty($rel)) {
183 183
                         continue;
184 184
                     }
185
-                    $field_module = getRelatedModule($field_module,$rel);
186
-                    $field_alias = $field_alias . ':'.$rel;
185
+                    $field_module = getRelatedModule($field_module, $rel);
186
+                    $field_alias = $field_alias.':'.$rel;
187 187
                 }
188 188
             }
189
-            $label = str_replace(' ','_',$field->label).$i;
189
+            $label = str_replace(' ', '_', $field->label).$i;
190 190
             $fields[$label]['field'] = $field->field;
191 191
             $fields[$label]['label'] = $field->label;
192 192
             $fields[$label]['display'] = $field->display;
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
 
202 202
             // get the main group
203 203
 
204
-            if($field->group_display) {
204
+            if ($field->group_display) {
205 205
 
206 206
                 // if we have a main group already thats wrong cause only one main grouping field possible
207
-                if(!is_null($mainGroupField)) {
207
+                if (!is_null($mainGroupField)) {
208 208
                     $GLOBALS['log']->fatal('main group already found');
209 209
                 }
210 210
 
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
         $query = $this->build_report_query();
220 220
         $result = $this->db->query($query);
221 221
         $data = array();
222
-        while($row = $this->db->fetchByAssoc($result, false))
222
+        while ($row = $this->db->fetchByAssoc($result, false))
223 223
         {
224
-            foreach($fields as $name => $att){
224
+            foreach ($fields as $name => $att) {
225 225
 
226 226
                 $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : '';
227 227
 
228
-                switch ($att['function']){
228
+                switch ($att['function']) {
229 229
                     case 'COUNT':
230 230
                         break;
231 231
                     default:
232
-                        if(!is_numeric($row[$name])) {
233
-                            $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id,$att['params'])));
232
+                        if (!is_numeric($row[$name])) {
233
+                            $row[$name] = trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params'])));
234 234
 
235 235
                         }
236 236
                         break;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         }
241 241
         $fields = $this->getReportFields();
242 242
 
243
-        switch($chartType) {
243
+        switch ($chartType) {
244 244
             case self::CHART_TYPE_PCHART:
245 245
                 $html = '<script src="modules/AOR_Charts/lib/pChart/imagemap.js"></script>';
246 246
                 break;
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
                 $html = '<script src="modules/AOR_Reports/js/Chart.js"></script>';
249 249
                 break;
250 250
             case self::CHART_TYPE_RGRAPH:
251
-                if($_REQUEST['module']!= 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit
251
+                if ($_REQUEST['module'] != 'Home')//Need the require_once for the rgraphincludes as they are only loaded when the home page is hit
252 252
                     require_once('include/SuiteGraphs/RGraphIncludes.php');
253 253
 
254 254
                 break;
255 255
         }
256 256
         $x = 0;
257
-        foreach($linkedCharts as $chart){
258
-            if($chartIds !== null && !in_array($chart->id,$chartIds)){
257
+        foreach ($linkedCharts as $chart) {
258
+            if ($chartIds !== null && !in_array($chart->id, $chartIds)) {
259 259
                 continue;
260 260
             }
261
-            $html .= $chart->buildChartHTML($data,$fields,$x, $chartType, $mainGroupField);
261
+            $html .= $chart->buildChartHTML($data, $fields, $x, $chartType, $mainGroupField);
262 262
             $x++;
263 263
         }
264 264
         return $html;
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 
271 271
         $rows = $this->getGroupDisplayFieldByReportId($this->id, $level);
272 272
 
273
-        if(count($rows) > 1) {
274
-            $GLOBALS['log']->fatal('ambiguous group display for report ' . $this->id);
273
+        if (count($rows) > 1) {
274
+            $GLOBALS['log']->fatal('ambiguous group display for report '.$this->id);
275 275
         }
276
-        else if(count($rows) == 1){
276
+        else if (count($rows) == 1) {
277 277
             $rows[0]['module_path'] = unserialize(base64_decode($rows[0]['module_path']));
278
-            if(!$rows[0]['module_path'][0]) {
278
+            if (!$rows[0]['module_path'][0]) {
279 279
                 $module = new $beanList[$this->report_module]();
280 280
                 $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'];
281 281
                 $rows[0]['module_path'][0] = $module->table_name;
@@ -285,23 +285,23 @@  discard block
 block discarded – undo
285 285
             }
286 286
             $path[] = $rows[0];
287 287
 
288
-            if($level>10) {
288
+            if ($level > 10) {
289 289
                 $msg = 'Too many nested groups';
290 290
                 $GLOBALS['log']->fatal($msg);
291 291
                 return null;
292 292
             }
293 293
 
294
-            return $this->buildMultiGroupReport($offset, $links, $level+1, $path);
294
+            return $this->buildMultiGroupReport($offset, $links, $level + 1, $path);
295 295
         }
296
-        else if(!$rows) {
297
-            if($path) {
296
+        else if (!$rows) {
297
+            if ($path) {
298 298
                 $html = '';
299 299
                 foreach ($path as $pth) {
300 300
                     $_fieldIdName = $this->db->quoteIdentifier($pth['field_id_name']);
301
-                    $query = "SELECT $_fieldIdName FROM " . $this->db->quoteIdentifier($pth['module_path'][0]) . " GROUP BY $_fieldIdName;";
301
+                    $query = "SELECT $_fieldIdName FROM ".$this->db->quoteIdentifier($pth['module_path'][0])." GROUP BY $_fieldIdName;";
302 302
                     $values = $this->dbSelect($query);
303 303
 
304
-                    foreach($values as $value) {
304
+                    foreach ($values as $value) {
305 305
 
306 306
                         //$where = [ $this->db->quote($pth['module_path'][0]) . '.' . $_fieldIdName . ' = \'' . $this->db->quote($value[$pth['field_id_name']]) . '\'' ];
307 307
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         // escape values for query
338 338
 
339 339
         $_id = $this->db->quote($reportId);
340
-        $_level = (int) $level;
340
+        $_level = (int)$level;
341 341
 
342 342
         // get results array
343 343
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         $results = $this->db->query($query);
353 353
 
354 354
         $rows = array();
355
-        while($row = $this->db->fetchByAssoc($results)) {
355
+        while ($row = $this->db->fetchByAssoc($results)) {
356 356
             $rows[] = $row;
357 357
         }
358 358
 
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
 
362 362
     private function getMultiGroupFrameHTML($header, $body) {
363 363
         $html = '<div class="multi-group-list" style="border: 1px solid black; padding: 10px;">
364
-                    <h3>' . $header . '</h3>
365
-                    <div class="multi-group-list-inner">' . $body . '</div>
364
+                    <h3>' . $header.'</h3>
365
+                    <div class="multi-group-list-inner">' . $body.'</div>
366 366
                 </div>';
367 367
         return $html;
368 368
     }
369 369
 
370 370
     private function addDataIdValueToInnertext($html) {
371 371
         preg_match('/\sdata-id-value\s*=\s*"([^"]*)"/', $html, $match);
372
-        $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2' . $match[1] . '$3', $html);
372
+        $html = preg_replace('/(>)([^<]*)(<\/\w+>$)/', '$1$2'.$match[1].'$3', $html);
373 373
         return $html;
374 374
     }
375 375
 
376 376
 
377
-    function build_group_report($offset = -1, $links = true, $extra = array()){
377
+    function build_group_report($offset = -1, $links = true, $extra = array()) {
378 378
         global $beanList;
379 379
 
380 380
         $html = '';
@@ -385,23 +385,23 @@  discard block
 block discarded – undo
385 385
         $sql = "SELECT id FROM aor_fields WHERE aor_report_id = '".$this->id."' AND group_display = 1 AND deleted = 0 ORDER BY field_order ASC";
386 386
         $field_id = $this->db->getOne($sql);
387 387
 
388
-        if(!$field_id) {
389
-            $query_array['select'][] = $module->table_name . ".id AS '" . $module->table_name . "_id'";
388
+        if (!$field_id) {
389
+            $query_array['select'][] = $module->table_name.".id AS '".$module->table_name."_id'";
390 390
         }
391 391
 
392
-        if($field_id != ''){
392
+        if ($field_id != '') {
393 393
             $field = new AOR_Field();
394 394
             $field->retrieve($field_id);
395 395
 
396
-            $field_label = str_replace(' ','_',$field->label);
396
+            $field_label = str_replace(' ', '_', $field->label);
397 397
 
398 398
             $path = unserialize(base64_decode($field->module_path));
399 399
 
400 400
             $field_module = $module;
401 401
             $table_alias = $field_module->table_name;
402
-            if(!empty($path[0]) && $path[0] != $module->module_dir){
403
-                foreach($path as $rel){
404
-                    $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)];
402
+            if (!empty($path[0]) && $path[0] != $module->module_dir) {
403
+                foreach ($path as $rel) {
404
+                    $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)];
405 405
                     $oldAlias = $table_alias;
406 406
                     $table_alias = $table_alias.":".$rel;
407 407
 
@@ -415,71 +415,71 @@  discard block
 block discarded – undo
415 415
 
416 416
             $data = $field_module->field_defs[$field->field];
417 417
 
418
-            if($data['type'] == 'relate' && isset($data['id_name'])) {
418
+            if ($data['type'] == 'relate' && isset($data['id_name'])) {
419 419
                 $field->field = $data['id_name'];
420 420
             }
421 421
 
422
-            if($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) {
423
-                if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) {
422
+            if ($data['type'] == 'currency' && !stripos($field->field, '_USD') && isset($field_module->field_defs['currency_id'])) {
423
+                if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) {
424 424
                     $query['select'][$table_alias.'_currency_id'] = $table_alias.'_cstm'.".currency_id AS '".$table_alias."_currency_id'";
425 425
                 } else {
426
-                    $query_array['select'][$table_alias . '_currency_id'] = $table_alias . ".currency_id AS '" . $table_alias . "_currency_id'";
426
+                    $query_array['select'][$table_alias.'_currency_id'] = $table_alias.".currency_id AS '".$table_alias."_currency_id'";
427 427
                 }
428 428
             }
429 429
 
430
-            if(  (isset($data['source']) && $data['source'] == 'custom_fields')) {
430
+            if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
431 431
                 $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field;
432 432
                 // Fix for #1251 - added a missing parameter to the function call
433 433
                 $query_array = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $table_alias, $field_module, 'custom', $query);
434 434
             } else {
435
-                $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field;
435
+                $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field;
436 436
             }
437 437
 
438
-            if($field->sort_by != ''){
438
+            if ($field->sort_by != '') {
439 439
                 $query_array['sort_by'][] = $field_label.' '.$field->sort_by;
440 440
             }
441 441
 
442
-            if($field->group_by == 1){
442
+            if ($field->group_by == 1) {
443 443
                 $query_array['group_by'][] = $select_field;
444 444
             }
445 445
 
446
-            if($field->field_function != null){
446
+            if ($field->field_function != null) {
447 447
                 $select_field = $field->field_function.'('.$select_field.')';
448 448
             }
449 449
 
450
-            $query_array['select'][] = $select_field ." AS '".$field_label."'";
451
-            if(isset($extra['select']) && $extra['select']) {
452
-                foreach($extra['select'] as $selectField => $selectAlias) {
453
-                    if($selectAlias) {
454
-                        $query_array['select'][] = $selectField . " AS " . $selectAlias;
450
+            $query_array['select'][] = $select_field." AS '".$field_label."'";
451
+            if (isset($extra['select']) && $extra['select']) {
452
+                foreach ($extra['select'] as $selectField => $selectAlias) {
453
+                    if ($selectAlias) {
454
+                        $query_array['select'][] = $selectField." AS ".$selectAlias;
455 455
                     }
456 456
                     else {
457 457
                         $query_array['select'][] = $selectField;
458 458
                     }
459 459
                 }
460 460
             }
461
-            $query_array['where'][] = $select_field ." IS NOT NULL AND ";
462
-            if(isset($extra['where']) && $extra['where']) {
463
-                $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND ';
461
+            $query_array['where'][] = $select_field." IS NOT NULL AND ";
462
+            if (isset($extra['where']) && $extra['where']) {
463
+                $query_array['where'][] = implode(' AND ', $extra['where']).' AND ';
464 464
             }
465 465
 
466 466
             $query_array = $this->build_report_query_where($query_array);
467 467
 
468
-            foreach ($query_array['select'] as $select){
469
-                $query .=  ($query == '' ? 'SELECT ' : ', ').$select;
468
+            foreach ($query_array['select'] as $select) {
469
+                $query .= ($query == '' ? 'SELECT ' : ', ').$select;
470 470
             }
471 471
 
472 472
             $query .= ' FROM '.$module->table_name.' ';
473 473
 
474
-            if(isset($query_array['join'])){
475
-                foreach ($query_array['join'] as $join){
474
+            if (isset($query_array['join'])) {
475
+                foreach ($query_array['join'] as $join) {
476 476
                     $query .= $join;
477 477
                 }
478 478
             }
479
-            if(isset($query_array['where'])){
479
+            if (isset($query_array['where'])) {
480 480
                 $query_where = '';
481
-                foreach ($query_array['where'] as $where){
482
-                    $query_where .=  ($query_where == '' ? 'WHERE ' : ' ').$where;
481
+                foreach ($query_array['where'] as $where) {
482
+                    $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where;
483 483
                 }
484 484
 
485 485
                 $query_where = $this->queryWhereRepair($query_where);
@@ -487,38 +487,38 @@  discard block
 block discarded – undo
487 487
                 $query .= ' '.$query_where;
488 488
             }
489 489
 
490
-            if(isset($query_array['group_by'])){
490
+            if (isset($query_array['group_by'])) {
491 491
                 $query_group_by = '';
492
-                foreach ($query_array['group_by'] as $group_by){
493
-                    $query_group_by .=  ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by;
492
+                foreach ($query_array['group_by'] as $group_by) {
493
+                    $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by;
494 494
                 }
495 495
                 $query .= ' '.$query_group_by;
496 496
             }
497 497
 
498
-            if(isset($query_array['sort_by'])){
498
+            if (isset($query_array['sort_by'])) {
499 499
                 $query_sort_by = '';
500
-                foreach ($query_array['sort_by'] as $sort_by){
501
-                    $query_sort_by .=  ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by;
500
+                foreach ($query_array['sort_by'] as $sort_by) {
501
+                    $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by;
502 502
                 }
503 503
                 $query .= ' '.$query_sort_by;
504 504
             }
505 505
             $result = $this->db->query($query);
506 506
 
507 507
             while ($row = $this->db->fetchByAssoc($result)) {
508
-                if($html != '') $html .= '<br />';
508
+                if ($html != '') $html .= '<br />';
509 509
 
510 510
                $html .= $this->build_report_html($offset, $links, $row[$field_label], '', $extra);
511 511
 
512 512
             }
513 513
         }
514 514
 
515
-        if($html == '') $html = $this->build_report_html($offset, $links);
515
+        if ($html == '') $html = $this->build_report_html($offset, $links);
516 516
         return $html;
517 517
 
518 518
     }
519 519
 
520 520
 
521
-    function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()){
521
+    function build_report_html($offset = -1, $links = true, $group_value = '', $tableIdentifier = '', $extra = array()) {
522 522
 
523 523
         global $beanList, $sugar_config;
524 524
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         $report_sql = $this->build_report_query($_group_value, $extra);
528 528
 
529 529
         // Fix for issue 1232 - items listed in a single report, should adhere to the same standard as ListView items.
530
-        if($sugar_config['list_max_entries_per_page']!='') {
530
+        if ($sugar_config['list_max_entries_per_page'] != '') {
531 531
             $max_rows = $sugar_config['list_max_entries_per_page'];
532 532
         } else {
533 533
             $max_rows = 20;
@@ -540,27 +540,27 @@  discard block
 block discarded – undo
540 540
         // We have a count query.  Run it and get the results.
541 541
         $result = $this->db->query($count_query);
542 542
         $assoc = $this->db->fetchByAssoc($result);
543
-        if(!empty($assoc['c']))
543
+        if (!empty($assoc['c']))
544 544
         {
545 545
             $total_rows = $assoc['c'];
546 546
         }
547 547
 
548 548
         $html = "<table class='list' id='report_table".$group_value."' width='100%' cellspacing='0' cellpadding='0' border='0' repeat_header='1'>";
549 549
 
550
-        if($offset >= 0){
550
+        if ($offset >= 0) {
551 551
             $start = 0;
552 552
             $end = 0;
553 553
             $previous_offset = 0;
554 554
             $next_offset = 0;
555 555
             $last_offset = 0;
556 556
 
557
-            if($total_rows > 0){
558
-                $start = $offset +1;
557
+            if ($total_rows > 0) {
558
+                $start = $offset + 1;
559 559
                 $end = (($offset + $max_rows) < $total_rows) ? $offset + $max_rows : $total_rows;
560 560
                 $previous_offset = ($offset - $max_rows) < 0 ? 0 : $offset - $max_rows;
561 561
                 $next_offset = $offset + $max_rows;
562
-                if(is_int($total_rows / $max_rows)){
563
-                    $last_offset = $max_rows * ($total_rows / $max_rows -1);
562
+                if (is_int($total_rows / $max_rows)) {
563
+                    $last_offset = $max_rows * ($total_rows / $max_rows - 1);
564 564
                 } else {
565 565
                     $last_offset = $max_rows * floor($total_rows / $max_rows);
566 566
                 }
@@ -572,36 +572,36 @@  discard block
 block discarded – undo
572 572
 
573 573
             $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value);
574 574
 
575
-            $html .="<td colspan='18'>
575
+            $html .= "<td colspan='18'>
576 576
                        <table class='paginationTable' border='0' cellpadding='0' cellspacing='0' width='100%'>
577 577
                         <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>
578 578
                         <td class='paginationChangeButtons' align='right' nowrap='nowrap' width='1%'>";
579 579
 
580
-            if($offset == 0){
581
-                $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'>
580
+            if ($offset == 0) {
581
+                $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' disabled='disabled'>
582 582
                     <img src='".SugarThemeRegistry::current()->getImageURL('start_off.gif')."' alt='Start' align='absmiddle' border='0'>
583 583
                 </button>
584 584
                 <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' disabled='disabled'>
585 585
                     <img src='".SugarThemeRegistry::current()->getImageURL('previous_off.gif')."' alt='Previous' align='absmiddle' border='0'>
586 586
                 </button>";
587 587
             } else {
588
-                $html .="<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'>
588
+                $html .= "<button type='button' id='listViewStartButton_top' name='listViewStartButton' title='Start' class='button' onclick='changeReportPage(\"".$this->id."\",0,\"".$group_value."\",\"".$tableIdentifier."\")'>
589 589
                     <img src='".SugarThemeRegistry::current()->getImageURL('start.gif')."' alt='Start' align='absmiddle' border='0'>
590 590
                 </button>
591 591
                 <button type='button' id='listViewPrevButton_top' name='listViewPrevButton' class='button' title='Previous' onclick='changeReportPage(\"".$this->id."\",".$previous_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'>
592 592
                     <img src='".SugarThemeRegistry::current()->getImageURL('previous.gif')."' alt='Previous' align='absmiddle' border='0'>
593 593
                 </button>";
594 594
             }
595
-            $html .=" <span class='pageNumbers'>(".$start ." - ".$end ." of ". $total_rows .")</span>";
596
-            if($next_offset < $total_rows){
597
-                $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'>
595
+            $html .= " <span class='pageNumbers'>(".$start." - ".$end." of ".$total_rows.")</span>";
596
+            if ($next_offset < $total_rows) {
597
+                $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button' onclick='changeReportPage(\"".$this->id."\",".$next_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'>
598 598
                         <img src='".SugarThemeRegistry::current()->getImageURL('next.gif')."' alt='Next' align='absmiddle' border='0'>
599 599
                     </button>
600 600
                      <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button' onclick='changeReportPage(\"".$this->id."\",".$last_offset.",\"".$group_value."\",\"".$tableIdentifier."\")'>
601 601
                         <img src='".SugarThemeRegistry::current()->getImageURL('end.gif')."' alt='End' align='absmiddle' border='0'>
602 602
                     </button>";
603 603
             } else {
604
-                $html .="<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button'  disabled='disabled'>
604
+                $html .= "<button type='button' id='listViewNextButton_top' name='listViewNextButton' title='Next' class='button'  disabled='disabled'>
605 605
                         <img src='".SugarThemeRegistry::current()->getImageURL('next_off.gif')."' alt='Next' align='absmiddle' border='0'>
606 606
                     </button>
607 607
                      <button type='button' id='listViewEndButton_top' name='listViewEndButton' title='End' class='button'  disabled='disabled'>
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
 
611 611
             }
612 612
 
613
-            $html .="</td>
613
+            $html .= "</td>
614 614
                        </table>
615 615
                       </td>";
616 616
 
617
-            $html .="</tr></thead>";
618
-        } else{
617
+            $html .= "</tr></thead>";
618
+        } else {
619 619
 
620 620
             $moduleFieldByGroupValue = $this->getModuleFieldByGroupValue($beanList, $group_value);
621 621
 
@@ -641,16 +641,16 @@  discard block
 block discarded – undo
641 641
 
642 642
             $field_module = $this->report_module;
643 643
             $field_alias = $field_bean->table_name;
644
-            if($path[0] != $this->report_module){
645
-                foreach($path as $rel){
646
-                    if(empty($rel)){
644
+            if ($path[0] != $this->report_module) {
645
+                foreach ($path as $rel) {
646
+                    if (empty($rel)) {
647 647
                         continue;
648 648
                     }
649
-                    $field_module = getRelatedModule($field_module,$rel);
650
-                    $field_alias = $field_alias . ':'.$rel;
649
+                    $field_module = getRelatedModule($field_module, $rel);
650
+                    $field_alias = $field_alias.':'.$rel;
651 651
                 }
652 652
             }
653
-            $label = str_replace(' ','_',$field->label).$i;
653
+            $label = str_replace(' ', '_', $field->label).$i;
654 654
             $fields[$label]['field'] = $field->field;
655 655
             $fields[$label]['label'] = $field->label;
656 656
             $fields[$label]['display'] = $field->display;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
             $fields[$label]['params'] = array("date_format" => $field->format);
664 664
 
665 665
 
666
-            if($fields[$label]['display']){
666
+            if ($fields[$label]['display']) {
667 667
                 $html .= "<th scope='col'>";
668 668
                 $html .= "<div style='white-space: normal;' width='100%' align='left'>";
669 669
                 $html .= $field->label;
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         $html .= "</thead>";
677 677
         $html .= "<tbody>";
678 678
 
679
-        if($offset >= 0){
679
+        if ($offset >= 0) {
680 680
             $result = $this->db->limitQuery($report_sql, $offset, $max_rows);
681 681
         } else {
682 682
             $result = $this->db->query($report_sql);
@@ -689,39 +689,39 @@  discard block
 block discarded – undo
689 689
         while ($row = $this->db->fetchByAssoc($result)) {
690 690
             $html .= "<tr class='".$row_class."' height='20'>";
691 691
 
692
-            foreach($fields as $name => $att){
693
-                if($att['display']){
692
+            foreach ($fields as $name => $att) {
693
+                if ($att['display']) {
694 694
                     $html .= "<td class='' valign='top' align='left'>";
695
-                    if($att['link'] && $links){
696
-                        $html .= "<a href='" . $sugar_config['site_url'] . "/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>";
695
+                    if ($att['link'] && $links) {
696
+                        $html .= "<a href='".$sugar_config['site_url']."/index.php?module=".$att['module']."&action=DetailView&record=".$row[$att['alias'].'_id']."'>";
697 697
                     }
698 698
 
699 699
                     $currency_id = isset($row[$att['alias'].'_currency_id']) ? $row[$att['alias'].'_currency_id'] : '';
700 700
 
701
-                    switch ($att['function']){
701
+                    switch ($att['function']) {
702 702
                         case 'COUNT':
703 703
                         //case 'SUM':
704 704
                             $html .= $row[$name];
705 705
                             break;
706 706
                         default:
707 707
 
708
-                            $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name],'',$currency_id, $att['params']);
708
+                            $html .= getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name], '', $currency_id, $att['params']);
709 709
                             break;
710 710
                     }
711
-                    if($att['total']){
711
+                    if ($att['total']) {
712 712
                         $totals[$name][] = $row[$name];
713 713
                     }
714
-                    if($att['link'] && $links) $html .= "</a>";
714
+                    if ($att['link'] && $links) $html .= "</a>";
715 715
                     $html .= "</td>";
716 716
                 }
717 717
             }
718 718
             $html .= "</tr>";
719 719
 
720
-            $row_class = $row_class == 'oddListRowS1' ?  'evenListRowS1':'oddListRowS1';
720
+            $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1' : 'oddListRowS1';
721 721
         }
722 722
         $html .= "</tbody>";
723 723
 
724
-        $html .= $this->getTotalHtml($fields,$totals);
724
+        $html .= $this->getTotalHtml($fields, $totals);
725 725
 
726 726
         $html .= "</table>";
727 727
 
@@ -764,13 +764,13 @@  discard block
 block discarded – undo
764 764
 
765 765
             $field_module = $this->report_module;
766 766
             $field_alias = $field_bean->table_name;
767
-            if($path[0] != $this->report_module){
768
-                foreach($path as $rel){
769
-                    if(empty($rel)){
767
+            if ($path[0] != $this->report_module) {
768
+                foreach ($path as $rel) {
769
+                    if (empty($rel)) {
770 770
                         continue;
771 771
                     }
772
-                    $field_module = getRelatedModule($field_module,$rel);
773
-                    $field_alias = $field_alias . ':'.$rel;
772
+                    $field_module = getRelatedModule($field_module, $rel);
773
+                    $field_alias = $field_alias.':'.$rel;
774 774
                 }
775 775
             }
776 776
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
         return $moduleFieldByGroupValue;
784 784
     }
785 785
 
786
-    function getTotalHTML($fields,$totals){
786
+    function getTotalHTML($fields, $totals) {
787 787
         global $app_list_strings;
788 788
 
789 789
         $currency = new Currency();
@@ -792,36 +792,36 @@  discard block
 block discarded – undo
792 792
         $html = '';
793 793
         $html .= "<tbody>";
794 794
         $html .= "<tr>";
795
-        foreach($fields as $label => $field){
796
-            if(!$field['display']){
795
+        foreach ($fields as $label => $field) {
796
+            if (!$field['display']) {
797 797
                 continue;
798 798
             }
799
-            if($field['total']){
800
-                $totalLabel = $field['label'] ." ".$app_list_strings['aor_total_options'][$field['total']];
799
+            if ($field['total']) {
800
+                $totalLabel = $field['label']." ".$app_list_strings['aor_total_options'][$field['total']];
801 801
                 $html .= "<th>{$totalLabel}</th>";
802
-            }else{
802
+            } else {
803 803
                 $html .= "<th></th>";
804 804
             }
805 805
         }
806 806
         $html .= "</tr>";
807 807
         $html .= "<tr>";
808
-        foreach($fields as $label => $field){
809
-            if(!$field['display']){
808
+        foreach ($fields as $label => $field) {
809
+            if (!$field['display']) {
810 810
                 continue;
811 811
             }
812
-            if($field['total'] && isset($totals[$label])){
812
+            if ($field['total'] && isset($totals[$label])) {
813 813
                 $type = $field['total'];
814 814
                 $total = $this->calculateTotal($type, $totals[$label]);
815 815
                 // Customise display based on the field type
816 816
                 $moduleBean = BeanFactory::newBean($field['module']);
817 817
                 $fieldDefinition = $moduleBean->field_defs[$field['field']];
818 818
                 $fieldDefinitionType = $fieldDefinition['type'];
819
-                switch($fieldDefinitionType) {
819
+                switch ($fieldDefinitionType) {
820 820
                     case "currency":
821 821
                         // Customise based on type of function
822
-                        switch($type){
822
+                        switch ($type) {
823 823
                             case 'SUM':
824
-                                if($currency->id == -99) {
824
+                                if ($currency->id == -99) {
825 825
                                     $total = $currency->symbol.format_number($total, null, null);
826 826
                                 } else {
827 827
                                     $total = $currency->symbol.format_number($total, null, null, array('convert' => true));
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
                             case 'COUNT':
830 830
                                 break;
831 831
                             case 'AVG':
832
-                                if($currency->id == -99) {
832
+                                if ($currency->id == -99) {
833 833
                                     $total = $currency->symbol.format_number($total, null, null);
834 834
                                 } else {
835 835
                                     $total = $currency->symbol.format_number($total, null, null, array('convert' => true));
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
                         break;
843 843
                 }
844 844
                 $html .= "<td>".$total."</td>";
845
-            }else{
845
+            } else {
846 846
                 $html .= "<td></td>";
847 847
             }
848 848
         }
@@ -851,24 +851,24 @@  discard block
 block discarded – undo
851 851
         return $html;
852 852
     }
853 853
 
854
-    function calculateTotal($type, $totals){
855
-        switch($type){
854
+    function calculateTotal($type, $totals) {
855
+        switch ($type) {
856 856
             case 'SUM':
857 857
                 return array_sum($totals);
858 858
             case 'COUNT':
859 859
                 return count($totals);
860 860
             case 'AVG':
861
-                return array_sum($totals)/count($totals);
861
+                return array_sum($totals) / count($totals);
862 862
             default:
863 863
                 return '';
864 864
         }
865 865
     }
866 866
 
867
-    private function encloseForCSV($field){
867
+    private function encloseForCSV($field) {
868 868
         return '"'.$field.'"';
869 869
     }
870 870
 
871
-    function build_report_csv(){
871
+    function build_report_csv() {
872 872
 
873 873
         ini_set('zlib.output_compression', 'Off');
874 874
 
@@ -892,20 +892,20 @@  discard block
 block discarded – undo
892 892
             $path = unserialize(base64_decode($field->module_path));
893 893
 
894 894
             $field_module = $this->report_module;
895
-            if($path[0] != $this->report_module){
896
-                foreach($path as $rel){
897
-                    $field_module = getRelatedModule($field_module,$rel);
895
+            if ($path[0] != $this->report_module) {
896
+                foreach ($path as $rel) {
897
+                    $field_module = getRelatedModule($field_module, $rel);
898 898
                 }
899 899
             }
900
-            $label = str_replace(' ','_',$field->label).$i;
900
+            $label = str_replace(' ', '_', $field->label).$i;
901 901
             $fields[$label]['field'] = $field->field;
902 902
             $fields[$label]['display'] = $field->display;
903 903
             $fields[$label]['function'] = $field->field_function;
904 904
             $fields[$label]['module'] = $field_module;
905 905
 
906 906
 
907
-            if($field->display){
908
-                $csv.= $this->encloseForCSV($field->label);
907
+            if ($field->display) {
908
+                $csv .= $this->encloseForCSV($field->label);
909 909
                 $csv .= $delimiter;
910 910
             }
911 911
             ++$i;
@@ -916,30 +916,30 @@  discard block
 block discarded – undo
916 916
 
917 917
         while ($row = $this->db->fetchByAssoc($result)) {
918 918
             $csv .= "\r\n";
919
-            foreach($fields as $name => $att){
920
-                if($att['display']){
921
-                    if($att['function'] != '' )
919
+            foreach ($fields as $name => $att) {
920
+                if ($att['display']) {
921
+                    if ($att['function'] != '')
922 922
                         $csv .= $this->encloseForCSV($row[$name]);
923 923
                     else
924
-                        $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView',$row[$name]))));
924
+                        $csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name]))));
925 925
                     $csv .= $delimiter;
926 926
                 }
927 927
             }
928 928
         }
929 929
 
930
-        $csv= $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset());
930
+        $csv = $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset());
931 931
 
932 932
         ob_clean();
933 933
         header("Pragma: cache");
934 934
         header("Content-type: text/comma-separated-values; charset=".$GLOBALS['locale']->getExportCharset());
935 935
         header("Content-Disposition: attachment; filename=\"{$this->name}.csv\"");
936 936
         header("Content-transfer-encoding: binary");
937
-        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
938
-        header("Last-Modified: " . TimeDate::httpTime() );
939
-        header("Cache-Control: post-check=0, pre-check=0", false );
937
+        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
938
+        header("Last-Modified: ".TimeDate::httpTime());
939
+        header("Cache-Control: post-check=0, pre-check=0", false);
940 940
         header("Content-Length: ".mb_strlen($csv, '8bit'));
941 941
         if (!empty($sugar_config['export_excel_compatible'])) {
942
-            $csv==chr(255) . chr(254) . mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8');
942
+            $csv == chr(255).chr(254).mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8');
943 943
         }
944 944
         print $csv;
945 945
 
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 
949 949
 
950 950
 
951
-    function build_report_query($group_value ='', $extra = array()){
951
+    function build_report_query($group_value = '', $extra = array()) {
952 952
         global $beanList;
953 953
 
954 954
         $module = new $beanList[$this->report_module]();
@@ -957,26 +957,26 @@  discard block
 block discarded – undo
957 957
         $query_array = array();
958 958
 
959 959
         $query_array = $this->build_report_query_select($query_array, $group_value);
960
-        if(isset($extra['where']) && $extra['where']) {
961
-            $query_array['where'][] = implode(' AND ', $extra['where']) . ' AND ';
960
+        if (isset($extra['where']) && $extra['where']) {
961
+            $query_array['where'][] = implode(' AND ', $extra['where']).' AND ';
962 962
         }
963 963
         $query_array = $this->build_report_query_where($query_array);
964 964
 
965
-        foreach ($query_array['select'] as $select){
966
-            $query .=  ($query == '' ? 'SELECT ' : ', ').$select;
965
+        foreach ($query_array['select'] as $select) {
966
+            $query .= ($query == '' ? 'SELECT ' : ', ').$select;
967 967
         }
968 968
 
969 969
         $query .= ' FROM '.$this->db->quoteIdentifier($module->table_name).' ';
970 970
 
971
-        if(isset($query_array['join'])){
972
-            foreach ($query_array['join'] as $join){
971
+        if (isset($query_array['join'])) {
972
+            foreach ($query_array['join'] as $join) {
973 973
                 $query .= $join;
974 974
             }
975 975
         }
976
-        if(isset($query_array['where'])){
976
+        if (isset($query_array['where'])) {
977 977
             $query_where = '';
978
-            foreach ($query_array['where'] as $where){
979
-                $query_where .=  ($query_where == '' ? 'WHERE ' : ' ').$where;
978
+            foreach ($query_array['where'] as $where) {
979
+                $query_where .= ($query_where == '' ? 'WHERE ' : ' ').$where;
980 980
             }
981 981
 
982 982
             $query_where = $this->queryWhereRepair($query_where);
@@ -984,23 +984,23 @@  discard block
 block discarded – undo
984 984
             $query .= ' '.$query_where;
985 985
         }
986 986
 
987
-        if(isset($query_array['group_by'])){
987
+        if (isset($query_array['group_by'])) {
988 988
             $query_group_by = '';
989
-            foreach ($query_array['group_by'] as $group_by){
990
-                $query_group_by .=  ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by;
989
+            foreach ($query_array['group_by'] as $group_by) {
990
+                $query_group_by .= ($query_group_by == '' ? 'GROUP BY ' : ', ').$group_by;
991 991
             }
992
-            if($query_group_by != '') {
992
+            if ($query_group_by != '') {
993 993
                 foreach ($query_array['second_group_by'] as $group_by) {
994
-                    $query_group_by .= ', ' . $group_by;
994
+                    $query_group_by .= ', '.$group_by;
995 995
                 }
996 996
             }
997 997
             $query .= ' '.$query_group_by;
998 998
         }
999 999
 
1000
-        if(isset($query_array['sort_by'])){
1000
+        if (isset($query_array['sort_by'])) {
1001 1001
             $query_sort_by = '';
1002
-            foreach ($query_array['sort_by'] as $sort_by){
1003
-                $query_sort_by .=  ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by;
1002
+            foreach ($query_array['sort_by'] as $sort_by) {
1003
+                $query_sort_by .= ($query_sort_by == '' ? 'ORDER BY ' : ', ').$sort_by;
1004 1004
             }
1005 1005
             $query .= ' '.$query_sort_by;
1006 1006
         }
@@ -1014,11 +1014,11 @@  discard block
 block discarded – undo
1014 1014
 
1015 1015
         $safe = 0;
1016 1016
         $query_where_clean = '';
1017
-        while($query_where_clean != $query_where) {
1017
+        while ($query_where_clean != $query_where) {
1018 1018
             $query_where_clean = $query_where;
1019 1019
             $query_where = preg_replace('/\b(AND|OR)\s*\(\s*\)|[^\w+\s*]\(\s*\)/i', '', $query_where_clean);
1020 1020
             $safe++;
1021
-            if($safe>100){
1021
+            if ($safe > 100) {
1022 1022
                 $GLOBALS['log']->fatal('Invalid report query conditions');
1023 1023
                 break;
1024 1024
             }
@@ -1027,10 +1027,10 @@  discard block
 block discarded – undo
1027 1027
         return $query_where;
1028 1028
     }
1029 1029
 
1030
-    function build_report_query_select($query = array(), $group_value =''){
1030
+    function build_report_query_select($query = array(), $group_value = '') {
1031 1031
         global $beanList;
1032 1032
 
1033
-        if($beanList[$this->report_module]){
1033
+        if ($beanList[$this->report_module]) {
1034 1034
             $module = new $beanList[$this->report_module]();
1035 1035
 
1036 1036
             $sql = "SELECT id FROM aor_fields WHERE aor_report_id = '".$this->id."' AND deleted = 0 ORDER BY field_order ASC";
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
                 $field = new AOR_Field();
1043 1043
                 $field->retrieve($row['id']);
1044 1044
 
1045
-                $field->label = str_replace(' ','_',$field->label).$i;
1045
+                $field->label = str_replace(' ', '_', $field->label).$i;
1046 1046
 
1047 1047
                 $path = unserialize(base64_decode($field->module_path));
1048 1048
 
1049 1049
                 $field_module = $module;
1050 1050
                 $table_alias = $field_module->table_name;
1051 1051
                 $oldAlias = $table_alias;
1052
-                if(!empty($path[0]) && $path[0] != $module->module_dir){
1053
-                    foreach($path as $rel){
1054
-                        $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$rel)];
1052
+                if (!empty($path[0]) && $path[0] != $module->module_dir) {
1053
+                    foreach ($path as $rel) {
1054
+                        $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $rel)];
1055 1055
                         $oldAlias = $table_alias;
1056 1056
                         $table_alias = $table_alias.":".$rel;
1057 1057
                         $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module);
@@ -1062,26 +1062,26 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
                 $data = $field_module->field_defs[$field->field];
1064 1064
 
1065
-                if($data['type'] == 'relate' && isset($data['id_name'])) {
1065
+                if ($data['type'] == 'relate' && isset($data['id_name'])) {
1066 1066
                     $field->field = $data['id_name'];
1067 1067
                     $data_new = $field_module->field_defs[$field->field];
1068
-                    if(isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])){
1068
+                    if (isset($data_new['source']) && $data_new['source'] == 'non-db' && $data_new['type'] != 'link' && isset($data['link'])) {
1069 1069
                         $data_new['type'] = 'link';
1070 1070
                         $data_new['relationship'] = $data['link'];
1071 1071
                     }
1072 1072
                     $data = $data_new;
1073 1073
                 }
1074 1074
 
1075
-                if($data['type'] == 'link' && $data['source'] == 'non-db') {
1076
-                    $new_field_module = new $beanList[getRelatedModule($field_module->module_dir,$data['relationship'])];
1075
+                if ($data['type'] == 'link' && $data['source'] == 'non-db') {
1076
+                    $new_field_module = new $beanList[getRelatedModule($field_module->module_dir, $data['relationship'])];
1077 1077
                     $table_alias = $data['relationship'];
1078
-                    $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module);
1078
+                    $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $field_module, 'relationship', $query, $new_field_module);
1079 1079
                     $field_module = $new_field_module;
1080 1080
                     $field->field = 'id';
1081 1081
                 }
1082 1082
 
1083
-                if($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) {
1084
-                    if((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) {
1083
+                if ($data['type'] == 'currency' && isset($field_module->field_defs['currency_id'])) {
1084
+                    if ((isset($field_module->field_defs['currency_id']['source']) && $field_module->field_defs['currency_id']['source'] == 'custom_fields')) {
1085 1085
                         $query['select'][$table_alias.'_currency_id'] = $this->db->quoteIdentifier($table_alias.'_cstm').".currency_id AS '".$table_alias."_currency_id'";
1086 1086
                         $query['second_group_by'][] = $this->db->quoteIdentifier($table_alias.'_cstm').".currency_id";
1087 1087
                     } else {
@@ -1090,30 +1090,30 @@  discard block
 block discarded – undo
1090 1090
                     }
1091 1091
                 }
1092 1092
 
1093
-                if((isset($data['source']) && $data['source'] == 'custom_fields')) {
1093
+                if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
1094 1094
                     $select_field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$field->field;
1095
-                    $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm',$table_alias, $field_module, 'custom', $query);
1095
+                    $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $table_alias, $field_module, 'custom', $query);
1096 1096
                 } else {
1097
-                    $select_field= $this->db->quoteIdentifier($table_alias).'.'.$field->field;
1097
+                    $select_field = $this->db->quoteIdentifier($table_alias).'.'.$field->field;
1098 1098
                 }
1099 1099
 
1100
-                if($field->group_by == 1){
1101
-                    $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;
1100
+                if ($field->group_by == 1) {
1101
+                    $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;
1102 1102
                 } else {
1103
-                    $query['second_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;
1103
+                    $query['second_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;
1104 1104
                 }
1105 1105
 
1106
-                if($field->field_function != null){
1106
+                if ($field->field_function != null) {
1107 1107
                     $select_field = $field->field_function.'('.$select_field.')';
1108 1108
                 }
1109 1109
 
1110
-                if($field->sort_by != ''){
1110
+                if ($field->sort_by != '') {
1111 1111
                     $query['sort_by'][] = $select_field." ".$field->sort_by;
1112 1112
                 }
1113 1113
 
1114
-                $query['select'][] = $select_field ." AS '".$field->label."'";
1114
+                $query['select'][] = $select_field." AS '".$field->label."'";
1115 1115
 
1116
-                if($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND ";
1116
+                if ($field->group_display == 1 && $group_value) $query['where'][] = $select_field." = '".$group_value."' AND ";
1117 1117
                     ++$i;
1118 1118
             }
1119 1119
         }
@@ -1121,30 +1121,30 @@  discard block
 block discarded – undo
1121 1121
     }
1122 1122
 
1123 1123
 
1124
-    function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(),SugarBean $rel_module = null ){
1124
+    function build_report_query_join($name, $alias, $parentAlias, SugarBean $module, $type, $query = array(), SugarBean $rel_module = null) {
1125 1125
 
1126
-        if(!isset($query['join'][$alias])){
1126
+        if (!isset($query['join'][$alias])) {
1127 1127
 
1128
-            switch ($type){
1128
+            switch ($type) {
1129 1129
                 case 'custom':
1130
-                    $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 ';
1130
+                    $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 ';
1131 1131
                     break;
1132 1132
 
1133 1133
                 case 'relationship':
1134
-                    if($module->load_relationship($name)){
1134
+                    if ($module->load_relationship($name)) {
1135 1135
                         $params['join_type'] = 'LEFT JOIN';
1136
-                        if($module->$name->relationship_type != 'one-to-many'){
1137
-                            if($module->$name->getSide() == REL_LHS){
1136
+                        if ($module->$name->relationship_type != 'one-to-many') {
1137
+                            if ($module->$name->getSide() == REL_LHS) {
1138 1138
                                 $params['right_join_table_alias'] = $this->db->quoteIdentifier($alias);
1139 1139
                                 $params['join_table_alias'] = $this->db->quoteIdentifier($alias);
1140 1140
                                 $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias);
1141
-                            }else{
1141
+                            } else {
1142 1142
                                 $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias);
1143 1143
                                 $params['join_table_alias'] = $this->db->quoteIdentifier($alias);
1144 1144
                                 $params['left_join_table_alias'] = $this->db->quoteIdentifier($alias);
1145 1145
                             }
1146 1146
 
1147
-                        }else{
1147
+                        } else {
1148 1148
                             $params['right_join_table_alias'] = $this->db->quoteIdentifier($parentAlias);
1149 1149
                             $params['join_table_alias'] = $this->db->quoteIdentifier($alias);
1150 1150
                             $params['left_join_table_alias'] = $this->db->quoteIdentifier($parentAlias);
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
                         $params['join_table_link_alias'] = $this->db->quoteIdentifier($linkAlias);
1154 1154
                         $join = $module->$name->getJoin($params, true);
1155 1155
                         $query['join'][$alias] = $join['join'];
1156
-                        if($rel_module != null) {
1156
+                        if ($rel_module != null) {
1157 1157
                             $query['join'][$alias] .= $this->build_report_access_query($rel_module, $name);
1158 1158
                         }
1159 1159
                     }
@@ -1167,11 +1167,11 @@  discard block
 block discarded – undo
1167 1167
         return $query;
1168 1168
     }
1169 1169
 
1170
-    function build_report_access_query(SugarBean $module, $alias){
1170
+    function build_report_access_query(SugarBean $module, $alias) {
1171 1171
 
1172 1172
         $module->table_name = $alias;
1173 1173
         $where = '';
1174
-        if($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list') )
1174
+        if ($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list'))
1175 1175
         {
1176 1176
             global $current_user;
1177 1177
             $owner_where = $module->getOwnerWhere($current_user->id);
@@ -1179,18 +1179,18 @@  discard block
 block discarded – undo
1179 1179
 
1180 1180
         }
1181 1181
 
1182
-        if(file_exists('modules/SecurityGroups/SecurityGroup.php')){
1182
+        if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
1183 1183
             /* BEGIN - SECURITY GROUPS */
1184
-            if($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list') )
1184
+            if ($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list'))
1185 1185
             {
1186 1186
                 require_once('modules/SecurityGroups/SecurityGroup.php');
1187 1187
                 global $current_user;
1188 1188
                 $owner_where = $module->getOwnerWhere($current_user->id);
1189
-                $group_where = SecurityGroup::getGroupWhere($alias,$module->module_dir,$current_user->id);
1190
-                if(!empty($owner_where)){
1191
-                    $where .= " AND (".  $owner_where." or ".$group_where.") ";
1189
+                $group_where = SecurityGroup::getGroupWhere($alias, $module->module_dir, $current_user->id);
1190
+                if (!empty($owner_where)) {
1191
+                    $where .= " AND (".$owner_where." or ".$group_where.") ";
1192 1192
                 } else {
1193
-                    $where .= ' AND '.  $group_where;
1193
+                    $where .= ' AND '.$group_where;
1194 1194
                 }
1195 1195
             }
1196 1196
             /* END - SECURITY GROUPS */
@@ -1203,16 +1203,16 @@  discard block
 block discarded – undo
1203 1203
      * @param array $query
1204 1204
      * @return array
1205 1205
      */
1206
-    function build_report_query_where($query = array()){
1206
+    function build_report_query_where($query = array()) {
1207 1207
         global $beanList, $app_list_strings, $sugar_config;
1208 1208
 
1209 1209
         $closure = false;
1210
-        if(!empty($query['where'])) {
1210
+        if (!empty($query['where'])) {
1211 1211
             $query['where'][] = '(';
1212 1212
             $closure = true;
1213 1213
         }
1214 1214
 
1215
-        if($beanList[$this->report_module]){
1215
+        if ($beanList[$this->report_module]) {
1216 1216
             $module = new $beanList[$this->report_module]();
1217 1217
 
1218 1218
             $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '".$this->id."' AND deleted = 0 ORDER BY condition_order ASC";
@@ -1229,21 +1229,21 @@  discard block
 block discarded – undo
1229 1229
                 $condition_module = $module;
1230 1230
                 $table_alias = $condition_module->table_name;
1231 1231
                 $oldAlias = $table_alias;
1232
-                if(!empty($path[0]) && $path[0] != $module->module_dir){
1233
-                    foreach($path as $rel){
1234
-                        if(empty($rel)){
1232
+                if (!empty($path[0]) && $path[0] != $module->module_dir) {
1233
+                    foreach ($path as $rel) {
1234
+                        if (empty($rel)) {
1235 1235
                             continue;
1236 1236
                         }
1237 1237
                         // Bug: Prevents relationships from loading.
1238 1238
                         //$rel = strtolower($rel);
1239
-                        $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir,$rel)];
1239
+                        $new_condition_module = new $beanList[getRelatedModule($condition_module->module_dir, $rel)];
1240 1240
                         $oldAlias = $table_alias;
1241 1241
                         $table_alias = $table_alias.":".$rel;
1242 1242
                         $query = $this->build_report_query_join($rel, $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_condition_module);
1243 1243
                         $condition_module = $new_condition_module;
1244 1244
                     }
1245 1245
                 }
1246
-                if(isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) {
1246
+                if (isset($app_list_strings['aor_sql_operator_list'][$condition->operator])) {
1247 1247
                     $where_set = false;
1248 1248
 
1249 1249
                     $data = $condition_module->field_defs[$condition->field];
@@ -1258,24 +1258,24 @@  discard block
 block discarded – undo
1258 1258
                         $data = $data_new;
1259 1259
                     }
1260 1260
 
1261
-                    if($data['type'] == 'link' && $data['source'] == 'non-db') {
1262
-                        $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir,$data['relationship'])];
1261
+                    if ($data['type'] == 'link' && $data['source'] == 'non-db') {
1262
+                        $new_field_module = new $beanList[getRelatedModule($condition_module->module_dir, $data['relationship'])];
1263 1263
                         $table_alias = $data['relationship'];
1264
-                        $query = $this->build_report_query_join($data['relationship'],$table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module);
1264
+                        $query = $this->build_report_query_join($data['relationship'], $table_alias, $oldAlias, $condition_module, 'relationship', $query, $new_field_module);
1265 1265
                         $condition_module = $new_field_module;
1266 1266
 
1267 1267
                         // Debugging: security groups conditions - It's a hack to just get the query working
1268
-                        if($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) {
1268
+                        if ($condition_module->module_dir = 'SecurityGroups' && count($path) > 1) {
1269 1269
 //                            $table_alias = 'opportunities:assigned_user_link:SecurityGroups' ;
1270
-                            $table_alias = $oldAlias. ':' .$rel;
1270
+                            $table_alias = $oldAlias.':'.$rel;
1271 1271
                         }
1272 1272
                         $condition->field = 'id';
1273 1273
                     }
1274 1274
                     if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
1275
-                        $field = $this->db->quoteIdentifier($table_alias . '_cstm') . '.' . $condition->field;
1276
-                        $query = $this->build_report_query_join($table_alias . '_cstm', $table_alias . '_cstm', $oldAlias, $condition_module, 'custom', $query);
1275
+                        $field = $this->db->quoteIdentifier($table_alias.'_cstm').'.'.$condition->field;
1276
+                        $query = $this->build_report_query_join($table_alias.'_cstm', $table_alias.'_cstm', $oldAlias, $condition_module, 'custom', $query);
1277 1277
                     } else {
1278
-                        $field = $this->db->quoteIdentifier($table_alias) . '.' . $condition->field;
1278
+                        $field = $this->db->quoteIdentifier($table_alias).'.'.$condition->field;
1279 1279
                     }
1280 1280
 
1281 1281
                     if (!empty($this->user_parameters[$condition->id]) && $condition->parameter) {
@@ -1307,10 +1307,10 @@  discard block
 block discarded – undo
1307 1307
                                 $condition->field = 'id';
1308 1308
                             }
1309 1309
                             if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
1310
-                                $value = $condition_module->table_name . '_cstm.' . $condition->value;
1311
-                                $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query);
1310
+                                $value = $condition_module->table_name.'_cstm.'.$condition->value;
1311
+                                $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query);
1312 1312
                             } else {
1313
-                                $value = ($table_alias ? "`$table_alias`" : $condition_module->table_name) . '.' . $condition->value;
1313
+                                $value = ($table_alias ? "`$table_alias`" : $condition_module->table_name).'.'.$condition->value;
1314 1314
                             }
1315 1315
                             break;
1316 1316
 
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
                             $params = unserialize(base64_decode($condition->value));
1319 1319
 
1320 1320
                             // Fix for issue #1272 - AOR_Report module cannot update Date type parameter.
1321
-                            if($params == false) {
1321
+                            if ($params == false) {
1322 1322
                                 $params = $condition->value;
1323 1323
                             }
1324 1324
 
@@ -1328,10 +1328,10 @@  discard block
 block discarded – undo
1328 1328
                                 } else {
1329 1329
                                     $value = 'NOW()';
1330 1330
                                 }
1331
-                            } else if($params[0] == 'today'){
1332
-                                if($sugar_config['dbconfig']['db_type'] == 'mssql'){
1331
+                            } else if ($params[0] == 'today') {
1332
+                                if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
1333 1333
                                     //$field =
1334
-                                    $value  = 'CAST(GETDATE() AS DATE)';
1334
+                                    $value = 'CAST(GETDATE() AS DATE)';
1335 1335
                                 } else {
1336 1336
                                     $field = 'DATE('.$field.')';
1337 1337
                                     $value = 'Curdate()';
@@ -1339,10 +1339,10 @@  discard block
 block discarded – undo
1339 1339
                             } else {
1340 1340
                                 $data = $condition_module->field_defs[$params[0]];
1341 1341
                                 if ((isset($data['source']) && $data['source'] == 'custom_fields')) {
1342
-                                    $value = $condition_module->table_name . '_cstm.' . $params[0];
1343
-                                    $query = $this->build_report_query_join($condition_module->table_name . '_cstm', $table_alias . '_cstm', $table_alias, $condition_module, 'custom', $query);
1342
+                                    $value = $condition_module->table_name.'_cstm.'.$params[0];
1343
+                                    $query = $this->build_report_query_join($condition_module->table_name.'_cstm', $table_alias.'_cstm', $table_alias, $condition_module, 'custom', $query);
1344 1344
                                 } else {
1345
-                                    $value = $condition_module->table_name . '.' . $params[0];
1345
+                                    $value = $condition_module->table_name.'.'.$params[0];
1346 1346
                                 }
1347 1347
                             }
1348 1348
 
@@ -1353,9 +1353,9 @@  discard block
 block discarded – undo
1353 1353
                                         $params[3] = 'hours';
1354 1354
                                     default:
1355 1355
                                         if ($sugar_config['dbconfig']['db_type'] == 'mssql') {
1356
-                                            $value = "DATEADD(" . $params[3] . ",  " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2], $value)";
1356
+                                            $value = "DATEADD(".$params[3].",  ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2], $value)";
1357 1357
                                         } else {
1358
-                                            $value = "DATE_ADD($value, INTERVAL " . $app_list_strings['aor_date_operator'][$params[1]] . " $params[2] " . $params[3] . ")";
1358
+                                            $value = "DATE_ADD($value, INTERVAL ".$app_list_strings['aor_date_operator'][$params[1]]." $params[2] ".$params[3].")";
1359 1359
                                         }
1360 1360
                                         break;
1361 1361
                                 }
@@ -1370,11 +1370,11 @@  discard block
 block discarded – undo
1370 1370
                                 $value = '(';
1371 1371
                                 foreach ($multi_values as $multi_value) {
1372 1372
                                     if ($value != '(') $value .= $sep;
1373
-                                    $value .= $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . " '" . $multi_value . "'";
1373
+                                    $value .= $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator]." '".$multi_value."'";
1374 1374
                                 }
1375 1375
                                 $value .= ')';
1376 1376
                             }
1377
-                            $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $value;
1377
+                            $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$value;
1378 1378
                             $where_set = true;
1379 1379
                             break;
1380 1380
                         case "Period":
@@ -1383,20 +1383,20 @@  discard block
 block discarded – undo
1383 1383
                             } else {
1384 1384
                                 $params = base64_decode($condition->value);
1385 1385
                             }
1386
-                            $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"';
1386
+                            $value = '"'.getPeriodDate($params)->format('Y-m-d H:i:s').'"';
1387 1387
                             break;
1388 1388
                         case "CurrentUserID":
1389 1389
                             global $current_user;
1390
-                            $value = '"' . $current_user->id . '"';
1390
+                            $value = '"'.$current_user->id.'"';
1391 1391
                             break;
1392 1392
                         case 'Value':
1393 1393
                         default:
1394
-                            $value = "'" . $this->db->quote($condition->value) . "'";
1394
+                            $value = "'".$this->db->quote($condition->value)."'";
1395 1395
                             break;
1396 1396
                     }
1397 1397
 
1398 1398
                     //handle like conditions
1399
-                    Switch($condition->operator) {
1399
+                    Switch ($condition->operator) {
1400 1400
                         case 'Contains':
1401 1401
                             $value = "CONCAT('%', ".$value." ,'%')";
1402 1402
                             break;
@@ -1408,11 +1408,11 @@  discard block
 block discarded – undo
1408 1408
                             break;
1409 1409
                     }
1410 1410
 
1411
-                    if($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') {
1411
+                    if ($condition->value_type == 'Value' && !$condition->value && $condition->operator == 'Equal_To') {
1412 1412
                         $value = "{$value} OR {$field} IS NULL";
1413 1413
                     }
1414 1414
 
1415
-                    if(!$where_set) {
1415
+                    if (!$where_set) {
1416 1416
                         if ($condition->value_type == "Period") {
1417 1417
                             if (array_key_exists($condition->value, $app_list_strings['date_time_period_list'])) {
1418 1418
                                 $params = $condition->value;
@@ -1420,34 +1420,34 @@  discard block
 block discarded – undo
1420 1420
                                 $params = base64_decode($condition->value);
1421 1421
                             }
1422 1422
                             $date = getPeriodEndDate($params)->format('Y-m-d H:i:s');
1423
-                            $value = '"' . getPeriodDate($params)->format('Y-m-d H:i:s') . '"';
1423
+                            $value = '"'.getPeriodDate($params)->format('Y-m-d H:i:s').'"';
1424 1424
 
1425
-                            $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND '));
1425
+                            $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND '));
1426 1426
                             $tiltLogicOp = false;
1427 1427
 
1428 1428
                             switch ($app_list_strings['aor_sql_operator_list'][$condition->operator]) {
1429 1429
                                 case "=":
1430
-                                    $query['where'][] = $field . ' BETWEEN ' . $value .  ' AND ' . '"' . $date . '"';
1430
+                                    $query['where'][] = $field.' BETWEEN '.$value.' AND '.'"'.$date.'"';
1431 1431
                                     break;
1432 1432
                                 case "!=":
1433
-                                    $query['where'][] = $field . ' NOT BETWEEN ' . $value .  ' AND ' . '"' . $date . '"';
1433
+                                    $query['where'][] = $field.' NOT BETWEEN '.$value.' AND '.'"'.$date.'"';
1434 1434
                                     break;
1435 1435
                                 case ">":
1436 1436
                                 case "<":
1437 1437
                                 case ">=":
1438 1438
                                 case "<=":
1439
-                                    $query['where'][] = $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value;
1439
+                                    $query['where'][] = $field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator].' '.$value;
1440 1440
                                     break;
1441 1441
                             }
1442 1442
                         } else {
1443
-                            if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ': 'AND ')) . $field . ' ' . $app_list_strings['aor_sql_operator_list'][$condition->operator] . ' ' . $value;
1443
+                            if (!$where_set) $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).$field.' '.$app_list_strings['aor_sql_operator_list'][$condition->operator].' '.$value;
1444 1444
                         }
1445 1445
                     }
1446 1446
                     $tiltLogicOp = false;
1447 1447
                 }
1448
-                else if($condition->parenthesis) {
1449
-                    if($condition->parenthesis == 'START') {
1450
-                        $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op . ' ' : 'AND ')) .  '(';
1448
+                else if ($condition->parenthesis) {
1449
+                    if ($condition->parenthesis == 'START') {
1450
+                        $query['where'][] = ($tiltLogicOp ? '' : ($condition->logic_op ? $condition->logic_op.' ' : 'AND ')).'(';
1451 1451
                         $tiltLogicOp = true;
1452 1452
                     }
1453 1453
                     else {
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 
1462 1462
             }
1463 1463
 
1464
-            if(isset($query['where']) && $query['where']) {
1464
+            if (isset($query['where']) && $query['where']) {
1465 1465
                 array_unshift($query['where'], '(');
1466 1466
                 $query['where'][] = ') AND ';
1467 1467
             }
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 
1470 1470
         }
1471 1471
 
1472
-        if($closure) {
1472
+        if ($closure) {
1473 1473
             $query['where'][] = ')';
1474 1474
         }
1475 1475
 
Please login to merge, or discard this patch.
modules/AOR_Conditions/AOR_Condition.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
     /**
78 78
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
79 79
      */
80
-    function AOR_Condition(){
80
+    function AOR_Condition() {
81 81
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
82
-        if(isset($GLOBALS['log'])) {
82
+        if (isset($GLOBALS['log'])) {
83 83
             $GLOBALS['log']->deprecated($deprecatedMessage);
84 84
         }
85 85
         else {
@@ -95,38 +95,38 @@  discard block
 block discarded – undo
95 95
         require_once('modules/AOW_WorkFlow/aow_utils.php');
96 96
 
97 97
         $j = 0;
98
-        foreach ($post_data[$key . 'field'] as $i => $field) {
98
+        foreach ($post_data[$key.'field'] as $i => $field) {
99 99
 
100
-            if ($post_data[$key . 'deleted'][$i] == 1) {
101
-                $this->mark_deleted($post_data[$key . 'id'][$i]);
100
+            if ($post_data[$key.'deleted'][$i] == 1) {
101
+                $this->mark_deleted($post_data[$key.'id'][$i]);
102 102
             } else {
103 103
                 $condition = new AOR_Condition();
104 104
                 foreach ($this->field_defs as $field_def) {
105 105
                     $field_name = $field_def['name'];
106
-                    if (isset($post_data[$key . $field_name][$i])) {
107
-                        if (is_array($post_data[$key . $field_name][$i])) {
106
+                    if (isset($post_data[$key.$field_name][$i])) {
107
+                        if (is_array($post_data[$key.$field_name][$i])) {
108 108
 
109 109
                             switch ($condition->value_type) {
110 110
                                 case 'Date':
111
-                                    $post_data[$key . $field_name][$i] = base64_encode(serialize($post_data[$key . $field_name][$i]));
111
+                                    $post_data[$key.$field_name][$i] = base64_encode(serialize($post_data[$key.$field_name][$i]));
112 112
                                     break;
113 113
                                 default:
114
-                                    $post_data[$key . $field_name][$i] = encodeMultienumValue($post_data[$key . $field_name][$i]);
114
+                                    $post_data[$key.$field_name][$i] = encodeMultienumValue($post_data[$key.$field_name][$i]);
115 115
                             }
116
-                        } else if ($field_name == 'value' && $post_data[$key . 'value_type'][$i] === 'Value') {
117
-                            $post_data[$key . $field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $condition->field, $post_data[$key . $field_name][$i]);
116
+                        } else if ($field_name == 'value' && $post_data[$key.'value_type'][$i] === 'Value') {
117
+                            $post_data[$key.$field_name][$i] = fixUpFormatting($_REQUEST['report_module'], $condition->field, $post_data[$key.$field_name][$i]);
118 118
                         } else if ($field_name == 'parameter') {
119
-                            $post_data[$key . $field_name][$i] = isset($post_data[$key . $field_name][$i]);
119
+                            $post_data[$key.$field_name][$i] = isset($post_data[$key.$field_name][$i]);
120 120
                         } else if ($field_name == 'module_path') {
121
-                            $post_data[$key . $field_name][$i] = base64_encode(serialize(explode(":", $post_data[$key . $field_name][$i])));
121
+                            $post_data[$key.$field_name][$i] = base64_encode(serialize(explode(":", $post_data[$key.$field_name][$i])));
122 122
                         }
123
-                        if ($field_name == 'parenthesis' && $post_data[$key . $field_name][$i] == 'END') {
123
+                        if ($field_name == 'parenthesis' && $post_data[$key.$field_name][$i] == 'END') {
124 124
                             if (!isset($lastParenthesisStartConditionId)) {
125 125
                                 throw new Exception('a closure parenthesis has no starter pair');
126 126
                             }
127 127
                             $condition->parenthesis = $lastParenthesisStartConditionId;
128 128
                         } else {
129
-                            $condition->$field_name = $post_data[$key . $field_name][$i];
129
+                            $condition->$field_name = $post_data[$key.$field_name][$i];
130 130
                         }
131 131
                     } else if ($field_name == 'parameter') {
132 132
                         $condition->$field_name = 0;
Please login to merge, or discard this patch.
modules/AOS_Products/metadata/SearchFields.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // created: 2013-05-07 12:48:58
3 3
 global $current_user;
4
-$searchFields['AOS_Products'] = array (
4
+$searchFields['AOS_Products'] = array(
5 5
   'name' => 
6
-  array (
6
+  array(
7 7
     'query_type' => 'default',
8 8
   ),
9 9
   'current_user_only' => 
10
-  array (
10
+  array(
11 11
     'query_type' => 'default',
12 12
     'db_field' => 
13
-    array (
13
+    array(
14 14
       0 => 'created_by',
15 15
     ),
16 16
     'my_items' => true,
@@ -18,67 +18,67 @@  discard block
 block discarded – undo
18 18
     'type' => 'bool',
19 19
   ),
20 20
   'range_price' => 
21
-  array (
21
+  array(
22 22
     'query_type' => 'default',
23 23
     'enable_range_search' => true,
24 24
   ),
25 25
   'start_range_price' => 
26
-  array (
26
+  array(
27 27
     'query_type' => 'default',
28 28
     'enable_range_search' => true,
29 29
   ),
30 30
   'end_range_price' => 
31
-  array (
31
+  array(
32 32
     'query_type' => 'default',
33 33
     'enable_range_search' => true,
34 34
   ),
35 35
   'range_cost' => 
36
-  array (
36
+  array(
37 37
     'query_type' => 'default',
38 38
     'enable_range_search' => true,
39 39
   ),
40 40
   'start_range_cost' => 
41
-  array (
41
+  array(
42 42
     'query_type' => 'default',
43 43
     'enable_range_search' => true,
44 44
   ),
45 45
   'end_range_cost' => 
46
-  array (
46
+  array(
47 47
     'query_type' => 'default',
48 48
     'enable_range_search' => true,
49 49
   ),
50 50
   'range_date_entered' => 
51
-  array (
51
+  array(
52 52
     'query_type' => 'default',
53 53
     'enable_range_search' => true,
54 54
     'is_date_field' => true,
55 55
   ),
56 56
   'start_range_date_entered' => 
57
-  array (
57
+  array(
58 58
     'query_type' => 'default',
59 59
     'enable_range_search' => true,
60 60
     'is_date_field' => true,
61 61
   ),
62 62
   'end_range_date_entered' => 
63
-  array (
63
+  array(
64 64
     'query_type' => 'default',
65 65
     'enable_range_search' => true,
66 66
     'is_date_field' => true,
67 67
   ),
68 68
   'range_date_modified' => 
69
-  array (
69
+  array(
70 70
     'query_type' => 'default',
71 71
     'enable_range_search' => true,
72 72
     'is_date_field' => true,
73 73
   ),
74 74
   'start_range_date_modified' => 
75
-  array (
75
+  array(
76 76
     'query_type' => 'default',
77 77
     'enable_range_search' => true,
78 78
     'is_date_field' => true,
79 79
   ),
80 80
   'end_range_date_modified' => 
81
-  array (
81
+  array(
82 82
     'query_type' => 'default',
83 83
     'enable_range_search' => true,
84 84
     'is_date_field' => true,
@@ -89,6 +89,6 @@  discard block
 block discarded – undo
89 89
         'subquery' => "SELECT favorites.parent_id FROM favorites
90 90
 			                    WHERE favorites.deleted = 0
91 91
 			                        and favorites.parent_type = '".$module_name."'
92
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
92
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
93 93
         'db_field'=>array('id')),
94 94
 );
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Documents/metadata/SearchFields.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,79 +2,79 @@  discard block
 block discarded – undo
2 2
 // created: 2015-02-17 15:14:28
3 3
 global $current_user;
4 4
 $module_name = "Documents";
5
-$searchFields['Documents'] = array (
5
+$searchFields['Documents'] = array(
6 6
   'document_name' => 
7
-  array (
7
+  array(
8 8
     'query_type' => 'default',
9 9
   ),
10 10
   'category_id' => 
11
-  array (
11
+  array(
12 12
     'query_type' => 'default',
13 13
     'options' => 'document_category_dom',
14 14
     'template_var' => 'CATEGORY_OPTIONS',
15 15
   ),
16 16
   'subcategory_id' => 
17
-  array (
17
+  array(
18 18
     'query_type' => 'default',
19 19
     'options' => 'document_subcategory_dom',
20 20
     'template_var' => 'SUBCATEGORY_OPTIONS',
21 21
   ),
22 22
   'active_date' => 
23
-  array (
23
+  array(
24 24
     'query_type' => 'default',
25 25
   ),
26 26
   'exp_date' => 
27
-  array (
27
+  array(
28 28
     'query_type' => 'default',
29 29
   ),
30 30
   'assigned_user_id' => 
31
-  array (
31
+  array(
32 32
     'query_type' => 'default',
33 33
   ),
34 34
   'filename' => 
35
-  array (
35
+  array(
36 36
     'query_type' => 'format',
37 37
     'operator' => 'subquery',
38 38
     'subquery' => 'SELECT document_revisions.id FROM document_revisions
39 39
 			           WHERE document_revisions.deleted=0
40 40
 				   AND document_revisions.filename LIKE \'{0}\'',
41 41
     'db_field' => 
42
-    array (
42
+    array(
43 43
       0 => 'document_revision_id',
44 44
     ),
45 45
   ),
46 46
   'range_date_entered' => 
47
-  array (
47
+  array(
48 48
     'query_type' => 'default',
49 49
     'enable_range_search' => true,
50 50
     'is_date_field' => true,
51 51
   ),
52 52
   'start_range_date_entered' => 
53
-  array (
53
+  array(
54 54
     'query_type' => 'default',
55 55
     'enable_range_search' => true,
56 56
     'is_date_field' => true,
57 57
   ),
58 58
   'end_range_date_entered' => 
59
-  array (
59
+  array(
60 60
     'query_type' => 'default',
61 61
     'enable_range_search' => true,
62 62
     'is_date_field' => true,
63 63
   ),
64 64
   'range_date_modified' => 
65
-  array (
65
+  array(
66 66
     'query_type' => 'default',
67 67
     'enable_range_search' => true,
68 68
     'is_date_field' => true,
69 69
   ),
70 70
   'start_range_date_modified' => 
71
-  array (
71
+  array(
72 72
     'query_type' => 'default',
73 73
     'enable_range_search' => true,
74 74
     'is_date_field' => true,
75 75
   ),
76 76
   'end_range_date_modified' => 
77
-  array (
77
+  array(
78 78
     'query_type' => 'default',
79 79
     'enable_range_search' => true,
80 80
     'is_date_field' => true,
@@ -85,6 +85,6 @@  discard block
 block discarded – undo
85 85
         'subquery' => "SELECT favorites.parent_id FROM favorites
86 86
 			                    WHERE favorites.deleted = 0
87 87
 			                        and favorites.parent_type = '".$module_name."'
88
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
88
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
89 89
         'db_field'=>array('id')),
90 90
 );
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Meetings/metadata/SearchFields.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Meetings";
42 42
 $searchFields['Meetings'] = 
43
-	array (
44
-		'name' => array( 'query_type'=>'default'),
45
-        'contact_name' => array( 'query_type'=>'default','db_field'=>array('contacts.first_name','contacts.last_name')),        
46
-        'date_start' => array( 'query_type'=>'default'),
47
-        'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
43
+	array(
44
+		'name' => array('query_type'=>'default'),
45
+        'contact_name' => array('query_type'=>'default', 'db_field'=>array('contacts.first_name', 'contacts.last_name')),        
46
+        'date_start' => array('query_type'=>'default'),
47
+        'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
48 48
         'assigned_user_id'=> array('query_type'=>'default'),
49 49
         'status'=> array('query_type'=>'default', 'options' => 'meeting_status_dom', 'template_var' => 'STATUS_FILTER'),
50 50
         
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 			'subquery' => "SELECT favorites.parent_id FROM favorites
62 62
 			                    WHERE favorites.deleted = 0
63 63
 			                        and favorites.parent_type = '".$module_name."'
64
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
64
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
65 65
             'db_field'=>array('id')),
66 66
 		//Range Search Support
67
-	   'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
68
-	   'start_range_date_entered' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
69
-	   'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
70
-	   'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
71
-	   'start_range_date_modified' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
72
-       'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
73
-	   'range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
74
-	   'start_range_date_start' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
75
-	   'end_range_date_start' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
76
-	   'range_date_end' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
77
-	   'start_range_date_end' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
78
-       'end_range_date_end' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
67
+	   'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
68
+	   'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
69
+	   'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
70
+	   'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
71
+	   'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
72
+       'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
73
+	   'range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
74
+	   'start_range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
75
+	   'end_range_date_start' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
76
+	   'range_date_end' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
77
+	   'start_range_date_end' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
78
+       'end_range_date_end' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
79 79
 	    //Range Search Support 				
80 80
 	);
81 81
 ?>
Please login to merge, or discard this patch.
modules/Leads/metadata/SearchFields.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Leads";
42 42
 $searchFields['Leads'] = 
43
-    array (
44
-        'first_name' => array( 'query_type'=>'default'),
43
+    array(
44
+        'first_name' => array('query_type'=>'default'),
45 45
         'last_name'=> array('query_type'=>'default'),
46
-        'search_name'=> array('query_type'=>'default','db_field'=>array('first_name','last_name'),'force_unifiedsearch'=>true),
47
-        'account_name'=> array('query_type'=>'default','db_field'=>array('leads.account_name')),
46
+        'search_name'=> array('query_type'=>'default', 'db_field'=>array('first_name', 'last_name'), 'force_unifiedsearch'=>true),
47
+        'account_name'=> array('query_type'=>'default', 'db_field'=>array('leads.account_name')),
48 48
 		/*'acc_name_from_accounts' => array('query_type'=>'default','related_field'=>'account_name'),*/
49
-        'lead_source'=> array('query_type'=>'default','operator'=>'=', 'options'=>'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
49
+        'lead_source'=> array('query_type'=>'default', 'operator'=>'=', 'options'=>'lead_source_dom', 'template_var' => 'LEAD_SOURCE_OPTIONS'),
50 50
         'do_not_call'=> array('query_type'=>'default', 'operator'=>'=', 'input_type' => 'checkbox'),
51
-        'phone'=> array('query_type'=>'default','db_field'=>array('phone_mobile','phone_work','phone_other','phone_fax','phone_home')),
51
+        'phone'=> array('query_type'=>'default', 'db_field'=>array('phone_mobile', 'phone_work', 'phone_other', 'phone_fax', 'phone_home')),
52 52
 		'email'=> array(
53 53
 			'query_type' => 'default',
54 54
 			'operator' => 'subquery',
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 			'subquery' => "SELECT favorites.parent_id FROM favorites
64 64
 			                    WHERE favorites.deleted = 0
65 65
 			                        and favorites.parent_type = '".$module_name."'
66
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
66
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
67 67
             'db_field'=>array('id')),
68 68
         'assistant'=> array('query_type'=>'default'),
69 69
         'website'=> array('query_type'=>'default'),
70
-        'address_street'=> array('query_type'=>'default','db_field'=>array('primary_address_street','alt_address_street')),
71
-        'address_city'=> array('query_type'=>'default','db_field'=>array('primary_address_city','alt_address_city')),
72
-        'address_state'=> array('query_type'=>'default','db_field'=>array('primary_address_state','alt_address_state')),
73
-        'address_postalcode'=> array('query_type'=>'default','db_field'=>array('primary_address_postalcode','alt_address_postalcode')),
74
-        'address_country'=> array('query_type'=>'default','db_field'=>array('primary_address_country','alt_address_country')),
75
-        'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
70
+        'address_street'=> array('query_type'=>'default', 'db_field'=>array('primary_address_street', 'alt_address_street')),
71
+        'address_city'=> array('query_type'=>'default', 'db_field'=>array('primary_address_city', 'alt_address_city')),
72
+        'address_state'=> array('query_type'=>'default', 'db_field'=>array('primary_address_state', 'alt_address_state')),
73
+        'address_postalcode'=> array('query_type'=>'default', 'db_field'=>array('primary_address_postalcode', 'alt_address_postalcode')),
74
+        'address_country'=> array('query_type'=>'default', 'db_field'=>array('primary_address_country', 'alt_address_country')),
75
+        'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
76 76
         'assigned_user_id'=> array('query_type'=>'default'),
77 77
         'status'=> array('query_type'=>'default', 'options'=>'lead_status_dom', 'template_var' => 'STATUS_OPTIONS'),
78 78
 		'open_only' => array(
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 			'type'=>'bool',
84 84
 		),
85 85
 		//Range Search Support 
86
-	    'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
87
-	    'start_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
88
-	    'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
89
-	    'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
90
-	    'start_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
91
-        'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
86
+	    'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
87
+	    'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
88
+	    'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
89
+	    'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
90
+	    'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
91
+        'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
92 92
 	    //Range Search Support 				
93 93
     );
94 94
 ?>
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Project/metadata/SearchFields.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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.
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
 global $current_user;
41 41
 $module_name = "Project";
42 42
 $searchFields['Project'] = 
43
-    array (
44
-        'name' => array( 'query_type'=>'default'),
45
-        'current_user_only'=> array('query_type'=>'default','db_field'=>array('assigned_user_id'),'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
43
+    array(
44
+        'name' => array('query_type'=>'default'),
45
+        'current_user_only'=> array('query_type'=>'default', 'db_field'=>array('assigned_user_id'), 'my_items'=>true, 'vname' => 'LBL_CURRENT_USER_FILTER', 'type' => 'bool'),
46 46
         'favorites_only' => array(
47 47
             'query_type'=>'format',
48 48
             'operator' => 'subquery',
49 49
 			'subquery' => "SELECT favorites.parent_id FROM favorites
50 50
 			                    WHERE favorites.deleted = 0
51 51
 			                        and favorites.parent_type = '".$module_name."'
52
-			                        and favorites.assigned_user_id = '" .$current_user->id . "') OR NOT ({0}",
52
+			                        and favorites.assigned_user_id = '" .$current_user->id."') OR NOT ({0}",
53 53
             'db_field'=>array('id')),
54 54
 		//Range Search Support 
55
-	   'range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
56
-	   'start_range_date_entered' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
57
-	   'end_range_date_entered' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
58
-	   'range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
59
-	   'start_range_date_modified' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
60
-       'end_range_date_modified' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
55
+	   'range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
56
+	   'start_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
57
+	   'end_range_date_entered' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
58
+	   'range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
59
+	   'start_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
60
+       'end_range_date_modified' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
61 61
 	    
62
-	   'range_estimated_start_date' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
63
-	   'start_range_estimated_start_date' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
64
-	   'end_range_estimated_start_date' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
65
-	   'range_estimated_end_date' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
66
-	   'start_range_estimated_end_date' => array ('query_type' => 'default',  'enable_range_search' => true, 'is_date_field' => true),
67
-       'end_range_estimated_end_date' => array ('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
62
+	   'range_estimated_start_date' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
63
+	   'start_range_estimated_start_date' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
64
+	   'end_range_estimated_start_date' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
65
+	   'range_estimated_end_date' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
66
+	   'start_range_estimated_end_date' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),
67
+       'end_range_estimated_end_date' => array('query_type' => 'default', 'enable_range_search' => true, 'is_date_field' => true),	
68 68
 		//Range Search Support 				
69 69
     );
70 70
 ?>
Please login to merge, or discard this patch.