Commit 0ccaac5a authored by Dieudonne Timma Meyatchie's avatar Dieudonne Timma Meyatchie
Browse files

Ingredient Anzeige eingefügt..!!

parent 5d532e57
......@@ -13,6 +13,20 @@ class THMReversCookings
$this->attribs['width'] = '335px';
$this->attribs['height'] = '250px';
}
//check , if the User has a profil
public static function hasprofil($userid){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id');
$query->from(' #__thm_reverscookingsprofils');
$query->where('created_by ='.$userid);
$db->setQuery($query);
$db->query();
$result = $db->loadObjectList();
if(empty($result))
return null;
return $result;
}
public static function hasbild($datenbanktabel,$element, $element_value){
$db = JFactory::getDbo();
......@@ -52,34 +66,56 @@ class THMReversCookings
public static function suchzutaten($rezeptid, $created_by){
$profilid = self::getprofilid($created_by);
$db = JFactory::getDbo();
$query = 'SELECT DISTINCT a.ingid FROM #__thm_reverscookings_ingredients_rezept as a
LEFT JOIN #__thm_reverscookings_virtual_fridge as b on a.ingid <> b.ingid
WHERE a.rezeptid ='.$rezeptid.' AND b.userid ='.$profilid;
$query = 'select a.ingid from #__thm_reverscookings_ingredients_rezept as a where a.rezeptid ='.$rezeptid.' and a.ingid
not in (SELECT b.ingid from #__thm_reverscookings_virtual_fridge as b where b.userid ='.$profilid.')';
$db->setQuery($query);
$db->query();
$ingdata = $db->loadObjectList();
$whererequest = ' ingid=';
$whererequest = 'a.ingid=';
for ($i=0; $i<count($ingdata); $i++){
$ing=$ingdata[$i];
$whererequest .=$ing->ingid;
if($i< count($ingdata)-1)
$whererequest.=' OR ingid=';
$whererequest.=' OR a.ingid=';
}
$userquery = 'SELECT userid , count(ingid) AS treffer
FROM #__thm_reverscookings_virtual_fridge WHERE userid <>'.$profilid.' AND ('.$whererequest.' ) GROUP BY userid ORDER BY treffer DESC';
$userquery = 'SELECT a.userid as userid ,a.ingid as ingid,b.ingname as ingname
FROM #__thm_reverscookings_virtual_fridge AS a LEFT JOIN #__thm_reverscookings_ingredients AS b ON a.ingid = b.id WHERE userid <>'.$profilid.' AND ('.$whererequest.' )';
$db->setQuery($userquery);
$db->query();
$userdata = $db->loadObjectList();
$result = array();
$userlist = $db->loadObjectList();
if(count($userlist)==0)
return null;
$userdata = array();
$inganzahl = count($ingdata)/2;
for ($i=0; $i<count($userdata); $i++){
$profiluser = $userdata[$i];
if($profiluser->treffer >= $inganzahl){
array_push($result, $profiluser->userid);
$result = array();
for($y =0; $y<count($userlist);$y++){
$userid = $userlist[$y]->userid;
$inglist = array();
$in =$y;
$treffer=0;
while($in<count($userlist) && $userlist[$in]->userid == $userid ){
array_push($inglist,$userlist[$in]->ingname);
$treffer++;
$in++;
}
if($treffer >= $inganzahl){
$element = new stdClass();
$element->userid = $userid;
$element->ing = $inglist;
$element->treffer = $treffer;
array_push($result, $element);
}
if($in == count($userlist))
break;
$y = $in-1;
}
if(count($result)==0)
return null;
$rand = 0;
if(count($result)>1){
$max = count($result)-1;
......
<?php
/**
* @version 1.0.0
* @package com_thm_reverscookings
* @copyright Copyright (C) 2012. All rights reserved.
* @license GNU General Public
* @author Bassing <dominik.bassing@mni.thm.de>
* @author Seefeldt <Stefan.Seefeldt@mni.thm.de>
* @author Schneider <stefan.schneider@mni.thm.de>
* @author Omoko <guy.bertrand.omoko@hotmail.com>
* @author Noubeva <guylene.deutcho.noubevam@mni.thm.de>
* @author Timma<dieudonne.timma.meyatchie@mni.thm.de>
*/
// No direct access to this file
// No direct access to this file
defined('_JEXEC') or die;
jimport('joomla.application.component.view');
......@@ -23,14 +12,21 @@ $requestid= JRequest :: getVar('id');
$requestview = JRequest :: getVar('view');
$has = THMReversCookings::hasprofil($userid);
if(isset($has)){
if($viewtype ==0){
if(isset($requestid) == true){
if(strcmp($requestview,'reverscookingsrezept') == 0){
$profilid = null;
$profilid = THMReversCookings::suchzutaten($requestid, $userid);
if($profilid != null){
$index = intval($profilid);
echo THMReversCookings::myprofil($index,'id');
$profilid = null;
$profilid = THMReversCookings::suchzutaten($requestid, $userid);
if($profilid != null){
$index = intval($profilid->userid);
$ingarr = $profilid->ing;
echo THMReversCookings::myprofil($index,'id');
echo "<div><h4> Ich habe:</h4>";
for($i=0; $i < count($ingarr); $i++)
echo '<h4>'.$ingarr[$i]."</h4>";
echo"</div>";
}
}else{
$id = intval($requestid);
......@@ -48,12 +44,19 @@ if($viewtype == 1){
$profilid = null;
$profilid = THMReversCookings::suchzutaten($requestid, $userid);
if($profilid != null){
$id = intval($profilid);
$id = intval($profilid->userid);
$ingarr = $profilid->ing;
echo THMReversCookings::myprofil($id,'id');
echo "<div><h4> Ich habe:</h4>";
for($i=0; $i < count($ingarr); $i++)
echo '<h4>'.$ingarr[$i]."</h4>";
echo"</div>";
}
else{echo THMReversCookings::myprofil($userid, 'created_by');}
}
else{echo THMReversCookings::myprofil($userid, 'created_by');}
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment