how to display data in a table column using fpdf - windows

My piece of code is:
for ( $i=2060; $i< $FINAL; $i++ ) {
$pdf->Cell( 36, 12, ( '05/' .number_format( $dataRow[$i] ) ), 1, 0, 'C', $fill );
}
expected pdf output as a column of cells using fpdf is:
05/2060
05/2061
05/2062
05/2063
05/2064
please guide me how to get the above desirable output.

Try adding 1 on the ln part instead of 0
for ( $i=2060; $i< $FINAL; $i++ ) {
$pdf->Cell( 36, 12, ( '05/' .number_format( $dataRow[$i] ) ), 1, 1, 'C', $fill );
}
and make sure that $FINAL has a value and you can do '05/'.$i also, and $fill must be true or false

Related

Merge 2 maps at specific index

I was wondering if I can merge 2 sass maps at a specific index of the first map.
$numbers: (
"one": 1,
"two": 2,
"three": 3,
"six": 6,
"seven": 7,
);
$more-numbers: (
"four": 4,
"five": 5,
);
#debug map.merge($numbers, $more-numbers);
// ("one": 1, "two": 2, "three": 3, "six": 6, "seven": 7, "four": 4, "five": 5)
Instead, I want:
("one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7)
I tried with the list module functions list.index() list.set-nth() but it replaces the index
$index: list.index($numbers, (three 3));
#debug list.set-nth($numbers, $index, $more-numbers);
// "one" 1, "two" 2, ("four": 4, "five": 5), "six" 6, "seven" 7
Even if that worked I am not sure how I can convert it back to a map.
Edit because someone asked the reason behind my question..
I am experimenting with generating utility classes.
u-padding-1: { padding: 0.375rem; }
I have already a map with the values:
$padding: (
"properties": (
"-padding": padding,
),
"directions": (
null: null,
"-horizontal": "-left" "-right",
"-vertical": "-top" "-bottom",
"-top": "-top",
"-right": "-right",
"-bottom": "-bottom",
"-left": "-left",
),
"values": (
"-none": 0rem,
"-tiny": t.rem(t.spacing(tiny)),
"-small": t.rem(t.spacing(small)),
null: t.rem(t.spacing(base)),
"-large": t.rem(t.spacing(large)),
"-huge": t.rem(t.spacing(huge)),
"-auto": auto,
),
) !default;
Now instead of manually adding all the utility key value pairs in the $padding->"values"
"-0": 0,
"-1": 1,
...
I generate them with a while loop and merge them. That would not be an issue but I need these utility classes to be added just before the keyword values like auto, full, etc. for cascading reasons.
I don't want to add another key value pair to my map, for example
"keywords: (
"-auto": auto,
"-full": 100%,
....
),
because I also generate responsive classes and it gets messy.
This is an example of a partial file.
#use "sass:map";
#use "sass:math";
#use "../settings/index.settings" as s;
#use "../tools/index.tools" as t;
$margin: (
"properties": (
"-margin": margin,
),
"directions": (
null: null,
"-horizontal": "-left" "-right",
"-vertical": "-top" "-bottom",
"-top": "-top",
"-right": "-right",
"-bottom": "-bottom",
"-left": "-left",
),
"values": (
"-none": 0px,
"-tiny": t.rem(t.spacing(tiny)),
"-small": t.rem(t.spacing(small)),
null: t.rem(t.spacing(base)),
"-large": t.rem(t.spacing(large)),
"-huge": t.rem(t.spacing(huge)),
"-auto": auto,
),
) !default;
// Populate map with values
$margin-arithmetic-progress: ();
$m: 0;
#while $m <= (t.strip-unit(s.$global-baseline) * 5) {
$converted: t.rem($m);
$margin-arithmetic-progress: map.set($margin-arithmetic-progress, "values", "-#{math.div($m, t.strip-unit(s.$global-baseline))}", $converted);
$m: $m + t.strip-unit(s.$global-baseline);
}
$margin: map.deep-merge($margin, $margin-arithmetic-progress);
#include t.generate-classes($margin);
#include t.generate-responsive-classes($margin);

Is there a solution to this formula stopping an AutoSort script

