Пример #1
0
 public function index()
 {
     if (!file_exists(EXTPATH . 'categories_module/views/categories_module.php')) {
         //check if file exists in views folder
         show_404();
         // Whoops, show 404 error page!
     }
     if (is_numeric($this->input->get('category_id'))) {
         $data['category_id'] = $this->input->get('category_id');
     } else {
         $data['category_id'] = 0;
     }
     $data['menu_total'] = $this->Menus_model->getCount();
     $data['categories'] = array();
     $results = $this->Categories_model->getCategories();
     // retrieve all menu categories from getCategories method in Menus model
     foreach (sort_array($results) as $result) {
         // loop through menu categories array
         $children_data = array();
         if ($result['child_id'] !== NULL) {
             $children = $this->Categories_model->getCategories($result['category_id']);
             // retrieve all menu categories from getCategories method in Menus model
             foreach ($children as $child) {
                 $children_data[$child['category_id']] = array('category_id' => $child['category_id'], 'category_name' => $child['name'], 'href' => site_url('menus?category_id=' . $child['category_id']));
             }
         }
         $data['categories'][$result['category_id']] = array('category_id' => $result['category_id'], 'category_name' => $result['name'], 'children' => $children_data, 'href' => site_url('menus?category_id=' . $result['category_id']));
     }
     // pass array $data and load view files
     return $this->load->view('categories_module/categories_module', $data, TRUE);
 }
 public function index()
 {
     $this->load->model('Menus_model');
     // load the menus model
     $this->load->model('Categories_model');
     // load the menus model
     $this->lang->load('categories_module/categories_module');
     if (!file_exists(EXTPATH . 'categories_module/views/categories_module.php')) {
         //check if file exists in views folder
         show_404();
         // Whoops, show 404 error page!
     }
     if (is_numeric($this->input->get('category_id'))) {
         $data['category_id'] = $this->input->get('category_id');
     } else {
         $data['category_id'] = 0;
     }
     $this->template->setStyleTag(extension_url('categories_module/views/stylesheet.css'), 'categories-module-css', '155000');
     $data['menu_total'] = $this->Menus_model->getCount();
     $data['categories'] = array();
     $results = $this->Categories_model->getCategories(0);
     // retrieve all menu categories from getCategories method in Menus model
     foreach (sort_array($results) as $result) {
         // loop through menu categories array
         $children_data = array();
         if (!empty($result['child_id'])) {
             $sibling_data = array();
             if (!empty($result['sibling_id'])) {
                 $sibling = $this->Categories_model->getCategories($result['child_id']);
                 // retrieve all menu categories from getCategories method in Menus model
                 foreach ($sibling as $sib) {
                     $sibling_data[$sib['category_id']] = array('category_id' => $sib['category_id'], 'category_name' => $sib['name'], 'href' => site_url('menus?category_id=' . $sib['category_id']));
                 }
             }
             $children = $this->Categories_model->getCategories($result['category_id']);
             // retrieve all menu categories from getCategories method in Menus model
             foreach ($children as $child) {
                 $children_data[$child['category_id']] = array('category_id' => $child['category_id'], 'category_name' => $child['name'], 'href' => site_url('menus?category_id=' . $child['category_id']), 'children' => $sibling_data);
             }
         }
         $data['categories'][$result['category_id']] = array('category_id' => $result['category_id'], 'category_name' => $result['name'], 'href' => site_url('menus?category_id=' . $result['category_id']), 'children' => $children_data);
     }
     $mix_it_up = (!empty($menu_total) and $menu_total > 500) ? FALSE : TRUE;
     $data['category_tree'] = $this->categoryTree($data['categories'], $mix_it_up);
     $fixed_top_offset = isset($ext_data['fixed_top_offset']) ? $ext_data['fixed_top_offset'] : '350';
     $fixed_bottom_offset = isset($ext_data['fixed_bottom_offset']) ? $ext_data['fixed_bottom_offset'] : '320';
     $data['fixed_categories'] = 'data-spy="affix" data-offset-top="' . $fixed_top_offset . '" data-offset-bottom="' . $fixed_bottom_offset . '"';
     // pass array $data and load view files
     return $this->load->view('categories_module/categories_module', $data, TRUE);
 }
Пример #3
0
 public function getList($filter, $list_data = array())
 {
     $url = '?';
     $list_data['quantities'] = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10');
     $list_data['show_menu_images'] = $this->config->item('show_menu_images');
     $list_data['menus'] = $this->Menus_model->getList($filter);
     $categories = $this->Categories_model->getCategories();
     $list_data['categories'] = array();
     foreach (sort_array($categories) as $category) {
         if (!empty($filter['filter_category']) and $filter['filter_category'] != $category['category_id']) {
             continue;
         }
         $category_image = '';
         if (!empty($category['image'])) {
             $category_image = $this->Image_tool_model->resize($category['image'], '800', '115');
         }
         $list_data['categories'][$category['category_id']] = array('category_id' => $category['category_id'], 'name' => $category['name'], 'description' => $category['description'], 'priority' => $category['priority'], 'image' => $category_image);
     }
     $list_data['menu_options'] = array();
     $menu_options = $this->Menu_options_model->getMenuOptions();
     foreach ($menu_options as $menu_id => $option) {
         $option_values = array();
         foreach ($option['option_values'] as $value) {
             $option_values[] = array('option_value_id' => $value['option_value_id'], 'value' => $value['value'], 'price' => (empty($value['new_price']) or $value['new_price'] == '0.00') ? $this->currency->format($value['price']) : $this->currency->format($value['new_price']));
         }
         $list_data['menu_options'][$option['menu_id']][] = array('menu_option_id' => $option['menu_option_id'], 'option_id' => $option['option_id'], 'option_name' => $option['option_name'], 'display_type' => $option['display_type'], 'priority' => $option['priority'], 'default_value_id' => isset($option['default_value_id']) ? $option['default_value_id'] : 0, 'option_values' => $option_values);
     }
     $list_data['option_values'] = array();
     foreach ($menu_options as $option) {
         if (!isset($list_data['option_values'][$option['option_id']])) {
             $list_data['option_values'][$option['option_id']] = $this->Menu_options_model->getOptionValues($option['option_id']);
         }
     }
     if ($this->input->get('category_id')) {
         $prefs['base_url'] = site_url('menus?category_id=' . $this->input->get('category_id')) . $url;
     } else {
         $prefs['base_url'] = site_url('menus' . $url);
     }
     $prefs['total_rows'] = $this->Menus_model->getCount($filter);
     $prefs['per_page'] = $filter['limit'];
     $this->load->library('pagination');
     $this->pagination->initialize($prefs);
     $list_data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     return $list_data;
 }
