Esempio n. 1
0
 /**
  * Fetch an item from the POST array and trim spaces at the beginning an end
  *
  * @param   string  The index key
  * @param   mixed   The default value
  * @return  string|array
  *
  * @access public
  *
  * @author Dao Anh Minh
  * @version 1.0
  * @since 1.0
  */
 public static function post($index = null, $default = null)
 {
     //get POST value
     $post = parent::post($index, $default);
     //return POST value with trim all spaces at the beginning and end
     return trim_post($post);
 }
Esempio n. 2
0
 public function action_create($id = null)
 {
     if (Fuel\Core\Input::post()) {
         $comment = Model_Comment::forge(array('name' => Fuel\Core\Input::post('comment'), 'comment' => Fuel\Core\Input::post('comment'), 'message_id' => Fuel\Core\Input::post('message_id')));
         if ($comment and $comment->save()) {
             Fuel\Core\Session::set_flash('success', 'Added comment #' . $comment->id . '.');
             Fuel\Core\Response::redirect('messages/view/' . $comment->message_id);
         } else {
             Fuel\Core\Session::set_flash('error', 'Could not save comment');
         }
     } else {
         $this->template->set_global('message', $id, false);
     }
     $data["subnav"] = array('create' => 'active');
     $this->template->title = 'Comments » Create';
     $data['form'] = View::forge('comments/_form');
     $this->template->content = View::forge('comments/create', $data);
 }
Esempio n. 3
0
 public function action_filter()
 {
     $user_id = \Fuel\Core\Input::param('user_id', 0);
     $client_id = Fuel\Core\Input::param('client_id', 0);
     $project_id = \Fuel\Core\Input::param('project_id', 0);
     $month = Fuel\Core\Input::param('month', '00');
     $year = Fuel\Core\Input::param('year', date('Y'));
     $status = 0;
     $data['open_tasks'] = THelper::get_tasks($user_id, $client_id, $project_id, $month, $year, $status, array(\Fuel\Core\Input::param('sort', 'priority') => \Fuel\Core\Input::param('order', 0)));
     $view = \Fuel\Core\View::forge('admin/tasks/index');
     $view->set_global('clients', Model_Customer::find('all', array('order_by' => array('name' => 'asc'))));
     $view->set_global('users', Model_User::find('all', array('order_by' => array('username' => 'asc'))));
     $view->set_global('years', range(2015, date('Y')));
     $view->set_global('months', THelper::get_months_array());
     $view->set_global('open_tasks', $data['open_tasks']);
     $view->set_global('admin', true);
     $this->template->title = 'Open Tasks';
     $this->template->content = $view;
 }
Esempio n. 4
0
				<div class="row">
					<div class="col-md-2">
						<label class="control-label">取引先(受注先)</label>
					</div>
					<div class="col-md-10">
						<select class="form-control" name="group_id">
							<option value="">全て</option>
							<?php 
foreach ($groups as $group_id => $name) {
    ?>
								<option value="<?php 
    echo $group_id;
    ?>
"<?php 
    echo Fuel\Core\Input::get('group_id') == $group_id ? ' selected' : '';
    ?>
><?php 
    echo htmlspecialchars($name);
}
?>
						</select>
						-
						<select class="form-control" name="partner_code">
							<option value="">全て</option>
						</select>
					</div>
				</div>

				<div class="row">
					<div class="col-md-2">
Esempio n. 5
0
$order_by_priority = \Fuel\Core\Input::param('sort', 'priority') == 'priority' ? \Fuel\Core\Input::param('order', 0) == 1 ? 0 : 1 : 1;
echo \Fuel\Core\Html::anchor($action . 'user_id=' . \Fuel\Core\Input::param('user_id', 0) . '&project_id=' . \Fuel\Core\Input::param('project-id', 0) . '&client_id=' . \Fuel\Core\Input::param('client_id', 0) . '&year=' . \Fuel\Core\Input::param('year', date('Y')) . '&month=' . \Fuel\Core\Input::param('month', date('m')) . '&sort=priority' . '&order=' . $order_by_priority, $order_by_priority == 1 ? '<span class="glyphicon icon-sort-by-alphabet"></span> Priority' : '<span class="glyphicon icon-sort-by-alphabet-alt"></span> Priority', array('style' => 'color: black'));
?>
                                            </th>
                                            <th>Hours Spent</th>
                                            <th style="width: 80px;">&nbsp;</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php 
