This topic is locked
[SOLVED]

 Semi Automatic Tabs on List Page

7/26/2019 3:02:16 PM
PHPRunner General questions
D
Daviant author

Good afternoon;
First of all I commented that my programming in PHP and the like is minimal.
I am trying to automate the creation of tabs in the list page with the help of some arrays.

Tabs should group by month and year.
In the code I have, the tabs are generated, but clicking on them does not show the data properly.
Any help is welcome
(Google translator)



List page Before Process Event

---------------------------------
$anos = array('2014', '2015', '2016', '2017', '2018','2019');

$mes = array('01', '02', '03', '04','05', '06', '07', '08','09', '10', '11', '12');

$mesp = array('ENE-', 'FEB-', 'MAR-', 'ABR-','MAY-', 'JUN-', 'JUL-', 'AGO-','SEP-', 'OCT-', 'NOV-', 'DIC-');

$identificador = 1;

global $conn;

foreach ($anos as $valor) {

$rano = $valor;

$contador = 1;

foreach ($mes as $valor) {

$rmes = $valor;

$strSQLExists = "SELECT EMISION from dbo.DVCSII where MONTH(dbo.DVCSII.EMISION) = ".$rmes." AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);
if($data) {

$etiqueta = $mesp[$contador].$rano;

$pageObject->addTab("MONTH(dbo.DVCSII.EMISION) = ".$rmes."AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'", $etiqueta,$identificador);

$contador++;

$identificador++;

}

}

unset($rmes);

}

unset($rano);
W
wpl 7/27/2019

Daviant,
this looks like a simple typo. Compare the two where parts of your statements:



$strSQLExists = "SELECT EMISION from dbo.DVCSII where MONTH(dbo.DVCSII.EMISION) = ".$rmes." AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'";



and



$pageObject->addTab("MONTH(dbo.DVCSII.EMISION) = ".$rmes."AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'"


there seems to be a missing space before AND in the second statement.



".$rmes." AND YEAR

versus

".$rmes."AND YEAR


Hope that helps



Good afternoon;
First of all I commented that my programming in PHP and the like is minimal.
I am trying to automate the creation of tabs in the list page with the help of some arrays.

Tabs should group by month and year.
In the code I have, the tabs are generated, but clicking on them does not show the data properly.
Any help is welcome
(Google translator)



List page Before Process Event

---------------------------------
$anos = array('2014', '2015', '2016', '2017', '2018','2019');

$mes = array('01', '02', '03', '04','05', '06', '07', '08','09', '10', '11', '12');

$mesp = array('ENE-', 'FEB-', 'MAR-', 'ABR-','MAY-', 'JUN-', 'JUL-', 'AGO-','SEP-', 'OCT-', 'NOV-', 'DIC-');

$identificador = 1;

global $conn;

foreach ($anos as $valor) {

$rano = $valor;

$contador = 1;

foreach ($mes as $valor) {

$rmes = $valor;

$strSQLExists = "SELECT EMISION from dbo.DVCSII where MONTH(dbo.DVCSII.EMISION) = ".$rmes." AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);
if($data) {

$etiqueta = $mesp[$contador].$rano;

$pageObject->addTab("MONTH(dbo.DVCSII.EMISION) = ".$rmes."AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'", $etiqueta,$identificador);

$contador++;

$identificador++;

}

}

unset($rmes);

}

unset($rano);


D
Daviant author 7/27/2019



Daviant,
this looks like a simple typo. Compare the two where parts of your statements:



$strSQLExists = "SELECT EMISION from dbo.DVCSII where MONTH(dbo.DVCSII.EMISION) = ".$rmes." AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'";



and



$pageObject->addTab("MONTH(dbo.DVCSII.EMISION) = ".$rmes."AND YEAR(dbo.DVCSII.EMISION) = '".$rano."'"


there seems to be a missing space before AND in the second statement.



".$rmes." AND YEAR

versus

".$rmes."AND YEAR


Hope that helps


Thank you very much for your help.

I made the change, but unfortunately everything remains the same ... there must be another problem ...

W
wpl 7/27/2019

Daviant,
then it comes to my mind that your $identificador is numeric. The manual shows this definition:


$pageObject->addTab($where, $title, $id);

Following this example:

$pageObject->addTab("CustomerID='ANTON'", "ANTON orders", "anton");
$id should be of type string to look like "1", "2", "3",....




Thank you very much for your help.

I made the change, but unfortunately everything remains the same ... there must be another problem ...

D
Daviant author 7/29/2019



Daviant,
then it comes to my mind that your $identificador is numeric. The manual shows this definition:


$pageObject->addTab($where, $title, $id);

Following this example:

$pageObject->addTab("CustomerID='ANTON'", "ANTON orders", "anton");
$id should be of type string to look like "1", "2", "3",....



Hi, I checked this point and you're right. Now it works. Of course, I now have a logical problem, because the tab in question that represents the month and the year is out of date one month ... but this is already a problem of the programming itself ... I am reviewing it.
Thank you

(Google translator)

D
Daviant author 7/29/2019



Hi, I checked this point and you're right. Now it works. Of course, I now have a logical problem, because the tab in question that represents the month and the year is out of date one month ... but this is already a problem of the programming itself ... I am reviewing it.
Thank you

(Google translator)


I preferred to simplify the code, it was very complex.

This way it works right.

Thank you very much for the help.
(Google translator)


$ano = array('2014', '2015', '2016', '2017', '2018','2019');

$mes = array('01', '02', '03', '04','05', '06', '07', '08','09', '10', '11', '12');

$mesT = array('ENE-', 'FEB-', 'MAR-', 'ABR-','MAY-', 'JUN-', 'JUL-', 'AGO-','SEP-', 'OCT-', 'NOV-', 'DIC-');
global $conn;
for($yy = 0; $yy < count($ano); ++$yy) {
for($mm = 0; $mm < count($mes); ++$mm) {

$strSQLExists = "SELECT EMISION from dbo.DVCSII where MONTH(dbo.DVCSII.EMISION) = ".$mes[$mm]." AND YEAR(dbo.DVCSII.EMISION) = '".$ano[$yy]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data) {

$identificador = "tab".$ano[$yy].$mes[$mm];

$etiqueta = $mesT[$mm]."-".$ano[$yy];

$pageObject->addTab("MONTH(dbo.DVCSII.EMISION) = ".$mes[$mm]." AND YEAR(dbo.DVCSII.EMISION) = '".$ano[$yy]."'", $etiqueta,$identificador);

}
}

}
W
wpl 7/30/2019

Daviant,
glad this was helpful. Oh, and, of course, I should have noticed that arrays are zero-based in PHP.
Have fun