Example #1
0
 public static function getPlants()
 {
     $plants = array();
     $plant1 = new Plant();
     $plant1->setIdPlant(1);
     $plant1->setName("Lemon Balm");
     $plants[$plant1->getIdPlant()] = $plant1;
     $plant2 = new Plant();
     $plant2->setIdPlant(2);
     $plant2->setName("Bay Laurel");
     $plants[$plant2->getIdPlant()] = $plant2;
     $plant3 = new Plant();
     $plant3->setIdPlant(3);
     $plant3->setName("Tarragon");
     $plants[$plant3->getIdPlant()] = $plant3;
     return $plants;
 }
Example #2
0
 public function HandleRemoteProcedureCall($func, $username, $pw, $plantname, $code, $plantid)
 {
     $plant = null;
     if ($this->m_User == null) {
         $this->m_User = $this->m_Database->GetUser($username);
     }
     if ($this->m_User != null) {
         if ($plantid != null) {
             $plant = $this->m_User->GetPlantById($plantid);
         } else {
             $plant = $this->m_User->GetPlant($plantname);
         }
     }
     $res = "";
     switch ($func) {
         case "IsLoggedIn":
             $res = $this->m_Server->IsLoggedIn();
             break;
         case "Auth":
             $res = $this->m_Server->LogIn($username, $pw);
             break;
         case "Logout":
             $res = $this->m_Server->LogOut();
             break;
         case "Register":
             $res = $this->m_Server->Register($username, $pw);
             break;
         case "SavePlant":
             if ($plant != null) {
                 $res = $plant->Save($code);
             } else {
                 $res = $this->CreatePlant($plantname, $code);
             }
             break;
         case "CreatePlant":
             $res = $this->CreatePlant($plantname, $code);
             break;
         case "ActivatePlant":
             $res = $plant->Activate();
             break;
         case "GetPlantList":
             if (isset($this->m_User)) {
                 $res = $this->m_User->GetPlantList();
             } else {
                 $res = "{ success: false, msg: 'Sie sind nicht angemeldet' }";
             }
             break;
         case "GetSeasonList":
             $res = $this->GetSeasonScoreList();
             break;
         case "DeletePlant":
             if ($plant != null) {
                 $res = $plant->Delete();
             } else {
                 $res = "{ success: false, msg: \"Keine Pflanze mit dem Namen '" . $plantname . "' für den Nutzer '" . $username . "' gefunden.\" }";
             }
             break;
         case "TestPlant":
             break;
         case "CheckSyntax":
             # Create a temporary plant
             $plant = new Plant(0, 0, $plantname, $code, 0, 0);
             $res = $plant->Validate();
             break;
         default:
             $res = "{ success : false, msg: \"Unkown RPC call '" . $func . "'\"}";
     }
     return new RPCAnswer($func, $res);
 }
Example #3
0
<?php

require_once 'Medical.php';
require_once 'Plant.php';
$plants = new Plant();
$plants = Plant::getPlants();
$plants[1]->insertIdOfMedical(1);
$plants[2]->insertIdOfMedical(2);
$plants[3]->insertIdOfMedical(3);
$plants[3]->insertIdOfMedical(2);
$medicals = Medical::getMedicals();
$medicals[1]->insertIdOfPlant(1);
$medicals[2]->insertIdOfPlant(3);
$medicals[3]->insertIdOfPlant(2);
$medicals[3]->insertIdOfPlant(2);
foreach ($medicals as $idOfMedicals => $medi) {
    echo "<br>" . $medi->getBenefit() . ': ';
    foreach ($medi->getIdOfPlant() as $medId) {
        echo $plants[$medId]->getName() . ' ';
    }
}
foreach ($plants as $idOfPlants => $pla) {
    echo "<br>" . $pla->getName() . ': ';
    foreach ($pla->getIdOfMedicals() as $plaId) {
        echo $medicals[$plaId]->getBenefit() . ' ';
    }
}
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     parent::actionIndex();
     $plant = new Plant('searchwstatus');
     $plant->unsetAttributes();
     // clear any default values
     if (isset($_GET['Plant'])) {
         $plant->attributes = $_GET['Plant'];
     }
     $model = new Sloc('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Sloc'])) {
         $model->attributes = $_GET['Sloc'];
     }
     if (isset($_GET['pageSize'])) {
         Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);
         unset($_GET['pageSize']);
         // would interfere with pager and repetitive page size change
     }
     $this->render('index', array('model' => $model, 'plant' => $plant));
 }