I am attempting to learn to script as I develop a project so please forgive me if I ask this question incorrectly.
I have created an AutoSort script for a google sheets document to sort a list of players by "Weight". It works fine until I add the following formula. Once I add this formula, my data is to be sorted by Column 7, largest to smallest and doesn't completely. The odd part of this is that the players that are out of order are listed as Substitutes.
The way this sheet works.
The Match Tool tab is where players are selected from Data Validation cells.
The Data Validation list comes from the MR1 Tab.
The MR1 tab gets it list based on an importrange defined in the MRTool.
This comes from a larger document and I've extracted the vital parts to make the error happen. I've tried to run a bare-bones version with only text and the AutoSort script and it sorts correctly. I have also tried changing which column the AutoSort looks in and it works correctly.
The formula that stops the script from working:
=if(or(C10="",C10=". Blank"),"",iferror(index('MR1'!$B$8:$H$87,(match(C10,'MR1'!$N$8:$N$87,0))),"Player Not Found"))
The Script for the AutoSort:
var roster = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Match Tool");
var range1 = roster.getRange("B10:K59");
var range2 = roster.getRange("N10:W59");
range1.sort( [{ column : 7, ascending: false}, { column : 11, ascending: false}] );
range2.sort( [{ column : 19, ascending: false}, { column : 23, ascending: false}] );
}
function SortLeft() {
var roster = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Match Tool");
var range1 = roster.getRange("B10:K59");
range1.sort( [{ column : 7, ascending: false}, { column : 11, ascending: false}] );
}
function SortRight() {
var roster = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Match Tool");
var range2 = roster.getRange("N10:W59");
// It seems that column numbers are always sequential from the first one, even if you are addressing a range. Hence using 14/18 here instead of 4/8
range2.sort( [{ column : 19, ascending: false}, { column : 23, ascending: false}] );
}
function SortSelection() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getActiveRange();
var firstcol = range.getColumn();
var lastcol = range.getLastColumn();
//Before sorting, this code checks to make sure that Clan through Combined heroes is selected on one side or the other. If not, an error appears.
if (firstcol == 2 && lastcol == 11 ) { range.sort( [{ column : 7, ascending: false}, { column : 11, ascending: false}] )} //&& lastcol == 11
else if ( firstcol == 14 && lastcol == 23 ) { range.sort( [{ column : 19, ascending: false}, { column : 23, ascending: false}] )} //&& lastcol == 23
else { SpreadsheetApp.getUi().alert('You can only sort selections that include all 8 data columns, from Clan to Notes.');}
}
function onEdit(e){
var roster = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Match Tool");
var autosort = roster.getRange(6, 13).getValue();
var range1 = roster.getRange("B10:K59");
var range2 = roster.getRange("N10:W59");
// if('B3' === GWL) {
// SpreadsheetApp.getActiveSheet().getRange('K2').setValue('40');
// }
// test if K2 (war size) was modified
if (e.source.getActiveSheet().getName() == "Match Tool" && e.range.rowStart === 6 && e.range.columnStart === 13) {
moveToSub();
}
//preform autosort if on
if ( autosort == "On" ){
range1.sort( [{ column : 7, ascending: false}, { column : 11, ascending: false}] );
range2.sort( [{ column : 19, ascending: false}, { column : 23, ascending: false}] );
}
}
I expect players to be sorted by column 7 (column G) descending and then column 11 (Column K) descending. What I'm getting is certain players not sorted correctly.
I am getting - 132, 131, 131, 113, 111, 132, 113, 90, 88, 87, 86.
I should see - 132, 132, 131, 131, 113, 113, 111, 90, 88, 87, 86.
Thank you for taking the time to help me.
After some help from a friend, we realized the problem wasn't anything to do with the script on this page, it was how the data was entered on the sheet the data was imported in from. Some numbers were entered as numerals while others were entered in as text. By changing the text to numerals, the script performed as expected.
So the moral of the story is, check to make sure the data being sort is of the same type.

Creating a new column in JMP using an if condition from another column

I am very new in JMP so I am still feeling around.
I want to create a new column called "Status" in JMP. This status is character and depends on the value of the column "Grade". If the value of the entry in column "Grade" is zero, the value of the entry in column "Status" should be "fail". If the "Grade" value is greater than 100, the entry in column "Status" should be "invalid". If the :Grade" value is less than 0, the "Status" value should be "invalid". This should be simple. But somehow, my script won't work:
dt = Current Data Table();
dt << New Column("Status", Character, Formula(
If(:Name( "Grade" )==0, "fail",
:Name( "Grade" )>100, "invalid",
:Name( "Grade" )<0, "invalid")
));
Can you help me debug this script?
I just tried the script and the formula is working for me.
Here is some JSL which is a bit more complete which also adds the "Grade" column upon which "Status" depends.
dt = Current Data Table();
dt << New Column( "Grade",
Numeric,
"Continuous",
Format( "Best", 12 ),
);
dt << New Column( "Status",
Character,
"Nominal",
Formula(
If(
:Grade == 0, "fail",
:Grade > 100, "invalid",
:Grade < 0, "invalid"
)
)
);
Perhaps the issue is that you don't already have a data table opened with a Grade column? Here's a script to create a brand new table with the formula and some values.
New Table( "Grading Test",
Add Rows( 7 ),
New Column( "Grade",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected,
Set Values( [45, 20, 100, 101, -4, 0, 120] )
),
New Column( "Status",
Character,
"Nominal",
Formula(
If(
:Grade == 0, "fail",
:Grade > 100, "invalid",
:Grade < 0, "invalid"
)
)
)
);
I created that by interactively creating the table and using the red-triangle menu and selected "Copy Table Script".
I tried JMP 12.0, which version are you using?

