Пример #1
0
 public function getLanguagesFromSegmentId($sid)
 {
     $family = repo('segment')->getFamilyfromItem((int) $sid);
     $market = current($family);
     $options = $this->getOptionsFromMarket($market['id']);
     return Arrays::get($options, 'langue.values', []);
 }
Пример #2
0
 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'];
 }
Пример #3
0
 public function getMealsFromType($resto_type_id)
 {
     $collection = [];
     if (!is_integer($resto_type_id)) {
         return $collection;
     }
     $ids = repo('segment')->getAllFamilyIds((int) $resto_type_id);
     $ids[] = $resto_type_id;
     $segments = Model::Mealtype()->where(['resto_type_id', 'IN', implode(',', $ids)])->exec();
     foreach ($segments as $segment) {
         $collection[] = $this->get((int) $segment['segment_id']);
     }
     return $collection;
 }
Пример #4
0
 function doctrine($entity)
 {
     $repo = repo($entity);
     $class = '\\Thin\\Doctrine' . ucfirst($entity) . 'Entity';
     return $class;
 }
Пример #5
0
 public function getOfferOut($reseller_id, $offerout_id)
 {
     $collection = [];
     $offers = Model::Offerout()->where(['id', '=', $offerout_id])->exec();
     foreach ($offers as $offer) {
         $item = [];
         $articles = Model::Articleout()->where(['offerout_id', '=', $offer['id']])->exec();
         $item['id'] = $offer['id'];
         $item['status_id'] = $offer['status_id'];
         $item['date_creation'] = $offer['created_at'];
         $item['date_expiration_offerin'] = $offer['expiration_offerin'];
         $zip = isAke($offer, 'zip', false);
         if (false !== $zip) {
             $item['buyer']['zip'] = $zip;
             $company = Model::Company()->find($offer['company_id']);
             if ($company) {
                 $item['buyer']['city'] = $company->city;
                 $item['buyer']['is_pro'] = $company->is_pro;
                 $item['buyer']['is_pro'] = $company->is_pro;
                 $item['buyer']['name'] = $company->name;
             }
             $market = jmodel('segment')->find($offer['market']);
             if ($market) {
                 $item['market']['id'] = $market->id;
                 $item['market']['name'] = $market->name;
                 $data = repo('segment')->getData($market->id);
                 $icon = isAke($data, 'icon', null);
                 $item['market']['icon'] = $icon;
             }
             $item['category_id'] = $offer['category'];
             if ($offer['category'] > 0) {
                 $segCat = jmodel('segment')->find($offer['category']);
                 $item['category_name'] = $segCat->name;
                 $data = repo('segment')->getData($segCat->id);
                 $icon = isAke($data, 'icon', null);
                 $item['category_icon'] = $icon;
             } else {
                 $item['category_name'] = 'autre';
                 $item['category_icon'] = 'fa fa-cubes';
             }
             foreach ($articles as $article) {
                 $it = $article;
                 $seg = jmodel('segment')->find($article['item_id']);
                 if ($seg) {
                     $it['family'] = repo('segment')->getFamilyfromItem($article['item_id']);
                     $it['name'] = $seg->name;
                     $item['articles'][] = $it;
                 } else {
                     if ($article['item_id'] == 0) {
                         $item['articles'][] = $article;
                     }
                 }
             }
             array_push($collection, $item);
         }
     }
     return current($collection);
 }
