AM_Core = new Application_Maker_Core();
// parent::__construct(); default_pagin_nb
}
//CREATE A CUSTOM DROP DOWN COMBO FILTER FOR A CHECKBOX CUSTOM FIELD
public function grid_show_custom_post_checkbox_dropdown($label, $object) {
global $post, $wpdb;
echo '
';
}
//SHOW USERS DROPDOWN COMBO
public function grid_show_userlist_dropdown($field, $object) {
global $post, $wpdb;
echo "";
$users_list = wp_dropdown_users(array(
'show_option_all' => __('Show All'),
'name' => 'key_' . $object
, 'selected' => $_GET['key_' . $object],
'echo' => '0'
));
$users_list = str_replace("'0'", "'all'", $users_list);
echo $users_list;
echo ' ';
}
public function grid_show_custom_post_dropdown($post_type, $post_type_label, $object = '') {
global $post, $wpdb;
if ($object == "") {
$object = $post_type;
}
$posts_list = $this->AM_Core->get_posts_list_alone($post_type);
echo '
';
}
public function set_top_modules_list() {
global $apm_settings, $app_name;
//var_dump($this->Parent->applications);//->applications
$appli_post_types = $this->config['app'] ['modules'];
$appName = $this->config['app']['name'];
$opappLabel = get_option($appName . '_app_name');
$appLabel = $this->config['app']['singular_name'];
$mod = $appli_post_types[$this->config['modulekey']];
if ($opappLabel !== '' and $opappLabel !== false and !empty($opappLabel)) {
$appLabel = $opappLabel;
}
echo '
';
// var_dump($mod);
$icon = '';
if (isset($mod['icon']) and $mod['icon'] !== '' and $mod['icon'] !== false) {
$icon = "
";
}
echo "- " . $icon . " " . $appLabel . " - " . $mod['name'] . "";
echo " ";
echo "
";
echo '';
$navmain_str = '';
$navother_str = '';
foreach ($appli_post_types as $subkey => $post_type_obj) {
$icon = '';
if (isset($post_type_obj['icon'])) {
$icon = "
";
}
$acti = '';
if ($subkey == $this->config['modulekey']) {
$acti = ' active ';
}
if (isset($post_type_obj['roles_authorized']) and $post_type_obj['roles_authorized'] != '') {
if (!$this->check_roles_authorized($post_type_obj['roles_authorized']))
continue;
}
if (isset($post_type_obj['is_secundary']) and $post_type_obj['is_secundary'] == true) {
$nav0bj = '
-
' . $icon . $post_type_obj['name'] . '
|
';
$navother_str.=$nav0bj;
} else {
$nav0bj = '
-
' . $icon . $post_type_obj['name'] . '
';
$navmain_str.=$nav0bj;
}
}
echo $navmain_str;
if ($navother_str !== '') {
echo '
- ';
echo '
OTHERS
';
echo '
';
}
echo ''; //MODULES:
echo ' -
APPS
';
echo '
';
}
public function set_sort_by() {
global $apm_settings;
if (!isset($this->config['module']['module_columns_sortby']) or !is_array($this->config['module']['module_columns_sortby']) or count($this->config['module']['module_columns_sortby']) == 0) {
return;
}
$a = $this->config['module']['module_columns_sortby'];
echo ' ';
//var_dump($this->default_fields);
}
public function set_advanced_search() {
global $apm_settings;
if (!isset($this->config['module']['module_columns_filters'])) {
return;
}
$filters = $this->config['module']['module_columns_filters'];
$taxo = get_object_taxonomies($this->config['modulekey']);
$nb_of_filters = 0;
foreach ($taxo as $tax_slug) {
if (substr(($tax_slug), 0, 3) == 'cat') {
$nb_of_filters++;
$tax_obj = get_taxonomy($tax_slug);
echo '
';
wp_dropdown_categories(array(
'show_option_all' => __('Show All '),
'taxonomy' => $tax_slug,
'name' => 'cat_' . $tax_obj->name,
'orderby' => 'term_order',
'selected' => $_GET[$tax_obj->query_var],
'hierarchical' => $tax_obj->hierarchical,
'show_count' => false,
'hide_empty' => true
));
}
}
foreach ($filters as $object) {
$nb_of_filters++;
$field = $this->default_fields[$object];
echo '
';
$field_type = $field['field_type'];
if (isset($field['filter_field_type'])) {
$field_type = $field['filter_field_type'];
}
switch ($field_type) {
case 'select':
if (isset($field['field_config']['post_type'])) {
$this->grid_show_custom_post_dropdown($field['field_config']['post_type'], $field['label'], $object);
} else if (isset($field['field_config']['use_values']) and $field['field_config']['use_values'] == true) {
echo '
';
}
break;
case 'autocomplete':
if (isset($field['field_config']['post_type'])) {
$select_post_type = $field['field_config']['post_type'];
$value = '';
$valueDisplay = '';
if (isset($_GET['key_' . $object])) {
$value = $_GET['key_' . $object];
}
if (isset($_GET['keydisplay_' . $object])) {
$valueDisplay = $_GET['keydisplay_' . $object];
}
$label = $field['label'];
if (isset($field['filter_label'])) {
$label = $field['filter_label'];
}
echo ' ";
echo '';
echo '';
$help_image = WP_PLUGIN_URL . '/' . WP_PLUGIN_FOLDER . '/img/bugsqa_16.png';
echo '
' . _('AutoSuggest field, please enter the first 3 characters.') . '';
}
break;
case 'checkbox':
$this->grid_show_custom_post_checkbox_dropdown($field['label'], $object);
break;
case 'userslist':
$this->grid_show_userlist_dropdown($field, $object);
break;
case 'assignee':
$this->grid_show_userlist_dropdown($field, $object);
break;
}
}
}
public function set_page_header() {
global $apm_settings;
$module_name = $this->config['module']['name'];
$appkey = $this->config['appkey'];
if (get_option($appkey . '_app_name') !== false and get_option($appkey . '_app_name') !== '') {
$app_name = get_option($appkey . '_app_name');
} else {
$app_name = $this->config['app']['name'];
}
$company_name = get_option('company_name');
if ($company_name !== false and $company_name !== '') {
$company_name = $company_name . " | ";
} else {
$company_name = '';
}
$iconCss = '';
if (isset($this->config['module']['icon'])) {
$iconCss = " background:url('" . $apm_settings['paths']['img'] . "/" . $this->config['module']['icon'] . "') no-repeat 5px 8px; ";
}
require_once APPLICATION_MAKER_VIEWS_PATH . 'datagrid/apm-datagrid-header.php';
}
public function do_basic_search_input() {
echo '";
if (isset($col_config['user_can_change_paging_nb_by_module']) and $col_config['user_can_change_paging_nb_by_module'] == true) {
if ($action == "get_nb_by_page_form") {
if (isset($_REQUEST['default_pagin_nb'])) {
$default_pagin_nb = intval($_REQUEST['default_pagin_nb']);
update_option($modulekey . '_default_paging_nb', $default_pagin_nb);
}
$ret = "Records by page:
";
}
}
switch ($action) {
case "header_paging":
$ret = " ";
break;
case "has_paging":
$ret = true;
break;
case "nb_by_page":
$ret = $default_pagin_nb;
break;
case "initial_page":
$ret = $page_nb;
break;
}
}
}
echo $ret;
}
public function get_datagrid_paging_nb($modulekey = '') {
global $apm_settings, $oThis;
if (isset($this->config['appkey'])) {
$appkey = $this->config['appkey'];
$module = $this->config['module'];
$modulekey = $this->config['modulekey'];
} else {
$module = $oThis->all_modules[$modulekey];
}
$module_name = $module['name'];
$default_pagin_nb = 'all';
if (isset($module['module_columns_config'])) {
$col_config = $module['module_columns_config'];
if (isset($col_config['use_paging']) and $col_config['use_paging'] == true) {
$default_pagin_nb = 15;
if (isset($col_config['use_global_default_paging_nb']) and $col_config['use_global_default_paging_nb'] == true) {
if (get_option('default_paging_nb') !== false and get_option('default_paging_nb') !== '' and intval(get_option('default_paging_nb')) > 0) {
$default_pagin_nb = get_option('default_paging_nb');
}
}
if (isset($col_config['nb_by_page']) and intval($col_config['nb_by_page']) > 0) {
$default_pagin_nb = intval($col_config['nb_by_page']);
}
if (isset($col_config['user_can_change_paging_nb_by_module']) and $col_config['user_can_change_paging_nb_by_module'] == true) {
if (get_option($modulekey . '_default_paging_nb') !== false and get_option($modulekey . '_default_paging_nb') !== '') {
$default_pagin_nb = intval(get_option($modulekey . '_default_paging_nb'));
}
}
}
}
return $default_pagin_nb;
}
public function set_datagrid_header() {
global $apm_settings, $oThis;
echo ' | ';
echo 'Acti. | ';
echo 'Sta. | ';
if (isset($this->config['module']['module_columns'])) {
foreach ($this->config['module']['module_columns'] as $column) {
$f = $this->default_fields[$column];
$label = $f['label'];
$clabel = '';
$width = '';
if (isset($f['column_label'])) {
$clabel = $f['column_label'];
}
if (isset($f['column_width'])) {
$width = ' style="width:' . $f['column_width'] . 'px;" ';
}
$label = $oThis->get_currency($label);
$clabel = $oThis->get_currency($clabel);
// $label = str_replace("{{currency}}", $apm_settings['configs']['default_currency'], $label);
// $clabel = str_replace("{{currency}}", $apm_settings['configs']['default_currency'], $clabel);
if ($column == "post_title") {
$label = 'Title';
}
if ($column == "post_date") {
$label = 'Date';
}
if ($column == "featured_image") {
$label = 'Image';
}
if ($column == "menu_order" or $column == "order") {
$label = 'Order';
}
if ($clabel == '') {
echo '' . $label . ' | ';
} else {
echo '' . $clabel . ' | ';
}
}
} else {
echo 'Title |
Status |
Date | ';
}
/* echo ' |
Title | Date | xxx | Childs | Acti. | '; */
}
public function set_footer() {
require_once APPLICATION_MAKER_VIEWS_PATH . 'datagrid/apm-datagrid-footer.php';
}
}
}