if ($open_tasks) {
    ?>
                                        <?php 
    $row_counter = 0;
    $datestart_timestamp = strtotime(Fuel\Core\Input::param('year', date('Y')) . '-' . Fuel\Core\Input::param('month', date('m')) . '-01');
    $dateend_timestamp = strtotime(date(Fuel\Core\Input::param('year', date('Y')) . '-' . Fuel\Core\Input::param('month', date('m')) . '-t'));
    ?>
                                        <?php 
    foreach ($open_tasks as $task) {
        ?>
                                        <tr>
                                            <td><?php 
        echo ++$row_counter . '. ' . \Fuel\Core\Html::anchor(isset($admin) && $admin ? 'admin/projects/view/' . $task->project_id : 'user/timesheets/logtimes/' . strtotime(date('Y-m-d')) . '?id=' . $task->id, trim(date('d-m-Y', strtotime($task->task_due))));
        ?>
</td>
                                            <td><?php 
        echo \Fuel\Core\Html::anchor(isset($admin) && $admin ? 'admin/projects/view/' . $task->project_id : 'user/timesheets/logtimes/' . strtotime(date('Y-m-d')) . '?id=' . $task->id, trim($task->project->name) . ' [ ' . trim(strtoupper($task->project->customer->name)) . ' ] ');
        ?>
</td>
                                            <td><?php 
        echo \Fuel\Core\Html::anchor(isset($admin) && $admin ? 'admin/projects/view/' . $task->project_id : 'user/timesheets/logtimes/' . strtotime(date('Y-m-d')) . '?id=' . $task->id, strtoupper(trim($task->user->username)));
Esempio n. 6
0
 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');
     }
     if (!$timestamp) {
         $timestamp = \Fuel\Core\Date::forge()->get_timestamp();
         // today
     }
     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);
             $starts = date('Y-m-d 00:00:00', $timestamp);
             $ends = date('Y-m-d 23:59:59', $timestamp);
             $project_task_logs = Model_Projecttasklog::find('all', array('related' => array('project_task'), 'where' => array(array('project_task.user_id', $this->current_user->id), array('task_started', 'BETWEEN', array($starts, $ends)))));
             foreach ($project_task_logs as $log) {
                 $date_starts = date('Y-m-d', $timestamp);
                 $date_ends = date('Y-m-d 23:59:59', $timestamp);
                 if ($log->get_project_task()->user_id == $this->current_user->id) {
                     if (in_array(strtotime($log->task_started), range(strtotime($date_starts), strtotime($date_ends)))) {
                         // delete the logs
                         $log->delete();
                     }
                 }
             }
             // insert new logs
             if (Fuel\Core\Input::post('timeslots')) {
                 $date = date('Y-m-d', $timestamp);
                 $last_comment = '';
                 $last_task_id = '';
                 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';
                     $project_task_id_array = Fuel\Core\Input::post('project_task_id');
                     $task_id = $project_task_id_array["'{$str}'"];
                     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;
                     }
                     if (empty($task_id)) {
                         $task_id = $last_task_id;
                     } else {
                         $last_task_id = $task_id;
                     }
                     if (empty($task_id)) {
                         continue;
                         // todo - display error
                     }
                     $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/advanced/logtimes/' . $timestamp);
         }
     }
     $now = \Fuel\Core\Date::forge($timestamp)->format('mysql');
     $day_starts = date('Y-m-d 00:00:00', strtotime($now));
     $day_ends = date('Y-m-d 23:59:59', strtotime($now));
     $today_logs = Model_Projecttasklog::find('all', array('related' => array('project_task', 'project_task.project', 'project_task.project_task_name', 'project_task.user'), 'where' => array(array('task_started', 'BETWEEN', array($day_starts, $day_ends)), array('project_task.user_id', $this->current_user->id)), 'order_by' => array(array('task_started', 'asc'))));
     // todo: use DB::query() instead
     $this->template->set_global('today_logs', $today_logs);
     $this->template->set_global('projects', Model_Project::find('all', array('order_by' => array(array('name', 'asc')))));
     $this->template->set_global('timezones', Model_Timezone::find('all', array('order_by' => array(array('starts', 'asc')))));
     $this->template->set_global('my_tasks', Model_Projecttask::find('all', array('where' => array(array('user_id', $this->current_user->id)), 'related' => array('project_task_name'), 'order_by' => array(array('project_task_description', 'asc')))));
     $this->template->set_global('timestamp', $timestamp);
     $this->template->set_global('date', \Fuel\Core\Date::forge($timestamp)->format('mysql_date'));
     $this->template->title = 'Timesheets';
     $this->template->content = View::forge('user/timesheets/advanced/_advanced_form');
 }