Пример #6
0
 public function consolidate($reseller_id = null)
 {
     $q = Model::Product();
     if (!is_null($reseller_id)) {
         $q->where(['reseller_id', '=', (int) $reseller_id]);
     }
     $products = $q->cursor();
     foreach ($products as $product) {
         if (isset($product['reseller_id']) && isset($product['segment_id']) && isset($product['sellzone_id'])) {
             $row = Model::Productdata()->firstOrCreate(['reseller_id' => (int) $product['reseller_id'], 'segment_id' => (int) $product['segment_id'], 'sellzone_id' => (int) $product['sellzone_id']]);
             unset($product['_id']);
             $row->product = $product;
             $family = repo('segment')->getFamilyfromItem((int) $product['segment_id']);
             if (!empty($family)) {
                 $market = current($family);
                 $market_id = (int) $market['id'];
             } else {
                 $market_id = $segment_id;
             }
             $company = Model::Company()->where(['reseller_id', '=', (int) $product['reseller_id']])->first(false);
             $reseller = Model::Reseller()->find((int) $product['reseller_id'], false);
             $segment = Model::Segment()->find((int) $product['segment_id'], false);
             $location = lib('utils')->remember('has.locations.companies.' . $product['reseller_id'], function ($reseller_id) {
                 $company = Model::Company()->where(['reseller_id', '=', (int) $reseller_id])->first(true);
                 if ($company) {
                     $coords = lib('geo')->getCoordsMap($company->address . ' ' . $company->zip . ' ' . $company->city);
                     $loc = ['lng' => $coords['lng'], 'lat' => $coords['lat']];
                 }
                 return $loc;
             }, Model::Company()->getAge(), [$product['reseller_id']]);
             $status = (int) lib('status')->getId('reseller', 'REGISTER') == $reseller['status_id'];
             $row->company = $company;
             $row->segment = $segment;
             $row->status = $status;
             $row->location = $location;
             $row->reseller = $reseller;
             $options = [];
             $resellerObj = Model::Reseller()->model($reseller);
             $hasAgenda = lib('option')->get('agenda.partage', $resellerObj, false);
             $distanceMaxReseller = (double) lib('option')->get('zone.intervention.' . $market_id, $resellerObj, 0);
             $delai_presta = lib('option')->get('delai.intervention.' . $market_id, $resellerObj, 0);
             $minAmount = lib('option')->get('montant.intervention.' . $market_id, $resellerObj, 0);
             $options['has_agenda'] = $hasAgenda;
             $options['distance_max'] = $distanceMaxReseller;
             $options['delai_min'] = $delai_presta;
             $options['amount_min'] = $minAmount;
             $options['languages'] = [];
             $languages = ['anglais', 'espagnol', 'allemand', 'italien', 'néerlandais', 'portugais', 'russe', 'japonais', 'chinois'];
             foreach ($languages as $language) {
                 $speak = lib('option')->get('langue.' . $market_id . '.' . $language, $resellerObj, false);
                 $options['languages'][$language] = $speak;
             }
             $row->options = $options;
             $row->save();
         }
     }
 }
Пример #7
0
 public function getSegment($idSegment)
 {
     $segment = Model::Segment()->find((int) $segmentId);
     if ($segment) {
         $datas = repo('segment')->getData($segmentId);
     }
 }
Пример #8
0
 *   - commit: string
 */
