コード例 #1
0
<?php

error_reporting(0);
include '../include/db.php';
//header to give the order to the browser
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=Registration-info.csv');
//select table to export the data
$select_table = mysql_query('select id, name,email,mobile,created_on from registration');
$rows = mysql_fetch_assoc($select_table);
if ($rows) {
    getcsv(array_keys($rows));
}
while ($rows) {
    getcsv($rows);
    $rows = mysql_fetch_assoc($select_table);
}
// get total number of fields present in the database
function getcsv($no_of_field_names)
{
    $separate = '';
    // do the action for all field names as field name
    foreach ($no_of_field_names as $field_name) {
        if (preg_match('/\\r|\\n|,|"/', $field_name)) {
            $field_name = '' . str_replace('', $field_name) . '';
        }
        echo $separate . $field_name;
        //sepearte with the comma
        $separate = ',';
    }
    //make new row and line
コード例 #2
0
/*
//header to give the order to the browser
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename='.$file);
*/
//select table to export the data
$select_table = $mysqli->query("SELECT tom.OrderNumber,tom.PartNumber,tom.DateOrdered,4 as HardCodedField,tom.QtyOrdered,tom.LineItemApproved FROM `tblorderlineitem` tom ");
//$select_table=$mysqli->query("SELECT * FROM `TABLE 13`");
//$rows = $select_table->fetch_assoc();
$fileRS = fopen($file, 'w');
if ($select_table->num_rows > 0) {
    //getcsv(array_keys($rows));
}
while ($row = $select_table->fetch_assoc()) {
    $row['ShipToID'] = (string) format($row['ShipToID']);
    $csv = getcsv($csv, $row);
    /*    
    getcsv($rows);
    $rows = mysql_fetch_assoc($select_table);
    */
}
fwrite($fileRS, $csv);
fclose($fileRS);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
コード例 #3
0
if (isset($_POST['export_orders']) && isset($_POST['fileName'])) {
    $orders = json_decode($_POST['export_orders']);
    $file = $_POST['fileName'];
    $time = time();
    //header to give the order to the browser
    header('Content-Type: text/csv');
    header('Content-Disposition: attachment;filename=' . $time . '_COLineItems.csv');
    //select table to export the data
    $select_table = $mysqli->query("SELECT tblordersmaster.OrderNumber, PartNumber, PromisedDate, 3 AS HardCodedField ,QtyOrdered FROM tblordersmaster LEFT JOIN `tblorderlineitem` ON tblordersmaster.OrderNumber = `tblorderlineitem`.OrderNumber WHERE LineItemApproved = 'Denied' AND tblordersmaster.OrderNumber IN ('" . implode("','", $orders) . "')");
    //$select_table=$mysqli->query("SELECT * FROM `TABLE 13`");
    //$rows = $select_table->fetch_assoc();
    if ($select_table->num_rows > 0) {
        //getcsv(array_keys($rows));
    }
    while ($row = $select_table->fetch_assoc()) {
        getcsv($row);
        /*    
        getcsv($rows);
        $rows = mysql_fetch_assoc($select_table);
        */
    }
}
// get total number of fields present in the database
function getcsv($no_of_field_names)
{
    $separate = '';
    // do the action for all field names as field name
    foreach ($no_of_field_names as $field_name) {
        if (preg_match('/\\r|\\n|,|"/', $field_name)) {
            $field_name = '' . str_replace('', $field_name) . '';
        }
コード例 #4
0
ファイル: api_data.php プロジェクト: jaksmid/website
 private function data_features_upload()
 {
     // get correct description
     if (isset($_FILES['description']) == false || check_uploaded_file($_FILES['description']) == false) {
         $this->returnError(432, $this->version);
         return;
     }
     // get description from string upload
     $description = $_FILES['description'];
     if (validateXml($description['tmp_name'], xsd('openml.data.features', $this->controller, $this->version), $xmlErrors) == false) {
         $this->returnError(433, $this->version, $this->openmlGeneralErrorCode, $xmlErrors);
         return;
     }
     if (!$this->ion_auth->in_group($this->groups_upload_rights, $this->user_id)) {
         $this->returnError(104, $this->version);
         return;
     }
     $xml = simplexml_load_file($description['tmp_name']);
     $did = '' . $xml->children('oml', true)->{'did'};
     $dataset = $this->Dataset->getById($did);
     if ($dataset == false) {
         $this->returnError(434, $this->version);
         return;
     }
     // prepare array for updating data object
     $data = array('processed' => now());
     if ($xml->children('oml', true)->{'error'}) {
         $data['error'] = "true";
         $data['error_message'] = htmlentities($xml->children('oml', true)->{'error'});
     }
     $this->db->trans_start();
     $success = true;
     //$current_index = -1;
     //copy special features into data_features
     $targets = array_map('trim', explode(",", $dataset->default_target_attribute));
     $rowids = array_map('trim', explode(",", $dataset->row_id_attribute));
     $ignores = getcsv($dataset->ignore_attribute);
     if (!$ignores) {
         $ignores = array();
     }
     foreach ($xml->children('oml', true)->{'feature'} as $q) {
         $feature = xml2object($q, true);
         $feature->did = $did;
         // add special features
         if (in_array($feature->name, $targets)) {
             $feature->is_target = 'true';
         } else {
             //this is needed because the Java feature extractor still chooses a target when there isn't any
             $feature->is_target = 'false';
         }
         if (in_array($feature->name, $rowids)) {
             $feature->is_row_identifier = 'true';
         }
         if (in_array($feature->name, $ignores)) {
             $feature->is_ignore = 'true';
         }
         //actual insert
         $this->Data_feature->insert_ignore($feature);
         // NOTE: this is commented out because not all datasets have targets, or they can have multiple ones. Targets should also be set more carefully.
         // if no specified attribute is the target, select the last one:
         //if( $dataset->default_target_attribute == false && $feature->index > $current_index ) {
         //  $current_index = $feature->index;
         //  $data['default_target_attribute'] = $feature->name;
         //}
     }
     $this->db->trans_complete();
     $this->Dataset->update($did, $data);
     if ($success) {
         $this->xmlContents('data-features-upload', $this->version, array('did' => $dataset->did));
     } else {
         $this->returnError(435, $this->version);
         return;
     }
 }
コード例 #5
0
ファイル: items.php プロジェクト: brijendratiwari/youaudit
 public function exporttocsv()
 {
     $output = array();
     $filename = $this->input->post('filename');
     $allData = explode('|', $this->input->post('allData'));
     foreach ($allData as $key => $value) {
         $output[] = preg_replace('/<\\/?[a-zA-Z]*[^>]*>/', '', preg_replace('/<\\/?[a-zA-Z]*[^>]*>/', '', $value));
     }
     foreach ($output as $key => $value) {
         $output[$key] = explode(',', $value);
     }
     $this->load->helper('csv');
     getcsv($output, "{$filename}.csv");
 }
コード例 #6
0
</oml:description>
	<?php 
if ($task_type->creator) {
    foreach (getcsv($task_type->creator) as $c) {
        ?>
	<oml:contributor><?php 
        echo $c;
        ?>
</oml:contributor>
	<?php 
    }
}
?>
	<?php 
if ($task_type->contributors) {
    foreach (getcsv($task_type->contributors) as $c) {
        ?>
	<oml:contributor><?php 
        echo $c;
        ?>
</oml:contributor>
	<?php 
    }
}
?>
   	<oml:date><?php 
echo dateNeat($task_type->date);
?>
</oml:date>
	<?php 
foreach ($io as $item) {
コード例 #7
0
    public function supplierlist($export = '') {
        $arrPageData['arrSessionData'] = $this->session->userdata;
        if ($export != '') {
            $this->db->select('supplier_name,type,ref_no,support_email,support_number,service_level,response,contract_name,contract_email,contract_no,supplier_address,supplier_city,supplier_state,supplier_postcode');
        } else {
            $this->db->select('*');
        }
        $this->db->where(array('account_id' => $arrPageData['arrSessionData']['objSystemUser']->accountid, 'archive' => 1));
        $res = $this->db->get('suppliers');
        $suppliers = $res->result_array();

        // csv and pdf code

        if ($export == 'CSV') {
            foreach ($suppliers as $key => $value) {
                $output[] = preg_replace('/<\/?[a-zA-Z]*[^>]*>/', '', preg_replace('/<\/?[a-zA-Z]*[^>]*>/', '', $value));
            }

            $this->load->helper('csv');
            getcsv($output, "Supplierlist.csv");
        } elseif ($export == 'PDF') {
            $arrFields = array(
                array('strName' => 'Company Name', 'strFieldReference' => 'supplier_name', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Type', 'strFieldReference' => 'type', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Ref No', 'strFieldReference' => 'ref_no', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Support Email', 'strFieldReference' => 'support_email', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Support Number', 'strFieldReference' => 'support_number', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Service Level', 'strFieldReference' => 'service_level', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Response', 'strFieldReference' => 'response', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Contract Name', 'strFieldReference' => 'contract_name', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Contract Email', 'strFieldReference' => 'contract_email', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Contract Number', 'strFieldReference' => 'contract_no', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Address', 'strFieldReference' => 'supplier_address', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'City', 'strFieldReference' => 'supplier_city', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'State', 'strFieldReference' => 'supplier_state', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
                array('strName' => 'Postcode', 'strFieldReference' => 'supplier_postcode', 'arrFooter' => array('booTotal' => false, 'booTotalLabel' => false, 'intColSpan' => 0)),
            );

            $this->outputPdfFile(date('d/m/Y Gis') . '.pdf', $arrFields, $res->result_array());
        }

        return $suppliers;
    }
コード例 #8
0
 public function getreport()
 {
     $this->load->model('tests_model');
     //        var_dump($this->input->post());
     $data = array();
     $temp0 = explode('/', $this->input->post('from_date'));
     $temp1 = explode('/', $this->input->post('to_date'));
     $from = $temp0[2] . '-' . $temp0[1] . '-' . $temp0[0];
     $to = $temp1[2] . '-' . $temp1[1] . '-' . $temp1[0] . ' 11:59:00';
     if ($this->input->post('item_barcode') == '0' && $this->input->post('manufacturer_items') == '0') {
         $items = explode(',', $this->input->post('item_selected'));
     } else {
         $items = $this->input->post('item_barcode');
     }
     if ($this->input->post('manufacturer_items') != '0') {
         $items = explode(',', $this->input->post('manufacturer_items'));
     }
     $header = array(0 => 'Compliance Name', 1 => 'Category', 2 => 'Frequency', 3 => 'Manager', 4 => 'QR Code', 5 => 'Manufacturer', 6 => 'Model', 7 => 'Owner', 8 => 'Location', 9 => 'Site', 10 => 'Logged By', 11 => 'Due Date', 12 => 'Complete Date', 13 => 'Complete Time', 14 => 'Result');
     $history = $this->tests_model->getComplianceHistoryReport((int) $this->input->post('check_name'), $to, $from, $items);
     foreach ($history as $key => $value) {
         $task_results = array();
         $history[$key]['location_name'] = $this->tests_model->getLocationforHistory($value['test_item_id'], $value['test_date']);
         $history[$key]['owner_name'] = $this->tests_model->getOwnerNameforHistory($value['test_item_id'], $value['test_date']);
         $history[$key]['site_name'] = $this->tests_model->getSiteNameforHistory($value['test_item_id'], $value['test_date']);
         $history[$key]['manager'] = $this->tests_model->getManagerforHistory($value['test_item_id'], $value['test_date']);
         $history[$key]['test_type_name'] = $this->tests_model->getComplianceNameforHistory($value['test_item_id'], $value['test_date']);
         $history[$key]['name'] = $this->tests_model->getCategoryforHistory($value['test_item_id'], $value['test_date']);
         $history[$key]['total_tasks'] = $this->tests_model->getTaskCount($value['test_date']);
         $history[$key]['tasks'] = $this->tests_model->getTaskCount($value['test_date'], 'details');
         if ((int) $value['test_type_id'] == (int) $this->input->post('check_name')) {
             $result = true;
             //                    var_dump($history[$key]['tasks']);
             foreach ($history[$key]['tasks'] as $k => $v) {
                 if ($v['result'] == '0') {
                     $task_results[] = 'Fail';
                     $result = false;
                 } elseif ($v['result'] == '1') {
                     $task_results[] = 'Pass';
                 } else {
                     $task_results[] = $v['result'];
                 }
             }
             $due_date = 'NA';
             if ($value['due_date']) {
                 $due_date = $value['due_date'];
             }
             if ($result) {
                 $result = 'Pass';
             } else {
                 $result = 'Fail';
             }
             $test_date = date('Y-m-d', strtotime($value['test_date']));
             if (date('A', strtotime($value['test_date'])) == 'AM') {
                 $mer = 'PM';
             } else {
                 $mer = 'AM';
             }
             $test_time = date('h:i', strtotime($value['test_date'])) . ' ' . $mer;
             $comp_details = array(0 => $history[$key]['test_type_name'], 1 => $history[$key]['name'], 2 => $value['frequency_name'], 3 => $history[$key]['manager'], 4 => $value['barcode'], 5 => $value['manufacturer'], 6 => $value['model'], 7 => $history[$key]['owner_name'], 8 => $history[$key]['location_name'], 9 => $history[$key]['site_name'], 10 => $value['test_person'], 11 => $due_date, 12 => $test_date, 13 => $test_time, 14 => $result);
             $data[] = array_merge($comp_details, $task_results);
         }
     }
     //        var_dump($history);
     //        var_dump($data);
     //        die;
     if ($history == false) {
         $this->session->set_userdata('booCourier', false);
         $this->session->set_userdata('arrCourier', array('arrUserMessages' => array('There is No Data to Show')));
         redirect('/compliance/report', 'refresh');
     } else {
         $header_part = array();
         $header_part_names = array();
         foreach ($header as $key => $value) {
             array_push($header_part_names, '');
         }
         //            $header_part_names = array(0=>'',1=>'',2=>'',3=>'',4=>'',5=>'',6=>'',7=>'',8=>'',9=>'',10=>'',11=>'',12=>'',13=>'',14=>'');
         foreach ($history[0]['tasks'] as $key => $value) {
             //                var_dump($value['type_of_task']);
             if ((int) $value['type_of_task'] == 0) {
                 //                    echo 'Task Name';
                 array_push($header_part, 'Task Name');
                 array_push($header_part_names, $value['task_name']);
             } else {
                 //                    echo 'Task Measurement Name';
                 array_push($header_part, 'Task Numerical Name');
                 array_push($header_part_names, $value['task_name']);
             }
         }
         $header = array_merge($header, $header_part);
         //            $header_part = implode(',',$header_part);
         //            $header_part_names = implode(',',$header_part_names);
         $final_header = array(0 => $header, 1 => $header_part_names);
         //            var_dump($final_header);die;
         $final_data = array_merge($final_header, $data);
         //            var_dump($final_data);die;
         $this->load->helper('csv');
         getcsv($final_data, "Compliance Report by Check.csv");
     }
 }
コード例 #9
0
ファイル: implementation.php プロジェクト: jaksmid/website
 private function _extendImplementation($implementation)
 {
     $implementation->creator = getcsv($implementation->creator);
     $implementation->contributor = getcsv($implementation->contributor);
     $implementation->parameterSetting = $this->Input->getWhere('implementation_id = "' . $implementation->id . '"');
     $implementation->bibliographicalReference = $this->Bibliographical_reference->getWhere('implementation_id = "' . $implementation->id . '"');
     $implementation->components = $this->getComponents($implementation);
     $implementation->tag = $this->Implementation_tag->getColumnWhere('tag', 'id = ' . $implementation->id);
     foreach (array('binary', 'source') as $type) {
         if ($implementation->{$type . '_file_id'} != false) {
             $file = $this->File->getById($implementation->{$type . '_file_id'});
             if ($file != false) {
                 $implementation->{$type . 'Url'} = fileRecordToUrl($file);
                 $implementation->{$type . 'Format'} = $file->extension;
                 $implementation->{$type . 'Md5'} = $file->md5_hash;
             }
         }
     }
     return $implementation;
 }