Example #5
0
 public function height_in_feet()
 {
     return parent::height_in_feet();
 }
 public function getAllUserPlants($user)
 {
     $db = new Db();
     $plants = array();
     $id = $user->getId();
     $results = $db->select("SELECT * from plants WHERE user_id = {$id}");
     foreach ($results as $result) {
         $plant = new Plant();
         $plant->hydrate($result);
         $plants[] = $plant;
     }
     return $plants;
 }
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'project-form', 'enableAjaxValidation' => false));
$this->widget('ToolbarButton', array('DialogID' => 'createdialog3', 'DialogGrid' => 'detailpurchasedatagrid', 'isSave' => true, 'UrlSave' => 'product/writepurchase', 'isCancel' => true, 'UrlCancel' => 'product/cancelwritepurchase'));
echo $form->hiddenField($model, 'productpurchaseid');
echo $form->hiddenField($model, 'productid');
?>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'plantid');
echo $form->hiddenField($model, 'plantid');
?>
          <input type="text" name="plantcode" id="plantcode" readonly >
          <?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'plant_dialog', 'options' => array('title' => Yii::t('app', 'Plant'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true)));
$plant = new Plant('searchwstatus');
$plant->unsetAttributes();
// clear any default values
if (isset($_GET['Plant'])) {
    $plant->attributes = $_GET['Plant'];
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'plant-grid', 'dataProvider' => $plant->Searchwstatus(), 'filter' => $plant, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("V",
                array("name" => "send_addresstype",
                "id" => "send_addresstype",
                "onClick" => "$(\\"#plant_dialog\\").dialog(\\"close\\"); 
                $(\\"#plantcode\\").val(\\"$data->plantcode\\");
                $(\\"#Productpurchase_plantid\\").val(\\"$data->plantid\\");"))'), array('name' => 'plantid', 'visible' => false, 'value' => '$data->plantid', 'htmlOptions' => array('width' => '1%')), 'plantcode')));
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::Button('...', array('onclick' => '$("#plant_dialog").dialog("open"); return false;'));
?>
		<?php 
Example #8
0
 public function this_refers_to_the_object_that_you_are_in()
 {
     $plant = new Plant();
     assert_that($plant->description_with_height())->is_identical_to(__);
 }
Example #9
0
if (!class_exists('Location')) {
    require_once 'models/Location.Class.php';
}
if (!isset($_SESSION)) {
    // print ("Starting Session SaveFLower<br><br>");
    session_start();
}
if (isset($_SESSION)) {
    if (isset($_SESSION['current_user'])) {
        $user = $_SESSION['current_user'];
    }
}
// to see what is defined and included use this:
// debug_print_backtrace();
$php_errormsg = null;
$Plant = new Plant();
$Soil = new soil();
$Location = new Location();
$Weather = new weather();
if (isset($_GET['uid'])) {
    $Plant->setPlantUser($_GET['uid']);
} else {
    $php_errormsg = "Missing UserID. ";
}
if (isset($_GET['PlantName'])) {
    $Plant->setPlantName($_GET['PlantName']);
} else {
    $php_errormsg = $php_errormsg . "Missing Plant Name.<br> ";
}
if (isset($_GET['OnSite'])) {
    $Plant->setPlantEnteredOnSite($_GET['OnSite']);
Example #10
0
     $userManager = new UserManager();
     $arr = array();
     $arr["id"] = isset($_GET["id"]) ? $_GET["id"] : '';
     $arr["name"] = isset($_GET["name"]) ? $_GET["name"] : '';
     $arr["location"] = isset($_GET["location"]) ? $_GET["location"] : '';
     $arr["longitude"] = isset($_GET["longitude"]) ? $_GET["longitude"] : '';
     $arr["latitude"] = isset($_GET["latitude"]) ? $_GET["latitude"] : '';
     // $arr["weather_id"] = isset($_GET["weather_id"])?$_GET["weather_id"]:'';
     // $arr["soilid_id"] = isset($_GET["soilid_id"])?$_GET["soilid_id"]:'';
     $arr["weather"] = isset($_GET["weather"]) ? $_GET["weather"] : '';
     $arr["soil"] = isset($_GET["soil"]) ? $_GET["soil"] : '';
     $arr["temperature"] = isset($_GET["temperature"]) ? $_GET["temperature"] : '';
     $arr["wind"] = isset($_GET["wind"]) ? $_GET["wind"] : '';
     $arr["humidity"] = isset($_GET["humidity"]) ? $_GET["humidity"] : '';
     $arr["notes"] = isset($_GET["notes"]) ? $_GET["notes"] : '';
     $plant = new Plant();
     $plant->hydrate($arr);
     $userManager->savePlant($plant);
     // var_dump($plant);
     $target = $_SESSION['current_user'];
     $userManager = new UserManager();
     $plants = $userManager->getAllUserPlants($target);
     include '../views/user_plants.php';
     break;
 case 'add_flora':
     //$userManager = new UserManager();
     //$plant = new Plant();
     include '../views/user_add_plant.php';
     break;
 case 'geo_finder':
     //$userManager = new UserManager();
Example #11
0
 public function InsertNewPlant($userid, $name, $code)
 {
     $result = false;
     $plant = new Plant(0, $userid, $plantname, $code, 0, this);
     $valid = $plant->IsValid();
     $stmt = $this->m_Connection->prepare("INSERT INTO plant (UserID, Name, Code, Valid) VALUES (?, ?, ?, ?)");
     if ($stmt) {
         $stmt->bind_param("dssi", $userid, $name, $code, $valid);
         $stmt->execute();
         if ($stmt->affected_rows == 1) {
             $result = true;
         }
         $stmt->close();
     } else {
         die("DAAAAAAMN.");
     }
     return $result;
 }
Example #12
0
 public static function createFromInput(\Illuminate\Http\Request $input, $id = null, $save = true)
 {
     $module = parent::createFromInput($input, $id, $save);
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // Register plants
     ////
     $inputPlants = $input->get('plant', []);
     $plantsById = [];
     foreach ($inputPlants as $plantId => $inPlant) {
         $plantsById[$plantId] = ['input' => $inPlant, 'model' => null];
     }
     $currentPlants = $module->plants;
     $module->plants()->detach();
     foreach ($currentPlants as $plant) {
         if (isset($plantsById[$plant->id])) {
             // plant updated
             $plantsById[$plant->id]['model'] = $plant;
         } else {
             $plant->delete();
         }
     }
     foreach ($plantsById as $plantId => $arrPlant) {
         if (is_null($arrPlant['model'])) {
             $arrPlant['model'] = Plant::find($plantId);
         }
         if (!$arrPlant['model']) {
             continue;
         }
         $module->plants()->save($arrPlant['model'], ['amount' => $arrPlant['input']['amount']]);
     }
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // Register categories
     ////
     $inputCategories = $input->get('category', []);
     $categoriesById = [];
     foreach ($inputCategories as $categoryId => $inCategory) {
         $categoriesById[$categoryId] = ['input' => $inCategory, 'model' => null];
     }
     $currentCategories = $module->categories;
     foreach ($currentCategories as $category) {
         if (isset($categoriesById[$category->id])) {
             // category updated
             $categoriesById[$category->id]['model'] = $category;
         } else {
             $module->categories()->detach($category->id);
         }
     }
     foreach ($categoriesById as $categoryId => $arrCategory) {
         if (!is_null($arrCategory['model'])) {
             continue;
         }
         $arrCategory['model'] = Category::find($categoryId);
         if (!$arrCategory['model']) {
             continue;
         }
         $module->categories()->attach($arrCategory['model']);
     }
     return $module;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Plant::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #14
0
//print "<br><br> " .$temp . "<br><br>";
if (!isset($_SESSION['current_user'])) {
    print "<p> <h1>session not set </h1> </p><br><br>";
    // header('Location: ' . $_SERVER['HTTP_HOST'] . '/site/phpsite/MyclassProject/index.php');
    // exit;
} else {
    $user = $_SESSION['current_user'];
    /* URW DEBUG
      print "Add FLower: Session print follows: <br>";
    var_dump ($_SESSION);
    print ("<br>AFter session print <br>");
    */
    if (isset($_SESSION['current_plant'])) {
        $Plant = $_SESSION['current_plant'];
    } else {
        $Plant = new Plant();
    }
    if (isset($_SESSION['current_location'])) {
        $Location = $_SESSION['current_location'];
    } else {
        $Location = new Location();
    }
    if (isset($_SESSION['current_weather'])) {
        $Weather = $_SESSION['current_weather'];
    } else {
        $Weather = new weather();
    }
}
$Soil = new soil();
$SoilList = $Soil->GetAllSoils();
$SoilMenu = new selectMenu();