Пример #4
0
 public function cartTotals()
 {
     $result = array();
     $order_totals = $this->CI->Cart_model->getTotals();
     $cart_totals = $this->CI->cart->totals();
     foreach ($cart_totals as $name => $cart_total) {
         $order_total = !empty($order_totals[$name]['status']) ? $order_totals[$name] : array('title' => '');
         if (empty($cart_total['amount']) or empty($order_total['status'])) {
             continue;
         }
         $cart_total['title'] = empty($cart_total['title']) ? $order_total['title'] : $cart_total['title'];
         if (isset($cart_total['code'])) {
             $cart_total['title'] = str_replace('{coupon}', $cart_total['code'], $cart_total['title']);
         } else {
             if (isset($cart_total['tax'])) {
                 $cart_total['title'] = str_replace('{tax}', $cart_total['tax'], $cart_total['title']);
             }
         }
         $result[$name] = array_merge($cart_total, array('title' => htmlspecialchars_decode($cart_total['title']), 'amount' => $this->CI->currency->format($cart_total['amount']), 'priority' => isset($order_total['priority']) ? $order_total['priority'] : $cart_total['priority']));
     }
     return sort_array($result, 'priority');
 }
Пример #5
0
function panel($tab, $e = 0, $l = 12, $tri = FALSE)
{
    if ($tri) {
        sort_array($tab);
    }
    $tabpanel = array();
    $i = 0;
    $nb = 0;
    while ($nb < count($tab) / $l) {
        echo "Veuillez patienter pendant la création des panels...\n";
        $width = my_getwidth($l, $tab, $i) + 40;
        $height = my_getheight($l, $e, $tab, $i) + 40;
        $panel = imagecreatetruecolor($width, $height);
        imagefilledrectangle($panel, 0, 0, $width, $height, 0xffffff);
        $dst_x = 40;
        $dst_y = 40;
        $counter = 0;
        $nm = 0;
        while ($counter < $l && isset($tab[$i])) {
            $im = redim(myimagecreate($tab[$i]), $tab[$i], $e);
            if ($im != 0) {
                $nm++;
                imagecopy($panel, $im, $dst_x, $dst_y, 0, 0, imagesx($im), imagesy($im));
                $dst_x += return_max_width($tab, $i, $i + 3) + 40;
                if ($nm % 3 == 0 && $nm > 0) {
                    $dst_y += return_max_height($tab, $i, $i + 3) + 40;
                    $dst_x = 40;
                }
            }
            $counter++;
            $i++;
        }
        array_push($tabpanel, $panel);
        $nb++;
    }
    return $tabpanel;
}
 public function testDropForeignKeyColumnPartOfUniqueConstraint()
 {
     self::$db->translatedQuery('ALTER TABLE "albums" DROP COLUMN "artist_id"');
     $this->rollback_statements[] = "ALTER TABLE albums ADD UNIQUE (artist_id, name)";
     $this->rollback_statements[] = "ALTER TABLE albums ALTER COLUMN artist_id SET NOT NULL";
     $this->rollback_statements[] = "UPDATE albums SET artist_id = 3 WHERE album_id IN (4, 5, 6, 7)";
     $this->rollback_statements[] = "UPDATE albums SET artist_id = 2 WHERE album_id IN (2, 3)";
     $this->rollback_statements[] = "UPDATE albums SET artist_id = 1 WHERE album_id = 1";
     $this->rollback_statements[] = "ALTER TABLE albums ADD COLUMN artist_id INTEGER REFERENCES artists(artist_id) ON UPDATE CASCADE ON DELETE CASCADE";
     $schema = new fSchema(self::$db);
     $this->assertSame(sort_array(array('album_id', 'name', 'year_released', 'msrp', 'genre')), sort_array(array_keys($schema->getColumnInfo('albums'))));
     $this->assertSame(array(), $schema->getKeys('albums', 'foreign'));
     $this->assertSame(array(), $schema->getKeys('albums', 'unique'));
     $this->assertEquals(7, self::$db->query("SELECT count(*) FROM albums")->fetchScalar());
 }
