sugarcrm 6.5 set number columns to 3 in one tab/panel, 2 in other tabs - sugarcrm

I know how to set the columns in a detailview to 3 columns instead of the default 2 by putting into detailviewdefs.php
(in modules/EvMgr_Pgm/metadata if creating a custom module
or in custom/modules/EvMgr_Pgm/metadata if editing an existing module)
'maxColumns' => '3',
'widths' =>
array (
0 =>
array (
'label' => '8',
'field' => '19',
),
1 =>
array (
'label' => '8',
'field' => '19',
),
2 =>
array (
'label' => '8',
'field' => '19',
),
),
However, that sets the columns for ALL the tabs/panels in a detailview
Is there a way I can have there be 3 columns in one tab/panel and 2 columns (default) in the other tabs/panels?

If you change the widths to exceed 100 it'll recalculate the widths for a panel/table that has 3 or more columns. Try this:
'maxColumns' => '3',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
2 =>
array (
'label' => '10',
'field' => '30',
),
),
This uses the standard 2 column 10/30 width. When a panel is created with 3 columns it'll recalculate the widths since it is greater than 100. At least as of 6.5.18 it does. Most likely it does for previous versions as well.

Related

How to update the table using array of values in Laravel 8

I do have a two array's, I would like to update the Db based on that.
Array ( [0] => Array ( [name] => 1 ) [1] => Array ( [name] => 1 ) )//Id array
Array ( [0] => Array ( [quantity] => 740 ) [1] => Array ( [quantity] => 705 ) ) //The values that I need to update based on the previous array.
Some thing like this,
DB::table('stock')->where('id' , $id_array)->update($value_array);
How Can I achieve that?
$id_array = array(
['name' => 1],
['name' => 2]
);
$value_array = array(
['quantity' => 740],
['quantity' => 705]
);
foreach($id_array as $key => $value) {
DB::table('stock')->where('id' , $id_array[$key]['name'])->update( $value_array[$key]['quantity']);
}
Assuming both arrays are equal size, we can loop through the $id_array and use the key index value for the $value_array.

Why matlab skips 2nd half of labels?

