Forum

Exportation Print/P...
 
Notifications
Clear all

Exportation Print/PDF/CSV + Notes

18 Posts
3 Users
0 Reactions
22.3 K Views
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 
[#1257]

Hi Babynus,

I'm working on the export functionality of Project'Or RIA and I had one proposition, one remark and one question.

PROPOSITION :

I made a dialog that pops up when you try to print/PDF/CSV on objectList.php.
This dialog proposes to choose the colomn you want to see in your print/PDF/CSV.

The idea comes from the lack of some infos when they are not in the model layout.

If you are interested, I can introduce it more to you with screenshot and .. text..

I was thinking of creating a XLSX export thingy too..

REMARK :

When exporting as a PDF, it seems that it does not take all the page width ... Columns are thin whereas when printing then the table takes all the page (sometimes more when it's to much ^^)

It is a bug ?

QUESTION :

I want to be able to export Notes as well as other column.. do you think it is possible with, for example, the jsonQuery.php ?

Have a good week end.


 
Posted : 12 Jul 2013 13H39
(@babynus)
Posts: 14952
Member Admin
 

I made a dialog that pops up when you try to print/PDF/CSV on objectList.php.
This dialog proposes to choose the colomn you want to see in your print/PDF/CSV.
The idea comes from the lack of some infos when they are not in the model layout.

Good idea. 🙂
I don't thing it is a real lack for CSV, as every data is exported.
But this could be a good improvement, and to keep the as-is behavious, maybe an automatic "check all" could be good.
Just pay attention to access rights. For instance some profiles may not see work or cost...

If you are interested, I can introduce it more to you with screenshot and .. text..

Yes please :woohoo:

I was thinking of creating a XLSX export thingy too..

Another good improvement 😛

When exporting as a PDF, it seems that it does not take all the page width ... Columns are thin whereas when printing then the table takes all the page (sometimes more when it's to much ^^)
It is a bug ?

I don't really understand what you mean. :blush:
Possibly some unexpected behavious depending on screen resolution ? :S
if you have any example / print screen ... 😉

I want to be able to export Notes as well as other column.. do you think it is possible with, for example, the jsonQuery.php ?

Well, jsonQuery won't be an issue, but it will be to export as CSV or XSLS : and don't see how you'll export several notes in one only line 🙁

Nive week-end to you too B)


 
Posted : 12 Jul 2013 22H40
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 

I made a dialog that pops up when you try to print/PDF/CSV on objectList.php.
This dialog proposes to choose the colomn you want to see in your print/PDF/CSV.
The idea comes from the lack of some infos when they are not in the model layout.

Good idea.
I don't thing it is a real lack for CSV, as every data is exported.
But this could be a good improvement, and to keep the as-is behavious, maybe an automatic "check all" could be good.
Just pay attention to access rights. For instance some profiles may not see work or cost...

There is already a check all and uncheck all boxes 😉
And I made a new table to store previous checkboxes configuration as soon as my customized datas have a lot of possible column and the operator could be bored to check his own config..
Today, it stores the config for everyone per model, but it can easily be done per user too.

I did not at all work on accessright .. because my own datas do not have such problem. But I guess I could add it and check when checkboxes are build. I'll investigate.

If you are interested, I can introduce it more to you with screenshot and .. text..

Yes please

When you click on extract buttons, this pops ups : (here for status)

I think it speacks for itself (at least for french readers..)
I am thinking of adding th section information to organize the window a bit more..

If you try to extract more than 200 data this shows up :

I added this because I think that it is unrealistic to extract that much of data..

Of course, every texts are translated by il18n().

Print window is unchanged.

I was thinking of creating a XLSX export thingy too..

Another good improvement

Only thinking ^^

When exporting as a PDF, it seems that it does not take all the page width ... Columns are thin whereas when printing then the table takes all the page (sometimes more when it's to much ^^)
It is a bug ?

I don't really understand what you mean.
Possibly some unexpected behavious depending on screen resolution ?
if you have any example / print screen ...

Two images to show my problem.
When I extract Status I have those two results : (with the same input layout)
With Print :
With PDF :

I don't really understand why the table does not takes all the page in the pdf extraction.. I would have if it was also in the print view.. but..

I want to be able to export Notes as well as other column.. do you think it is possible with, for example, the jsonQuery.php ?

Well, jsonQuery won't be an issue, but it will be to export as CSV or XSLS : and don't see how you'll export several notes in one only line

If I can print it in one column like a basical varchar I'll be happy ^^
My operators have some particular way of using notes so perhaps should I make my own notes.. like a new field...


 
Posted : 15 Jul 2013 11H40
(@babynus)
Posts: 14952
Member Admin
 

Hi,

About PDF export :
I just tested on current version, export is correct in PDF.

I thing you changed some behavious in your version.
What is important to know about pdf Export, is that the library used (html2pdf) will not display correctly if you set width only on headers...
So you must specify the width of colomns on each line...
Moreover, for width in %, the total "must" be 100%. If less, it won't fulfill the page, if more, it won't fit in the page. This may be a real issue is your set columns selectable : you'll have to recalculate width to that total is 100% depending on selection :ohmy:


 
Posted : 15 Jul 2013 12H45
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 

Annnh... And my happiness is gone..

I actually thought that the width parameter worked like print, and did not care too much about it ^^

So yes, when I create the export Layout, it has its own witdhs..

OK, I think I have a solution... 🙂

And problem solved 🙂


 
Posted : 15 Jul 2013 12H52
DEDIEU
(@jcde)
Posts: 104
Active Member
 

Very interresting these developments!! Congratulations.

Another point would be interresting: Add possibility of extracting data to import.

  1. Do not write the name (project, type, ...), but the IDs
  2. Set the first line in the correct import format

This will have the advantage of being able to do extractions, make the changes to the file and import effortlessly.

Thanks


 
Posted : 15 Jul 2013 17H41
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 

Hi JCDe,

I think its already possible with the CSV exportation. Importation procedure will read the project, type... and associate it with the corresponding one line the database.

However, I did not try 🙂


 
Posted : 15 Jul 2013 18H16
DEDIEU
(@jcde)
Posts: 104
Active Member
 

And no ...
I'll place pictures to show: Following an export attached

In this file you see: The names of activities, projects and header line with spaces between the names

Attached is an import file

1) Note that the header line corresponds to BDD table (more space)
2) The names of projects, types are replaced by the corresponding IDs.

This requires the user after a export transfmormer by hand all names with the corresponding IDs with risk of this mistake.
In the ideal should be two assemblies to navigate (Cells with IDs and a comment on the cell with actual name)

Thanks


 
Posted : 15 Jul 2013 19H34
(@babynus)
Posts: 14952
Member Admin
 

You should have tried (or read the fucking manual 👿 )
http://track.projectorria.org/manual/manual.php?page=107&tag=import
It works. :woohoo:
You can export data to csv, update file (just pay attention to date format if you do this with Excel), and re-import it.
Import procedure is done for this to work ! 😉


 
Posted : 15 Jul 2013 20H35
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 

Hey Babynus, you didn't really tell me if you were interested in my export thingy.

I don't know if the code really meets your expectations, but well... why not

(And btw I did not implemented the accessright issue, but I dont need it to be ... and I dont really know how ^^)

(Ok, I'll investigate.. ! ^^)


 
Posted : 06 Aug 2013 17H12
(@babynus)
Posts: 14952
Member Admin
 

Of course I am interested :woohoo:

Please send me your devs.
I'll try to fulfill devs about accessright and fiabilization, if it's not too buggy.

Thanks.


 
Posted : 06 Aug 2013 18H43
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 

Allright.. there is a bunch of things :

In view/js/projectorDialog.js I added :

var ReportPrintType ='';

//open the dialog with checkboxes
function openReportPrint (Type) {
    ReportPrintType =Type;
    if (formChangeInProgress) {
            showAlert(i18n('alertOngoingChange'));
            return;
    }
    top.dijit.byId("dialogReportPrint").show();  
    
}

//close the dialog with checkboxes 
function closeReportPrint (obj,idUser) {
    top.dijit.byId("dialogReportPrint").hide(); 
    saveCheckboxReportPrint(obj,idUser);
}


//save current state of checkboxes
function saveCheckboxReportPrint(obj,idUser){

    var val = dojo.byId('column0').value;
    var toStore=obj+";"+idUser;
    val = eval(val);

    for(i=1; i<val+1;i++){
        var checkbox=dojo.byId('column'+i);
        if(checkbox) {
            if(checkbox.checked) {
                var field=checkbox.value.split(';');
                toStore=toStore + ";" + field[4];
            }
        }
    }

    var xhr = getXMLHttpRequest(); 

    var toSend = encodeURIComponent(toStore);

    xhr.open("GET", "../tool/saveCheckboxes.php?toStore=" + toSend , true);
    xhr.send(null);

}

//pretty sure you're familiar with this
function getXMLHttpRequest() {
    var xhr = null;
     
    if (window.XMLHttpRequest || window.ActiveXObject) {
        if (window.ActiveXObject) {
            try {
                xhr = new ActiveXObject("Msxml2.XMLHTTP");
            } catch(e) {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
        } else {
            xhr = new XMLHttpRequest(); 
        }
    } else {
        alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
        return null;
    }
     
    return xhr;
}

//computes witch so pdf export takes all page.
function egalizeWidth(width){
var SumWidth=0;

for (var i in width){
  SumWidth = parseInt(SumWidth)+parseInt(width);
}

for (var i in width){
  width=100*width/SumWidth;
}

return width;
}

var layoutPrint ='';
//Executes the report (shows the print/pdf/csv)
function executeReportPrint(obj,idUser) {  
    layoutPrint ='';
    var verif=0;
    var val = dojo.byId('column0').value;
    val = eval(val);
    var width = {};
    for(i=1; i<val+1;i++){
        var checkbox=dojo.byId('column'+i);
        if(checkbox) {
            if(checkbox.checked) {
                var field=checkbox.value.split(';');
                width[field[0]]=field[2];
            }
        }
    }
    
    width = egalizeWidth(width);
   
    for(i=1; i<val+1;i++){
        var checkbox=dojo.byId('column'+i);
        if(checkbox) {
            if(checkbox.checked) {
                var field=checkbox.value.split(';');
                layoutPrint+=''+field[1]+' ';
                verif=1;        
            }
        }
    }
    if(verif==1){
        var grid = dijit.byId("objectGrid");
        if(grid.rowCount > 200) {
            actionYes=function() { 
                if(ReportPrintType=='print') {
                    showPrint("../tool/jsonQuery.php", 'list');
                } else if(ReportPrintType=='csv') {
                    showPrint("../tool/jsonQuery.php", 'list', null, 'csv');  
                } else if(ReportPrintType=='pdf') {
                    showPrint("../tool/jsonQuery.php", 'list', null, 'pdf');
                } else {
                    showPrint("../tool/jsonQuery.php", 'list');
                }
                closeReportPrint (obj,idUser);
            };
            actionNo=function() { closeReportPrint (obj,idUser); };
            showQuestion("" + i18n('extracting') + " " + grid.rowCount + " " + i18n('lines')+".
" + i18n('longTraitment') + ".
" + i18n('wantToExtract'),actionYes,actionNo); } else { if(ReportPrintType=='print') { showPrint("../tool/jsonQuery.php", 'list'); } else if(ReportPrintType=='csv') { showPrint("../tool/jsonQuery.php", 'list', null, 'csv'); } else if(ReportPrintType=='pdf') { showPrint("../tool/jsonQuery.php", 'list', null, 'pdf'); } else { showPrint("../tool/jsonQuery.php", 'list'); } closeReportPrint (obj,idUser); } } else { showAlert(i18n('alertChooseOneAtLeast')); } } //Check or uncheck all boxes function checkReportPrint () { var check = dojo.byId('checkUncheck').checked; var val = dojo.byId('column0').value; val = eval(val); for(i=1; i<val+1;i++){ var checkbox=dijit.byId('column'+i); if(checkbox) { dijit.byId(checkbox).setValue(check); } } }

In view/objectList.php :

<div id="dialogReportPrint" dojoType="dijit.Dialog" title=""
     style=";margin-left: 0px;margin-top: 0px;">
    
            
    id;
        
        $query='SELECT checkboxes FROM printcheckbox WHERE `objclass`="'.$objectClass.'" AND `idUser`="'.$idUser.'";';
        $result=Sql::query($query);
        
        $line = Sql::fetchLine($result);
        $checkboxDB=array();
        while($line) {
            $checkboxDB[]=$line;
            $line = Sql::fetchLine($result);
        }

        if(count($checkboxDB)>0){
            $checkboxDB=$checkboxDB[0]['checkboxes'];
            $checkboxDB=explode(";",$checkboxDB);
        }

    
        $htmlresult="
"; $htmlresult.="".i18n("chooseColumnPrint").' :

'; $htmlresult.=''; $htmlresult.=''; $FieldsArray=$obj->getFieldsArray(); foreach($FieldsArray as $key => $val) { $FieldsArray[$key]=$obj->getColCaption($val); if (substr($val,0,5)=='_col_') { if (strlen($val)>8) { $section=substr($val,9); $FieldsArray[$key]=i18n('section' . ucfirst($section)); } } if(substr($FieldsArray[$key],0,1)=="["){ unset($FieldsArray[$key]); continue; } } $countFields=count($FieldsArray); $htmlresult.=''; $index=1; $last_key = end($FieldsArray); foreach($FieldsArray as $key => $val){ if(substr($key,0,5)=="_col_"){ if($val!=$last_key) { $htmlresult.=''.$val.'
'; } } else if(substr($key,0,5)=="input"){ }else { $checked=''; foreach($checkboxDB as $valchecked){ if($valchecked==$key){ $checked='checked'; } } $dataType = $obj->getDataType($key); $dataLength = $obj->getDataLength($key); $width=5; $formatter=''; if ($key=='id') { // id $formatter="numericFormatter"; $htmlresult.=''.$val.'
'; } else if ($key=='password') { // PassWord // nothing } else if ($dataType=='date' and $val!=null and $val != '') { // Date $formatter="dateFormatter"; $htmlresult.=''.$val.'
'; } else if ($dataType=='datetime' and $val!=null and $val != '') { // Date and Time $formatter="dateFormatter"; $htmlresult.=''.$val.'
'; } else if ($dataType=='time' and $val!=null and $val != '') { // Time $formatter="dateFormatter"; $htmlresult.=''.$val.'
'; } else if ($key=='color' and $dataLength == 7 ) { // color $formatter="colorFormatter"; $htmlresult.=''.$val.'
'; } else if ($dataType=='int' and $dataLength==1) { // boolean $formatter="booleanFormatter"; $htmlresult.=''.$val.'
'; } else if ($dataLength > 100) { // Text Area (must reproduce BR, spaces, ... $width=20; $htmlresult.=''.$val.'
'; } else if (substr($key,0,2)=='id' and $dataType=='int' and strlen($key)>2 and substr($key,2,1)==strtoupper(substr($key,2,1)) ) { // Idxxx if(substr($key,2,strlen($key))=='Status') { $formatter="colorNameFormatter"; $htmlresult.=''.$val.'
'; } else if(substr($key,2,strlen($key))=='Profile') { $formatter="translateFormatter"; $htmlresult.=''.$val.'
'; } else { $htmlresult.=''.$val.'
'; } } else { $htmlresult.=''.$val.'
'; } $index++; } } $htmlresult.="
"; $htmlresult.=''.i18n("checkUncheckAll").'

'; echo $htmlresult; ?>
<button align="left" dojoType="dijit.form.Button" id="dialogePrintSubmit" onclick="executeReportPrint('','');"> <button align="right" dojoType="dijit.form.Button" onclick="closeReportPrint('','');">

Created the file tool/saveCheckboxes.php:

/tool/jsonQuery.php'); 
    
    header("Content-Type: text/plain"); // Utilisation d'un header pour spécifier le type de contenu de la page. Ici, il s'agit juste de texte brut (text/plain). 

    $toStore = (isset($_GET["toStore"])) ? $_GET["toStore"] : NULL;
    
    $toStore=explode(";",$toStore);
    

    
    if(count($toStore)>1){
        
        $objClass = $toStore[0];
        $idUser = $toStore[1];
        unset($toStore[0]);
        unset($toStore[1]);
        
        if(count($toStore)==0) {
            $toStore='';
        } else {
            $toStore=implode(";",$toStore);
        }
        
        $query='SELECT objclass FROM printcheckbox WHERE `objclass`="'.$objClass.'" AND idUser="'.$idUser.'";';
        $result=Sql::query($query);
        
        $line = Sql::fetchLine($result);
        $checkboxDB=array();
        while($line) {
            $checkboxDB[]=$line;
            $line = Sql::fetchLine($result);
        }
        
        if(count($checkboxDB)>0){
            $query ="UPDATE printcheckbox set checkboxes='".$toStore."' WHERE objclass='".$objClass."' AND idUser='".$idUser."';";
        } else {
            $query ="INSERT INTO printcheckbox (`objclass`,`checkboxes`,`idUser`) VALUES('".$objClass."','".$toStore."','".$idUser."')";
        }

        
        $result=Sql::query($query);
        

    }

?>

Created table :

CREATE TABLE `${prefix}printcheckbox` (
  `id` int(12) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `objclass` varchar(50) DEFAULT NULL,
  `idUser` int(12) unsigned DEFAULT NULL,
  `checkboxes` varchar(500) DEFAULt NULL,
  `idle` int(1) unsigned DEFAULT '0'
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ;

Since the last time, I added the fact that it stores checkboxes states for each user.

Note : my queries do not take $prefix into account.


 
Posted : 06 Aug 2013 19H05
(@babynus)
Posts: 14952
Member Admin
 

Thanks !

I will have a look for integration in V3.5.0


 
Posted : 07 Aug 2013 23H23
LEVA
 LEVA
(@leva)
Posts: 54
Active Member
Topic starter
 

You're welcome ^^

I hope it will meet your standards !


 
Posted : 08 Aug 2013 10H29
(@babynus)
Posts: 14952
Member Admin
 

Hi LEVA,

I tried to test your code to try and include it in next version.
Here are my remarks :

  1. Some minor html tags incorrect closure in the objectList new div.
    I fixed them.
  2. Direct SQL in code is not good coding practice.
    Must use some object.
    This will make the use of $prefix transparent.
    I'll try and translate your SQL into some object management, it should not be complex
  3. You forgot to include some objectList change, to change button click behaviour.
    I could manage to fix one. Others should be simple.
  4. You also forgot to include some change in jsonQuery.php.
    This is a major part of your code.
    Could you please post you changes in jsonQuery.php so that I can include you code in next version ?
  5. I guess some fields are missing in your list : for project and activities, all progress data are stored in a remote object PlanningElement (not easy to guess on your side).
    I'll have a look to check how to retrieve them
  6. Some fileds with attribute "noExport" must not be exported. Once again, it was not easy to guess

I hope I can finish to implement your coding in next version, because it is very good job.
Thnaks for your contribution.


 
Posted : 05 Oct 2013 22H06
(@babynus)
Posts: 14952
Member Admin
 

I guess some fields are missing in your list : for project and activities, all progress data are stored in a remote object PlanningElement (not easy to guess on your side).
I'll have a look to check how to retrieve them

My mistake !
Your code correctly takes these fields into account !


 
Posted : 05 Oct 2013 22H13
(@babynus)
Posts: 14952
Member Admin
 

Other issue that has to be fixed : some work and cost fields should not be exposed (not exported, nor displayed is selection list) depending on defined rights.


 
Posted : 06 Oct 2013 1H45
(@babynus)
Posts: 14952
Member Admin
 

Hi LEVA,

Hope you'll see posts : it seems the email you provided is not rooted correctly.


 
Posted : 06 Oct 2013 2H13
Share:

Scroll to Top