Example #1
0
 public static function render($widget_area)
 {
     $view = Libraries_View::getInstance();
     $page = $view->getSharedData('_SYSTEM_PAGE');
     $page_template = $view->getSharedData('_SYSTEM_PAGE_TEMPLATE');
     $where = array();
     $where[] = array('AND', 'id_page', '=', $page->id);
     $where[] = array('AND', 'area_name', '=', $widget_area);
     $order = array();
     $order[] = array('order_index', 'ASC');
     $widget_instance = new Page_Models_Page_Widget_Instance();
     $widget_instances = $widget_instance->search($where, $order);
     foreach ($widget_instances as $widget_instance) {
         $widget = new Page_Models_Page_Widget();
         $widget->load($widget_instance->id_page_widget);
         $sys_object = new Crud_Models_Object();
         $sys_object->load($widget->id_sys_object);
         $row = new Libraries_Db_Mysql_Model($sys_object->table_name);
         $row->load($widget_instance->id_row);
         $widget_class_name = $widget->class_name;
         /*
         echo '<pre>'; print_r($widget); echo '</pre>';
         echo '<pre>'; print_r($widget_instance); echo '</pre>'; exit;
         */
         echo '<div class="widget" data-widget-id="' . $widget->id . '" data-widget-instance-id="' . $widget_instance->id . '" data-widget-object-id="' . $widget->id_sys_object . '" data-widget-row-id="' . $widget_instance->id_row . '">';
         call_user_func_array(array(new $widget_class_name(), 'render'), array($widget, $widget_instance, $row));
         echo '</div>';
     }
 }
Example #2
0
 public function query($table_name)
 {
     //$table_name = $_POST['table_name'];
     $query = $_GET['term'];
     $sys_object = new Crud_Models_Object();
     $sys_object->load($table_name, 'table_name');
     $sys_object->loadFieldsForObject();
     $searchable_fields = array();
     foreach ($sys_object->sys_field_list as $sys_field) {
         if ($sys_field->is_hidden == 0 && $sys_field->is_identification == 1) {
             $searchable_fields[] = $sys_field->field_name;
         }
     }
     $data = array();
     $sql = "SELECT id, " . implode(', ', $searchable_fields) . "\r\n\t\t        FROM {$table_name} \r\n\t\t        WHERE is_deleted = 0 AND (";
     foreach ($searchable_fields as $searchable_field) {
         $sql .= " {$searchable_field} LIKE ?";
         $data[] = "%" . $query . "%";
         if (end($searchable_fields) != $searchable_field) {
             $sql .= " OR";
         } else {
             $sql .= ')';
         }
     }
     $results = Libraries_Db_Factory::getDb()->fetchAll($sql, $data, Libraries_Db_Adapter::FETCH_TYPE_ASSOC);
     $response = array();
     foreach ($results as $result) {
         $id = array_shift($result);
         $response[] = array('id' => $id, 'value' => implode(', ', $result));
     }
     echo json_encode($response);
 }
Example #3
0
 public function content($sys_object_id)
 {
     $sys_object = new Crud_Models_Object();
     $sys_object->load(intval($sys_object_id));
     $sys_object->loadFieldsForObject();
     if ($sys_object->is_system == 1 && $this->user->role->safe_title != 'administrator') {
         echo '<script>window.location="' . SITE_ROOT_URI . '/admin/error/' . '"</script>';
         exit;
     }
     if (!$this->user->role->canExecuteAction('can_view_' . $sys_object->table_name)) {
         echo '<script>window.location="' . SITE_ROOT_URI . '/admin/error/' . '"</script>';
         exit;
     }
     $order = array();
     $order[] = array('title', 'ASC');
     $role = new Libraries_Db_Mysql_Model('adm_user_role');
     $roles = $role->search(array(), $order);
     if (isset($_POST) && !empty($_POST)) {
         foreach ($roles as $role) {
             $sql = "DELETE \r\n\t\t\t\t\t\tFROM adm_user_role_permission\r\n\t\t\t\t\t\tWHERE id_adm_user_role = ?";
             $data = array($role->id);
             Libraries_Db_Factory::getDb()->execute($sql, $data);
             foreach ($_POST as $action => $data) {
                 $permission = new Libraries_Db_Mysql_Model('adm_user_role_permission');
                 $permission->id_adm_user_role = $role->id;
                 $permission->action = $action;
                 $permission->is_active = array_key_exists($role->id, $data) && $data[$role->id] == 1 ? 1 : 0;
                 $permission->save();
             }
         }
         Libraries_Flashdata::set('saved', __('Permissions is saved'));
     }
     $order = array();
     $order[] = array('table_name', 'ASC');
     $where = array();
     $where[] = array('AND', 'is_system', '!=', 1);
     $objects = $sys_object->search($where, $order);
     Libraries_View::getInstance()->roles = $roles;
     Libraries_View::getInstance()->objects = $objects;
     Libraries_View::getInstance()->saved_status = Libraries_Flashdata::get('saved');
     $content = Libraries_View::getInstance()->setModule('admin')->load('permissions');
     Libraries_Layout::getInstance()->setTheme('admin');
     Libraries_Layout::getInstance()->setLayout('admin');
     Libraries_Layout::getInstance()->setRegionContent('content', $content);
     Libraries_Layout::getInstance()->render();
 }
