public function action_main($params = array())
 {
     $config = $this->config;
     $gConfig = \Config::load('novius_social_widget::config', true);
     if (Arr::get($gConfig, 'embed_js', true)) {
         if (!empty($config['js'])) {
             foreach ($config['js'] as $script) {
                 Nos::main_controller()->addJavascript($script);
             }
         }
     }
     $chrome = array();
     $typeList = array('chrome');
     foreach ($params as $param => $value) {
         if ($value) {
             foreach ($typeList as $type) {
                 $typePrefix = "{$type}-";
                 if ($value && \Str::starts_with($param, $typePrefix)) {
                     array_push(${$type}, \Str::sub($param, \Str::length($typePrefix)));
                 }
             }
         }
     }
     return \View::forge('novius_social_widget::front/enhancer/twitter', array('widgetId' => $params['widget-id'], 'chrome' => $chrome, 'limit' => \Arr::get($params, 'limit'), 'width' => \Arr::get($params, 'width'), 'height' => \Arr::get($params, 'height')), false);
 }
Example #2
0
 private function buildListCategory()
 {
     try {
         $dbObj = DB::select("ID", "TypeName")->from($this->_tableStoryType)->where("ParentID", 0);
         $dbResponse = $dbObj->execute();
         $this->listCategory = [];
         if (count($dbResponse) > 0) {
             $this->listCategory = Arr::assoc_to_keyval($dbResponse->as_array(), 'ID', 'TypeName');
         }
     } catch (\Exception $e) {
     }
 }
 public function action_index()
 {
     $pagination = \Fuel\Core\Pagination::forge('userprojects', array('pagination_url' => \Fuel\Core\Config::get('pagination.pagination_url', '') . 'user/projects/index/', 'total_items' => Model_Project::count(array('related' => array('customer', 'project_members'), 'where' => array(array('project_members.user_id', $this->current_user->id)))), 'per_page' => \Fuel\Core\Config::get('pagination.per_page', 10), 'num_links' => \Fuel\Core\Config::get('pagination.num_links', 10), 'uri_segment' => \Fuel\Core\Config::get('pagination.uri_segment', 4), 'show_first' => \Fuel\Core\Config::get('pagination.show_first', false), 'show_last' => \Fuel\Core\Config::get('pagination.show_last', false)));
     $view = Fuel\Core\View::forge('user/projects/index');
     $view->set_global('user_is_admin', false);
     $view->set_global('projects', Model_Project::find('all', array('related' => array('customer', 'project_members'), 'order_by' => array('customer.name' => 'asc', 'name' => 'asc'), 'where' => array(array('project_members.user_id', $this->current_user->id)), 'limit' => $pagination->per_page, 'offset' => $pagination->offset)));
     $view->set_global('customers', \Fuel\Core\Arr::assoc_to_keyval(Model_Customer::find('all', array('order_by' => array('name' => 'asc'))), 'id', 'name'));
     $view->set_global('project_statuses', Model_Projectstatus::find('all', array('order_by' => array(array('description', 'asc')))));
     $view->set_global('selected_status_id', \Fuel\Core\Config::get('projects.default_status_id', 0));
     $view->set_global('user_is_admin', $this->check_user_is_admin());
     $view->set_global('project_status_id', 0);
     $view->set_global('selected_status_id', 0);
     $view->set_global('pagination', $pagination, false);
     $view->set_global('admin', false);
     $this->template->title = 'My Projects';
     $this->template->content = $view;
 }
 public function action_page($params = array())
 {
     $config = $this->config;
     $gConfig = \Config::load('novius_social_widget::config', true);
     if (Arr::get($gConfig, 'embed_js', true)) {
         if (!empty($config['js'])) {
             foreach ($config['js'] as $script) {
                 Nos::main_controller()->addJavascript($script);
             }
         }
     }
     $data = array();
     $list = $this->getDataList();
     foreach ($list as $key => $values) {
         $data[$key] = \Arr::get($params, "data-" . $key, 0);
     }
     return \View::forge('novius_social_widget::front/enhancer/facebook', array('url' => $params['url'], 'data' => $data, 'width' => \Arr::get($params, 'width'), 'height' => \Arr::get($params, 'height')), false);
 }
