public function getAffiliation($reseller_id, $array = true) { $metiers = Model::Segmentreseller()->where(['reseller_id', '=', (int) $reseller_id])->with('segment'); $out = $marches = []; foreach ($metiers as $metier) { if (isset($metier['segment'])) { switch ($metier['segment']['id']) { case 413: $marches[413] = ['id' => 413, 'name' => $metier['segment']['name']]; $opt_data = lib('forms')->getOptionsMacroData(413); if (isAke($opt_data, 'affiliation_resto', null) == 1) { $marches[413]['name'] = $marches[413]['name'] . ' ' . 'resto'; } elseif (isAke($opt_data, 'affiliation_snack', null) == 1) { $marches[413]['name'] = $marches[413]['name'] . ' ' . 'snack'; } elseif (isAke($opt_data, 'affiliation_vin', null) == 1) { $marches[413]['name'] = $marches[413]['name'] . ' ' . 'vin'; } break; default: $seg = repo('segment')->getFamilyFromItem($metier['segment']['id']); if (isset($seg[0]['id'])) { $marches[$seg[0]['id']] = $seg[0]; } } } } $out['txt'] = ''; $vir = ''; foreach ($marches as $marche) { $out['txt'] = $vir . $marche['name']; $vir = ', '; } $out['tab'] = $marches; return $array ? $out['tab'] : $out['txt']; }
private function resellerHasAuth($articles, $reseller) { foreach ($articles as $article) { $item_id = isAke($article, 'item_id', 0); if (0 < $item_id) { $family = repo('segment')->getFamilyfromItem($item_id); $cat = isset($family[1]) ? $family[1] : false; if (false !== $cat) { $check = Model::Segmentreseller()->where(['reseller_id', '=', $reseller])->where(['segment_id', '=', $cat['id']])->count(); if ($check > 0) { return true; } } } } return false; }