Commit b55b4b62 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Dépenses : Fix export des données (format CSV et colonne montant OK)

- Ajout de droits pour les accès aux recettes/donnèes ignorées
parent d21dcd5f
Loading
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -624,6 +624,22 @@
    "fullcode": "DEPENSE-DOWNLOAD"
  },

  "DEPENSE-RECETTES": {
    "category_id": 9,
    "spot": 7,
    "code": "RECETTES",
    "libelle": "Peut voir les recettes",
    "fullcode": "DEPENSE-RECETTES"
  },

  "DEPENSE-IGNORED": {
    "category_id": 9,
    "spot": 7,
    "code": "IGNORED",
    "libelle": "Peut voir les données ignorées",
    "fullcode": "DEPENSE-IGNORED"
  },

  "MAINTENANCE-SPENDTYPEGROUP_MANAGE": {
    "category_id": 6,
    "spot": 7,
+27 −25
Original line number Diff line number Diff line
@@ -38,39 +38,41 @@ class SpentActivityDetailsExcelFormater implements IFormatter
        $activityNumOscar = $this->activity->getOscarNum();
        $project = $this->activity->getAcronym();

        // Génération des clefs
        $headers = ['PFI', 'PROJECT', 'ACTIVITY', 'ACTIVITYNUM','MONTANT','TEXTE','TYPE','COMPTE', 'DATE COMPTABLE', 'DATE PAIEMENT', 'ANNEE', 'NUM PIECE', 'OSCARID', 'SYNCID'];

        $headers = ['id',
            'syncid',
            'pfi',
            'numSifac',
            'numPiece',
            'montant',
            'compteBudgetaire',
            'centreProfit',
            'compteGeneral',
            'centreFinancier',
            'texteFacture',
            'designation',
            'dateAnneeExercice',
            'datePaiement',
            'datePiece',
            'dateComptable',
            'masse',
            'compte',
            'type'];
        $filename = sprintf('/tmp/spent-%s.csv', uniqid());
        $writer = fopen($filename, 'w');
        fputcsv($writer, $headers);
        foreach ($this->datas as $stack) {
            foreach ($stack['details'] as $line) {
                $wroteLine = [
                    $pfi,
                    $project,
                    (string)$this->activity,
                    $activityNumOscar,
                    $line['montant'],
                    $line['textFacture'] ? $line['textFacture'] : $line['designation'],
                    $line['codeStr'],
                    $line['compteBudgetaire'],
                    $line['dateComptable'],
                    $line['datePaiement'],
                    $line['dateAnneeExercice'],
                    $line['numPiece'],
                    $this->activity->getId(),
                    implode(',', $line['syncIds']),
                ];
                fputcsv($writer, $wroteLine);
            }
        foreach ($this->datas['spents'] as $line) {
            $line['montant'] = number_format($line['montant'], 2, ',', ' ');


                fputcsv($writer, $line);
        }
        fclose($writer);

          //


        if( array_key_exists('download', $options) && $options['download'] === true ){
            $downloader = new CSVDownloader();
            $downloader->downloadCSVToExcel($filename);
            $downloader->downloadCSV($filename);
        }

    }
+3 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ class SpentActivityExcelFormater implements IFormatter
        $filename = sprintf('/tmp/spent-%s.csv', uniqid());
        $writer = fopen($filename, 'w');
        fputcsv($writer, $headers);
        foreach ($this->datas as $line) {
        foreach ($this->datas['spents'] as $line) {
            $wroteLine = [
                $pfi,
                $project,
@@ -61,10 +61,11 @@ class SpentActivityExcelFormater implements IFormatter
                $this->activity->getId(),
                implode(',', $line['syncIds']),
            ];
            var_dump($wroteLine);
            fputcsv($writer, $wroteLine);
        }
        fclose($writer);

        die();
        //
        if( array_key_exists('download', $options) && $options['download'] === true ){
            $downloader = new CSVDownloader();
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges
    const DEPENSE_SHOW = 'DEPENSE-SHOW';
    const DEPENSE_SYNC = 'DEPENSE-SYNC';
    const DEPENSE_DOWNLOAD = 'DEPENSE-DOWNLOAD';
    const DEPENSE_RECETTES = 'DEPENSE-RECETTES';
    const DEPENSE_IGNORED = 'DEPENSE-IGNORED';

    public static function getResourceId($privilege)
    {
+4 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@
        border-collapse: collapse;
    }
    tr.total {
        border-top: solid 2px #999;
        background: #0b97c4;
        border-top: solid 2px #a4bbbb;
        background: rgb(236, 243, 245);
    }
</style>
<section class="container-fluid">
@@ -55,6 +55,8 @@
                        return h(SpentLinePFI.default, { props: {
                                informations: <?= json_encode($activity->toArray()) ?>,
                                masses: <?= json_encode($masses) ?>,
                                manageRecettes: <?= $this->grant()->privilege(\Oscar\Provider\Privileges::DEPENSE_RECETTES, $activity) ? 'true' : 'false' ?>,
                                manageIgnored: <?= $this->grant()->privilege(\Oscar\Provider\Privileges::DEPENSE_IGNORED, $activity) ? 'true' : 'false' ?>,
                                url: "<?= $this->url('spent/activity-api', ['id' => $activity->getId()]) ?>",
                                urlActivity: "<?= $this->url('contract/show', ['id' => $activity->getId()]) ?>",
                                urlSync: <?= $this->grant()->privilege(\Oscar\Provider\Privileges::DEPENSE_SYNC) ?
Loading