예제 #1
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">
예제 #2
0
파일: orders.php 프로젝트: huylv-hust/uosbo
    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();
    }
예제 #3
0
파일: index.php 프로젝트: huylv-hust/uosbo
		<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 
예제 #4
0
파일: ujob.php 프로젝트: huylv-hust/uosbo
    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;
    }
예제 #5
0
 /**
  * 
  * @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;
 }
예제 #6
0
파일: index.php 프로젝트: huylv-hust/uosbo
							</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>