Esempio n. 7
0
<fieldset>
    <div class="form-group">
        <?php 
echo \Fuel\Core\Form::label('Name', 'name', array('class' => 'control-label'));
?>
        <?php 
echo \Fuel\Core\Form::input('name', isset($comment->name) ? $comment->name : '', array('class' => 'form-control'));
?>
    </div>
    
    <div class="form-group">
        <?php 
echo \Fuel\Core\Form::label('Comment', 'comment', array('class' => 'control-label'));
?>
        <?php 
echo \Fuel\Core\Form::textarea('comment', Fuel\Core\Input::post('comment', isset($comment) ? $comment->comment : ''), array('class' => 'form-control'));
?>
        
    </div>
</fieldset>

<div class="actions">
    <?php 
echo \Fuel\Core\Form::hidden('message_id', isset($message) ? $message : '');
?>
    <?php 
echo \Fuel\Core\Form::submit('submit', 'Submit', array('class' => 'btn btn-primary'));
?>
</div>

<?php 
Esempio n. 8
0
    public static function get_all_order_list($limit = null, $offset = null, $search)
    {
        $model_ss = new \Model_Mss();
        $model_partner = new Model_Mpartner();
        $model_user = new \Model_Muser();
        $query = DB::select(DB::expr('*,(SELECT name FROM m_user WHERE m_user.user_id = orders.author_user_id) as user_name'))->from(self::$_table_name);
        if (isset($search['order_user_id']) && $search['order_user_id'] != '') {
            $query->and_where('order_user_id', '=', $search['order_user_id']);
        } else {
            if (isset($search['order_department']) && $search['order_department'] != null) {
                $list_order_user_id = array(-1);
                $list_users = $model_user->get_list_user_by_departmentid($search['order_department']);
                foreach ($list_users as $key => $val) {
                    $list_order_user_id[] = $val['user_id'];
                }
                $query->and_where('order_user_id', 'IN', $list_order_user_id);
            }
        }
        if (isset($search['ssid']) && $search['ssid'] != null) {
            $query->and_where('ss_id', $search['ssid']);
        }
        if (isset($search['group']) && $search['group'] != null) {
            $sql = 'select m_ss.ss_id from m_ss
				inner join m_partner on (m_ss.partner_code = m_partner.partner_code)
				where m_partner.m_group_id = :group_id';
            $group_id = Fuel\Core\Input::get('group_search');
            $_array = Fuel\Core\DB::query($sql)->bind('group_id', $search['group'])->execute()->as_array();
            if (count($_array) == 0) {
                return array();
            }
            $query->and_where('ss_id', 'in', array_column($_array, 'ss_id'));
        } elseif (isset($search['partner']) && $search['partner'] != null) {
            $list_ss_id_partner = array();
            $list_ss = $model_ss->get_data(array('partner_code' => $search['partner']));
            foreach ($list_ss as $key => $val) {
                $list_ss_id_partner[] = $val->ss_id;
            }
            if (count($list_ss_id_partner) <= 0) {
                return array();
            } else {
                $query->and_where('ss_id', 'in', $list_ss_id_partner);
            }
        } elseif (isset($search['addr1']) && $search['addr1'] != null) {
            $list_ss_id_addr1 = array();
            $list_partner_code = array();
            $list_partner = $model_partner->get_filter_partner(array('addr1' => $search['addr1']));
            foreach ($list_partner as $key => $value) {
                $list_partner_code[] = $value['partner_code'];
            }
            $config['where'][] = array('partner_code', 'IN', $list_partner_code);
            if (count($list_partner_code) <= 0) {
                return array();
            } else {
                $list_ss = \Model_Mss::forge()->find($config);
                if ($list_ss) {
                    foreach ($list_ss as $key => $val) {
                        $list_ss_id_addr1[] = $val->ss_id;
                    }
                }
                if (count($list_ss_id_addr1) <= 0) {
                    return array();
                } else {
                    $query->and_where('ss_id', 'in', $list_ss_id_addr1);
                }
            }
        }
        if (isset($search['apply_date']) && $search['apply_date'] != null) {
            $query->where(DB::expr("DATE_FORMAT(apply_date,'%Y-%m-%d') >= '" . $search['apply_date'] . "'"));
        }
        if (isset($search['post_date']) && $search['post_date'] != null) {
            $query->where(DB::expr("DATE_FORMAT(apply_date,'%Y-%m-%d') <= '" . $search['post_date'] . "'"));
        }
        if (isset($search['media_id']) && $search['media_id'] != null) {
            $model_post = new Model_Mpost();
            $list_post = $model_post->get_list_by_media($search['media_id']);
            if ($list_post) {
                $list_post_id = array_column($list_post, 'post_id');
                $query->and_where('post_id', 'in', $list_post_id);
            }
        }
        if (isset($search['maddr2']) && $search['maddr2'] != null) {
            $list_ss_id_add2 = array();
            $listss = $model_ss->get_list_all_ss(array('addr2' => $search['maddr2']));
            foreach ($listss as $key => $val) {
                $list_ss_id_add2[] = $val['ss_id'];
            }
            if (count($list_ss_id_add2)) {
                $query->and_where('ss_id', 'in', $list_ss_id_add2);
            }
        }
        //get follow author_user_id
        if (isset($search['user_id']) && $search['user_id'] != null) {
            $list_ss_id_user_temp[] = -1;
            $list_ss_id_user = self::find_ss_list($search['user_id']);
            if ($list_ss_id_user) {
                $query->and_where('ss_id', 'IN', $list_ss_id_user);
            } else {
                $query->and_where('ss_id', 'IN', $list_ss_id_user_temp);
            }
        } elseif (isset($search['department']) && $search['department'] != null) {
            $list_user_id = array();
            $list_users = $model_user->get_list_user_by_departmentid($search['department']);
            foreach ($list_users as $key => $val) {
                $list_user_id[] = $val['user_id'];
            }
            $list_partner_code = array();
            if ($list_user_id) {
                $config_partner['where'][] = array('user_id', 'IN', $list_user_id);
                $list_user_partner = \Model_Mpartner::forge()->find($config_partner);
                if ($list_user_partner) {
                    foreach ($list_user_partner as $partner) {
                        $list_partner_code[] = $partner['partner_code'];
                    }
                }
            }
            $list_ss_id_partner[] = -1;
            if ($list_partner_code) {
                $config_partner_ss['where'][] = array('partner_code', 'IN', $list_partner_code);
                $list_ss_partner = \Model_Mss::forge()->find($config_partner_ss);
                if ($list_ss_partner) {
                    foreach ($list_ss_partner as $ss_id) {
                        $list_ss_id_partner[] = $ss_id['ss_id'];
                    }
                }
            }
            $query->and_where('ss_id', 'IN', $list_ss_id_partner);
        }
        if (isset($search['department_id']) && $search['department_id'] != null) {
            $list_partnercode_department = array();
            $list_partner_department = $model_partner->get_partnercode_department($search['department_id']);
            foreach ($list_partner_department as $key => $val) {
                $list_partnercode_department[] = $val['partner_code'];
            }
            $list_ss_id_deparment[] = -1;
            if ($list_partnercode_department) {
                $config_partner_department['where'][] = array('partner_code', 'IN', $list_partnercode_department);
                $list_ss_deparment = \Model_Mss::forge()->find($config_partner_department);
                if ($list_ss_deparment) {
                    foreach ($list_ss_deparment as $ss_id) {
                        $list_ss_id_deparment[] = $ss_id['ss_id'];
                    }
                }
            }
            $query->and_where('ss_id', 'IN', $list_ss_id_deparment);
        }
        $or_where = null;
        $flag = 0;
        if (isset($search['unapproved']) && $search['unapproved'] == 0) {
            $or_where .= 'status = 0';
            $flag += 1;
        }
        if (isset($search['approved']) && $search['approved'] == 1) {
            $or_where .= $flag > 0 ? ' OR status = 1' : 'status = 1';
            $flag += 1;
        }
        if (isset($search['confirmed']) && $search['confirmed'] == 2) {
            $or_where .= $flag > 0 ? ' OR status = 2' : 'status = 2';
            $flag += 1;
        }
        if (isset($search['nonapproved']) && $search['nonapproved'] == -1) {
            $or_where .= $flag > 0 ? ' OR status = -1' : 'status = -1';
            $flag += 1;
        }
        if (isset($search['stop']) && $search['stop'] == 3) {
            $or_where .= $flag > 0 ? ' OR status = 3' : 'status = 3';
            $flag += 1;
        }
        if ($or_where) {
            $query->and_where(DB::expr('(' . $or_where . ')'));
        }
        if (isset($search['order_id']) && $search['order_id']) {
            $query->and_where('order_id', '=', $search['order_id']);
        }
        if (isset($search['start_date']) && $search['start_date']) {
            $query->where('post_date', '>=', $search['start_date']);
        }
        if (isset($search['end_date']) && $search['end_date']) {
            $query->where('post_date', '<=', $search['end_date']);
        }
        if (isset($search['keyword']) && $search['keyword']) {
            $arr_keyword = array_filter(preg_split('/\\s|\\s+| /', trim($search['keyword'])));
            $sql = 'select orders.order_id from orders
				inner join m_ss on (orders.ss_id = m_ss.ss_id)
				inner join m_partner on (m_ss.partner_code = m_partner.partner_code)
				inner join sssale on (orders.agreement_type = sssale.sssale_id)
				left join m_post on (m_post.post_id = orders.post_id)
				left join m_media on (m_media.m_media_id = m_post.m_media_id)';
            $where = ' WHERE ';
            foreach ($arr_keyword as $k => $v) {
                $where .= " CONCAT(m_ss.ss_name, m_partner.branch_name, IF(sssale.sale_name IS NULL,'' ,sssale.sale_name), IF(m_media.media_name IS NULL,'' ,m_media.media_name)) like '%{$v}%' AND";
            }
            $where = trim($where, 'AND');
            $sql = $sql . $where;
            $rs = \Fuel\Core\DB::query($sql)->execute();
            $order_id = [-1];
            foreach ($rs as $item) {
                $order_id[] = $item['order_id'];
            }
            $query->where('order_id', 'in', $order_id);
        }
        if (isset($search['sale_type']) && $search['sale_type']) {
            $sql = 'select sssale_id from sssale where sale_type = ' . $search['sale_type'];
            $rs = \Fuel\Core\DB::query($sql)->execute();
            $sssale_id = [-1];
            foreach ($rs as $item) {
                $sssale_id[] = $item['sssale_id'];
            }
            $query->where('agreement_type', 'in', $sssale_id);
        }
        if ($limit) {
            $query->limit($limit);
        }
        if ($offset) {
            $query->offset($offset);
        }
        $query->order_by('order_id', 'desc');
        return $query->as_object('Model_Orders')->execute();
    }