Example #5
0
 /**
  * query値配列からstring値をbuild
  *
  * @param array $query_arr key => value配列
  * @return srting
  */
 protected static function _make_query($query_arr)
 {
     // init check function
     $check_hash_array = function ($arr) {
         foreach (array_keys($arr) as $key) {
             if (is_string($key)) {
                 return true;
             }
         }
         return false;
     };
     // sort array by name asc
     ksort($query_arr);
     $query = array();
     // re-insert if page exists, get first
     if (strlen(\Fuel\Core\Arr::get($query_arr, 'page')) > 0) {
         // if page = 1, it's remove
         if ($query_arr['page'] > 1) {
             $query['page'] = $query_arr['page'];
         }
         unset($query_arr['page']);
     }
     // re-insert only value exists
     foreach ($query_arr as $key => $value) {
         if (is_array($value)) {
             // check has string key
             $is_hash_array = $check_hash_array($value);
             if ($is_hash_array) {
                 ksort($value, SORT_STRING);
             } else {
                 sort($value, SORT_STRING);
             }
             foreach ($value as $k => $v) {
                 if (strlen($v) > 0) {
                     $query[$key][$k] = $v;
                 }
             }
         } elseif (strlen($value) > 0) {
             $query[$key] = $value;
         }
     }
     if (empty($query)) {
         return '';
     }
     $return_string = '?';
     foreach ($query as $key => $value) {
         if (is_array($value)) {
             $is_hash_array = $check_hash_array($value);
             foreach ($value as $k => $v) {
                 if ($is_hash_array) {
                     $return_string .= $key . '[' . $k . ']=' . rawurlencode($v) . '&';
                 } else {
                     $return_string .= $key . '[]=' . rawurlencode($v) . '&';
                 }
             }
         } else {
             $return_string .= $key . '=' . rawurlencode($value) . '&';
         }
     }
     return substr($return_string, 0, -1);
 }
				<?php 
echo Form::input('short_code', Input::post('short_code', isset($inventory) ? $inventory->short_code : ''), array('class' => 'col-md-4 form-control', 'placeholder' => 'Short code'));
?>

		</div>
		<div class="form-group">
			<?php 
echo Form::label('Units', 'inventory_units_id', array('class' => 'control-label'));
?>

				<?php 
// echo Form::input('inventory_units_id', Input::post('inventory_units_id', isset($inventory) ? $inventory->inventory_units_id : ''), array('class' => 'col-md-4 form-control', 'placeholder'=>'Inventory units id'));
?>
                        <?php 
echo \Fuel\Core\Form::select('inventory_units_id', Input::post('inventory_units_id', isset($inventory) ? $inventory->inventory_units_id : 0), \Fuel\Core\Arr::assoc_to_keyval($inventory_units, 'id', 'name'), array('class' => 'form-control', 'required'));
?>
		</div>
		<div class="form-group">
			<?php 
echo Form::label('Warning level', 'warning_level', array('class' => 'control-label'));
?>

				<?php 