Example #4
0
 public function query()
 {
     $sys_object_id = intval($_POST['sys_object_id']);
     $sys_object = new Crud_Models_Object();
     $sys_object->load($sys_object_id);
     $sys_object->loadFieldsForObject();
     $data = new Libraries_Db_Mysql_Model($sys_object->table_name);
     $data = $data->search();
     $response = array();
     foreach ($data as $row) {
         $text_value = '';
         foreach ($sys_object->sys_field_list as $sys_field) {
             if ($sys_field->is_identification == 1 && array_key_exists($sys_field->field_name, $row->data)) {
                 $text_value .= $row->{$sys_field->field_name} . ', ';
             }
         }
         $item = array($row->id, trim($text_value, ', '));
         $response[] = $item;
     }
     echo json_encode($response);
 }
Example #5
0
 public function reordermanual()
 {
     $object = new Crud_Models_Object();
     $object->load($_POST['object_id']);
     $field = new Crud_Models_Field();
     $field->load($_POST['field_id']);
     $row = new Libraries_Db_Mysql_Model($object->table_name);
     $row->load($_POST['row_id']);
     $where = array();
     $order = array();
     $replacement_row = new Libraries_Db_Mysql_Model($object->table_name);
     $replacement_row->load(intval($_POST['value']), $field->field_name);
     if ($replacement_row->isEmpty()) {
         $sql = "SELECT MIN({$field->field_name}) as min, MAX({$field->field_name}) as max\r\n\t\t\t\t\tFROM {$object->table_name}\r\n\t\t\t\t\tWHERE is_deleted = 0";
         $min_max = Libraries_Db_Factory::getDb()->fetchRow($sql, array(), Libraries_Db_Adapter::FETCH_TYPE_CLASS);
         if ($_POST['value'] < $min_max->min) {
             $replacement_row = $replacement_row->load($min_max->min, $field->field_name);
             $_POST['value'] = $min_max->min;
         }
         if ($_POST['value'] > $min_max->max) {
             $replacement_row = $replacement_row->load($min_max->max, $field->field_name);
             $_POST['value'] = $min_max->max;
         }
         /*
         $response = array();
         $response['error'] = 'Can\'t find this object';
         
         echo json_encode($response);
         return;
         */
     }
     $replacement_row->{$field->field_name} = $row->{$field->field_name};
     $replacement_row->save();
     $row->{$field->field_name} = $_POST['value'];
     $row->save();
     $response = array();
     $response['success'] = 1;
     echo json_encode($response);
     return;
 }
Example #6
0
<?php

$table_name = $control_properties->table_name;
$sys_object = new Crud_Models_Object();
$sys_object->load($table_name, 'table_name');
$sys_object->loadFieldsForObject();
$data = new Libraries_Db_Mysql_Model($sys_object->table_name);
$data = $data->search();
?>
<div class="ocp-select">
	<select id="<?php 
echo $field->field_name;
?>
" name="<?php 
echo $field->field_name;
?>
" class="form-control" tabindex="<?php 
echo $index;
?>
">
		<option value=""></option>
		
		<?php 