function repo($path, $branch)
{
    $escPath = escapeshellarg($path);
    $escBranch = escapeshellarg($branch);
    $commit = file_exists($path) ? trim(`cd {$escPath} ; git show {$escBranch} | head -n1 | cut -f2 -d\\ `) : NULL;
    if (!empty($commit)) {
        return array('branch' => $branch, 'commit' => $commit);
    } else {
        return array();
    }
}
$DM_SOURCEDIR = getenv('DM_SOURCEDIR');
$DM_VERSION = getenv('DM_VERSION');
$data = array('version' => $DM_VERSION, 'timestamp' => array('pretty' => date('r'), 'epoch' => time()), 'tar' => array(), 'git' => array('civicrm-backdrop@1.x' => repo("{$DM_SOURCEDIR}/backdrop", getenv('DM_REF_BACKDROP')), 'civicrm-core' => repo("{$DM_SOURCEDIR}", getenv('DM_REF_CORE')), 'civicrm-drupal@6.x' => repo("{$DM_SOURCEDIR}/drupal", getenv('DM_REF_DRUPAL6')), 'civicrm-drupal@7.x' => repo("{$DM_SOURCEDIR}/drupal", getenv('DM_REF_DRUPAL')), 'civicrm-packages' => repo("{$DM_SOURCEDIR}/packages", getenv('DM_REF_PACKAGES')), 'civicrm-wordpress' => repo("{$DM_SOURCEDIR}/WordPress", getenv('DM_REF_WORDPRESS'))));
if (getenv('BPACK')) {
    $data['tar']['Backdrop'] = "civicrm-{$DM_VERSION}-backdrop-unstable.tar.gz";
}
if (getenv('J5PACK')) {
    $data['tar']['Joomla'] = "civicrm-{$DM_VERSION}-joomla.zip";
}
if (getenv('D56PACK')) {
    $data['tar']['Drupal6'] = "civicrm-{$DM_VERSION}-drupal6.tar.gz";
}
if (getenv('D5PACK')) {
    $data['tar']['Drupal'] = "civicrm-{$DM_VERSION}-drupal.tar.gz";
}
if (getenv('WPPACK')) {
    $data['tar']['WordPress'] = "civicrm-{$DM_VERSION}-wordpress.zip";
}
Пример #9
0
 function addSegmentToReseller($segment, $reseller)
 {
     if (is_object($reseller)) {
         $reseller = $reseller->id;
     }
     if (!is_numeric($reseller)) {
         throw new Exception('Reseller must be an instance of reseller or be an id');
     }
     if (is_object($segment)) {
         $segment = $segment->id;
     }
     if (!is_numeric($segment)) {
         throw new Exception('Segment must be an instance of segment or be an id');
     }
     $market = current(repo('segment')->getFamilyfromItem($segment));
     $market = isAke($market, 'id', $segment);
     return bigDb('segmentreseller')->firstOrCreate(['segment_id' => $segment, 'reseller_id' => $reseller, 'market' => $market]);
 }
Пример #10
0
 private function analyseSuggestions($choosePlates, $suggestions, $resto)
 {
     $tuples = $collection = $newPlates = [];
     $ap = isAke($resto, 'all_plats', []);
     foreach ($suggestions as $sugId) {
         $s = Model::Suggestion()->where(['segment_id', '=', $sugId])->first();
         $datas = repo('segment')->getData($sugId);
         $segments = isAke($datas, 'segments', '');
         if (fnmatch('*,*', $segments)) {
             $segments = explode(',', $segments);
             $item = [];
             $item['id'] = isAke($s, 'id', '');
             $item['name'] = isAke($s, 'name', '');
             $item['plats'] = [];
             foreach ($choosePlates as $cp) {
                 $plats = isAke($cp, 'plats', []);
                 foreach ($plats as $pl) {
                     $infos = isset($ap[$pl['id']]) ? current($ap[$pl['id']]) : [];
                     $attributes = $this->getAttributes(isAke($infos, 'data', []));
                     $addItem = false;
                     foreach ($attributes as $idAtt) {
                         if (in_array($idAtt, $segments)) {
                             $addItem = true;
                             break;
                         }
                     }
                     if ($addItem) {
                         $tuples[] = $cp['id'];
                         $item['plats'][] = $pl;
                     }
                 }
             }
             if (count($item['plats'])) {
                 $item['plats'] = array_values($item['plats']);
                 $item['nb'] = count($item['plats']);
                 $coll = lib('collection', [$item['plats']]);
                 $item['min_price'] = $coll->min('price');
                 $item['max_price'] = $coll->max('price');
                 $newPlates[] = $item;
             }
         } else {
             foreach ($choosePlates as $cp) {
                 if ($cp['id'] == $segments) {
                     $newPlates[] = $cp;
                     $tuples[] = $cp['id'];
                 }
             }
         }
     }
     foreach ($choosePlates as $cp) {
         if (!in_array($cp['id'], $tuples)) {
             $newPlates[] = $cp;
         }
     }
     foreach ($newPlates as $cp) {
         $plats = isAke($cp, 'plats', []);
         $cp['plats'] = array_values($plats);
         $collection[] = $cp;
     }
     return $collection;
 }