Ignore:
Timestamp:
Jan 30, 2013, 9:58:22 AM (7 years ago)
Author:
goya
Message:

refacto api code to add task to generate dump of all amdmts for a bill

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/api/templates/csvSuccess.php

    r2839 r3091  
    1515echo "\n";
    1616
    17 function depile_assoc($asso, $breakline, $multi) {
    18   global $alreadyline;
    19   $semi = 0;
    20   foreach (array_keys($asso) as $k) {
    21     if (isset($multi[$k]) && $multi[$k]) {
    22       $semi = 1;
    23     }
    24     depile($asso[$k], $breakline, $multi, $semi);
    25     if ($k == $breakline) {
    26       echo "\n";
    27     }
    28   }
    29   return $semi;
    30 }
    31 
    32 function depile($res, $breakline, $multi, $comma = 0) {
    33   if (is_array($res)) {
    34     if (isset($res['organisme']) && isset($res['fonction']))
    35       return depile($res['organisme']." - ".$res['fonction'], $breakline, $multi, $comma);
    36     if (!isset($res[0])) {
    37       if (array_keys($res))
    38         return depile_assoc($res, $breakline, $multi);
    39       echo ";";
    40       return;
    41     }
    42     foreach($res as $r)
    43       $semi = depile($r, $breakline, $multi);
    44     if ($semi)
    45       echo ';';
    46   }else{
    47     if ($comma)
    48       $res = preg_replace('/[,;]/', '', $res);
    49     $string = preg_match('/[,;"]/', $res);
    50     if ($string) {
    51       $res = preg_replace('/"/', '\"', $res);
    52       echo '"';
    53     }
    54     echo $res;
    55     if ($string)
    56       echo '"';
    57     if ($comma)
    58       echo '|';
    59     else echo ';';
    60   }
    61 }
    62 
    63 depile($res, $breakline, $multi);
     17myTools::depile_csv($res, $breakline, $multi);
     18?>
Note: See TracChangeset for help on using the changeset viewer.