function exportAllData($inbox) { global $uid; $delim = ','; $db = DB_DataObject::factory($inbox ? 'playsms_tblUserInbox' : 'playsms_tblSMSOutgoing'); if (isadmin() && !$uid) { } else { if ($inbox) { $db->in_uid = $uid; } else { $db->uid = $uid; } } if ($inbox) { $db->in_hidden = '0'; $orderBy = "in_id DESC"; $filename = "inbox-export.csv"; } else { $db->flag_deleted = '0'; $filename = "outbox-export.csv"; $orderBy = "smslog_id DESC"; } // send the file contents to the browser // so that it'll prompt the user to save it header('Content-type: text/csv'); header("Content-Disposition: attachment; filename=\"{$filename}\""); $line = "id,date,phone number"; if (!$inbox) { $line .= ",status"; } $line .= ",message\n"; echo $line; $db->orderBy($orderBy); $db->find(); while ($db->fetch()) { if ($inbox) { $msg = prepLongFieldForCsv($db->in_msg); $line = $db->in_id . $delim . $db->in_datetime . $delim . $db->in_sender . $delim . "\"{$msg}\"" . "\n"; } else { $msg = prepLongFieldforCsv($db->p_msg); $line = $db->smslog_id . $delim . $db->p_datetime . $delim . $db->p_dst . $delim . getStatusName($db->p_status) . $delim . "\"{$msg}\"" . "\n"; } echo $line; } }
function makeList($uid, $selfurl, $offset = 0, $numShow = 75) { $db = DB_DataObject::factory('playsms_tblSMSOutgoing'); if (!$offset) { $offset = 0; } $db->limit($offset, $numShow); $db->orderBy("smslog_id DESC"); $pagetitle = "Delivery report"; if (isadmin() && !$uid) { $pagetitle .= " (All)"; } else { $db->uid = $uid; } $db->flag_deleted = '0'; if ($offset) { $newOffset = $offset - $numShow; $prevUrl = "{$selfurl}&offset={$newOffset}"; } else { $prevUrl = "#"; } $newOffset = $offset + $numShow; $nextUrl = "{$selfurl}&offset={$newOffset}"; $exportUrl = "{$selfurl}&op=export"; $linksPrevNext = "<a href='{$prevUrl}'>[ Prev] </a>\n \t\t \t\t <a href='{$nextUrl}'>[ Next ]</a>\n <a href='{$exportUrl}'>[ Export ]</a>"; // create hidden form with the // id to delete, this way it will // get POSTed // $delForm = generateActionSubmitter("del", "{$selfurl}&op=del", "smslog_id"); $resendForm = generateActionSubmitter("resend", "{$selfurl}&op=resend", "smslog_id"); $content = "{$delForm} \n {$resendForm}\n \t\t <h2>{$pagetitle}</h2>\n \t\t <p/>\n\t\t\t\t{$linksPrevNext}\n \t\t <p/>\n \t\t <table width=100% cellpadding=1 cellspacing=1 border=1>\n \t\t <tr>\n \t\t <td align=center class=box_title width=2%>id</td>\n \t\t <td align=center class=box_title width=12%>Time</td>\n \t\t <td align=center class=box_title width=12%>Receiver</td>\n \t\t <td align=center class=box_title width=50%>Message</td>\n \t\t <td align=center class=box_title width=8%>Status</td>\n \t\t <td align=center class=box_title width=8%>Group</td>\n \t\t <td align=center class=box_title width=8%>Action</td>\n \t\t </tr>\n \t\t"; $db->find(); while ($db->fetch()) { $p_desc = pnum2pdesc($db->p_dst); $current_p_dst = $db->p_dst; if ($p_desc) { $current_p_dst = "{$db->p_dst}<br/>({$p_desc})"; } $hide_p_dst = $db->p_dst; if ($p_desc) { $hide_p_dst = "{$p_dst} ({$p_desc})"; } $p_sms_type = $db->p_sms_type; $hide_p_dst = str_replace("\\'", "", $hide_p_dst); $hide_p_dst = str_replace("\"", "", $hide_p_dst); $p_msg = nl2br($db->p_msg); if (($p_footer = $db->p_footer) && ($p_sms_type == "text" || $p_sms_type == "flash")) { $p_msg = $p_msg . " {$p_footer}"; } $p_datetime = $db->p_datetime; $p_update = $db->p_update; $p_status = $db->p_status; $p_gpid = $db->p_gpid; $status_color = getStatusColor($p_status); $status_name = getStatusName($p_status); $p_status = "<font color={$status_color}>{$status_name}</font> <br/>({$db->send_tries} tries)"; $p_status .= " {$db_row['p_status']}"; if ($p_gpid) { $db_query1 = "SELECT gp_code FROM playsms_tblUserGroupPhonebook WHERE gpid='{$p_gpid}'"; $db_result1 = dba_query($db_query1); $db_row1 = dba_fetch_array($db_result1); $p_gpcode = strtoupper($db_row1[gp_code]); } else { $p_gpcode = " "; } $deleteCode = "javascript: del({$db->smslog_id}, " . "'Are you sure you want to delete outgoing SMS to `{$hide_p_dst}`, number {$db->smslog_id} ?');"; $resendCode = "javascript: resend({$db->smslog_id});"; $actionCode = "<a href=\"{$deleteCode}\">[Delete]</a> <br/>\n\t\t <a href=\"{$resendCode}\">[Resend]</a>"; $content .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td valign=top class=box_text align=left width=2%>{$db->smslog_id}</td>\n\t\t\t\t\t<td valign=top class=box_text align=center width=12%>{$db->p_datetime}</td>\n\t\t\t\t\t<td valign=top class=box_text align=center width=12%>{$current_p_dst}</td>\n\t\t\t\t\t<td valign=top class=box_text align=left width=50%>{$p_msg}</td>\n\t\t\t\t\t<td valign=top class=box_text align=center width=8%>{$p_status}</td>\n\t\t\t\t\t<td valign=top class=box_text align=center width=8%>{$p_gpcode}</td>\n\t\t\t\t\t<td valign=top class=box_text align=center width=8%>\n\t\t\t\t\t\t{$actionCode}\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t "; } $content .= "</form></table>\n \t\t\t<p/>\n \t\t {$linksPrevNext}"; return $content; }
protected function setInfoCart66() { include_once PLUGIN_PATH_SHIPWORKSWORDPRESS . 'functions/cart66/functionsCart66.php'; global $wpdb; $table = $wpdb->prefix . "cart66_cart_settings"; $rows = $wpdb->get_results("SELECT * FROM " . $table, ARRAY_A); foreach ($rows as $line) { if ($line['key'] == 'status_options') { $val = $line['value']; } } $status = preg_split("/,/", $val); if ($val != null) { $tab = array(); $i = 1; foreach ($status as $stat) { $tab[$i] = trim($stat); $i++; } $status = $tab[$this->status]; } else { $status = getStatusName($this->status); } $table = $wpdb->prefix . "cart66_orders"; $this->result = $wpdb->update($table, array('status' => $status), array('id' => $this->order)); if ($this->result === false) { $this->code = 'ERR004'; $this->description = "The Status coudn't be update in the database"; } else { if ($this->comment != '') { /*add_comment( $this->comment, $this->order );*/ } } }