echo Form::input('warning_level', Input::post('warning_level', isset($inventory) ? $inventory->warning_level : 0), array('class' => 'col-md-4 form-control', 'placeholder' => 'Warning level'));
?>

		</div>
		<div class="form-group">
			<label class='control-label'>&nbsp;</label>
                        <?php 
 /**
  * 
  * @param type $timestamp
  */
 public function action_logtimes($timestamp = null)
 {
     if (!Auth\Auth::has_access('timesheets.read')) {
         Fuel\Core\Session::set_flash('error', 'You do not have access to view timesheets');
         Fuel\Core\Response::redirect('user');
     }
     Fuel\Core\Response::redirect('user/timesheets/advanced/logtimes/' . $timestamp);
     $task_id = 0;
     try {
         if (Fuel\Core\Input::method() == 'GET') {
             $task_id = Fuel\Core\Input::get('id');
         } else {
             if (Fuel\Core\Input::method() == 'POST') {
                 $task_id = Fuel\Core\Input::post('id');
             }
         }
     } catch (\Exception $ex) {
         $task_id = 0;
     }
     if (!($task = Model_Projecttask::find($task_id))) {
         Fuel\Core\Session::set_flash('error', 'Cannot find selected task # ' . $task_id);
         Fuel\Core\Response::redirect('user/timesheets');
     }
     if ($timestamp == null || !is_numeric($timestamp) || intval($timestamp) <= 0) {
         $timestamp = strtotime(date('d M Y'));
     }
     if (Fuel\Core\Input::method() == 'POST') {
         try {
             // start a db transaction
             \Fuel\Core\DB::start_transaction();
             // find all logs for this task for this day
             $date = date('Y-m-d', $timestamp);
             foreach ($task->project_task_logs as $log) {
                 $date_starts = date('Y-m-d', $timestamp);
                 $date_ends = date('Y-m-d 23:59:59', $timestamp);
                 if (in_array(strtotime($log->task_started), range(strtotime($date_starts), strtotime($date_ends)))) {
                     $id = $log->id;
                     // delete the logs
                     $log->delete();
                 }
             }
             // insert new logs
             if (Fuel\Core\Input::post('timeslots')) {
                 $date = date('Y-m-d', $timestamp);
                 $last_comment = '';
                 foreach (Fuel\Core\Input::post('timeslots') as $str) {
                     $times = explode('_', $str);
                     $is_billable = 0;
                     $task_started = $date . ' ' . $times[0] . ':00';
                     $task_completed = $date . ' ' . $times[1] . ':00';
                     if (Fuel\Core\Input::post('comment_' . $str) != '') {
                         $last_comment = Fuel\Core\Input::post('comment_' . $str);
                     }
                     if (intval(Fuel\Core\Input::post('is_billable_' . $str, '0')) == 1) {
                         $is_billable = 1;
                     }
                     $task_log = Model_Projecttasklog::forge(array('project_task_id' => $task->id, 'comment' => $last_comment, 'task_started' => $task_started, 'task_completed' => $task_completed, 'is_billable' => $is_billable));
                     $task_log->save();
                 }
             }
             // commit to database
             \Fuel\Core\DB::commit_transaction();
             \Fuel\Core\Session::set_flash('success', 'Time logs saved successfully.');
             Fuel\Core\Response::redirect('user/timesheets/index/' . $timestamp);
         } catch (Exception $ex) {
             // rollback on error
             \Fuel\Core\DB::rollback_transaction();
             \Fuel\Core\Session::set_flash('error', $ex->getMessage());
             Fuel\Core\Response::redirect('user/timesheets/index/' . $timestamp);
         }
     }
     $user_id = $this->current_user->id;
     $view = View::forge('user/timesheets/logtimes');
     $view->set_global('timestamp', $timestamp);
     $view->set_global('task', $task);
     $view->set_global('timezones', Model_Timezone::find('all'));
     $view->set_global('project_tasks', array_merge(array('0' => '- Select Task -'), \Fuel\Core\Arr::assoc_to_keyval(Model_Projecttask::find('all', array('where' => array(array('user_id', $user_id)))), 'id', 'project_task_description')));
     $this->template->user_is_admin = $this->check_user_is_admin();
     $this->template->title = 'Timesheets';
     $this->template->content = $view;
 }
Example #8
0
 public static function get_status($status, $default = "")
 {
     $status_array = self::get_statuses();
     return \Fuel\Core\Arr::get($status_array, $status, $default);
 }