Example #1
0
function get_articles($country_id)
{
    $db = new db();
    $articles = $db->array_select("SELECT * FROM news WHERE country_id = '{$country_id}' ORDER BY pubdate DESC");
    foreach ($articles as $article) {
        $article['pubdate'] = reverse_date($article['pubdate']);
    }
    return $articles;
}
Example #2
0
 public function save_new_event_sequence($post)
 {
     /* BENCHMARK */
     $this->benchmark->mark('func_save_new_event_sequence_start');
     // get the calendar and days
     $calendar = $this->node_model->get_node($post['calendar_id'], 'calendar');
     $calendar_days = json_decode($calendar['event_json'], true);
     // save the calendar undo
     $this->save_undo_calendar($calendar['id'], 'new sequence', $post['name']);
     // do the dates
     // from date
     if ('' == $post['from_date']) {
         $from_date = "10000000";
     } else {
         $from_date = str_replace('-', '', reverse_date($post['from_date'], '-'));
     }
     // until date
     if ('' == $post['until_date']) {
         // default end of the calendar
         $year = date('Y', time()) + $this->config->item('years_ahead') - 1;
         $until_date = $year . "1231";
     } else {
         // else get the until date from post
         $until_date = str_replace('-', '', reverse_date($post['until_date'], '-'));
     }
     // until date is equal to from date if there is no repeat set
     if (!isset($post['show_repeat']) or isset($post['show_repeat']) && !isset($post['weekly']) && !isset($post['fortnightly']) && !isset($post['monthly'])) {
         $until_date = $from_date;
     }
     // process
     // save new node if applicable
     if (is_numeric($post['event_id'])) {
         $node_id = $post['event_id'];
     } else {
         // save the event as a new node
         $vals = $post;
         $vals['id'] = '';
         $vals['node_html'] = '';
         unset($vals['event_id']);
         // wrap up the repetition data as json and remove from the $vals array
         $repetition = array();
         foreach ($post as $k => $v) {
             if ("daily_" == substr($k, 0, 6) or "weekly" == substr($k, 0, 6) or "fortnightly" == substr($k, 0, 11) or "monthly" == substr($k, 0, 7)) {
                 $repetition[$k] = $v;
                 unset($vals[$k]);
             }
         }
         $vals['repetition'] = json_encode($repetition);
         // set some values for the db table
         $vals['duration'] = $vals['duration_value'] . $vals['duration'];
         $vals['from_date'] = substr($from_date, 0, 4) . '-' . substr($from_date, 4, 2) . '-' . substr($from_date, 6, 2);
         $vals['until_date'] = substr($until_date, 0, 4) . '-' . substr($until_date, 4, 2) . '-' . substr($until_date, 6, 2);
         // unset some $vals that dont have a matching db column
         unset($vals['duration_value']);
         unset($vals['month_date']);
         if (isset($vals['show_repeat']) ? $vals['show_repeat'] = 1 : ($vals['show_repeat'] = 0)) {
         }
         if (isset($vals['exclusive']) ? $vals['exclusive'] = 1 : ($vals['exclusive'] = 0)) {
         }
         // actually save
         $node_id = $this->node_admin_model->node_save($vals, 'event');
     }
     // get the day set array
     $day_events = array();
     $c = 0;
     foreach ($post as $k => $v) {
         if ("daily_" == substr($k, 0, 6)) {
             $day_events[$c] = array('t' => substr($k, 6, 2) . substr($k, 8, 2), 's' => $post['spaces']);
             $c++;
         }
     }
     // create a default day event if no time(s) selected
     if (0 == count($day_events)) {
         $day_events[] = array('t' => 'd', 's' => $post['spaces']);
     }
     // counters - used by fortnightly
     $day_count = 1;
     $week_count = 1;
     // month position to match up with the right cell value for the month day position, ie 3rd wednesday etc.
     $month_date = substr($post['month_date'], 6, 2);
     $month_position = "";
     if ($month_date <= 7) {
         $month_position = "1";
     } elseif ($month_date >= 8 && $month_date <= 14) {
         $month_position = "2";
     } elseif ($month_date >= 15 && $month_date <= 21) {
         $month_position = "3";
     } elseif ($month_date >= 22 && $month_date <= 28) {
         $month_position = "4";
     } elseif ($month_date >= 29) {
         $month_position = "5";
     }
     $rform_mdate = substr($post['month_date'], 0, 4) . '-' . substr($post['month_date'], 4, 2) . '-' . substr($post['month_date'], 6, 2);
     $month_position .= " " . format_date($rform_mdate, 'N');
     // exclusivity
     if (isset($post['exclusive']) ? $exclusive = 1 : ($exclusive = 0)) {
     }
     // event durations array used to store current events at any point in the loop
     // this is only used by the exclusive event logic though it is run for all event adds
     // as we need to ensure that any existing exclusives effect the added event
     $event_durations = array();
     foreach ($calendar_days as $date => $day_details) {
         // add the key array to the value
         $day_details['x'] = array();
         if ($date >= $from_date && $date <= $until_date) {
             // now we need to check that the cell we are looking at fits the repeat data
             // always add events on the chosen date, otherwise don't add unless the date passes repeat checks
             // also we don't add on this day if any of the repeats are set because the repeats define the days to place it
             if (!isset($post['weekly']) && !isset($post['fortnightly']) && !isset($post['monthly'])) {
                 $add_events = 1;
             } else {
                 $add_events = 0;
             }
             // repeat check the post values against the date of this iteration
             if (isset($post['weekly'])) {
                 if (isset($post['weekly_' . $day_details['dn']])) {
                     $add_events = 1;
                 }
             } elseif (isset($post['fortnightly'])) {
                 // only if the day name is correct every other week
                 // week count
                 if (0 == $day_count % 7) {
                     $week_count++;
                 }
                 // check which week
                 if (1 == $week_count % 2) {
                     if (isset($post['fortnightly1_' . $day_details['dn']])) {
                         $add_events = 1;
                     }
                 } else {
                     if (isset($post['fortnightly2_' . $day_details['dn']])) {
                         $add_events = 1;
                     }
                 }
                 // increment day count
                 $day_count++;
             } elseif (isset($post['monthly'])) {
                 if (isset($post['monthly_on_this_day'])) {
                     if (substr($date, 6, 2) == substr($from_date, 6, 2)) {
                         $add_events = 1;
                     }
                 } elseif (isset($post['monthly_at_this_position'])) {
                     if ($day_details['md'] == $month_position) {
                         $add_events = 1;
                     }
                 }
             }
             // only add events if the above checks have returned true
             if (1 == $add_events) {
                 // for each day event from above add a variation and store the product ids in the day event
                 for ($x = 0; $x < count($day_events); $x++) {
                     if ('d' == $day_events[$x]['t'] ? $time_for_stamp = '09:00' : ($time_for_stamp = $day_events[$x]['t'])) {
                     }
                     $date_for_stamp = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2);
                     // create a variation of this meta event product
                     $insert_data = array('node_id' => $node_id, 'price' => $post['price'], 'stock_level' => $post['spaces'], 'event_timestamp' => strtotime($date_for_stamp . ' ' . $time_for_stamp));
                     $this->db->insert('nvar', $insert_data);
                     $nvar_id = $this->db->insert_id();
                     // add product and variation id to the day event
                     $day_events[$x]['nv'] = $nvar_id;
                 }
                 // store the day events accesible by iteration or key
                 $day_details['e'][$node_id]['t'] = $day_events;
                 // add the event meta id as a keyed value for easier access than if it is just the key
                 $day_details['e'][$node_id]['id'] = $node_id;
                 $day_details['e'][$node_id]['p'] = $post['price'];
                 $day_details['e'][$node_id]['n'] = $post['name'];
                 $day_details['e'][$node_id]['dr'] = $post['duration_value'] . $post['duration'];
                 if (1 == $exclusive) {
                     $day_details['e'][$node_id]['x'] = 1;
                 }
                 // save the date as the last in the sequence
                 // this will be stored
                 $last_in_sequence = reverse_date(date_key_to_human($date), '-');
             }
         }
         // get all over the events from this day into the event durations array
         // done right the way through the calendar to catch the trailing events
         foreach ($day_details['e'] as $day_event) {
             $dur = $this->events_model->get_duration($day_event['dr']);
             if ('days' == $dur['unit'] ? $elength = $dur['count'] : ($elength = ceil($dur['count'] / 24))) {
             }
             if (isset($day_event['x']) ? $ex = 1 : ($ex = 0)) {
             }
             $event_durations[] = array('length' => $elength, 'exclusive' => $ex, 'key' => $date . '-' . $day_event['id']);
         }
         //dev_dump($event_durations);
         // now decrement each event duration record to mark the passing of the day so only those over lapping will be effected
         for ($x = 0; $x < count($event_durations); $x++) {
             // add the key for this event to the x array at the date level shows all the currently live events
             // but not if they have counted down to 0
             if ($event_durations[$x]['length'] > 0) {
                 $day_details['x'][$event_durations[$x]['key']] = $event_durations[$x]['exclusive'];
             }
             // decrement first
             $event_durations[$x]['length'] -= 1;
             // get rid of the zeros for ease and efficiency - finished events won't be tagged
             /* if ($event_durations[$x]['length']<1)
                {
                    array_splice($event_durations,$x,1);
                } */
         }
         // finally add the whole array to the master event array
         $calendar_days[$date] = $day_details;
     }
     // save the event sequence
     $update_data = array('event_json' => json_encode($calendar_days));
     $this->db->where('node_id', $post['calendar_id']);
     $this->db->update('calendar', $update_data);
     // save the last sequence date of this event
     if (!isset($last_in_sequence)) {
         // last in this sequence is this date
         $last_in_sequence = $post['from_date'];
     }
     $update_data = array('last_in_sequence' => $last_in_sequence);
     $this->db->where('node_id', $node_id);
     $this->db->update('event', $update_data);
     return $node_id;
     /* BENCHMARK */
     $this->benchmark->mark('func_save_new_event_sequence_end');
 }
