public function executeQuickinput(sfWebRequest $request) { //this will only handle inputstring and parsing. //All other functions will be delegated. //---initialize vars------------------------------------------------------------------------------- $this->linestrings = array(); $this->cellstrings = array(); $this->inputstring = ""; $this->errors = array(); $this->messages = array(); $this->generate = false; $this->tested = false; //---------case 2: method=get, init vars but do nothing: [ok]--------- //show empty if ($request->getMethod() == "GET") { } else { $this->inputstring = $request->getParameter("inputstring"); $this->parse(); $this->tested = true; if ($request->getParameter("submit") == "Save") { $this->generate = true; } //test parsed data //var_dump($this->cellstrings); //processing: //save each item under product type //expect 2 columns: producttype and product //optional column:price? foreach ($this->cellstrings as $row) { $producttypename = $row[0]; $productname = $row[1]; //check if product exists $product = Doctrine_Query::create()->from('Product p')->where('p.name ="' . $productname . '"')->fetchOne(); if ($product) { $this->errors[] = "Product " . $productname . " already exists."; } $producttype = null; if ($producttypename) { $producttype = Doctrine_Query::create()->from('Producttype pt')->where('pt.path ="' . $producttypename . '"')->fetchOne(); } if (!$producttype) { $this->errors[] = "Producttype " . $producttypename . " not found."; } if (count($this->errors) == 0) { if ($this->generate) { $product = new Product(); $product->setName($productname); if ($producttype) { $product->setProducttypeId($producttype->getId()); } $product->save(); $this->messages[] = "Product " . $productname . " created."; } } } /* $this->pricelistdata->process($this->cellstrings,$request); $this->producttypedata->process($this->cellstrings); $this->productdata->process($this->cellstrings,$this->producttypedata); $this->quotedata->process($this->cellstrings,$request); $this->productsfromproducttypedata->process($this->cellstrings,$this->producttypedata); if($request->getParameter("submit")=="Save" and count($this->errors)==0) { $this->pricelistdata->save(); $this->producttypedata->save(); $this->productdata->save(); $this->quotedata->save(); } //---update input string----------------------------------------------------------------------- $this->inputstring= $this->pricelistdata->getInputString(). $this->producttypedata->getInputString(). $this->productdata->getInputString(); */ } }