How to show Invoice Creation Date on Magento

Now on magento when I print an Invoice as PDF, it shows "Order date".. we need to replace it with the "Invoice Creation Date".
Can you tell me how to do that?
Thanks.
Load the invoice by
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceIncrementId);
and then get the invoice date using
$createdDate = $invoice->getCreatedAt();
and put $createdDate and modify the below code from
$page->drawText(
Mage::helper('sales')->__('Order Date: ') . Mage::helper('core')->formatDate(
$order->getCreatedAtStoreDate(), 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
To
$page->drawText(
Mage::helper('sales')->__('Invoice Creation Date: ') . Mage::helper('core')->formatDate(
$createdDate, 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
NOTE :-
If you have multiple invoices for the same order then you can get the all invoice increment id by
$_invoices = $_order->getInvoiceCollection();
foreach($_invoices as $_invoice){
$_invoice->getIncrementId() = $_invoice->getIncrementId();
}
Since Magento is creating PDF of orders strictly via PHP code (means it doesn't use any html->pdf parser or any similar idea), you will have to extend the class that does that and modify it accordingly. So, the class that you are looking for is:
Mage_Sales_Model_Order_Pdf_Invoice
with the method
protected function insertOrder(&$page, $obj, $putOrderId = true)
then search for
$page->drawText( Mage::helper('sales')->__('Order Date: ') . Mage::helper('core')->formatDate($order->getCreatedAtStoreDate(), 'medium', false), 35, ($top -= 15), 'UTF-8');
And I would guess that you know how to extend it with your own module. If not, the process is described in How to create a simple 'Hello World' module in Magento?.
I had same problem and added invoice date to app/code/core/Mage/Sales/Model/Order/invoice.php at line 132
/* Add document text and number */
$this->insertDocumentNumber(
$page,
Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId()
.' '.
Mage::helper('sales')->__('Invoice date: ') . Mage::helper('core')->formatDate(
$invoice->getCreatedAt(), 'medium', false
),
35,
($top -= 15),
'UTF-8'
);

how to send array of values to a query dynamically in codeigniter

The code in model is
public function get_report6_8($type, $filter_id=NULL) {
$values = array($filter_id);
$select = '';
if ($filter_id && $type == 'jh') {
$select = 'and natbuild_rep.jh_rep_id = ?';
}
else if ($filter_id && $type == 'natbuild') {
$select = 'and natbuild_principal.id = ?';
}
$sql = "select sum(total) total
from (
select value_of_sale total
from lead
left join natbuild_rep
on natbuild_rep.mobile = lead.mobile
left join natbuild_store
on natbuild_store.id = natbuild_rep.store_id
left join natbuild_principal
on natbuild_principal.store_group = ifnull(natbuild_store.store_group2, natbuild_store.store_group)
where (status = 1 OR status = 2)
and value_of_sale is not null
{$select}
group by lead.id
) temp";
return $this->db->query($sql, $values)->row();
}
The code in controller is
$data['report8'] = $this->lead_report_model->get_report6_8($type, $this->input->post('filter'));
code in view is
Grand Total: $total)) ? $report8->total: 0;?>
if I run query like
select sum(total) total
from (
select value_of_sale total
from lead
left join natbuild_rep
on natbuild_rep.mobile = lead.mobile
left join natbuild_store
on natbuild_store.id = natbuild_rep.store_id
left join natbuild_principal
on natbuild_principal.store_group = ifnull(natbuild_store.store_group2, natbuild_store.store_group)
where (status = 1 OR status = 2)
and value_of_sale is not null
and natbuild_principal.id in (18, 30, 31, 35, 33, 25, 23, 15, 8, 6, 5, 29, 7, 3, 2, 1, 24, 27, 22, 21, 20, 26, 36)
group by lead.id ) temp
the result is right. please help how can I send array of values to the $select. This happens when I select grand total from a dropdown which contains all other values up there.
your dropdown is multiselect so it will pass an array with the values.
use
implode(",", $dropdownSelections);
$select = 'and natbuild_principal.id in ('.implode(",", $dropdownSelections).')';

Resources