duaiwo9093 2019-04-29 09:34
浏览 50

webform记录需要csv文件和文件特定的电子邮件

I cant stored data CSV in file

I can Load the data but I cant stored the data in the CSV files and stored the file in the specific folder My requirement was to load the web form details and send the email to specific users. I can able to download the CSV file but I can't store the details in CSV file

  function webform_email_menu() {
        $items = array();
         $items['webform_email'] = array(
            'title'             =>  'Webform Email',  //page title
            'description'       =>  'Webform Information',  //description show when mouse hover on link
            'page callback'     =>  'webform_list',  //callback function which is invoked when menu item is called.
            'access callback'   =>  true,  //any user can access this page
           );
         return $items;
    }



function webform_list() {
    module_load_include('inc', 'webform', 'includes/webform.export');
    module_load_include('inc', 'webform', 'includes/webform.components');
    module_load_include('inc', 'webform', 'includes/webform.submissions');  
    $submissions = webform_get_submissions(125);
echo "installation Type,Date of Purchase,Date of Install    ,Outdoor Unit Model,Outdoor Unit Serial,Indoor Unit 1 Model,Indoor Unit 1 Serial,Indoor Unit 2 Model,Indoor Unit 2 Serial,Indoor Unit 3 Model,Indoor Unit 3 Serial,Indoor Unit 4 Model,Indoor Unit 4 Serial,Indoor Unit 5 Model,Indoor Unit 5 Serial,Indoor Unit 6 Model,Indoor Unit 6 Serial,Indoor Unit 7 Model,Indoor Unit 7 Serial,Indoor Unit 8 Model,Indoor Unit 8 Serial,Indoor Unit 9 Model,Indoor Unit 9 Serial,Owner First Name,Owner Last Name,Installation Address 1,Installation Address 2,City,State/Province,Zip/Postal Code,Country ,Owner Phone Number,Owner Email,Contractor Information,Contractor Name,Contractor Address 1 ,Contractor Address 2,City,State/Province,Zip/Postal Code,Country,Contractor Phone Number,Contractor Email,Distributor Name,Distributor Address 1,Distributor Address 2,City,State/Province,Zip/Postal Code,Country,TAC,Privacy Statement
";
   $surveycomponents = db_select('webform_component')
     ->fields('webform_component')
     ->condition('nid', 125)
     ->orderBy('weight')
     ->orderBy('name')
     ->execute()
     ->fetchAllAssoc('cid', PDO::FETCH_ASSOC);
$count =0;
$i=2;
   foreach ($submissions as &$submission) {
       $submission_value=$submission->data;
       $i=0;
       foreach($submission_value as $submissionvalue){
            $numItems = count($submission_value);
            if(++$i === $numItems) {
                echo $csv_export="
";
            }else{
                echo $csv_export=$submissionvalue[0].',';
            }
       }
    }

        $file_open = fopen('sites/default/files/csv/csvfile.csv', "a");
        file_put_contents("sites/default/files/csv/csvfile.csv", $csv_export);
    $csv_handler = fopen ('sites/default/files/csv/csvfile.csv','w');
    fwrite ($csv_handler,$csv_export);
    fclose ($csv_handler);

}