if (!empty($data)) {
    ?>
			<?php 
    foreach ($data as $row) {
        ?>
				<option value="<?php 
        echo $row->id;
        ?>
Example #7
0
 public function getfields()
 {
     $object = new Crud_Models_Object();
     $object->load(intval($_POST['sys_object_id']));
     $object->loadFieldsForObject();
     $response = array();
     foreach ($object->sys_field_list as $field) {
         if ($field->is_hidden == 1) {
             continue;
         }
         $response[] = $field->data;
     }
     echo json_encode($response);
 }
Example #8
0
<?php

$table_name = $control_properties->table_name;
$conditional_field_id = $control_properties->conditional_field_id;
if (!empty($table_name)) {
    $sys_object = new Crud_Models_Object();
    $sys_object->load($table_name, 'table_name');
    $sys_object->loadFieldsForObject();
} else {
    $sys_field = new Crud_Models_Field();
    $sys_field->load($conditional_field_id);
    $sys_field->loadControl();
    $sys_object = new Crud_Models_Object();
    $sys_object->load($row->{$sys_field->field_name});
    $sys_object->loadFieldsForObject();
}
$text_value = '';
if ($value) {
    $row = new Libraries_Db_Mysql_Model($sys_object->table_name);
    $row->load($value);
    if (!$row->isEmpty()) {
        foreach ($sys_object->sys_field_list as $sys_field) {
            if ($sys_field->is_identification == 1 && array_key_exists($sys_field->field_name, $row->data)) {
                $text_value .= $row->{$sys_field->field_name} . ', ';
            }
        }
    }
}
echo trim($text_value, ', ');
Example #9
0
				<tr>
					<th>Object</th>
					<th>Field</th>
					<th>Relation title</th>
					<th style="width: 110px;"><i class="fa fa-cogs"></i> Action</th>
				</tr>
			</tfoot>
			<tbody>
				<?php 
foreach ($selected_maped_objects as $selected_maped_object) {
    ?>
					<?php 
    $field = new Crud_Models_Field();
    $field->load($selected_maped_object->id_sys_field);
    $sys_object = new Crud_Models_Object();
    $sys_object->load($selected_maped_object->id_sys_object_child);
    $sys_object->loadFieldsForObject();
    ?>
					<tr class="form-group">
						<td>
							<div class="ocp-select">
								<select name="id_sys_object_child[<?php 
    echo $selected_maped_object->id;
    ?>
]" class="form-control table-selector">
									<option value=""></option>
									<?php 
    foreach ($maped_objects as $maped_object) {
        ?>
										<option <?php 
        echo $maped_object->id == $selected_maped_object->id_sys_object_child ? 'selected="selected"' : '';
Example #10
0
 public function restore($sys_object_id, $row_id)
 {
     $sys_object = new Crud_Models_Object();
     $sys_object->load(intval($sys_object_id));
     $sql = "UPDATE {$sys_object->table_name}\r\n\t\t\t\tSET is_deleted = 0\r\n\t\t\t\tWHERE id = ?";
     $data = array($row_id);
     Libraries_Db_Factory::getDb()->execute($sql, $data);
 }
Example #11
0
File: row.php Project: vukasins/ocp
    ?>
			            	<?php 
}
?>
		            	</form>
			        </div>
			        
			        <?php 
if ($object_data->id > 0) {
    ?>
				        <?php 
    foreach ($subforms as $subform) {
        ?>
							<?php 
        $subobject = new Crud_Models_Object();
        $subobject->load($subform->id_sys_object_child);
        if (!$user->role->canExecuteAction('can_edit_' . $subobject->table_name)) {
            continue;
        }
        ?>
							<div id="<?php 
        echo $subobject->table_name;
        ?>
" class="tab-pane fade">
					            <div class="subform" data-subform-relation-id="<?php 
        echo $subform->id;
        ?>
" data-subform-relation-value="<?php 
        echo $object_data->id;
        ?>
" data-sys-object-id="<?php 
Example #12
0
<?php

$table_name = $control_properties->table_name;
$conditional_field_id = isset($control_properties->conditional_field_id) ? $control_properties->conditional_field_id : '';
$sys_object = new Crud_Models_Object();
if (!empty($table_name)) {
    $sys_object->load($table_name, 'table_name');
    $sys_object->loadFieldsForObject();
} else {
    $sys_field = new Crud_Models_Field();
    $sys_field->load($conditional_field_id);
    $sys_field->loadControl();
    $sys_object->load($row->{$sys_field->field_name});
    $sys_object->loadFieldsForObject();
}
if ($sys_object->isEmpty()) {
    $data = array();
} else {
    $data = new Libraries_Db_Mysql_Model($sys_object->table_name);
    $data = $data->search();
}
?>
<div class="ocp-select">
	<select id="<?php 
echo $field->field_name;
?>
" name="<?php 
echo $field->field_name;
?>
" class="form-control" tabindex="<?php 
echo $index;
Example #13
0
							<th>Object</th>
							<th>Title</th>
							<th style="width: 240px;"><i class="fa fa-cogs"></i> Actions</th>
						</tr>
					</tfoot>

					<tbody role="alert" aria-live="polite" aria-relevant="all">
					<?php 
$system_objects = array();
?>
					<?php 
foreach ($available_db_objects as $i => $available_db_object) {
    ?>
						<?php 
    $object = new Crud_Models_Object();
    $object->load($available_db_object, 'table_name');
    if (!$object->isEmpty() && $object->is_system == 1) {
        $system_objects[] = $object;
        continue;
    }
    ?>
						<tr class="<?php 
    echo ($i + 1) % 2 == 0 ? 'event' : 'odd';
    ?>
">
							<td><?php 
    echo $i + 1;
    ?>
</td>
							<td><?php 
    echo $available_db_object;