<?php

/**
 * Gets core libraries and defines some variables
 */
require_once '../library/common.php';
require_once '../library/configuration.php';
$conn_id = connect();
require_once "security.php";
if (is_array($HTTP_GET_VARS)) {
    extract($HTTP_GET_VARS, EXTR_SKIP);
}
if ($HTTP_POST_VARS[action]) {
    extract($HTTP_POST_VARS, EXTR_OVERWRITE);
    $note_text = $elm1;
    $note_date = reverse_date($note_date);
    if ($note_special) {
        $status_berita = "TRUE";
    } else {
        $status_berita = "FALSE";
    }
    $file_uploaded = $HTTP_POST_FILES[gambar];
    if ($file_uploaded[name]) {
        $tipe = $file_uploaded[type];
        if (stristr($tipe, "image") and !stristr($tipe, "bmp")) {
            $temp = explode(".", $file_uploaded[name]);
            $ext = $temp[@count($temp) - 1];
            $nama_file = date("dmYHis") . "." . $ext;
            if (!copy($file_uploaded[tmp_name], "../{$note_path}/{$nama_file}")) {
                $error = true;
            } else {
        echo $product_name[$i]->title_bn;
        ?>
</a></td>
                                            <td><?php 
        echo reverse_number($row->item_qty);
        ?>
</td>
                                            <td><?php 
        echo get_string('currency') . ' ' . reverse_number($row->item_total);
        ?>
</td>
                                            <?php 
        if ($order_record->status == 1) {
            ?>
                                             <td><?php 
            echo reverse_date(date("d-M-Y", strtotime($row->finish_date)));
            ?>
</td>
                                            <?php 
        } else {
            echo '<td>' . get_string('not_calculated_yet') . '</td>';
        }
        ?>
                                        </tr>
                                        <?php 
        $i++;
    }
    ?>

                                </tbody>
                            </table>
Example #5
0
                            <tr>

                                <td><a href="<?php 
    echo base_url('product/detail/' . $row->product_id);
    ?>
"><?php 
    echo $row->title_bn;
    ?>
</a></td>

                                <td><?php 
    echo get_price_html($row->product_id);
    ?>
</td>
                                <td><?php 
    echo reverse_date(date("d-M-Y", strtotime($row->create_date)));
    ?>
</td>


                                <td class="action-btn"><a href="<?php 
    echo base_url('dashboard/product/edit/' . $row->product_id);
    ?>
"><button class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></button></a></td>
                                <td class="action-btn"><a href="<?php 
    echo base_url('product/delete_product/' . $row->product_id);
    ?>
" 
                                 <?php 
    if ($row->is_published == 1) {
        $msg = get_string('sure_unpublish');
Example #6
0
        ?>
</td>
                                    <td><?php 
        echo reverse_number($row->mobile_number);
        ?>
</td>
                                    <td><?php 
        echo reverse_date($row->date);
        ?>
</td>
                                    <td><?php 
        echo get_string('currency') . reverse_number($row->total);
        ?>
</td>
                                    <td><?php 
        echo reverse_date($row->delivery_date);
        ?>
</td>
                                    <?php 
        if ($all_volentire_name[$i] === 0) {
            ?>
                                        <td><?php 
            echo get_string('dsply_status');
            ?>
</td>
                                        <?php 
        } else {
            ?>
                                        <td><a href="<?php 
            echo base_url('dashboard/user/view/' . $row->delivered_by);
            ?>