本文整理汇总了PHP中array_to_csv函数的典型用法代码示例。如果您正苦于以下问题:PHP array_to_csv函数的具体用法?PHP array_to_csv怎么用?PHP array_to_csv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_to_csv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query_to_csv
function query_to_csv($query, $headers = TRUE, $download = "")
{
if (!is_object($query) or !method_exists($query, 'list_fields')) {
show_error('invalid query');
}
$array = array();
if ($headers) {
$line = array();
foreach ($query->list_fields() as $name) {
$line[] = ucwords(str_replace('_', ' ', $name));
}
$array[] = $line;
}
foreach ($query->result_array() as $row) {
$line = array();
foreach ($row as $item) {
if (dateChecker($item) == true) {
$item = date("D jS F Y", strtotime($item));
}
$line[] = strip_word_html($item);
}
$array[] = $line;
}
echo array_to_csv($array, $download);
}
示例2: query_to_csv
function query_to_csv($query, $headers = TRUE, $download = "")
{
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
{
show_error('invalid query');
}
$array = array();
if ($headers)
{
$line = array();
foreach ($query->list_fields() as $name)
{
$line[] = $name;
}
$array[] = $line;
}
foreach ($query->result_array() as $row)
{
$line = array();
foreach ($row as $item)
{
$line[] = $item;
}
$array[] = $line;
}
echo array_to_csv($array, $download);
}
示例3: create_csv
function create_csv()
{
$query = $this->db->query('SELECT * FROM user ');
// $query=$query->result();
// $num = $query->num_fields();
// // var_dump($num); exit();
// $var =array();
// $i=1;
// $fname="";
// while($i <= $num){
// $test = $i;
// $value = $this->input->post($test);
// if($value != ''){
// $fname= $fname." ".$value;
// array_push($var, $value);
// }
// $i++;
// }
// $fname = trim($fname);
// $fname=str_replace(' ', ',', $fname);
// $this->db->select($fname);
// $quer = $this->db->get('user');
// $quer=$quer->result();
// var_dump($quer); exit();
// query_to_csv($quer,TRUE,'Products_'.date('dMy').'.csv');
$array = array(array('Last Name', 'First Name', 'Gender'), array('Furtado', 'Nelly', 'female'), array('Twain', 'Shania', 'female'), array('Farmer', 'Mylene', 'female'));
//$this->load->helper('csv');
//echo array_to_csv($array);
array_to_csv($array, 'toto.csv');
}
示例4: createcsv
public function createcsv($id_kls = '')
{
if (!$id_kls == '') {
//ambil data nilai
$filter_kls = "p.id_kls = '" . $id_kls . "'";
$temp_nilai = $this->feeder->getrset($this->session->userdata('token'), $this->tbl_nilai, $filter_kls, $this->order, '', $this->offset);
$dumy_nilai = $temp_nilai['result'];
//var_dump($dumy_nilai);
//ambil struktur tabel nilai
$temp_dic = $this->feeder->getdic($this->session->userdata('token'), $this->tbl_nilai);
$dumy_dic = $temp_dic['result'];
$array = array();
$header_nilai = array('no_urut', 'id_kls', 'id_reg_pd', 'nim', 'nm_mhs', 'nilai_angka', 'nilai_huruf', 'nilai_indeks');
$array[] = $header_nilai;
//create content
$i = 0;
foreach ($dumy_nilai as $row) {
++$i;
$filter_mhs_pt = "id_reg_pd = '" . $row['id_reg_pd'] . "'";
$temp_mhs_pt = $this->feeder->getrecord($this->session->userdata('token'), 'mahasiswa_pt', $filter_mhs_pt);
$filter_mhs = "id_pd = '" . $temp_mhs_pt['result']['id_pd'] . "'";
$temp_mhs = $this->feeder->getrecord($this->session->userdata('token'), 'mahasiswa', $filter_mhs);
$content_nilai = array($i, $row['id_kls'], $row['id_reg_pd'], $temp_mhs_pt['result']['nipd'], $temp_mhs['result']['nm_pd'], $row['nilai_angka'], $row['nilai_huruf'], $row['nilai_indeks']);
$array[] = $content_nilai;
}
//$array[] = $header_nilai;
array_to_csv($array, $id_kls . '.csv');
//var_dump($array);
} else {
echo "Cannot create CSV";
}
}
示例5: download
public function download()
{
error_reporting(0);
$this->load->helper('csv');
$this->load->model('crm/lead_call_funnel_model');
// $data['title']="Lead Call funnel";
// $this->load->view('include/header',$data);
// $this->load->view('lead_call_funnel_view');
$leadCallData = array();
//$fh = @fopen( 'php://output', 'w' );
$start_data = $this->input->post('start_date');
$end_date = $this->input->post('end_date');
$type = $this->input->post('type');
$distinct_source = $this->lead_call_funnel_model->distinct_source();
//print_r($distinct_source);
$first_iteration = 1;
$rows = array(array());
$rows[0][0] = 'sources';
$row_count = 0;
foreach ($distinct_source as $row) {
$source = (string) $row->Source;
$rows[][0] = $source;
$getQueries = $this->lead_call_funnel_model->get_query($type);
if ($first_iteration) {
$first_iteration = 0;
foreach ($getQueries as $getQuery) {
$columnName = $getQuery->columnName;
//echo $columnName;
$rows[$row_count][] = $columnName;
}
$row_count = $row_count + 1;
continue;
}
foreach ($getQueries as $getQuery) {
$sqlQuery = $getQuery->sqlQuery;
//echo $columnName;
$rows[$row_count][] = $this->lead_call_funnel_model->main_query($sqlQuery, $source, $start_data, $end_date);
}
$row_count = $row_count + 1;
}
//print_r($first_row);
$list = array(array('aaa', 'bbb', 'ccc', 'dddd'), array('123', '456', '789'), array('"aaa"', '"bbb"'));
array_to_csv($rows, 'toto.csv');
//fputcsv($fh, $first_row);
//fclose($fh);
}
示例6: createcsv
public function createcsv()
{
$separasi = $this->input->post('separasi');
$array = array();
$temp_header = array('nim_mhs', 'nm_mhs', 'semester', 'ips', 'ipk', 'sks_semester', 'sks_total', 'status_mhs');
$array[] = $temp_header;
$sample = array('Nomor Induk Mahasiswa', 'Nama Mahasiswa', 'Semester Mahasiswa (contoh: 20142)', 'IP Semester', 'IP Kumulatif', 'SKS Semester', 'SKS Total', 'Status Mahasiswa (A: Aktif, C: Cuti, D: Drop-out/Putus Studi, L: Lulus, P: , K: Keluar, N: Non Aktif, G: Sedang Double Degree, X: Unknown)');
$array[] = $sample;
$time = time();
//var_dump($array);
$temp_tulis = write_file('temps/' . $time . '_akm.csv', array_to_csv($array, '', $separasi));
//echo "File berhasil digenerate. <a href=\"".base_url()."temps/".$time."_mahasiswa.csv\">Download</a>";
if ($temp_tulis) {
echo "<div class=\"bs-callout bs-callout-success\">\n File berhasil digenerate. <a href=\"" . base_url() . "temps/" . $time . "_akm.csv\">Download</a>\n </div>";
} else {
echo "<div class=\"bs-callout bs-callout-danger\">\n <h4>Error</h4>File tidak bisa digenerate. Folder 'temps' tidak ada atau tidak bisa ditulisi.\n </div>";
}
}
示例7: createcsv
public function createcsv()
{
$id_kls = $this->input->post('id_kls', TRUE);
$separasi = $this->input->post('separasi', TRUE);
if (!$id_kls == '') {
//ambil data nilai
$filter_kls = "p.id_kls = '" . $id_kls . "'";
$temp_nilai = $this->feeder->getrset($this->session->userdata('token'), $this->tbl_nilai, $filter_kls, $this->order, '', $this->offset);
$dumy_nilai = $temp_nilai['result'];
//var_dump($dumy_nilai);
//ambil struktur tabel nilai
$temp_dic = $this->feeder->getdic($this->session->userdata('token'), $this->tbl_nilai);
$dumy_dic = $temp_dic['result'];
$array = array();
$header_nilai = array('no_urut', 'id_kls', 'id_reg_pd', 'nim', 'nm_mhs', 'nilai_angka', 'nilai_huruf', 'nilai_indeks');
$array[] = $header_nilai;
//create content
$i = 0;
foreach ($dumy_nilai as $row) {
++$i;
$filter_mhs_pt = "id_reg_pd = '" . $row['id_reg_pd'] . "'";
$temp_mhs_pt = $this->feeder->getrecord($this->session->userdata('token'), 'mahasiswa_pt', $filter_mhs_pt);
$filter_mhs = "id_pd = '" . $temp_mhs_pt['result']['id_pd'] . "'";
$temp_mhs = $this->feeder->getrecord($this->session->userdata('token'), 'mahasiswa', $filter_mhs);
$content_nilai = array($i, $row['id_kls'], $row['id_reg_pd'], $temp_mhs_pt['result']['nipd'], $temp_mhs['result']['nm_pd'], $row['nilai_angka'], $row['nilai_huruf'], $row['nilai_indeks']);
$array[] = $content_nilai;
}
//$array[] = $header_nilai;
//array_to_csv($array, $id_kls.'.csv');
//var_dump($array);
$date = date('Y-m-d');
$time = time();
write_file('temps/nilai_' . $date . '-' . $time . '.csv', array_to_csv($array, '', $separasi));
//echo "File berhasil digenerate. <a href=\"".base_url()."temps/".$time."_mahasiswa.csv\">Download</a>";
echo "<div class=\"bs-callout bs-callout-success\">\n File berhasil digenerate. <a href=\"" . base_url() . "temps/nilai_" . $date . '-' . $time . ".csv\">Download</a>\n </div>";
} else {
echo "Cannot create CSV";
}
}
示例8: query_to_csv
function query_to_csv($query, $headers = TRUE, $download = "")
{
if (!is_object($query) or !method_exists($query, 'getFieldNames')) {
show_error('invalid query: ' . $query);
}
$array = array();
if ($headers) {
$line = array();
foreach ($query->getFieldNames() as $name) {
$line[] = $name;
}
$array[] = $line;
}
foreach ($query->toArray() as $row) {
$line = array();
foreach ($row as $item) {
$line[] = $item;
}
$array[] = $line;
}
echo array_to_csv($array, $download);
}
示例9: createCSV
function createCSV()
{
$pharmacy_stateId = $this->input->post('pharmacy_stateId');
$pharmacy_cityId = $this->input->post('pharmacy_cityId');
if ($pharmacy_stateId != '' && $pharmacy_stateId != null) {
$pharmacy_stateId = $this->input->post('pharmacy_stateId');
}
if ($pharmacy_cityId != '' && $pharmacy_cityId != null) {
$pharmacy_cityId = $this->input->post('pharmacy_cityId');
}
$where = array('pharmacy_deleted' => 0, 'pharmacy_cityId' => $pharmacy_cityId, 'pharmacy_stateId' => $pharmacy_stateId);
// print_r($where); exit;
$array[] = array('Image Name', 'Pharmacy Name', 'City', 'Phone Number', 'Address');
$data = $this->Pharmacy_model->createCSVdata($where);
$arrayFinal = array_merge($array, $data);
array_to_csv($arrayFinal, 'PharmacyDetail.csv');
return True;
exit;
}
示例10: directCall
public function directCall($item = "", $param = "")
{
$dbArr = array();
switch ($item) {
case "export":
if ($_GET['area_no'] != "" && $_GET['area_no'] != "'<ALL>'") {
$isoWhere = "AND area_no in ({$_GET['area_no']})";
}
if ($_GET['rsOption'] > 0) {
$spoolWhere = "AND spool.workable_dt " . ($_GET['rsOption'] == 1 ? "!= NULL" : "= NULL");
}
$fieldVal = "";
if (isset($_GET['fieldF']) && is_array($_GET['fieldF'])) {
foreach ($_GET['fieldF'] as $field => $val) {
$res = explode(";", $val);
$fieldVal .= " AND " . $res[0] . $this->operatorArr[$res[2]] . $res[1] . (in_array($res[2], $this->blankThis) ? "" : "%") . "'";
}
}
foreach ($this->iso_model->area_query_export(isset($fieldVal) ? $fieldVal : "", isset($isoWhere) ? $isoWhere : "", isset($spoolWhere) ? $spoolWhere : "") as $r) {
foreach ($r as $r2 => $v2) {
if (is_object($v2)) {
$date_array = (array) $v2;
$date_time = $date_array['date'];
$date_only = explode(" ", $date_time);
$r[$r2] = $date_only[0];
}
}
array_push($dbArr, $r);
}
// ------ Create and download csv ----
$csv = array_to_csv($dbArr, "area_query.csv");
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="area_query.csv"');
$csv = urldecode($csv);
echo $csv;
return true;
break;
case "export_insTo":
$this->read("inst_takeoff", "get_all_export", $fieldVal, $dbArr);
// ------ Create and download csv ----
$csv = array_to_csv($dbArr, "insto.csv");
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="insto.csv"');
$csv = urldecode($csv);
echo $csv;
return true;
break;
case "client":
$fieldVal = $this->session->userdata('department') == "MIS" ? "1" : "short_desc != 'ARCC'";
$this->load->model('portal/rclient_model');
$this->read("rclient", "get_all", $fieldVal, $dbArr);
break;
case "files":
//echo (!isset($_GET['tgHist']) || $_GET['tgHist'] == 1) ? "here" : " AND date_open is null";
$fieldVal = " ";
if (isset($_GET['type_of_trans']) && $_GET['type_of_trans'] == "download") {
//$fieldVal = " find_in_set({$_GET['client_id']},recipients) > 0 AND find_in_set({$this->session->userdata('id')},users) > 0";
$fieldVal = " find_in_set({$_GET['client_id']},recipients) > 0 AND find_in_set({$this->session->userdata('id')},users) > 0 " . (!isset($_GET['tgHist']) || $_GET['tgHist'] == 1 ? "" : " AND date_open is null");
} else {
$fieldVal = " t.log_created like '{$this->session->userdata('user_id')}%'";
}
$this->load->model('portal/files_model');
$this->read("files", "get_all", $fieldVal, $dbArr);
// foreach ($dbArr as $key => $value) {
// foreach ($value as $key2 => $value2) {
// if ($key2 == "name")
// $dbArr[$key][$key2] = str_replace("'", "\\'", $value2);
// }
// }
break;
case "client_cretorId":
// $fieldVal = ($this->session->userdata('department') == "MIS" ? "1" : ("t.log_created like '" . $this->session->userdata('user_id') . "%'"));
// $fieldVal = "t.log_created like '" . $this->session->userdata('user_id') . "%' and t.user_id != '" . $this->session->userdata('user_id') . "'"; //improvements
//$fieldVal = "find_in_set(t.id,'" . $_GET['follows'] . "') != 0 and t.user_id != '" . $this->session->userdata('user_id') . "'"; //improvements
$fieldVal = "t.department = '{$_GET['creator']}' and t.user_id != '" . $this->session->userdata('user_id') . "'";
$this->load->model('portal/ruser_model');
$this->read("ruser", "get_all", $fieldVal, $dbArr);
break;
case "user_assign":
// $fieldVal = ($this->session->userdata('department') == "MIS" ? "1" : ("t.log_created like '" . $this->session->userdata('user_id') . "%'"));
// $fieldVal = "t.log_created like '" . $this->session->userdata('user_id') . "%' and t.user_id != '" . $this->session->userdata('user_id') . "'"; //improvements
//$fieldVal = "find_in_set(t.id,'" . $_GET['follows'] . "') != 0 and t.user_id != '" . $this->session->userdata('user_id') . "'"; //improvements
$fieldVal = "t.client_id != 15";
//t.creator = '' and
$this->load->model('portal/ruser_model');
$this->read("ruser", "get_all", $fieldVal, $dbArr);
break;
case "user":
// $fieldVal = ($this->session->userdata('department') == "MIS" ? "1" : ("t.log_created like '" . $this->session->userdata('user_id') . "%'"));
// $fieldVal = "t.log_created like '" . $this->session->userdata('user_id') . "%' and t.user_id != '" . $this->session->userdata('user_id') . "'"; //improvements
$fieldVal = "find_in_set(t.id,'" . $_GET['follows'] . "') != 0 and t.user_id != '" . $this->session->userdata('user_id') . "'";
//improvements
$this->load->model('portal/ruser_model');
$this->read("ruser", "get_all", $fieldVal, $dbArr);
break;
case "modified_connect":
if ($this->session->userdata('department') == "MIS") {
if ($_GET['type'] == "1") {
$fieldVal = "find_in_set(t.id,'" . $_GET['follows'] . "') != 0 and t.user_id != '" . $this->session->userdata('user_id') . "'";
} else {
//.........这里部分代码省略.........
示例11: createCSV
function createCSV()
{
$stateId = '';
$cityId = '';
if (isset($_POST['diagnostic_stateId'])) {
$stateId = $this->input->post('diagnostic_stateId');
}
if (isset($_POST['diagnostic_cityId'])) {
$cityId = $this->input->post('diagnostic_cityId');
}
$where = array('diagnostic_deleted' => 0, 'diagnostic_cityId' => $cityId, 'diagnostic_stateId' => $stateId);
$array[] = array('Image Name', 'Diagnostic Name', 'City', 'Phone Number', 'Address');
$data = $this->diagnostic_model->createCSVdata($where);
$arrayFinal = array_merge($array, $data);
array_to_csv($arrayFinal, 'DiagnosticDetail.csv');
return True;
exit;
}
示例12: createCSV
/**
* @project Qyura
* @method createCSV
* @description reviews create csv file
* @access public
* @return array
*/
function createCSV()
{
$sDate = '';
$eDate = '';
if (isset($_POST['date-1']) && isset($_POST['date-2']) && !empty($_POST['date-1']) && !empty($_POST['date-2'])) {
$sDate = $this->input->post('date-1');
$eDate = $this->input->post('date-2');
}
$filter = $this->input->post('filter');
$reviews = $this->reviews_model->fetchReviews(array('filter' => $filter, 'sDate' => $sDate, 'eDate' => $eDate));
$result = array();
$i = 1;
$imgUrl = base_url() . 'assets/patientImages/';
foreach ($reviews as $key => $val) {
$result[$i]['reviewBy'] = $val['reviewBy'];
$result[$i]['patientDetails_patientImg'] = $imgUrl . $val['patientDetails_patientImg'];
$result[$i]['reviews_details'] = $val['reviews_details'];
$result[$i]['reviews_rating'] = $val['reviews_rating'];
$result[$i]['reviewTo'] = $val['reviewTo'];
$result[$i]['reviews_post_details'] = $val['reviews_post_details'];
$result[$i]['creationTime'] = date('d F Y h:i:s A', $val['creationTime']);
$i++;
}
$array[] = array('Patient Name', 'Patient Image', 'Patient Review', 'Rating', 'MI Name', 'MI Comment', 'Review Date');
$arrayFinal = array_merge($array, $result);
array_to_csv($arrayFinal, 'Reviews.csv');
return True;
exit;
}
示例13: download
function download($statement, $id = NULL)
{
/********************** TRIAL BALANCE *************************/
if ($statement == "trialbalance") {
$this->load->model('Ledger_model');
$all_ledgers = $this->Ledger_model->get_all_ledgers();
$counter = 0;
$trialbalance = array();
$temp_dr_total = 0;
$temp_cr_total = 0;
$trialbalance[$counter] = array("TRIAL BALANCE", "", "", "", "", "", "", "", "");
$counter++;
$trialbalance[$counter] = array("FY " . date_mysql_to_php($this->config->item('account_fy_start')) . " - " . date_mysql_to_php($this->config->item('account_fy_end')), "", "", "", "", "", "", "", "");
$counter++;
$trialbalance[$counter][0] = "Ledger";
$trialbalance[$counter][1] = "";
$trialbalance[$counter][2] = "Opening";
$trialbalance[$counter][3] = "";
$trialbalance[$counter][4] = "Closing";
$trialbalance[$counter][5] = "";
$trialbalance[$counter][6] = "Dr Total";
$trialbalance[$counter][7] = "";
$trialbalance[$counter][8] = "Cr Total";
$counter++;
foreach ($all_ledgers as $ledger_id => $ledger_name) {
if ($ledger_id == 0) {
continue;
}
$trialbalance[$counter][0] = $ledger_name;
list($opbal_amount, $opbal_type) = $this->Ledger_model->get_op_balance($ledger_id);
if (float_ops($opbal_amount, 0, '==')) {
$trialbalance[$counter][1] = "";
$trialbalance[$counter][2] = 0;
} else {
$trialbalance[$counter][1] = convert_dc($opbal_type);
$trialbalance[$counter][2] = $opbal_amount;
}
$clbal_amount = $this->Ledger_model->get_ledger_balance($ledger_id);
if (float_ops($clbal_amount, 0, '==')) {
$trialbalance[$counter][3] = "";
$trialbalance[$counter][4] = 0;
} else {
if (float_ops($clbal_amount, 0, '<')) {
$trialbalance[$counter][3] = "Cr";
$trialbalance[$counter][4] = convert_cur(-$clbal_amount);
} else {
$trialbalance[$counter][3] = "Dr";
$trialbalance[$counter][4] = convert_cur($clbal_amount);
}
}
$dr_total = $this->Ledger_model->get_dr_total($ledger_id);
if ($dr_total) {
$trialbalance[$counter][5] = "Dr";
$trialbalance[$counter][6] = convert_cur($dr_total);
$temp_dr_total = float_ops($temp_dr_total, $dr_total, '+');
} else {
$trialbalance[$counter][5] = "";
$trialbalance[$counter][6] = 0;
}
$cr_total = $this->Ledger_model->get_cr_total($ledger_id);
if ($cr_total) {
$trialbalance[$counter][7] = "Cr";
$trialbalance[$counter][8] = convert_cur($cr_total);
$temp_cr_total = float_ops($temp_cr_total, $cr_total, '+');
} else {
$trialbalance[$counter][7] = "";
$trialbalance[$counter][8] = 0;
}
$counter++;
}
$trialbalance[$counter][0] = "";
$trialbalance[$counter][1] = "";
$trialbalance[$counter][2] = "";
$trialbalance[$counter][3] = "";
$trialbalance[$counter][4] = "";
$trialbalance[$counter][5] = "";
$trialbalance[$counter][6] = "";
$trialbalance[$counter][7] = "";
$trialbalance[$counter][8] = "";
$counter++;
$trialbalance[$counter][0] = "Total";
$trialbalance[$counter][1] = "";
$trialbalance[$counter][2] = "";
$trialbalance[$counter][3] = "";
$trialbalance[$counter][4] = "";
$trialbalance[$counter][5] = "Dr";
$trialbalance[$counter][6] = convert_cur($temp_dr_total);
$trialbalance[$counter][7] = "Cr";
$trialbalance[$counter][8] = convert_cur($temp_cr_total);
$this->load->helper('csv');
echo array_to_csv($trialbalance, "trialbalance.csv");
return;
}
/********************** LEDGER STATEMENT **********************/
if ($statement == "ledgerst") {
$ledger_id = (int) $this->uri->segment(4);
if ($ledger_id < 1) {
return;
}
$this->load->model('Ledger_model');
//.........这里部分代码省略.........
示例14: getExportResults
//.........这里部分代码省略.........
if ($opt['superFilter']) {
$this->db->join($this->getTableName('filters') . ' f1', 'f1.imported_data_id = a.imported_data_id');
$this->db->where_in('f1.chronicle_id', $opt['chronicle']);
$this->db->where('f1.filter_id', $opt['superFilter']);
}
// If searchFilter exists and not empty
if ($opt['searchFilter'] && !empty($opt['searchFilter'])) {
switch ($opt['searchColumn']) {
case 'average_review':
case 'column_reviews':
case 'images_cmp':
case 'video_count':
case 'content_health_score_normalized':
case 'long_description_wc':
case 'short_description_wc':
case 'total_description_wc':
case "Meta_Description_Count":
case 'product_name_length':
//$this->db->where("a.row_data ~* '\"" . $opt['searchColumn'] . "\":([0-9]*)" . $opt['searchFilter'] . "([0-9]*),'");
$this->db->where("REPLACE(a.row_data,'\\','') ~* '\"" . $opt['searchColumn'] . "([0-9])?\":(\"{1,})?([0-9]*)" . $opt['searchFilter'] . "([0-9]*)(\"{1,})?,'");
break;
case "title_seo_phrases":
$this->db->where("REPLACE(regexp_replace(regexp_replace(a.row_data, '<[^>]+display[^>]+none[^>]+>[^>]+>', '', 'g'), '<.*?>', '', 'g'),'\\','') ~* '\"" . $type_column . "\":\"([^\"]*)" . $sSearch . "([^\"]*)\"'");
break;
case 'prodcat':
$this->db->join($this->getTableName('brands') . ' b', 'b.id = a.brand_id', 'left');
$this->db->join($this->getTableName('product_categories') . ' p', 'p.id = a.category_id', 'left');
$this->db->where('"p"."category_name" ILIKE \'%' . $opt['searchFilter'] . '%\'');
break;
case 'brand':
$this->db->join($this->getTableName('brands') . ' b', 'b.id = a.brand_id', 'left');
$this->db->join($this->getTableName('product_categories') . ' p', 'p.id = a.category_id', 'left');
$this->db->where('"b"."name" ILIKE \'%' . $opt['searchFilter'] . '%\'');
break;
case 'price_diff':
if (strstr($opt['searchFilter'], '.')) {
$this->db->where("REPLACE(a.row_data,'\\','') ~* '\"own_price\":(\"{1,})?" . $opt['searchFilter'] . "(.*)?(\"{1,})?,'");
} else {
$this->db->where("REPLACE(a.row_data,'\\','') ~* '\"own_price\":(\"{1,})?" . $opt['searchFilter'] . "(\\..*)?(\"{1,})?,'");
}
break;
default:
$this->db->where("REPLACE(regexp_replace(a.row_data, '<.*?>', '', 'g'),'\\','') ~* '\"" . $opt['searchColumn'] . "\":\"([^\"]*)" . $opt['searchFilter'] . "([^\"]*)\"'");
}
//$this->db->where('a.row_data LIKE \'%"'.$opt['searchColumn'].'":"%'.$opt['searchFilter'].'%"%\'');
}
$this->db->where_in('f.chronicle_id', $opt['chronicle']);
$this->db->where_in('a.combination', $opt['chronicle']);
$query = $this->db->get($this->getTableName('filters') . ' f');
// Returning empty array if result empty
if ($query->num_rows() == 0) {
return array();
}
$this->load->helper('csv');
// Checking each row for lines
$result = '';
$count = 0;
if ($mode == 'export_primary') {
while ($val = pg_fetch_object($query->result_id)) {
$result .= $val->url . PHP_EOL;
$count++;
}
} else {
while ($val = pg_fetch_object($query->result_id)) {
// Trying to decode unstripped data
$row = json_decode(strip_tags($val->row_data), TRUE);
// If such operation wasn`t succesfull - trying to unstrip each part
if ($row === NULL) {
$row = array();
$row_parts = json_decode($val->row_data, TRUE);
// If decoded json is not array - skipping current row
if (!is_array($row_parts)) {
continue;
}
foreach ($row_parts as $part_key => &$part_val) {
// Decoding only needed parts
if (isset($line[$part_key])) {
$row[$part_key] = strip_tags($part_val);
}
}
unset($row_parts);
}
// Getting data for each line
$temp = array();
foreach ($line as $key => $line_value) {
if (isset($row[$key])) {
$temp[] = $row[$key];
}
unset($row_parts);
}
if ($temp) {
$result .= array_to_csv(array($temp));
$count++;
}
}
}
$query->free_result();
unset($query);
return array('data' => $result, 'count' => $count);
}
示例15: index
//.........这里部分代码省略.........
$total_due_amount_additional = 0;
$total_due_tax = 0;
$total_due_tax_additional = 0;
$total_collection = 0;
$total_balance = 0;
foreach ($due_report as $due) {
$total_sale_amount += $due['purchase_cost'];
$total_due_amount += $due['due_amount'];
$total_due_amount_additional += $due['due_amount_additional'];
$total_due_tax += $due['total_tax'];
$total_due_tax_additional += $due['total_tax_additional'];
$total_collection += $due['total_amt'];
$total_balance += $due['due_amount'] + $due['total_tax'] + $due['due_amount_additional'] + $due['total_tax_additional'] - $due['total_amt'];
$html .= '<tr>';
$html .= '<td width="30">' . ($n + 1) . '</td>';
$html .= '<td width="65">' . date('d-m-Y', strtotime($due['booking_date'])) . '</td>';
$html .= '<td width="75">' . $due['client_name'] . '</td>';
$html .= '<td width="60">' . $due['project'] . '</td>';
$html .= ' <td width="40">' . number_format($due['rate']) . '</td>';
$html .= ' <td width="65">' . number_format($due['purchase_cost']) . '</td>';
$html .= ' <td width="65">' . number_format($due['due_amount_additional'] + $due['total_tax_additional'] + ($due['due_amount'] + $due['total_tax'])) . '</td>';
$html .= ' <td width="65">' . number_format($due['total_amt']) . '</td>';
$html .= ' <td width="65">' . number_format($due['due_amount'] + $due['total_tax'] + $due['due_amount_additional'] + $due['total_tax_additional'] - $due['total_amt']) . '</td>';
$html .= '<td width="60">' . $due['sales_region'] . '</td>';
$html .= '<td width="60">' . $due['sales_person'] . '</td>';
$html .= '</tr>';
$n++;
}
$html .= '</tbody>';
$html .= '<tfoot>';
$html .= '<tr style="font-weight: bolder">';
$html .= '<td colspan="5"></td>';
$html .= '<td>' . number_format($purchase_cost) . '</td>';
$html .= '<td>' . number_format($due_amount + $due_amount_additional + $total_tax + $total_tax_additional) . '</td>';
$html .= '<td>' . number_format($total_amt_collected) . '</td>';
$html .= '<td>' . number_format($due_amount + $due_amount_additional + $total_tax + $total_tax_additional - $total_amt_collected) . '</td>';
$html .= '<td></td>';
$html .= '<td></td>';
$html .= '</tr>';
$html .= '</tfoot>';
$html .= '</table><br /><br />';
//echo $html;
//exit();
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
$pdf->Output('receipt.pdf', 'I');
} elseif (isset($_POST['generate_csv'])) {
$csv_array = array();
$csv_array_line = array();
$csv_array_line[] = 'No.';
$csv_array_line[] = 'Date of Booking';
$csv_array_line[] = 'Client Name';
$csv_array_line[] = 'Contact Number';
$csv_array_line[] = 'Email';
$csv_array_line[] = 'Area';
$csv_array_line[] = 'Rate';
$csv_array_line[] = 'Project';
$csv_array_line[] = 'Sale Value';
$csv_array_line[] = 'Prin Amt Due';
$csv_array_line[] = 'Tax Amt Due';
$csv_array_line[] = 'Additional Due';
$csv_array_line[] = 'Additional Due Tax';
$csv_array_line[] = 'Total Due';
$csv_array_line[] = 'Total Collection';
$csv_array_line[] = 'Balance Due';
$csv_array_line[] = 'Sales Region';
$csv_array_line[] = 'Sales Person';
$csv_array[] = $csv_array_line;
foreach ($due_report as $due) {
$csv_array_line = array();
$csv_array_line[] = $n + 1;
$csv_array_line[] = date('d-m-Y', strtotime($due['booking_date']));
$csv_array_line[] = $due['client_name'];
$csv_array_line[] = $due['phone'];
$csv_array_line[] = $due['email'];
$csv_array_line[] = $due['area'];
$csv_array_line[] = $due['rate'];
$csv_array_line[] = $due['project'];
$csv_array_line[] = $due['due_amount'] + $due['due_amount_additional'];
$csv_array_line[] = $due['due_amount'];
$csv_array_line[] = $due['total_tax'];
$csv_array_line[] = $due['due_amount_additional'];
$csv_array_line[] = $due['total_tax_additional'];
$csv_array_line[] = $due['due_amount_additional'] + $due['total_tax_additional'] + ($due['due_amount'] + $due['total_tax']);
$csv_array_line[] = $due['total_amt'];
$csv_array_line[] = $due['due_amount'] + $due['total_tax'] + $due['due_amount_additional'] + $due['total_tax_additional'] - $due['total_amt'];
$csv_array_line[] = $due['sales_region'];
$csv_array_line[] = $due['sales_person'];
$csv_array[] = $csv_array_line;
}
echo array_to_csv($csv_array, 'due_letter.csv');
exit;
} else {
$data['due_report'] = $due_report;
$data['from_date_selected'] = $this->input->post('from_date');
$data['to_date_selected'] = $this->input->post('to_date');
$data['project_selected'] = $this->input->post('project');
$this->load->view('reports/sales_report', $data);
}
}
}