?> <?php if (!$is_ajax) { ?> <?php if ($related_tables) { ?> <?php $i = 0; ?> <tr> <td style="text-transform:uppercase; font-weight:bold; font-size:10px;">Note: Once you submit, you will be able to add <?php foreach ($related_tables as $rt) { $i++; echo humanizer($rt->table_name) . ($i == sizeof($related_tables) ? ' ' : ', '); } ?> </td> </tr> <?php } ?> <?php } ?> </table> </td> </tr> </table>
<?php if (isset($s_status)) { ?> <div class="<?php echo $s_status; ?> "><?php echo urldecode($s_message); ?> </div> <?php } ?> <p>Refunds for <?php echo singular(humanizer($table_name)); ?> # <?php echo remove_semicol($dataid); ?> </p> <table style="width:100%" class="borderless"> <tr><td style="width:150px;">Grand Total:</td><td>$<?php echo my_number_format($grand_total); ?> </td></tr> <tr><td>Refunds to date:</td><td>$<?php echo my_number_format($refunded); ?> </td></tr> <tr><td>Shipping Refund:</td><td>$<input size="3" class="max_num" max="<?php
echo form_open(base_url() . '_search', 'method="get" class="_searchform"'); ?> <span class="big_input"><input type="text" value="search..." name="search" class="_search"/></span> <span class="big_select"> <select name="table" class="searchtable"> <?php $dataset = $this->db->query("SELECT table_name FROM cms_table_rules where is_hidden=0")->result(); ?> <?php foreach ($dataset as $data) { ?> <option value="<?php echo $data->table_name; ?> ">in <?php echo humanizer(plural($data->table_name)); ?> </option> <?php } ?> </select> </span> <input type="submit" value="Go ›"/> <?php echo form_close(); ?> <?php } ?> </div>
<input type="hidden" name="__keyword_primary_table" value="<?php echo $primary_table; ?> "/> <input type="hidden" name="__keyword_primary_table_id" value="<?php echo $primary_table_id; ?> "/> <?php // now display normal form ?> <?php foreach ($fields as $field) { ?> <?php echo humanizer($field->COLUMN_NAME); ?> :<br/> <?php if ($field->DATA_TYPE == 'int' || $field->DATA_TYPE == 'varchar' || $field->DATA_TYPE == 'tinyint' || $field->DATA_TYPE == 'bigint' || $field->DATA_TYPE == 'timestamp' || $field->DATA_TYPE == 'datetime') { ?> <input type="text" class="proxy_contents" name="<?php echo $field->COLUMN_NAME; ?> " value="<?php echo $field->COLUMN_DEFAULT; ?> "/><br/> <?php } elseif ($field->DATA_TYPE == 'longtext' || $field->DATA_TYPE == 'mediumtext' || $field->DATA_TYPE == 'text') { ?>
function searchFields($data) { $data = (array) $data; $field_structure = array('name' => $data['column_name'], 'id' => $data['column_name']); if ($data['data_type'] == 'varchar' || $data['data_type'] == 'text') { $ret = "<td>" . humanizer(singular($data['table_name']) . ' ' . $data['column_name']) . ':</td><td>' . form_input($field_structure, isset($_POST[$data['column_name']]) ? $_POST[$data['column_name']] : '') . "</td>"; } if ($data['data_type'] == 'timestamp' || $data['data_type'] == 'datetime') { $tfield_structure1['size'] = 12; $tfield_structure1['name'] = "__from_" . $data['column_name']; $tfield_structure2['size'] = 12; $tfield_structure2['name'] = "__to_" . $data['column_name']; $ret = "<td>" . humanizer($data['column_name']) . " Between:</td><td>" . form_input($tfield_structure1, isset($_POST["__from_" . $data['column_name']]) ? $_POST["__from_" . $data['column_name']] : '', 'class="date1"') . " and " . form_input($tfield_structure2, isset($_POST["__to_" . $data['column_name']]) ? $_POST["__to_" . $data['column_name']] : date('m/d/Y', time()), 'class="date2"') . '</td>'; } if ($data['data_type'] == 'int' || $data['data_type'] == 'decimal') { $tfield_structure1['size'] = 3; $tfield_structure1['name'] = "__min_" . $data['column_name']; $tfield_structure2['size'] = 3; $tfield_structure2['name'] = "__max_" . $data['column_name']; $ret = "<td>" . humanizer($data['column_name']) . " Between:</td><td>" . form_input($tfield_structure1, isset($_POST["__min_" . $data['column_name']]) ? $_POST["__min_" . $data['column_name']] : '', '') . " and " . form_input($tfield_structure2, isset($_POST["__max_" . $data['column_name']]) ? $_POST["__max_" . $data['column_name']] : '') . '</td>'; } if (isset($ret)) { return $ret; } }
?> <tr><td> </td><td><?php echo form_submit('', 'Search'); ?> </td></tr> </table> </form> <?php } ?> <?php if (!$data) { ?> <p>There are no <?php echo humanizer($table_name); ?> available.</p> <?php } else { ?> <p class="flash_bar" style="display: none; float: right; width:40%; margin-top: -40px;">Sorted order has been updated successfully!</p> <?php $i = 0; $close_tbody = 0; ?> <?php echo form_open(base_url() . 'masstrash/' . $table_name, 'class="sortable_form"'); ?>
<?php foreach ($bubble_data as $bubbles) { ?> <span class="bubble_divided"><?php echo $bubbles->{$sec_identifier}; ?> <img src="/media/images/small_x.png"/></span> <?php } ?> </div> <span contenteditable="true" class="quick_adder <?php echo $sec_identifier; ?> " style=""> </span><span class="help_text"><a href="#">Add <?php echo strtolower(singular(humanizer($sec_table))); ?> </a></span> </td> </tr> <?php } ?> </tbody> <?php } ?> <tbody class="extra_parameters"> <?php if ($related_tables) {
$i++; ?> <?php } ?> <?php } ?> </td> </tr> </table> <ul style="display: none;"> <?php foreach ($tables as $table) { ?> <li><a href="<?php echo base_url(); ?> content/<?php echo $table->table_name; ?> "><?php echo humanizer(plural($table->table_name)); ?> </a></li> <?php } ?> </ul>
"><?php echo $labels[$s]; ?> </h1> <table width="100%;"> <?php foreach ($detailed_report as $th) { ?> <?php $th = (array) $th; ?> <tr><?php foreach ($th as $header => $name) { ?> <th><?php echo $head = $header == 'id' ? trim($labels[$s]) : humanizer($header); ?> </th><?php } ?> </tr> <?php break; ?> <?php } ?> <?php foreach ($detailed_report as $th) { ?> <tr>
<?php } ?> <?php if ($key == 'PRI') { ?> <?php $linking = $this->ContentModel->getIdentifier($pritable); ?> <td style="border:0; border-bottom: 1px solid #DDD; padding-bottom: 15px;"> <?php if ($items) { ?> <div style="float: right; width:49%;">Click on <?php echo singular(humanizer($pritable)); ?> below to add to "<?php echo $objectname; ?> "</div><br clear="all"/> <select class="multipleselect" multiple="multiple" name="<?php echo $pritable; ?> []" id="<?php echo $pritable; ?> "> <?php foreach ($items as $item) {
echo $s_status; ?> "><?php echo urldecode($s_message); ?> </div> <?php } ?> <form method="post"> <?php if (!$data->is_captured) { ?> <p><strong><?php echo humanizer(singular($table_name)); ?> Information:</strong></p> <?php if ($data->is_voided) { ?> <p class="red">Note: This transaction has been voided.</p><?php } ?> <p>Tracking Number: <input type="text" name="tracking_number"/></p> <p><input type="checkbox" name="notify_email" checked="checked"/>Also notify customer via email.</p> <p><input name="_action" type="submit" onclick="blockade()" value="Add Tracking Number"/> <input name="_action" type="submit" value="Cancel"/></p> <?php } else { ?> <p><strong>Note: </strong>This transaction has already been captured.</p>
?> <?php if ($pdata_id == $prelated_id) { ?> <strong><?php echo humanizer($pdata_id); ?> :</strong> <?php echo humanizer($pdata_content); ?> <br/> <?php } else { ?> <strong><?php echo humanizer($pdata_id); ?> :</strong><br/> <?php $fielddef = $this->ContentModel->getFieldType($ptablename, $pdata_id); ?> <?php if ($fielddef->data_type == 'int' || $fielddef->data_type == 'varchar' || $fielddef->data_type == 'tinyint' || $fielddef->data_type == 'bigint' || $fielddef->data_type == 'timestamp' || $fielddef->data_type == 'datetime') { ?> <input type="text" class="proxy_contents" name="<?php echo $pdata_id; ?> " value="<?php echo $pdata_content; ?> "/><br/>
function massuntrash($table) { checklogin(); if (!can_update($table)) { redirect(base_url() . 'content/' . $table . '/:error:' . urlencode('Sorry. You do not have permissions to update things from ' . humanizer($table))); exit; } if (!$_POST || !$_POST['ids']) { redirect(base_url() . 'content/' . $table); exit; } $table = mysql_real_escape_string($table); $id = mysql_real_escape_string($id); $parent_tables = $this->db->query("SELECT COLUMN_NAME, REFERENCED_COLUMN_NAME, REFERENCED_TABLE_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_NAME='{$table}' AND REFERENCED_TABLE_NAME IS NOT NULL")->result(); foreach ($_POST['ids'] as $id) { /*** remove this object from trash ***/ $this->db->query("UPDATE {$table} SET __is_trash=0 WHERE id='{$id}' LIMIT 1"); // $this->memcached_library->flush(); /*** remove object parent from trash ***/ if ($parent_tables) { foreach ($parent_tables as $parent_table) { $c = $parent_table->COLUMN_NAME; $parent_id = $this->db->query("SELECT {$c} FROM {$table} WHERE id='{$id}' LIMIT 1")->row()->{$c}; //TODO: bug: check if parent doesn't have trash $this->db->query("UPDATE {$parent_table->REFERENCED_TABLE_NAME} SET __is_trash=0 WHERE {$parent_table->REFERENCED_COLUMN_NAME}='{$parent_id}'"); //$this->memcached_library->flush(); } } } redirect(base_url() . 'content/' . $table . '/:success:' . urlencode('Items have been removed from trash.')); }
' from <?php echo $proper_table_name; ?> , the following will be modified and/or deleted:</p> <ul> <?php //two loops had to be done for related tables and actual tables ?> <?php foreach ($related_tables as $related_table) { ?> <?php if ($table != $related_table->table_name) { ?> <?php $proper_related_table_name = humanizer(plural($related_table->table_name)); ?> <?php $tdata = $this->db->query("SELECT TABLE_NAME, IS_NULLABLE, COLUMN_KEY, COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='" . DATABASE . "' AND TABLE_NAME='" . $related_table->table_name . "' AND COLUMN_NAME='{$table_linking_name}'")->row(); ?> <?php if ($tdata) { ?> <?php if ($tdata->COLUMN_KEY == 'MUL') { ?> <li style="font-size:1.2em;"> <?php if ($tdata->IS_NULLABLE == 'NO') {
function refund($table_name = FALSE, $id = FALSE) { if ($table_name == FALSE || $id == FALSE) { redirect(base_url()); } $table_details = 'order_details'; if ($_POST && $_POST['_action'] == 'Cancel') { redirect(base_url() . 'content/' . $table_name); } if ($_POST && $_POST['_action'] == 'Process Refunds') { $order_details_refund = array(); $grand_refund = 0; $r_subtotal = 0; if (key_exists('items', $_POST)) { foreach ($_POST['items'] as $oid => $products) { //get the amount that is supposed to be refunded in this trans and the corresponding order_detail_id $order_details_refund[$products] = $_POST[$products]; $grand_refund += $_POST[$products]; } } $r_subtotal = $grand_refund; if (key_exists('shipping_amount', $_POST)) { $grand_refund += $_POST['shipping_amount']; $r_shipping_amount = $_POST['shipping_amount']; } if (key_exists('tax_amount', $_POST)) { $grand_refund += $_POST['tax_amount']; $r_tax = $_POST['tax_amount']; } //get the user information $data['user'] = $this->db->query("SELECT * FROM {$table_name} o LEFT JOIN users u on u.id=o.user_id LEFT JOIN user_address ua ON ua.user_id=u.id WHERE o.id='{$id}'")->row(); $process = $this->payment->refund($grand_refund, $data['user']->customer_profile_id, $data['user']->customer_payment_profile_id, $data['user']->transaction_id); foreach ($_POST['refund'] as $refundables) { $ab = explode('_', $refundables); $a = $ab[0]; $b = $ab[1]; $this->db->query("UPDATE order_details SET is_returned='{$a}' WHERE id='{$b}'"); } if ($process === TRUE) { if (key_exists('notify', $_POST)) { send_email($data['user']->email, SITENAME . " :: Transaction Refunds", 'Refunds of $' . $grand_refund . ' has been refunded to the card with which you used to make this payment. Yay you.', ''); } //update details foreach ($order_details_refund as $r_id => $r_amount) { $this->db->query("UPDATE order_details SET refunded_amount=refunded_amount+{$r_amount} WHERE id='{$r_id}'"); } $this->db->query("UPDATE orders SET refunded_shipping_amount=refunded_shipping_amount+{$r_shipping_amount} WHERE id='{$id}'"); $this->db->query("UPDATE orders SET refunded_tax=refunded_tax+{$r_tax} WHERE id='{$id}'"); $this->db->query("UPDATE orders SET refunded_sub_total=refunded_sub_total+{$r_subtotal} WHERE id='{$id}'"); $this->db->query("UPDATE orders SET is_voidable=0"); redirect(base_url() . 'process/refund/' . $table_name . '/' . remove_semicol($id) . ':success:' . urlencode("This item has been refunded successfully!")); } elseif ($grand_refund < 1) { if (key_exists('notify', $_POST)) { send_email($data['user']->email, SITENAME . " :: Transaction Returns", 'We reveived the items you returned and have updated our records!', 'We reveived the items you returned and have updated our records!'); } redirect(base_url() . 'process/refund/' . $table_name . '/' . remove_semicol($id) . ':note:' . urlencode("No refunds were made. Returns have been updated successfully.")); } else { redirect(base_url() . 'process/refund/' . $table_name . '/' . remove_semicol($id) . ':error:' . urlencode("{$process} Please process them manually with the payment processor.")); } } //**addition for cms styles: keep this comment incase of clashes **// $table_name = mysql_real_escape_string($table_name); $data['group'] = $this->db->query("SELECT * FROM " . DATABASE_MENU_GROUPS . " WHERE id=(SELECT group_id FROM " . DATABASE_TABLE_RULES . " WHERE table_name='{$table_name}' LIMIT 1)")->row(); //backwards $data['groups'] = $this->db->query("SELECT * FROM " . DATABASE_MENU_GROUPS)->result(); $data['tables'] = $this->db->query("SELECT m.table_name FROM " . DATABASE_TABLE_RULES . " m JOIN " . DATABASE_MENU_GROUPS . " n ON n.id=m.group_id WHERE m.is_hidden=0 AND n.id=(SELECT group_id FROM " . DATABASE_TABLE_RULES . " WHERE table_name='{$table_name}' order by `order` LIMIT 1) order by `order`")->result(); //** end addition for cms styles: keep this comment incase of clashes **// $meta['page_title'] = 'Refund'; $meta['breadcrumbs']['content/' . $table_name] = plural(humanizer($table_name)); $meta['breadcrumbs']['none'] = 'Refund'; $data['table_name'] = $table_name; $data['dataid'] = $id; $data['object'] = $this->db->query("SELECT * FROM {$table_name} o LEFT JOIN users u on u.id=o.user_id WHERE o.id='{$id}'")->row(); $data['object_details'] = $this->db->query("SELECT od.id as order_details_id, od.amount, od.refunded_amount, od.is_returned, od.is_refundable, p.name FROM order_details od JOIN upc u on u.id=od.upc_id JOIN products p ON p.id=u.product_id WHERE od.order_id='{$id}'")->result(); $data['grand_total'] = $data['object']->sub_total + $data['object']->tax + $data['object']->shipping_amount; $data['refunded'] = $data['object']->refunded_sub_total + $data['object']->refunded_tax + $data['object']->refunded_shipping_amount; $data['max_shipping_refund'] = $data['object']->shipping_amount - $data['object']->refunded_shipping_amount; $data['max_tax_refund'] = $data['object']->tax - $data['object']->refunded_tax; $data['refunded_shipping_amount'] = $data['object']->refunded_shipping_amount; if (stripos(uri_string(), ':')) { $mess = explode(':', uri_string()); if (count($mess) > 2) { $data['s_message'] = $mess[2]; $data['s_status'] = $mess[1]; } } $this->load->view('includes/header', $meta); $this->load->view("process/refundview", $data); $this->load->view('includes/footer'); }
function getProperTableNameSingular($table_name) { return humanizer(singular($table_name)); }