Here is a pretty streightforward code for displaying matrix in scaled color using imagesc command. The problem is that final figure has wrong labeling and doesnt show 2nd half of labels(it should be from 1 to 21, but it is from 1 to 10)
figure;
imagesc(magic(21));
set(gca,'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
set(gca,'YTickLabel',{'1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21'})
I am using Ubuntu 16.04 and Matlab 2016b.
You set up the label text, but not the location, thus it will automatically put label locations and then substitute their text.
To set up the locations of the labels, first do:
set(gca,'XTick',...)
Then you can write in those labels whatever you preffer:
set(gca,'XTickLabel',{'banana', 'platano', 'potato',... })
You have to assign locations for those ticks, not just add labels.
figure;
imagesc(magic(21));
ax1 = gca;
ax1.YTick = 1:21;
ax1.XTick = 1:21;
ax1.XTickLabels = {'One','Two','Three',...
ax1.YTickLabels = {'Red','Brown','Green',...
Also since Matlab 2014b Mathworks created a new graphics system. You can access your graphics as objects directly instead of using set and get everywhere.
You can test this:
imagesc(magic(21));
set(gca,'XLim',[1 21])
set(gca,'XTick',[1:1:21])
set(gca,'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
set(gca,'YLim',[1 21])
set(gca,'YTick',[1:1:21])
set(gca,'YTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})

Creating an index on a nested field

I have a MongoDB document that is structured similar to the structure below follows. There are is a large number of these documents with thousands of people in them, so I want to speed things up by putting indexes on the people.#.search_columns.surname and people.#.search_columns.givenname. Howe can I do this in MongoDB? Thanks for your help.
[_id] => MongoId Object (
[$id] => 53b1b1ab72f4f852140dbdc9
)
[name] => People From 1921
[people] => Array (
[0] => Array (
[name] => Barada, Valentine
[search_columns] => Array (
[surname] => Array (
[0] => Mardan,
[1] => Barada
)
[givenname] => Array (
[0] => Valentine
)
)
)
[1] => Array (
[name] => Barsaloux, Nicholas
[search_columns] => Array (
[surname] => Array (
[1] => Barsaloux
)
[givenname] => Array (
[0] => Nicholas
)
[place] => Array (
)
)
)
)
You can create indexes for nested fields using the dot notation:
db.collection.ensureIndex({'people.search_columns.surname': 1});
db.collection.ensureIndex({'people.search_columns.givenname': 1});

Searching Record in mongodb using php

I am getting the records from collections in following format using find() function of mongodb
Array
(
[_id] => MongoId Object
(
[$id] => 52a9b86578e9288a378b4567
)
[0] => Array
(
[senderID] => 1
[followingID] => 15
[type] => TW
)
[1] => Array
(
[senderID] => 1
[followingID] => 16
[type] => TW
)
[2] => Array
(
[senderID] => 1
[followingID] => 17
[type] => TW
)
[3] => Array
(
[senderID] => 2
[followingID] => 17
[type] => TW
)
)
Now I want all the records whose senderID is 2. I have tried by passing array in find function
$myarray("senderID"=> 1)
$collection->find($myarray)
but it will not get the correct record.

Perl DBI Oracle not preserving column order after SELECT

I'm using Perl v5.12.3 built by ActiveState on Windows. DBD::Oracle version 1.27. DBI version 1.616. I'm selecting the data below in this particular order and wanting the resulting data to be retrieved in that same order. Below are the code samples and some examples.
SQL Snippet (contents of $report_sql below)
select student_number, lastfirst, counselor,
a.dateenrolled as "Date Enrolled 1", a.dateleft as "Date Left 1", a.termid as "Term ID 1", a.course_number as "Course Number 1",
a.expression as "Expression 1", b.dateenrolled as "Date Enrolled 2", b.dateleft as "Date Left 2",
b.termid as "Term ID 2", b.course_number as "Course Number 2", b.expression as "Expression 2"
Perl code snippet
## run the resulting query
my $report_result = $dbh->prepare( $report_sql );
$report_result->execute();
while( my $report_row = $report_result->fetchrow_hashref())
{
print Dumper(\$report_row); ## contents of this posted below
Contents of print Dumper for $report_row
$VAR1 = \{
'Expression 2' => 'x',
'LASTFIRST' => 'xx',
'Term ID 1' => 'xx',
'Date Enrolled 2' => 'xx',
'Course Number 1' => 'xx',
'Term ID 2' => 'xx',
'STUDENT_NUMBER' => 'xx',
'Date Left 2' => 'xx',
'Expression 1' => 'xx',
'COUNSELOR' => 'xx',
'Date Left 1' => 'xx',
'Course Number 2' => 'xx',
'Date Enrolled 1' => 'xx'
};
Order I EXPECTED it to be printed
$VAR1 = \{
'STUDENT_NUMBER' => 'xx',
'LASTFIRST' => 'xx',
'COUNSELOR' => 'xx',
'Date Enrolled 1' => 'xx',
'Date Left 1' => 'xx',
'Term ID 1' => 'xx',
'Course Number 1' => 'xx',
'Expression 1' => 'xx',
'Date Enrolled 2' => 'xx',
'Date Left 2' => 'xx',
'Term ID 2' => 'xx',
'Course Number 2' => 'xx',
'Expression 2' => 'x'
};
One thing to note is that this query being ran is one of many that are being ran. This particular script runs through a series of queries and generates reports based on the returned results. The queries are stored in files on the hd alongside the perl script. The queries are read in and then ran. It's not always the same columns being selected.
You used a hash. Hash elements have no controllable order*. The order of elememts in an arrays can be controlled. If you want to present the order in which the fields were received, use an array instead of hash.
If you actually need the names, you can get the ordered names of the fields using #{ $sth->{NAME} }. You should still use an array for efficiency reasons, but you could use a hash if you wanted to.
* — Just like array elements are returned in the order they are "physically" organised in the array, hash elements are returned in the order they are physically organised in the hash. You cannot control where an element is physically placed in a hash, and the position changes as the hash is changed. With an array, you decide the physical position of an element, and it will remain in that position.
When the order of columns in a DBI result matters you can get the column names and values as array references.
...
my $names = $report_result->{NAME}; # or NAME_lc or NAME_uc
while( my $report_row = $report_result->fetchrow_arrayref() ) {
for my $col_idx ( 0 .. $#{$names} ) {
print "$names->[$col_idx]: $report_row->[$col_idx]\n";
}
}
Back before I had to worry about internationalization I used this a lot to generate CSV reports, just pass the NAME array to Text::CSV before passing the result arrays and writing a report just becomes writing a query.