Пример #7
0
 private function getFormData($order_data, $data = array())
 {
     if ($this->input->post('checkout_step')) {
         $data['checkout_step'] = $this->input->post('checkout_step');
     } else {
         if (isset($order_data['checkout_step'])) {
             $data['checkout_step'] = $order_data['checkout_step'];
             // retrieve customer first name from session data
         } else {
             $data['checkout_step'] = 'one';
         }
     }
     if ($this->input->post('first_name')) {
         $data['first_name'] = $this->input->post('first_name');
     } else {
         if (isset($order_data['first_name'])) {
             $data['first_name'] = $order_data['first_name'];
             // retrieve customer first name from session data
         } else {
             if ($this->customer->getFirstName()) {
                 $data['first_name'] = $this->customer->getFirstName();
                 // retrieve customer first name from customer library
             } else {
                 $data['first_name'] = '';
             }
         }
     }
     if ($this->input->post('last_name')) {
         $data['last_name'] = $this->input->post('last_name');
     } else {
         if (isset($order_data['last_name'])) {
             $data['last_name'] = $order_data['last_name'];
             // retrieve customer last name from session data
         } else {
             if ($this->customer->getLastName()) {
                 $data['last_name'] = $this->customer->getLastName();
                 // retrieve customer last name from customer library
             } else {
                 $data['last_name'] = '';
             }
         }
     }
     if ($this->input->post('email')) {
         $data['email'] = $this->input->post('email');
     } else {
         if (isset($order_data['email'])) {
             $data['email'] = $order_data['email'];
             // retrieve customer email from session data
         } else {
             if ($this->customer->getEmail()) {
                 $data['email'] = $this->customer->getEmail();
                 // retrieve customer email address from customer library
             } else {
                 $data['email'] = '';
             }
         }
     }
     if ($this->input->post('telephone')) {
         $data['telephone'] = $this->input->post('telephone');
     } else {
         if (isset($order_data['telephone'])) {
             $data['telephone'] = $order_data['telephone'];
             // retrieve telephone from session data
         } else {
             if ($this->customer->getTelephone()) {
                 $data['telephone'] = $this->customer->getTelephone();
                 // retrieve customer telephone from customer library
             } else {
                 $data['telephone'] = '';
             }
         }
     }
     $local_info = $this->session->userdata('local_info');
     if ($this->input->post('order_type')) {
         $data['order_type'] = $this->input->post('order_type');
         // retrieve order_type value from $_POST data if set
     } else {
         if (isset($order_data['order_type'])) {
             $data['order_type'] = $order_data['order_type'];
             // retrieve order_type from session data
         } else {
             if (isset($local_info['order_type'])) {
                 $data['order_type'] = $local_info['order_type'];
             } else {
                 $data['order_type'] = '1';
             }
         }
     }
     if ($this->input->post('order_time')) {
         $data['order_time'] = $this->input->post('order_time');
         // retrieve order_time value from $_POST data if set
     } else {
         if (isset($order_data['order_time'])) {
             $data['order_time'] = $order_data['order_time'];
             // retrieve order_type from session data
         } else {
             $data['order_time'] = '';
         }
     }
     if ($this->input->post('address_id')) {
         $data['address_id'] = $this->input->post('address_id');
         // retrieve existing_address value from $_POST data if set
     } else {
         if (isset($order_data['address_id'])) {
             $data['address_id'] = $order_data['address_id'];
             // retrieve existing_address from session data
         } else {
             if ($this->customer->getAddressId()) {
                 $data['address_id'] = $this->customer->getAddressId();
                 // retrieve customer default address id from customer library
             } else {
                 $data['address_id'] = '';
             }
         }
     }
     if ($this->config->item('country_id')) {
         $country_id = $this->config->item('country_id');
         // retrieve country_id from config settings
     }
     if ($this->input->post('address')) {
         $addresses = $this->input->post('address');
         // retrieve address value from $_POST data if set
     } else {
         if ($this->customer->islogged()) {
             $addresses = $this->Addresses_model->getAddresses($this->customer->getId());
             // retrieve customer addresses array from getAddresses method in Customers model
         } else {
             if (!empty($order_data['address_id'])) {
                 $addresses = array($this->Addresses_model->getGuestAddress($order_data['address_id']));
                 // retrieve customer addresses array from getAddresses method in Customers model
             }
         }
     }
     if (empty($addresses)) {
         $addresses = array(array('address_id' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country_id' => $country_id));
     }
     $data['addresses'] = array();
     if ($addresses) {
         foreach ($addresses as $address) {
             // loop through customer addresses arrary
             if (empty($address['country'])) {
                 $country = $this->Countries_model->getCountry($address['country_id']);
                 $address['country'] = !empty($address['country']) ? $address['country'] : $country['country_name'];
             }
             $data['addresses'][] = array('address_id' => isset($address['address_id']) ? $address['address_id'] : NULL, 'address_1' => $address['address_1'], 'address_2' => $address['address_2'], 'city' => $address['city'], 'state' => $address['state'], 'postcode' => $address['postcode'], 'country_id' => $address['country_id'], 'address' => $this->country->addressFormat($address));
         }
     }
     if ($this->input->post('comment')) {
         $data['comment'] = $this->input->post('comment');
         // retrieve comment value from $_POST data if set
     } else {
         if (isset($order_data['comment'])) {
             $data['comment'] = $order_data['comment'];
             // retrieve comment from session data
         } else {
             $data['comment'] = '';
         }
     }
     if ($this->input->post('payment')) {
         $data['payment'] = $this->input->post('payment');
         // retrieve comment value from $_POST data if set
     } else {
         if (isset($order_data['payment'])) {
             $data['payment'] = $order_data['payment'];
             // retrieve comment from session data
         } else {
             $data['payment'] = '';
         }
     }
     if ($this->config->item('checkout_terms') > 0) {
         $data['checkout_terms'] = str_replace(root_url(), '/', site_url('pages?popup=1&page_id=' . $this->config->item('checkout_terms')));
     } else {
         $data['checkout_terms'] = FALSE;
     }
     if ($this->input->ip_address()) {
         $data['ip_address'] = $this->input->ip_address();
         // retrieve ip_address value if set
     }
     $data['countries'] = array();
     $results = $this->Countries_model->getCountries();
     // retrieve countries array from getCountries method in locations model
     foreach ($results as $result) {
         // loop through crountries array
         $data['countries'][] = array('country_id' => $result['country_id'], 'name' => $result['country_name']);
     }
     $time_format = $this->config->item('time_format') ? $this->config->item('time_format') : '%h:%i %a';
     $current_time = $this->location->currentTime();
     // retrieve the location current time from location library
     $data['delivery_times'] = array();
     $data['asap_time'] = mdate('%H:%i', strtotime($current_time) + $this->location->deliveryTime() * 60);
     if (strtotime($current_time) > strtotime($this->location->openingTime())) {
         $delivery_times = time_range($this->location->openingTime(), $this->location->lastOrderTime(), $this->location->deliveryTime());
         // retrieve the location delivery times from location library
         foreach ($delivery_times as $key => $value) {
             // loop through delivery times
             if (strtotime($value) > strtotime($data['asap_time']) or $this->config->item('future_orders') === '1') {
                 $data['delivery_times'][$value] = mdate($time_format, strtotime($value));
             }
         }
     }
     $local_payments = $this->location->payments();
     $data['payments'] = array();
     $payments = $this->extension->getAvailablePayments();
     foreach (sort_array($payments) as $code => $payment) {
         if (!empty($local_payments) and !in_array($payment['code'], $local_payments)) {
             continue;
         }
         $data['payments'][] = $payment;
     }
     return $data;
 }
function notify_birthday()
{
    $rows_member = getAllActiveMid();
    $output = array();
    //循环出一个含有有效生日的激活用户array
    $n = 0;
    foreach ($rows_member as $row_member) {
        $time = time();
        $mid = $row_member['mid'];
        $name = getMemberInfo($mid)['name'];
        $birthday_raw = getMemberInfo($mid)['birthday'];
        if ($birthday_raw != '0000-00-00') {
            $Ymd = explode('-', $birthday_raw);
            $birthday = $Ymd[1] . '-' . $Ymd[2];
            for ($i = 0; $i <= 3; $i++) {
                if (date('m-d', $time) == $birthday) {
                    $output[$n]['mid'] = $mid;
                    $output[$n]['name'] = $name;
                    $output[$n]['birthday_raw'] = $birthday_raw;
                    $output[$n]['age'] = date('Y', $time) - $Ymd[0];
                    $output[$n]['days_left'] = $i;
                }
                $time = $time + 24 * 3600;
            }
            $n++;
        }
    }
    $output = sort_array($output, 'days_left');
    return $output;
}
Пример #9
0
 private function getFormData($order_data, $data = array())
 {
     if ($this->input->post('checkout_step')) {
         $data['checkout_step'] = $this->input->post('checkout_step');
     } else {
         if (isset($order_data['checkout_step'])) {
             $data['checkout_step'] = $order_data['checkout_step'];
             // retrieve customer first name from session data
         } else {
             $data['checkout_step'] = 'one';
         }
     }
     $data['is_logged'] = $this->customer->isLogged();
     if ($this->input->post('first_name')) {
         $data['first_name'] = $this->input->post('first_name');
     } else {
         if (isset($order_data['first_name'])) {
             $data['first_name'] = $order_data['first_name'];
             // retrieve customer first name from session data
         } else {
             if ($this->customer->getFirstName()) {
                 $data['first_name'] = $this->customer->getFirstName();
                 // retrieve customer first name from customer library
             } else {
                 $data['first_name'] = '';
             }
         }
     }
     if ($this->input->post('last_name')) {
         $data['last_name'] = $this->input->post('last_name');
     } else {
         if (isset($order_data['last_name'])) {
             $data['last_name'] = $order_data['last_name'];
             // retrieve customer last name from session data
         } else {
             if ($this->customer->getLastName()) {
                 $data['last_name'] = $this->customer->getLastName();
                 // retrieve customer last name from customer library
             } else {
                 $data['last_name'] = '';
             }
         }
     }
     if ($this->customer->isLogged()) {
         $data['email'] = $this->customer->getEmail();
         // retrieve customer email address from customer library
     } else {
         if ($this->input->post('email')) {
             $data['email'] = $this->input->post('email');
         } else {
             if (isset($order_data['email'])) {
                 $data['email'] = $order_data['email'];
                 // retrieve customer email from session data
             } else {
                 $data['email'] = '';
             }
         }
     }
     if ($this->input->post('telephone')) {
         $data['telephone'] = $this->input->post('telephone');
     } else {
         if (isset($order_data['telephone'])) {
             $data['telephone'] = $order_data['telephone'];
             // retrieve telephone from session data
         } else {
             if ($this->customer->getTelephone()) {
                 $data['telephone'] = $this->customer->getTelephone();
                 // retrieve customer telephone from customer library
             } else {
                 $data['telephone'] = '';
             }
         }
     }
     $local_info = $this->session->userdata('local_info');
     if (isset($local_info['order_type'])) {
         $data['order_type'] = $local_info['order_type'];
     } else {
         $data['order_type'] = '1';
     }
     $data['order_type_text'] = $data['order_type'] === '1' ? $this->lang->line('label_delivery') : $this->lang->line('label_collection');
     $data['order_times'] = $this->location->orderTimeRange();
     $data['order_time_interval'] = $data['order_type'] === '1' ? $this->location->deliveryTime() : $this->location->collectionTime();
     $count = 1;
     $order_date = $order_hour = $order_minute = '';
     foreach ($data['order_times'] as $date => $times) {
         if ($date === 'asap') {
             continue;
         }
         if ($count === 1) {
             $order_date = $date;
             $order_hour = key($times);
             $order_minute = isset($times[$order_hour]) ? current($times[$order_hour]) : '';
         }
         $count++;
     }
     if ($this->input->post('order_time_type')) {
         $data['order_time_type'] = $this->input->post('order_time_type');
         // retrieve order_time value from $_POST data if set
     } else {
         if (isset($order_data['order_time_type'])) {
             $data['order_time_type'] = $order_data['order_time_type'];
             // retrieve order_type from session data
         } else {
             if (!empty($data['order_times']['asap'])) {
                 $data['order_time_type'] = 'asap';
             } else {
                 $data['order_time_type'] = 'later';
             }
         }
     }
     if ($this->input->post('order_date')) {
         $data['order_date'] = $this->input->post('order_date');
         // retrieve order_time value from $_POST data if set
     } else {
         if (isset($order_data['order_date']) and !empty($data['order_times'][$order_data['order_date']])) {
             $data['order_date'] = $order_data['order_date'];
             // retrieve order_type from session data
         } else {
             $data['order_date'] = $order_date;
         }
     }
     if ($this->input->post('order_hour')) {
         $data['order_hour'] = $this->input->post('order_hour');
         // retrieve order_time value from $_POST data if set
     } else {
         if (isset($order_data['order_hour']) and !empty($data['order_times'][$data['order_date']][$order_data['order_hour']])) {
             $data['order_hour'] = $order_data['order_hour'];
             // retrieve order_type from session data
         } else {
             $data['order_hour'] = $order_hour;
         }
     }
     if ($this->input->post('order_minute')) {
         $data['order_minute'] = $this->input->post('order_minute');
         // retrieve order_time value from $_POST data if set
     } else {
         if (isset($order_data['order_minute'], $data['order_times'][$data['order_date']][$order_data['order_hour']]) and in_array($order_data['order_minute'], $data['order_times'][$data['order_date']][$order_data['order_hour']])) {
             $data['order_minute'] = $order_data['order_minute'];
             // retrieve order_type from session data
         } else {
             $data['order_minute'] = $order_minute;
         }
     }
     if ($this->input->post('order_time')) {
         $data['order_time'] = $this->input->post('order_time');
         // retrieve order_time value from $_POST data if set
     } else {
         if (isset($order_data['order_time'])) {
             $data['order_time'] = $order_data['order_time'];
             // retrieve order_type from session data
         } else {
             $data['order_time'] = '';
         }
     }
     if ($this->input->post('address_id')) {
         $data['address_id'] = $this->input->post('address_id');
         // retrieve existing_address value from $_POST data if set
     } else {
         if (isset($order_data['address_id'])) {
             $data['address_id'] = $order_data['address_id'];
             // retrieve existing_address from session data
         } else {
             if ($this->customer->getAddressId()) {
                 $data['address_id'] = $this->customer->getAddressId();
                 // retrieve customer default address id from customer library
             } else {
                 $data['address_id'] = '';
             }
         }
     }
     if ($this->config->item('country_id')) {
         $country_id = $this->config->item('country_id');
         // retrieve country_id from config settings
     }
     if ($this->input->post('address')) {
         $addresses = $this->input->post('address');
         // retrieve address value from $_POST data if set
     } else {
         if ($this->customer->islogged()) {
             $addresses = $this->Addresses_model->getAddresses($this->customer->getId());
             // retrieve customer addresses array from getAddresses method in Customers model
         } else {
             if (!empty($order_data['address_id'])) {
                 $addresses = array($this->Addresses_model->getGuestAddress($order_data['address_id']));
                 // retrieve customer addresses array from getAddresses method in Customers model
             }
         }
     }
     if (empty($addresses)) {
         $addresses = array(array('address_id' => '0', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country_id' => $country_id));
     }
     $data['addresses'] = array();
     if ($addresses) {
         foreach ($addresses as $address) {
             // loop through customer addresses arrary
             if (empty($address['country'])) {
                 $country = $this->Countries_model->getCountry($address['country_id']);
                 $address['country'] = !empty($address['country']) ? $address['country'] : $country['country_name'];
             }
             $data['addresses'][] = array('address_id' => isset($address['address_id']) ? $address['address_id'] : NULL, 'address_1' => $address['address_1'], 'address_2' => $address['address_2'], 'city' => $address['city'], 'state' => $address['state'], 'postcode' => $address['postcode'], 'country_id' => $address['country_id'], 'address' => $this->country->addressFormat($address));
         }
     }
     if ($this->input->post('comment')) {
         $data['comment'] = $this->input->post('comment');
         // retrieve comment value from $_POST data if set
     } else {
         if (isset($order_data['comment'])) {
             $data['comment'] = $order_data['comment'];
             // retrieve comment from session data
         } else {
             $data['comment'] = '';
         }
     }
     if ($this->input->post('payment')) {
         $data['payment'] = $this->input->post('payment');
         // retrieve comment value from $_POST data if set
     } else {
         if (isset($order_data['payment'])) {
             $data['payment'] = $order_data['payment'];
             // retrieve comment from session data
         } else {
             $data['payment'] = '';
         }
     }
     if ($this->config->item('checkout_terms') > 0) {
         $data['checkout_terms'] = str_replace(root_url(), '/', site_url('pages?popup=1&page_id=' . $this->config->item('checkout_terms')));
     } else {
         $data['checkout_terms'] = FALSE;
     }
     if ($this->input->ip_address()) {
         $data['ip_address'] = $this->input->ip_address();
         // retrieve ip_address value if set
     }
     $data['countries'] = array();
     $results = $this->Countries_model->getCountries();
     // retrieve countries array from getCountries method in locations model
     foreach ($results as $result) {
         // loop through crountries array
         $data['countries'][] = array('country_id' => $result['country_id'], 'name' => $result['country_name']);
     }
     $data['payments'] = array();
     $local_payments = $this->location->payments();
     $payments = $this->extension->getAvailablePayments();
     foreach (sort_array($payments) as $code => $payment) {
         if (!empty($local_payments) and !in_array($payment['code'], $local_payments)) {
             continue;
         }
         $data['payments'][] = $payment;
     }
     return $data;
 }
Пример #10
0
        $ADDRESS->delGRP($adr_grp_id, 0, 1);
    }
    $_MAIN_MESSAGE .= "<br>" . ___("Eintrag und die zugeordneten Adressen wurden gelöscht.");
}
$GRP = $ADDRESS->getGroup(0, 0, 0, 1);
//sort array:
$sortIndex = getVar("si");
if (empty($sortIndex)) {
    $sortIndex = "id";
}
$sortType = getVar("st");
if (empty($sortType)) {
    $sortType = "0";
    //asc
}
$GRP = sort_array($GRP, $sortIndex, $sortType);
//count entries:
$acg = count($GRP);
$editURLPara = tmObjCopy($mSTDURL);
$editURLPara->addParam("act", "adr_grp_edit");
$addadrURLPara = tmObjCopy($mSTDURL);
$addadrURLPara->addParam("act", "adr_new");
$showadrURLPara = tmObjCopy($mSTDURL);
$showadrURLPara->addParam("act", "adr_list");
$aktivURLPara = tmObjCopy($mSTDURL);
$aktivURLPara->addParam("act", "adr_grp_list");
$aktivURLPara->addParam("set", "aktiv");
$prodURLPara = tmObjCopy($mSTDURL);
$prodURLPara->addParam("act", "adr_grp_list");
$prodURLPara->addParam("set", "prod");
$delURLPara = tmObjCopy($mSTDURL);
 public function testDropColumnCheckConstraint()
 {
     self::$db->translatedQuery('ALTER TABLE users DROP COLUMN "status"');
     $this->rollback_statements[] = "UPDATE users SET status = 'Inactive' WHERE user_id = 3";
     $this->rollback_statements[] = "ALTER TABLE users ADD COLUMN status VARCHAR(8) NOT NULL DEFAULT 'Active' CHECK(status IN ('Active', 'Inactive', 'Pending'))";
     $schema = new fSchema(self::$db);
     $this->assertEquals(sort_array(array('user_id', 'first_name', 'middle_initial', 'last_name', 'email_address', 'times_logged_in', 'date_created', 'birthday', 'time_of_last_login', 'is_validated', 'hashed_password')), sort_array(array_keys($schema->getColumnInfo('users'))));
 }
Пример #12
0
    }
    foreach ($tmp_Array as $key => $tmp) {
        $sorted[] = $array[$key];
    }
    return $sorted;
}
if ($findgit !== "") {
    $json = array_sha($findgit, true);
    $total_count = count($json);
    if (isset($json['message'])) {
        $html .= "<br><strong>message: " . $json['message'] . "</strong><br>";
    } else {
        if ($total_count > 0) {
            $html .= "<br>Всего комментариев: " . $total_count . ".<br>";
            $json = array_sha($findgit, false, $page, $per_page);
            $json = sort_array($json, 'date');
            $html .= "<table border='0' id='table_git'>";
            $html .= "<tr align='center'><td>N</td><td>Автор</td><td>Дата</td><td>Файлы</td><td>Комментарий</td></tr>";
            foreach ($json as $key => $value) {
                $html .= "<tr><td>" . ++$key . "</td><td>" . htmlentities($value['name'], ENT_QUOTES | ENT_IGNORE, "UTF-8") . "</td><td>" . $value['date'] . "</td><td>" . $value['files'] . "</td><td>" . htmlentities($value['message'], ENT_QUOTES | ENT_IGNORE, "UTF-8") . "</td></tr>";
            }
            $html .= "</table>";
            // ссылки по страницам
            if ($total_count > $per_page) {
                $page_count = ceil($total_count / $per_page);
                $html .= "<br>страница (" . $page . " из " . $page_count . "): ";
                if ($page_count <= 10) {
                    for ($i = 1; $i <= $page_count; ++$i) {
                        $html .= $page !== $i ? "<a href='#' id='page_curl' title='" . $i . "'>" . $i . "</a> " : "<font class='red'>" . $i . "</font> ";
                    }
                } else {
Пример #13
0
 public function getTotals($filter = array('filter_status' => '1'))
 {
     $this->db->from('extensions');
     $this->db->where('type', 'cart_total');
     if (!empty($filter['filter_status'])) {
         $this->db->where('status', $filter['filter_status']);
     }
     $query = $this->db->get();
     $results = array();
     if ($query->num_rows() > 0) {
         foreach ($query->result_array() as $row) {
             $row['data'] = ($row['serialized'] === '1' and !empty($row['data'])) ? unserialize($row['data']) : array();
             $results[$row['name']] = array('name' => $row['name'], 'title' => htmlspecialchars_decode($row['data']['title']), 'admin_title' => htmlspecialchars_decode($row['data']['admin_title']), 'type' => $row['type'], 'data' => $row['data'], 'status' => $row['status'], 'priority' => $row['data']['priority']);
         }
     }
     return sort_array($results, 'priority');
 }
Пример #14
0
$nextURLPara->addParam("limit", $limit);
$nextURLPara->addParam("st", $sortType);
$nextURLPara->addParam("si", $sortIndex);
$nextURLPara_ = $nextURLPara->getAllParams();
$prevURLPara = tmObjCopy($mSTDURL);
$prevURLPara->addParam("act", "bl_list");
$prevURLPara->addParam("offset", $offset - $limit);
$prevURLPara->addParam("limit", $limit);
$prevURLPara->addParam("st", $sortType);
$prevURLPara->addParam("si", $sortIndex);
$prevURLPara_ = $prevURLPara->getAllParams();
$exportURLPara = tmObjCopy($mSTDURL);
$exportURLPara->addParam("set", "export_blacklist");
$exportURLPara_ = $exportURLPara->getAllParams();
$BL = $BLACKLIST->getBL(0, array("type" => $type), $offset, $limit);
$BL = sort_array($BL, $sortIndex, $sortType);
$bc = count($BL);
$entrys = $bc;
// fuer pager.inc!!!
$pagesURLPara = tmObjCopy($mSTDURL);
//will be defined and use in pager.inc.php
//show log summary
//search for logs, only section
$search_log['object'] = "bl";
include TM_INCLUDEPATH . "/log_summary_section.inc.php";
require_once TM_INCLUDEPATH . "/bl_list_form.inc.php";
require_once TM_INCLUDEPATH . "/bl_list_form_show.inc.php";
//pager
require TM_INCLUDEPATH . "/pager.inc.php";
//table
$_MAIN_OUTPUT .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">";
Пример #15
0
 public function all()
 {
     $this->load->library('country');
     $this->load->library('pagination');
     $this->load->library('cart');
     // load the cart library
     $this->load->model('Image_tool_model');
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('menus_page_limit')) {
         $filter['limit'] = $this->config->item('menus_page_limit');
     }
     $filter['filter_status'] = '1';
     $filter['order_by'] = 'ASC';
     if ($this->input->get('search')) {
         $filter['filter_search'] = $this->input->get('search');
         $url .= 'search=' . $filter['filter_search'] . '&';
     }
     if ($this->input->get('sort_by')) {
         $sort_by = $this->input->get('sort_by');
         if ($sort_by === 'newest') {
             $filter['sort_by'] = 'location_id';
             $filter['order_by'] = 'DESC';
         } else {
             if ($sort_by === 'name') {
                 $filter['sort_by'] = 'location_name';
             }
         }
         $url .= 'sort_by=' . $sort_by . '&';
     }
     $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/');
     $this->template->setBreadcrumb($this->lang->line('text_heading'), 'local/all');
     $this->template->setTitle($this->lang->line('text_heading'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $review_totals = $this->Reviews_model->getTotalsbyId();
     // retrieve all customer reviews from getMainList method in Reviews model
     $data['locations'] = array();
     $locations = $this->Locations_model->getList($filter);
     if ($locations) {
         foreach ($locations as $location) {
             $this->location->setLocation($location['location_id'], FALSE);
             $opening_status = $this->location->workingStatus('opening');
             $delivery_status = $this->location->workingStatus('delivery');
             $collection_status = $this->location->workingStatus('collection');
             $delivery_time = $this->location->deliveryTime();
             if ($delivery_status === 'closed') {
                 $delivery_time = 'closed';
             } else {
                 if ($delivery_status === 'opening') {
                     $delivery_time = $this->location->workingTime('delivery', 'open');
                 }
             }
             $collection_time = $this->location->collectionTime();
             if ($collection_status === 'closed') {
                 $collection_time = 'closed';
             } else {
                 if ($collection_status === 'opening') {
                     $collection_time = $this->location->workingTime('collection', 'open');
                 }
             }
             $review_totals = isset($review_totals[$location['location_id']]) ? $review_totals[$location['location_id']] : 0;
             $data['locations'][] = array('location_id' => $location['location_id'], 'location_name' => $location['location_name'], 'description' => strlen($location['description']) > 120 ? substr($location['description'], 0, 120) . '...' : $location['description'], 'address' => $this->location->getAddress(TRUE), 'total_reviews' => $review_totals, 'location_image' => $this->location->getImage(), 'is_opened' => $this->location->isOpened(), 'is_closed' => $this->location->isClosed(), 'opening_status' => $opening_status, 'delivery_status' => $delivery_status, 'collection_status' => $collection_status, 'delivery_time' => $delivery_time, 'collection_time' => $collection_time, 'opening_time' => $this->location->openingTime(), 'closing_time' => $this->location->closingTime(), 'min_total' => $this->location->minimumOrder($this->cart->total()), 'delivery_charge' => $this->location->deliveryCharge($this->cart->total()), 'has_delivery' => $this->location->hasDelivery(), 'has_collection' => $this->location->hasCollection(), 'last_order_time' => $this->location->lastOrderTime(), 'distance' => round($this->location->checkDistance()), 'distance_unit' => $this->config->item('distance_unit') === 'km' ? $this->lang->line('text_kilometers') : $this->lang->line('text_miles'), 'href' => site_url('local?location_id=' . $location['location_id']));
         }
     }
     if (!empty($sort_by) and $sort_by === 'distance') {
         $data['locations'] = sort_array($data['locations'], 'distance');
     } else {
         if (!empty($sort_by) and $sort_by === 'rating') {
             $data['locations'] = sort_array($data['locations'], 'total_reviews');
         }
     }
     $config['base_url'] = site_url('local/all' . $url);
     $config['total_rows'] = $this->Locations_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->location->initialize();
     $data['locations_filter'] = $this->filter($url);
     $this->template->render('local_all', $data);
 }
Пример #16
0
    //id,offset,limit,group
} else {
    $FRM = $FORMULAR->getForm(0, 0, 0, 0);
    //id,offset,limit,group
}
$ac = count($FRM);
$sortIndex = getVar("si");
if (empty($sortIndex)) {
    $sortIndex = "id";
}
$sortType = getVar("st");
if (empty($sortType)) {
    $sortType = "0";
    //asc
}
$FRM = sort_array($FRM, $sortIndex, $sortType);
$stdURLPara = tmObjCopy($mSTDURL);
$stdURLPara->addParam("act", "form_list");
$stdURLPara->addParam("set", "standard");
$editTplPara = tmObjCopy($mSTDURL);
$editTplPara->addParam("act", "file_edit");
$editTplPara->addParam("file_section", "frm");
$sortURLPara = tmObjCopy($mSTDURL);
$sortURLPara->addParam("act", "form_list");
$sortURLPara_ = $sortURLPara->getAllParams();
$editURLPara = tmObjCopy($mSTDURL);
$editURLPara->addParam("act", "form_edit");
$aktivURLPara = tmObjCopy($mSTDURL);
$aktivURLPara->addParam("act", "form_list");
$aktivURLPara->addParam("set", "aktiv");
$delURLPara = tmObjCopy($mSTDURL);
Пример #17
0
 /**
  * Save the cart array to the session DB
  *
  * @access	private
  * @return	bool
  */
 protected function _save_cart()
 {
     // Let's add up the individual prices and set the cart sub-total
     $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = $this->_cart_contents['order_total'] = 0;
     foreach ($this->_cart_contents as $key => $val) {
         // We make sure the array contains the proper indexes
         if (!is_array($val) or !isset($val['price'], $val['qty'])) {
             continue;
         }
         $this->_cart_contents['cart_total'] += $val['price'] * $val['qty'];
         $this->_cart_contents['total_items'] += $val['qty'];
         $this->_cart_contents[$key]['subtotal'] = $this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty'];
     }
     $total = $this->_cart_contents['cart_total'];
     $this->_cart_contents['totals'] = sort_array($this->_cart_totals);
     foreach ($this->_cart_contents['totals'] as $key => $val) {
         if (!is_array($val) or !isset($val['amount'], $val['action'], $val['priority'])) {
             continue;
         }
         if ($val['action'] === 'add') {
             $total += $val['amount'];
         } else {
             if ($val['action'] === 'subtract') {
                 $total -= $val['amount'];
             }
         }
     }
     $this->_cart_contents['order_total'] = $total;
     // Is our cart empty? If so we delete it from the session
     if (count($this->_cart_contents) <= 4) {
         $this->CI->session->unset_userdata('cart_contents');
         // Nothing more to do... coffee time!
         return FALSE;
     }
     // If we made it this far it means that our cart has data.
     // Let's pass it to the Session class so it can be stored
     $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents));
     // Woot!
     return TRUE;
 }
Пример #18
0
    $inter = $val1;
    $val1 = $val2;
    $val2 = $inter;
}
function sort_array(&$array1, &$array2)
{
    for ($i = 0; $i < sizeof($array1); $i++) {
        for ($j = 0; $j < sizeof($array1); $j++) {
            if ($array1[$i] > $array1[$j]) {
                permute($array1[$i], $array1[$j]);
                permute($array2[$i], $array2[$j]);
            }
        }
    }
}
sort_array($tab_occurence, $tab_mot);
$table_final = array("mots" => $tab_mot, "occurence" => $tab_occurence);
echo ' <script>
          var chart = AmCharts.makeChart( "chartdiv", {
            "type": "serial",
            "theme": "light",
            "dataProvider": [';
for ($i = 0; $i < sizeof($tab_mot); $i++) {
    if ($i < 10) {
        echo '  {
              "country": "' . $tab_mot[$i] . '",
              "visits": ' . $tab_occurence[$i] . '},';
    }
}
echo '],
            "valueAxes": [ {
Пример #19
0
    ?>
 images
	</div>  
	   
	<div class="clear"></div>
	
	<?php 
    if ($numFiles == 0) {
        ?>

	    
		 <div class="p10-lr"><p>There are no images in this album.</p></div>
	
	<?php 
    } else {
        sort_array($files, $album, $sort_images_by_date);
        // rearrange array either by date or name
        $numPages = ceil($numFiles / $numPerPage);
        if (isset($_REQUEST['p'])) {
            $currentPage = (int) $_REQUEST['p'] > $numPages ? $numPages : (int) $_REQUEST['p'];
        } else {
            $currentPage = 1;
        }
        $start = $currentPage * $numPerPage - $numPerPage;
        if (!is_dir($album . '/thumbs')) {
            mkdir($album . '/thumbs');
            chmod($album . '/thumbs', 0777);
            //chown($album.'/thumbs', 'apache');
        }
        for ($i = 0; $i <= $numFiles; $i++) {
            if (isset($files[$i]) && is_file($album . '/' . $files[$i])) {
Пример #20
0
function list_directory($display_name, $path)
{
    global $localconfig;
    // Allow local configuration file to override any of these globals.
    global $mimetype, $disposition, $cacheable, $ignore, $recurse, $indexfile;
    // And these locals.
    $title = '';
    $annotation = '';
    if (file_exists("{$path}/{$localconfig}")) {
        include "{$path}/{$localconfig}";
    }
    $handle = @opendir($path) or die("Directory {$display_name} not found.");
    $files = array();
    $subdirs = array();
    while ($entry = readdir($handle)) {
        if (is_indexfile($entry)) {
            closedir($handle);
            send_file("{$path}/{$entry}");
            return;
        } elseif ($entry != '..' && $entry != '.' && !is_ignored($entry)) {
            if (!is_dir("{$path}/{$entry}")) {
                $files[] = $entry;
            } elseif ($recurse) {
                $subdirs[] = $entry;
            }
        }
    }
    closedir($handle);
    sort_array($files);
    sort_array($subdirs);
    open_doc($title);
    announce_directory($display_name, $title, $annotation);
    print "<table width=\"100%\" border=0 cellspacing=1 cellpadding=2>\n";
    for ($s = reset($subdirs); $s; $s = next($subdirs)) {
        print_entry("{$s}/", '(dir)', '&nbsp');
    }
    for ($s = reset($files); $s; $s = next($files)) {
        print_entry($s, solidify(pretty_size(filesize("{$path}/{$s}"))), solidify(pretty_date(filemtime("{$path}/{$s}"))));
    }
    print "</table>\n";
    close_doc();
}
Пример #21
0
} else {
    $requested_album = sanitize($_REQUEST['album']);
    // xss prevention
    $albums = 'thumbs/' . $requested_album;
    $files = scandir('thumbs/' . $requested_album);
    $files = array_diff($files, array('..', '.'));
    $numFiles = count($files);
    // var_dump($requested_album);
    // var_dump($files);
    // var_dump($numFiles);
    if ($numFiles == 0) {
        ?>
                            <div class="p10-lr"><p>There are no images in this album.</p></div>
                            <?php 
    } else {
        sort_array($files, $albums, true);
        // rearrange array either by date or name
        // var_dump($files);
        for ($i = 0; $i <= $numFiles; $i++) {
            if (isset($files[$i]) && is_file($albums . '/' . $files[$i])) {
                $ext = strtolower(pathinfo($files[$i], PATHINFO_EXTENSION));
                if (in_array($ext, $extensions)) {
                    $thumb = $albums . '/' . $files[$i];
                    ?>
                                <div class="col-xs-3 col-sm-3 col-md-3">
                                    <a class="group1" href="{{asset('source/'.$requested_album.'/'.$files[$i])}}">
                                    <div class="thumbnail">
                                        <img src="{{asset($thumb)}}" alt="<?php 
                    echo $files[$i];
                    ?>
">
Пример #22
0
}
$search_nl['is_template'] = $s_nl_istemplate;
if ($nl_grp_id != 0) {
    $NL = $NEWSLETTER->getNL(0, $offset, $limit, $nl_grp_id, 0, $sortIndex, $sortType, $search_nl);
    //
    $nl_grp = $NEWSLETTER->getGroup($nl_grp_id);
    $_MAIN_MESSAGE .= "<br>" . sprintf(___("Gewählte Gruppe: %s"), "<b>" . display($nl_grp[0]['name']) . "</b>");
} else {
    $NL = $NEWSLETTER->getNL(0, $offset, $limit, 0, 0, $sortIndex, $sortType, $search_nl);
    //
}
$nc = count($NL);
$entrys = $nc;
// fuer pager.inc!!!
$entrys_total = $NEWSLETTER->countNL($nl_grp_id, $search_nl);
$NL = sort_array($NL, $sortIndex, $sortType);
//defaults
$mSTDURL->addParam("act", "nl_list");
$mSTDURL->addParam("offset", $offset);
$mSTDURL->addParam("limit", $limit);
$mSTDURL->addParam("st", $sortType);
$mSTDURL->addParam("si", $sortIndex);
$mSTDURL->addParam("s_nl_istemplate", $s_nl_istemplate);
$firstURLPara = tmObjCopy($mSTDURL);
$firstURLPara->addParam("nl_grp_id", $nl_grp_id);
$firstURLPara->addParam("offset", 0);
$firstURLPara_ = $firstURLPara->getAllParams();
$lastURLPara = tmObjCopy($mSTDURL);
$lastURLPara->addParam("act", "nl_list");
$lastURLPara->addParam("offset", $entrys_total - $limit);
$lastURLPara_ = $lastURLPara->getAllParams();