Example #1
0
 protected static function personPrepare()
 {
     return PersonModel::join(PersonLangModel::getTableName(), PersonLangModel::getField("person_id"), '=', PersonModel::getField("id"))->join(PersonRelModel::getTableName(), PersonRelModel::getField("person_id"), '=', PersonModel::getField("id"))->leftJoin(Files::getTableName(), function ($join) {
         $join->on(Files::getField("module_id"), '=', PersonModel::getField("id"));
         $join->on(Files::getField("module_name"), '=', DB::raw("'person'"));
     })->where(PersonLangModel::getField("lang_id"), \WebAPL\Language::getId())->orderBy('first_name', 'asc')->orderBy('last_name', 'asc');
 }
Example #2
0
 public function edit_item($id = 0)
 {
     \User::onlyHas('calendar-view');
     $data = array('calendar' => CalendarModel::find($id));
     if ($data['calendar']) {
         $langs = CalendarLangModel::where('calendar_item_id', $id)->get();
         $data['langs'] = array();
         foreach ($langs as $lang) {
             $data['langs'][$lang->lang_id] = $lang;
         }
         if (\WebAPL\Modules::checkInstance('person')) {
             $this->loadClass(['PersonLangModel'], 'person');
             $data['persons'] = \PersonLangModel::where('lang_id', Language::getId())->orderBy(\DB::raw(\PersonLangModel::getField('first_name') . ', ' . \PersonLangModel::getField('last_name')), 'asc')->get();
         }
         $data['groups'] = \CalendarGroup::orderBy('name', 'asc')->get();
         //            $data['posts'] = Post::join(PostLang::$ftable, PostLang::$ftable . ".post_id", '=', Post::$ftable . ".id")
         //                    ->select(CalendarPostModel::$ftable . ".post_id", CalendarPostModel::$ftable . ".calendar_item_id", PostLang::$ftable . ".title")
         //                    ->join(CalendarPostModel::$ftable, CalendarPostModel::$ftable . ".post_id", '=', Post::$ftable . ".id")
         //                    ->where(CalendarPostModel::$ftable . ".calendar_item_id", $id)
         //                    ->get();
         //
         //            $data['posts_all'] = Post::prepareAll()
         //                    ->select(PostLang::$ftable . ".title", Post::$ftable . ".id")
         //                    ->where(Post::$ftable . ".view_mod", $this->page_view_mod)
         //                    ->get();
         $this->layout->content = Template::moduleView($this->module_name, 'views.edit_form', $data);
         return $this->layout;
     } else {
         \App::abort(404);
     }
 }
Example #3
0
 /**
  * get list of persons for jqgrid
  * @return json
  */
 public function getlist()
 {
     User::onlyHas('person-view');
     $jqgrid = new jQgrid('apl_person', 'person_id');
     echo $jqgrid->populate(function ($start, $limit) {
         $persons = PersonLangModel::select('person_id', 'first_name', 'last_name')->where('lang_id', Language::getId())->skip($start)->take($limit)->orderBy(DB::raw(\PersonLangModel::getField('first_name') . ', ' . \PersonLangModel::getField('last_name')), 'asc')->get();
         foreach ($persons as &$person) {
             $groups = \PersonRelModel::join(\PersonGroupLang::getTableName(), \PersonRelModel::getField('group_id'), '=', \PersonGroupLang::getField('group_id'))->select(\PersonGroupLang::getField('name'))->where(\PersonRelModel::getField('person_id'), $person->person_id)->where(\PersonGroupLang::getField('lang_id'), '=', \WebAPL\Language::getId())->get();
             $array_groups = [];
             foreach ($groups as $group) {
                 $array_groups[] = $group->name;
             }
             $person['group'] = $array_groups ? implode(', ', $array_groups) : '---';
         }
         return $persons;
     });
 }