My input like multidimensional array

    Array
    (
        [0] => Array
            (
                [2] => Array
                    (
                        [0] => XXXXX
                    )

                [3] => Array
                    (
                        [0] => 2017-06-02
                    )

                [4] => Array
                    (
                        [0] => 2017-06-16
                    )

                [5] => Array
                    (
                        [0] => Tested Value 1
                    )

                [6] => Array
                    (
                        [0] => Tested Value 1
                    )

                [7] => Array
                    (
                        [0] => Tested Value 1
                    )

                [8] => Array
                    (
                        [0] => Tested Value 1
                    )

                [9] => Array
                    (
                        [0] => 
                    )

                [10] => Array
                    (
                        [0] => 
                    )

                [11] => Array
                    (
                        [0] => 
                    )

                [12] => Array
                    (
                        [0] => 
                    )

                [13] => Array
                    (
                        [0] => 
                    )

                [14] => Array
                    (
                        [0] => 
                    )

                [16] => Array
                    (
                        [0] => Tested Value 1
                    )

                [17] => Array
                    (
                        [0] => Tested Value 1
                    )

                [18] => Array
                    (
                        [0] => Tested Value 1
                    )

                [19] => Array
                    (
                        [0] => 
                    )

                [20] => Array
                    (
                        [0] => Tested Value 1
                    )

                [21] => Array
                    (
                        [0] => Tested Value 1
                    )

                [22] => Array
                    (
                        [0] => Tested Value 1
                    )

                [23] => Array
                    (
                        [0] => Tested Value 1
                    )

                [24] => Array
                    (
                        [0] => test@gmail.com
                    )

                [26] => Array
                    (
                        [0] => Tested Value 1
                    )

                [27] => Array
                    (
                        [0] => Tested Value 1
                    )

                [28] => Array
                    (
                        [0] => 
                    )

                [29] => Array
                    (
                        [0] => Tested Value 1
                    )

                [30] => Array
                    (
                        [0] => ST
                    )

                [31] => Array
                    (
                        [0] => 47834
                    )

                [32] => Array
                    (
                        [0] => SH
                    )

                [33] => Array
                    (
                        [0] => test@gmail.com
                    )

                [35] => Array
                    (
                        [0] => Tested Value 1
                    )

                [36] => Array
                    (
                        [0] => Tested Value 1
                    )

                [37] => Array
                    (
                        [0] => 
                    )

                [38] => Array
                    (
                        [0] => Tested Value 1
                    )

                [39] => Array
                    (
                        [0] => DJ
                    )

                [40] => Array
                    (
                        [0] => 0225
                    )

                [41] => Array
                    (
                        [0] => IN
                    )

                [42] => Array
                    (
                        [0] => yes
                    )

                [43] => Array
                    (
                        [0] => 
                    )

                [44] => Array
                    (
                        [0] => 
                    )

                [45] => Array
                    (
                        [0] => 
                    )

                [46] => Array
                    (
                        [0] => 
                    )

                [47] => Array
                    (
                        [0] => 
                    )

                [48] => Array
                    (
                        [0] => 
                    )

                [49] => Array
                    (
                        [0] => 
                    )

                [50] => Array
                    (
                        [0] => 
                    )

                [51] => Array
                    (
                        [0] => 
                    )

                [52] => Array
                    (
                        [0] => 
                    )

                [53] => Array
                    (
                        [0] => 
                    )

                [54] => Array
                    (
                        [0] => (000) 123-4567
                    )

                [55] => Array
                    (
                        [0] => (000) 123-4567
                    )

            )

        [1] => Array
            (
                [2] => Array
                    (
                        [0] => XXXXX
                    )

                [3] => Array
                    (
                        [0] => 2017-06-02
                    )

                [4] => Array
                    (
                        [0] => 2017-06-16
                    )

                [5] => Array
                    (
                        [0] => Tested Value 2
                    )

                [6] => Array
                    (
                        [0] => Tested Value 2
                    )

                [7] => Array
                    (
                        [0] => Tested Value 2
                    )

                [8] => Array
                    (
                        [0] => Tested Value 2
                    )

                [9] => Array
                    (
                        [0] => 
                    )

                [10] => Array
                    (
                        [0] => 
                    )

                [11] => Array
                    (
                        [0] => 
                    )

                [12] => Array
                    (
                        [0] => 
                    )

                [13] => Array
                    (
                        [0] => 
                    )

                [14] => Array
                    (
                        [0] => 
                    )

                [16] => Array
                    (
                        [0] => Tested Value 2
                    )

                [17] => Array
                    (
                        [0] => Tested Value 2
                    )

                [18] => Array
                    (
                        [0] => Tested Value 2
                    )

                [19] => Array
                    (
                        [0] => 
                    )

                [20] => Array
                    (
                        [0] => Tested Value 2
                    )

                [21] => Array
                    (
                        [0] => Tested Value 2
                    )

                [22] => Array
                    (
                        [0] => Tested Value 2
                    )

                [23] => Array
                    (
                        [0] => Tested Value 2
                    )

                [24] => Array
                    (
                        [0] => test@gmail.com
                    )

                [26] => Array
                    (
                        [0] => Tested Value 2
                    )

                [27] => Array
                    (
                        [0] => Tested Value 2
                    )

                [28] => Array
                    (
                        [0] => 
                    )

                [29] => Array
                    (
                        [0] => Tested Value 2
                    )

                [30] => Array
                    (
                        [0] => ST
                    )

                [31] => Array
                    (
                        [0] => 47834
                    )

                [32] => Array
                    (
                        [0] => SH
                    )

                [33] => Array
                    (
                        [0] => test@gmail.com
                    )

                [35] => Array
                    (
                        [0] => Tested Value 2
                    )

                [36] => Array
                    (
                        [0] => Tested Value 2
                    )

                [37] => Array
                    (
                        [0] => 
                    )

                [38] => Array
                    (
                        [0] => Tested Value 2
                    )

                [39] => Array
                    (
                        [0] => DJ
                    )

                [40] => Array
                    (
                        [0] => 0225
                    )

                [41] => Array
                    (
                        [0] => IN
                    )

                [42] => Array
                    (
                        [0] => yes
                    )

                [43] => Array
                    (
                        [0] => 
                    )

                [44] => Array
                    (
                        [0] => 
                    )

                [45] => Array
                    (
                        [0] => 
                    )

                [46] => Array
                    (
                        [0] => 
                    )

                [47] => Array
                    (
                        [0] => 
                    )

                [48] => Array
                    (
                        [0] => 
                    )

                [49] => Array
                    (
                        [0] => 
                    )

                [50] => Array
                    (
                        [0] => 
                    )

                [51] => Array
                    (
                        [0] => 
                    )

                [52] => Array
                    (
                        [0] => 
                    )

                [53] => Array
                    (
                        [0] => 
                    )

                [54] => Array
                    (
                        [0] => (000) 123-4567
                    )

                [55] => Array
                    (
                        [0] => (000) 123-4567
                    )

            )

        [2] => Array
            (
                [2] => Array
                    (
                        [0] => XXXXX
                    )

                [3] => Array
                    (
                        [0] => 2017-06-02
                    )

                [4] => Array
                    (
                        [0] => 2017-06-16
                    )

                [5] => Array
                    (
                        [0] => Tested Value 3
                    )

                [6] => Array
                    (
                        [0] => Tested Value 3
                    )

                [7] => Array
                    (
                        [0] => Tested Value 3
                    )

                [8] => Array
                    (
                        [0] => Tested Value 3
                    )

                [9] => Array
                    (
                        [0] => 
                    )

                [10] => Array
                    (
                        [0] => 
                    )

                [11] => Array
                    (
                        [0] => 
                    )

                [12] => Array
                    (
                        [0] => 
                    )

                [13] => Array
                    (
                        [0] => 
                    )

                [14] => Array
                    (
                        [0] => 
                    )

                [16] => Array
                    (
                        [0] => Tested Value 3
                    )

                [17] => Array
                    (
                        [0] => Tested Value 3
                    )

                [18] => Array
                    (
                        [0] => Tested Value 3
                    )

                [19] => Array
                    (
                        [0] => 
                    )

                [20] => Array
                    (
                        [0] => Tested Value 3
                    )

                [21] => Array
                    (
                        [0] => Tested Value 3
                    )

                [22] => Array
                    (
                        [0] => Tested Value 3
                    )

                [23] => Array
                    (
                        [0] => Tested Value 3
                    )

                [24] => Array
                    (
                        [0] => test@gmail.com
                    )

                [26] => Array
                    (
                        [0] => Tested Value 3
                    )

                [27] => Array
                    (
                        [0] => Tested Value 3
                    )

                [28] => Array
                    (
                        [0] => 
                    )

                [29] => Array
                    (
                        [0] => Tested Value 3
                    )

                [30] => Array
                    (
                        [0] => ST
                    )

                [31] => Array
                    (
                        [0] => 47834
                    )

                [32] => Array
                    (
                        [0] => SH
                    )

                [33] => Array
                    (
                        [0] => test@gmail.com
                    )

                [35] => Array
                    (
                        [0] => Tested Value 3
                    )

                [36] => Array
                    (
                        [0] => Tested Value 3
                    )

                [37] => Array
                    (
                        [0] => 
                    )

                [38] => Array
                    (
                        [0] => Tested Value 3
                    )

                [39] => Array
                    (
                        [0] => DJ
                    )

                [40] => Array
                    (
                        [0] => 0225
                    )

                [41] => Array
                    (
                        [0] => IN
                    )

                [42] => Array
                    (
                        [0] => yes
                    )

                [43] => Array
                    (
                        [0] => 
                    )

                [44] => Array
                    (
                        [0] => 
                    )

                [45] => Array
                    (
                        [0] => 
                    )

                [46] => Array
                    (
                        [0] => 
                    )

                [47] => Array
                    (
                        [0] => 
                    )

                [48] => Array
                    (
                        [0] => 
                    )

                [49] => Array
                    (
                        [0] => 
                    )

                [50] => Array
                    (
                        [0] => 
                    )

                [51] => Array
                    (
                        [0] => 
                    )

                [52] => Array
                    (
                        [0] => 
                    )

                [53] => Array
                    (
                        [0] => 
                    )

                [54] => Array
                    (
                        [0] => (000) 123-4567
                    )

                [55] => Array
                    (
                        [0] => (000) 123-4567
                    )

            )
    )
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试