public function createAction() { $this->view->Title = "Phong thủy xe"; $this->view->headTitle($this->view->Title); if ($this->getRequest()->isPost()) { $request = $this->getRequest()->getParams(); $error = $this->_checkForm($request); $Product = new Color(); $Product->merge($request); if ($Product->trySave()) { $folder = $Product->id; } if ($_FILES['image']['name']) { $dirname = "uploads/color/" . $folder . "/"; $upload = new My_Plugin_Upload(); $error = $upload->uploadImageFile($_FILES['image'], 800, 600, 1024000, array("image/png", "image/jpg", "image/gif", "image/x-png", "image/jpeg"), $dirname); if (!$error) { $filename = $upload->fileName; } } if (count($error) == 0) { if ($filename != "") { $Product->image = $filename; } $Product->save(); $this->Member->log('Phong thủy xe:' . $Product->car_paint_color . '(' . $Product->id . ')', 'Tạo mới'); My_Plugin_Libs::setSplash('Phong thủy xe: <b>' . $Product->car_paint_color . '</b> đã tạo thành công. '); $this->_redirect($this->_helper->url('index', 'color', 'admin')); } if (count($error)) { $this->view->error = $error; } } }
public function postAgregacolor() { $color = new Color(); $color->nombre = Input::get('nombre_color'); $color->save(); $material_color = new MaterialColor(); $material_color->color_id = $color->id; $material_color->material_id = Input::get('material_id'); $material_color->save(); return Redirect::action('InventarioRecubControlador@getColores'); }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aProduct !== null) { if ($this->aProduct->isModified() || $this->aProduct->isNew()) { $affectedRows += $this->aProduct->save($con); } $this->setProduct($this->aProduct); } if ($this->aColor !== null) { if ($this->aColor->isModified() || $this->aColor->isNew()) { $affectedRows += $this->aColor->save($con); } $this->setColor($this->aColor); } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = ProductHasColorPeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setNew(false); } else { $affectedRows += ProductHasColorPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
function getColor() { $this->autoRender = false; $sql = "select * from inventory where Department = 'Stain';"; $datas = $this->Cabinet->query($sql); App::import("Model", "Inventory.Color"); App::import("Model", "Inventory.ColorSection"); $i = 1; foreach ($datas as $data) { $color_model = new Color(); $color_data = array(); $color_data['Color']['name'] = $data['inventory']['Description']; $color_data['Color']['code'] = $data['inventory']['Material'] . "C" . $i; if (!$color_model->save($color_data)) { pr($color_model->validationErrors); } //Cabinet Material $cabinet_material_data = array(); $cabinet_material_data['ColorSection']['color_id'] = $color_model->id; $cabinet_material_data['ColorSection']['edgetape_id'] = 0; $cabinet_material_data['ColorSection']['cost'] = $data['inventory']['Cost']; $cabinet_material_data['ColorSection']['markup'] = 1; $cabinet_material_data['ColorSection']['price'] = $data['inventory']['Price']; $cabinet_material_data['ColorSection']['type'] = "cabinate_material"; $color_section_model1 = new ColorSection(); if (!$color_section_model1->save($cabinet_material_data)) { pr($color_section_model1->validationErrors); } //Door Material $door_material_data = array(); $door_material_data['ColorSection']['color_id'] = $color_model->id; $door_material_data['ColorSection']['edgetape_id'] = 0; $door_material_data['ColorSection']['cost'] = $data['inventory']['Cost']; $door_material_data['ColorSection']['markup'] = 1; $door_material_data['ColorSection']['price'] = $data['inventory']['Price']; $door_material_data['ColorSection']['type'] = "door_material"; $color_section_model2 = new ColorSection(); if (!$color_section_model2->save($door_material_data)) { pr($color_section_model2->validationErrors); } $i++; } }
} else { $session->message($session->message . "The color " . $_POST["{$i}"] . " failed to update. "); } } } } // check if a new color has been added if ($_POST["new_color"] != "") { // check if the color name already exists if (Color::find_by_name("{$_POST["new_color"]}")) { $session->message($session->message . "The color " . $_POST["new_color"] . " already exists and was not added. "); } else { // add new color $new_color = new Color(); $new_color->name = $_POST["new_color"]; if ($new_color->save()) { $session->message($session->message . "The color " . $_POST["new_color"] . " was successfully added! "); redirect_head(ROOT_URL . "admin/manage_colors.php"); } else { $session->message($session->message . "The color " . $_POST["new_color"] . " cannot be added at this time. "); } } } // redirect for colors(s) were updated but no new color added redirect_head(ROOT_URL . "admin/manage_colors.php"); } //header template require_once "../requires/template/header.php"; ?> <section id="registration" class="container"><form class="center" role="form" action="<?php