Esempio n. 9
0
		<div class="text-center">
			<button type="submit" class="btn btn-primary btn-sm">
				<i class="glyphicon glyphicon-pencil icon-white"></i>
				保存
			</button>
		</div>
	</form>

	<?php 
echo Asset::js('validate/job.js');
?>
<script type="text/javascript">
	    $('.dateform').datepicker();
				<?php 
if (Fuel\Core\Input::get('view')) {
    ?>
$("input").prop('disabled', true);
$("select").prop('disabled', true);
$("textarea ").prop('disabled', true);
$(".btn-primary").prop('disabled', true);
$(".btn-success").prop('disabled', true);
$(".work_remove_btn").prop('disabled', true);
$(".recruit_remove_btn ").prop('disabled', true);
$(".delete_image ").prop('disabled', true);
$("[name=remove-media-btn]").prop('disabled', true);<?php 
}
?>

$("#form_ss_id").change(function(){
		$.post('<?php 
Esempio n. 10
0
    public function get_search_data($export = false)
    {
        $config['where'] = array();
        $config_pagination = array();
        $rs = true;
        if (\Fuel\Core\Input::get('media_search', null) != null) {
            $config['where'][] = array('media_list', 'LIKE', '%,' . \Fuel\Core\Input::get('media_search') . ',%');
        }
        if (Fuel\Core\Input::get('group_search', null) != null) {
            $sql = 'select m_ss.ss_id from m_ss
				inner join m_partner on (m_ss.partner_code = m_partner.partner_code)
				where m_partner.m_group_id = :group_id';
            $group_id = Fuel\Core\Input::get('group_search');
            $_array = Fuel\Core\DB::query($sql)->bind('group_id', $group_id)->execute()->as_array();
            $ss_list_id[] = -1;
            foreach ($_array as $row) {
                $ss_list_id[] = $row['ss_id'];
            }
            $config['where'][] = array('ss_id', 'IN', $ss_list_id);
        }
        if (Fuel\Core\Input::get('partner_search')) {
            $ss_list_id = array();
            $list_ss_search = $this->get_list_ss('partner_code="' . Fuel\Core\Input::get('partner_search') . '"');
            $ss_list_id[] = -1;
            foreach ($list_ss_search as $row) {
                $ss_list_id[] = $row['ss_id'];
            }
            $config['where'][] = array('ss_id', 'IN', $ss_list_id);
        }
        if (\Fuel\Core\Input::get('address_1') || \Fuel\Core\Input::get('address_2')) {
            $filter = array('addr_1' => \Fuel\Core\Input::get('address_1', 0), 'addr_2' => \Fuel\Core\Input::get('address_2', ''));
            $ss_list_id = $this->mss->get_list_ss_addr($filter);
            if (!empty($ss_list_id)) {
                $config['where'][] = array('ss_id', 'IN', $ss_list_id);
            } else {
                $config['where'][] = array('ss_id', 'IN', array(-1));
            }
        }
        if (Fuel\Core\Input::get('ss_search')) {
            $config['where'][] = array('ss_id', '=', Fuel\Core\Input::get('ss_search'));
        }
        if (\Fuel\Core\Input::get('public_type_1') && \Fuel\Core\Input::get('public_type_2')) {
            $config['where'][] = array('public_type', '&9=', '9');
        } else {
            if (\Fuel\Core\Input::get('public_type_1')) {
                $config['where'][] = array('public_type', '&1=', '1');
            }
            if (\Fuel\Core\Input::get('public_type_2')) {
                $config['where'][] = array('public_type', '&8=', '8');
            }
        }
        if (\Fuel\Core\Input::get('status', null) != null) {
            $config['where'][] = array('status', '=', \Fuel\Core\Input::get('status'));
        }
        if (\Fuel\Core\Input::get('start_date')) {
            $config['where'][] = array('start_date', '>=', \Fuel\Core\Input::get('start_date'));
        }
        if (\Fuel\Core\Input::get('end_date')) {
            $config['where'][] = array('end_date', '<=', \Fuel\Core\Input::get('end_date'));
        }
        if (\Fuel\Core\Input::get('is_available', null) != null) {
            $config['where'][] = array('is_available', '=', \Fuel\Core\Input::get('is_available'));
        }
        if (\Fuel\Core\Input::get('department_id', null) != null) {
            $sql = 'select m_ss.ss_id from m_ss
				inner join m_partner on (m_ss.partner_code = m_partner.partner_code)
				where m_partner.department_id = :department_id';
            $department_id = Fuel\Core\Input::get('department_id');
            $_array = Fuel\Core\DB::query($sql)->bind('department_id', $department_id)->execute()->as_array();
            $department_ss_list_id[] = -1;
            foreach ($_array as $row) {
                $department_ss_list_id[] = $row['ss_id'];
            }
            $config['where'][] = array('ss_id', 'IN', $department_ss_list_id);
        }
        $config_pagination = $config['where'];
        $config_pagination = array('pagination_url' => \Uri::base() . 'job/jobs/index?' . http_build_query(\Input::get()), 'total_items' => $this->job->count('job_id', true, $config_pagination), 'per_page' => Constants::$default_limit_pagination, 'uri_segment' => 'page', 'num_links' => Constants::$default_num_links, 'show_last' => true);
        if ($export) {
            $config_pagination['per_page'] = 100000;
            // get all
        }
        $pagination = \Uospagination::forge('jobpage', $config_pagination);
        $config['limit'] = $pagination->per_page;
        $config['offset'] = $pagination->offset;
        $config['order_by'] = array('job_id' => 'desc');
        $res = $this->job->find($config);
        $list_ss_id = '';
        $list_sssale_id = '';
        $list_partner_id = '';
        $_arr_res = $_arr_res = array('res' => array(), 'res_ss' => array(), 'res_partner' => array(), 'res_sssale' => array());
        if (count($res)) {
            foreach ($res as $row) {
                if ($row['ss_id']) {
                    $list_ss_id .= $row['ss_id'] . ',';
                }
                if ($row['sssale_id']) {
                    $list_sssale_id .= $row['sssale_id'] . ',';
                }
            }
            $list_sssale_id = trim($list_sssale_id, ',');
            $list_ss_id = trim($list_ss_id, ',');
            $res_ss = array();
            if ($list_ss_id) {
                $res_ss = $this->get_list_ss('ss_id IN (' . $list_ss_id . ')');
                foreach ($res_ss as $row) {
                    $list_partner_id .= '"' . $row['partner_code'] . '",';
                }
                $list_partner_id = trim($list_partner_id, ',');
            }
            $list_sssale = array();
            if ($list_sssale_id) {
                $list_sssale = $this->get_list_sssale('sssale_id IN (' . $list_sssale_id . ')');
            }
            $list_partner = array();
            $list_group = array();
            if ($list_partner_id) {
                $list_partner = $this->get_list_partner('partner_code IN (' . $list_partner_id . ')');
                /*Get group name */
                $list_group_id = array();
                foreach ($list_partner as $row) {
                    $list_group_id[] = $row['m_group_id'];
                }
                $list_group = $this->mgroup->get_list_by_partner($list_group_id);
            }
            $_arr_res = array('res' => $res, 'res_ss' => $this->array_key_value($res_ss, 'ss_id'), 'res_partner' => $this->array_key_value($list_partner, 'partner_code'), 'res_sssale' => $this->array_key_value($list_sssale, 'sssale_id'), 'res_group' => $this->array_key_value($list_group, 'm_group_id'), 'paging' => $pagination);
        }
        return $_arr_res;
    }
Esempio n. 11
0
 /**
  * 
  * @param type $task_log_id
  */
 public function action_edittimes($task_log_id = null)
 {
     if (Fuel\Core\Input::method() == 'POST') {
         $task_log_id = Fuel\Core\Input::post('id');
     }
     if (!($task_log = Model_Projecttasklog::find($task_log_id))) {
         \Fuel\Core\Session::set_flash('error', 'Cannot find task log # ' . $task_log_id);
         \Fuel\Core\Response::redirect_back('user/timesheets');
     }
     if (Fuel\Core\Input::method() == 'POST') {
         $val = Model_Projecttasklog::validate('edit');
         if ($val->run()) {
             $task_log->comment = Fuel\Core\Input::post('comment');
             $task_log->task_started = Fuel\Core\Input::post('task_started') . ' ' . Fuel\Core\Input::post('task_started_hr') . ':' . Fuel\Core\Input::post('task_started_min') . ':00';
             $task_log->task_completed = Fuel\Core\Input::post('task_completed') . ' ' . Fuel\Core\Input::post('task_completed_hr') . ':' . Fuel\Core\Input::post('task_completed_min') . ':00';
             if ($task_log->save()) {
                 \Fuel\Core\Session::set_flash('success', 'Saved time log for task # ' . $task_log_id);
                 \Fuel\Core\Response::redirect('user/timesheets/view/' . $task_log->project_task_id);
             } else {
                 \Fuel\Core\Session::set_flash('error', 'Cannot save task log # ' . $task_log_id);
             }
         } else {
             \Fuel\Core\Session::set_flash('error', $val->error());
         }
     }
     $view = \Fuel\Core\View::forge('user/timesheets/edittimes');
     $view->set_global('task_log', $task_log);
     $view->set_global('task', $task_log->project_task);
     $this->template->user_is_admin = $this->check_user_is_admin();
     $this->template->title = 'Timesheets';
     $this->template->content = $view;
 }
Esempio n. 12
0
							</div>
							<div class="col-md-4">
								<label class="checkbox-inline"><input id="is_available_1" type="checkbox" value="1" name="is_available" <?php 
if (Fuel\Core\Input::get('is_available') == '1') {
    echo 'checked="checked"';
}
?>
>公開</label>
								<label class="checkbox-inline"><input id="is_available_0" type="checkbox" value="0" name="is_available" <?php 
if (Fuel\Core\Input::get('is_available') == '0') {
    echo 'checked="checked"';
}
?>
>非公開</label>
								<label class="checkbox-inline"><input type="checkbox" value="0" name="status" <?php 
if (Fuel\Core\Input::get('status') == '0') {
    echo 'checked="checked"';
}
?>
>承認待ち</label>
							</div>
						</div>
						<div class="row text-center">
							<button type="submit" class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-search icon-white"></i> フィルタ</button>
							<button type="button" class="btn btn-info btn-sm" name="filter-clear-btn"><i class="glyphicon glyphicon-refresh icon-white"></i> フィルタ解除</button>
							<a class="btn btn-warning btn-sm" href="<?php 
echo \Uri::base() . 'job/jobs/index/' . (\Uri::segment(4) ? \Uri::segment(4) : 1) . '?' . http_build_query(\Input::get()) . '&export=true';
?>
"><i class="glyphicon glyphicon-download-alt icon-white"></i>CSVダウンロード</button></a>
						</div>
					</div>