public function upload($name = '') { if (!$name) { throw new CException(Yii::t('no file name')); } $file = CUploadedFile::getInstanceByName($name); if (!$file->hasError) { //生成目录 $filename = md5(time()) . '.' . $file->extensionName; $filepath = $this->getDirByTime() . DIRECTORY_SEPARATOR; $allFilePath = $this->_dirPath . DIRECTORY_SEPARATOR . $filepath . $filename; if (!$this->createDir($this->_dirPath . DIRECTORY_SEPARATOR . $filepath) || !is_writable($this->_dirPath . DIRECTORY_SEPARATOR . $filepath)) { throw new CException(Yii::t('yii', 'dir can not create or can not writeable')); } if ($file->saveAs($allFilePath)) { //获取图片宽和高 $picSize = getimagesize($allFilePath); $imgInfo = array('name' => $file->name, 'filepath' => $filepath, 'filename' => $filename, 'filesize' => $file->size, 'type' => $file->extensionName, 'mark' => 'img', 'imgwidth' => $picSize[0], 'imgheight' => $picSize[1], 'create_time' => time()); //素材数据入库 $model = new Material(); $model->attributes = $imgInfo; $model->save(); $imgInfo['id'] = $model->id; return $imgInfo; } else { throw new CException(Yii::t('yii', 'file save error')); } } else { throw new CException(Yii::t('yii', 'there is an error for upload ,error:{error}', array('{error}' => $file->error))); } }
/** * @param Material $cost * * @return $this */ public function addCost(Material $cost) { if (array_key_exists($cost->getName(), $this->cost)) { $amount = $this->cost[$cost->getName()]->getAmount(); $amount->add($cost->getAmount()); } else { $this->cost[$cost->getName()] = $cost; } return $this; }
static function inicialitza($id, $idMG, $idS) { $OM = self::retrieveByPK($id); if (!$OM instanceof Material) { $OM = new Material(); $OM->setMaterialgenericIdmaterialgeneric($idMG); $OM->setUnitats(1); $OM->setSiteId($idS); $OM->setActiu(true); } return new MaterialForm($OM, array('IDS' => $idS)); }
public function __construct($filename, $directory = '') { $found = FALSE; // Some OBJ files provide full relative pathname. Extract just the filename. $path_info = pathinfo($filename); $filename = $path_info['basename']; $files = file_scan_directory($directory, '/.*' . $filename . '$/', array('recurse' => TRUE)); foreach ($files as $uri => $file) { if ($file->filename != $filename) { continue; } $found = TRUE; $handle = fopen($uri, 'r'); $material = NULL; $text = ''; while (($line = fgets($handle)) !== FALSE) { $line = trim($line); // Start of a new material. // Store the old material first. if (strpos($line, 'newmtl ') === 0) { // Start a new material. // First close the previous material. if (!empty($text)) { $material = new Material($text, $directory); if ($error = $material->getError()) { $this->error = $error; return; } $this->materials[$material->name] = $material; } $text = $line; } elseif (!empty($line) && strpos($line, '#') !== 0) { $text .= PHP_EOL . $line; } } // End of file. Create the material. if (!empty($text)) { $material = new Material($text, $directory); if ($error = $material->getError()) { $this->error = $error; return; } $this->materials[$material->name] = $material; } } if (!$found) { $this->error = 'File ' . $filename . ' doesn\'t exist.'; return; } }
public function all($id, $cliente) { $arr = array(); if (is_null($id)) { $sql = "SELECT `material`.`idmaterial`, `material`.`nome`, `material`.`endereco`, `material`.`descricao`, `material`.`aula_idaula`, `material`.`cliente_idcliente`, `aula`.`nome` AS `aulaNome` FROM `material` \n\t\tINNER JOIN `aula` ON `aula_idaula`=`idaula` WHERE `material`.`cliente_idcliente`={$cliente};"; $vai = new MySQLDB(); $result = $vai->executeQuery($sql); } else { $sql = "SELECT `material`.`idmaterial`, `material`.`nome`, `material`.`endereco`, `material`.`descricao`, `material`.`cliente_idcliente`, `material`.`aula_idaula`, `aula`.`nome` AS `aulaNome` FROM `material` \n\t\tINNER JOIN `aula` ON `aula_idaula`=`idaula` WHERE `material`.`idmaterial` = {$id};"; $vai = new MySQLDB(); $result = $vai->executeQuery($sql); } while ($dados = mysql_fetch_array($result)) { $cliente = new Material(); $cliente->setidmaterial(array('idmaterial' => $dados['idmaterial'])); $cliente->setnome(array('nome' => $dados['nome'])); $cliente->setendereco(array('endereco' => $dados['endereco'])); $cliente->setdescricao(array('descricao' => $dados['descricao'])); $cliente->setaula_idaula(array('aula_idaula' => $dados['aula_idaula'])); $cliente->setaulaNome(array('aulaNome' => $dados['aulaNome'])); $cliente->setcliente_idcliente(array('cliente_idcliente' => $dados['cliente_idcliente'])); $arr[] = $cliente; } return $arr; }
public function getSelect($t) { $index = Input::get('i'); $type = str_replace('_', ' ', $t); $obj = Material::join('types', 'types.id', '=', 'materials.type')->where('types.name', 'LIKE', $type . '%')->where('availability', '!=', 'Out of stacks')->get(array('materials.*', 'types.name AS type')); return View::make('partials.product.options')->with('products', $obj)->with('type', $t)->with('i', $index); }
/** * @return null|object|Material * get singleton instance */ public static function getInstance() { if (!self::$instance) { self::$instance = new Material(); } return self::$instance; }
public function destroy() { $id = Input::get('id'); $material = Material::find($id); $material->delete(); return Redirect::route('materiales.index'); }
public function all($id) { $arr = array(); $vai = new MySQLDB(); $sql = "SELECT `material`.`idmaterial`, `material`.`nome`, `material`.`endereco`, `material`.`descricao` FROM `material` \n\t\t\tWHERE `material`.`aula_idaula` = {$id};"; $result = $vai->executeQuery($sql); while ($dados = mysql_fetch_array($result)) { $cliente = new Material(); $cliente->setidmaterial(array('idmaterial' => $dados['idmaterial'])); $cliente->setnome(array('nome' => $dados['nome'])); $cliente->setendereco(array('endereco' => $dados['endereco'])); $cliente->setdescricao(array('descricao' => $dados['descricao'])); $arr[] = $cliente; } return $arr; }
/** * @param string $language Language */ public function __construct($language = null) { parent::__construct(); if (!is_null($language)) { $this->language = $language; } }
public function show($id) { try { $iteration = Iterations::findOrFail($id); $iterations = Iterations::where('projectid', '=', $iteration->projectid)->get(); $project = Project::findOrFail($iteration->projectid); $issues = Issue::where('iterationid', '=', $id)->get(); //$issues = $iteration->issues; $countIssues = sizeof($issues); $categories = Category::all(); $idCategory = 0; $totalPoints = $issues->sum('points'); $materiales = Material::all(); $personal = PersonalType::all(); $team = Teams::where('projectid', '=', $project->id)->get()->first(); $members = DB::table('memberof')->where('teamid', '=', $team->id)->get(); $hasmembers = sizeof($members) > 0 ? true : false; $users = array(); foreach ($members as $member) { $users[] = User::findOrFail($member->usersid); echo $hasmembers; } $this->layout->content = View::make('layouts.iterations.show')->with('iteration', $iteration)->with('iterations', $iterations)->with('issues', $issues)->with('categories', $categories)->with('idCategory', $idCategory)->with('countIssues', $countIssues)->with('totalPoints', $totalPoints)->with('project', $project)->with('materiales', $materiales)->with('personal', $personal)->with('hasmembers', $hasmembers)->with('members', $members)->with('users', $users)->with('message', ''); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { return Redirect::to('/projects/')->with('message', 'Error al crear la iteración'); } }
/** * 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 $id the ID of the model to be loaded * @return Menus the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Material::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $message = Message::find($id); $message->fill(Input::all()); $message->save(); $material = Material::find(Input::get('materialid')); $material->status = 'ok'; $material->save(); return Redirect::to('/beheer'); }
public function destroy($id) { $material = Material::find($id); if (sizeof($material->tasks) < 1) { $material->delete(); return Redirect::to('/materials')->with('message', 'Registro eliminado')->with('organization', app('organization')); } else { return Redirect::to('/materials')->with('error', 'El registro ya se encuentra como gasto dentro de las actividades.'); } }
public function incluir() { $this->setData(date("Y-m-d H:i:s")); $this->setMaterialId(trim(strip_tags(filter_input(INPUT_POST, "material_id")))); $this->setQuantidade(str_replace(',', '.', trim(strip_tags(filter_input(INPUT_POST, "quantidade"))))); $this->setTipo(trim(strip_tags(filter_input(INPUT_POST, "tipo")))); $this->setObservacao(trim(strip_tags(filter_input(INPUT_POST, "observacao")))); $this->setPessoaId($_SESSION["usr_id"]); $retorno = $this->incluirMovEstoque(); if ($retorno) { $material = new Material(); if ($this->getTipo() == 'E') { $material->somaEstoque($this->getMaterialId(), $this->getQuantidade()); } else { $material->subtraiEstoque($this->getMaterialId(), $this->getQuantidade()); } } return $retorno; }
private function createMeshFromArray($input) { if ($input['type'] != 'mesh') { $this->error = 'Supplied array does not represent a mesh.'; return; } if (!empty($input['name'])) { $this->name = $input['name']; } if (!empty($input['data'])) { $this->face_data = $input['data']; } if (!empty($input['material'])) { $material = new Material($input['material']); if ($error = $material->getError()) { $this->error = $error; return; } } }
function Mat_Nuevo($rut_usuario) { $queryNuevo = "INSERT INTO material (Sub_Cat_ID, Nombre_Mat, Imagen_Mat, DESCRIPCION_MAT) VALUES ($this->material_categoria, '$this->material_nombre', 'no_imagen.jpg', '$this->material_descripcion')"; db_connect(); if (mysql_query($queryNuevo)) { $ultimoID = mysql_insert_id(); $instanciaMaterial = new Material($ultimoID, 0, 0, 0, 0, $this->material_rut_proveedor); $validadorProveedor = $instanciaMaterial->Mat_Proveedor($rut_usuario); if ($validadorProveedor == true) { $return = $ultimoID; } else { $return = false; } } else { $return = false; } db_close(); return $return; }
function LineaDeVenta_Buscar($busqueda) { $query = "SELECT * FROM venta_de_material WHERE rut_cli = '$busqueda';"; db_connect(); $resulsetRut = mysql_query($query); $contador = 0; $egresos = array(); while ($rowRut = mysql_fetch_array($resulsetRut)) { $vta_id = $rowRut["VENTA_MATERIAL_ID"]; $egresos[$contador][0] = $vta_id; $egresos[$contador][1] = $rowRut["RUT_CLI"]; $egresos[$contador][2] = $rowRut["FECHA"]; $contador++; } $egresos_cont = array(); for ($count = 0; count($egresos) > $count; $count++) { $vta_id = $egresos[$count][0]; $query_egreso = "SELECT * FROM egreso_material_venta WHERE venta_material_id = $vta_id"; $resulset_egreso = mysql_query($query_egreso); $contadors = 0; while ($rowRuts = mysql_fetch_array($resulset_egreso)) { $egresos_cont[$contadors][2] = $rowRuts["MATERIAL_ID"]; $egresos_cont[$contadors][1] = $rowRuts["CANTIDAD"]; $contadors++; } } db_close(); for ($counts = 0; count($egresos_cont) > $counts; $counts++) { $material_id = $egresos_cont[$counts][2]; $instancia_material = new Material($material_id, 0, 0, 0, 0, 0); $material = array(); $material = $instancia_material->Mat_Ver(); $egresos_cont[$counts][0] = $material[2]; } $return = array(); $return[0] = $egresos; $return[1] = $egresos_cont; return $return; }
public function actionIndex() { //获取用户名和密码 $name = Yii::app()->request->getParam('name'); $password = Yii::app()->request->getParam('password'); if (!$name) { Error::output(Error::ERR_NO_USER_NAME); } if (!$password) { Error::output(Error::ERR_NO_PASSWORD); } //获取用户模型 $userinfo = Members::model()->find('name=:name', array(':name' => $name)); if (!$userinfo) { Error::output(Error::ERR_NO_USER); } else { $_password = md5($userinfo->salt . $password); if ($_password != $userinfo->password) { Error::output(Error::ERR_INVALID_PASSWORD); } } //登陆成功生成user_login $userLogin = UserLogin::model()->find('user_id = :user_id', array(':user_id' => $userinfo->id)); if (!$userLogin) { //不存在就创建 $userLogin = new UserLogin(); $userLogin->user_id = $userinfo->id; $userLogin->username = $name; } $userLogin->login_time = time(); $userLogin->token = md5(time() . Common::getGenerateSalt()); $userLogin->visit_client = Common::getClientType(); $userLogin->ip = Common::getIp(); $userLogin->save(); $member = CJSON::decode(CJSON::encode($userinfo)); $member['token'] = $userLogin->token; unset($member['password'], $member['salt']); //返回数据 //如果存在头像,就返回 if ($member['avatar']) { //取图片数据 $material = Material::model()->findByPk($member['avatar']); $member['avatar'] = array('host' => Yii::app()->params['img_url'], 'filepath' => $material->filepath, 'filename' => $material->filename); } Out::jsonOutput($member); }
public function searchMaterial($name, $status, $availability, $categorie) { $qeury = Material::select('*'); if ($name != '') { $qeury = $qeury->where('name', 'LIKE', '%' . $name . '%'); } if ($status != 'all') { $qeury = $qeury->where('status', '=', $status); } if ($availability != 'all') { $qeury = $qeury->where('availability', '=', $availability); } if ($categorie != 'all') { $qeury = $qeury->whereHas('categories', function ($q) use($categorie) { $q->where('categories.id', '=', $categorie); }); } $result = $qeury->get(); return $result; }
public function beforeControllerAction($controller, $action) { if (parent::beforeControllerAction($controller, $action)) { //如果需要登陆就检测用户是否登陆 if (defined('NEED_LOGIN') && NEED_LOGIN) { //检测 $accessToken = Yii::app()->request->getParam('access_token'); if (!$accessToken) { Error::output(Error::ERR_NO_LOGIN); } else { //检测token有没有过期 $userLogin = UserLogin::model()->find("token = :token AND login_time + " . Yii::app()->params['login_expire_time'] . " > " . time(), array(':token' => $accessToken)); if ($userLogin) { //根据用户id查询用户信息 $memberInfo = Members::model()->find('id = :id', array(':id' => $userLogin->user_id)); if (!$memberInfo) { Error::output(Error::ERR_NO_LOGIN); } //转换成数组 $memberInfo = CJSON::decode(CJSON::encode($memberInfo)); //把用户信息存放到user里面供访问 unset($memberInfo['password'], $memberInfo['salt']); //如果存在头像,就返回 if ($memberInfo['avatar']) { //取图片数据 $material = Material::model()->findByPk($memberInfo['avatar']); $memberInfo['avatar'] = array('host' => Yii::app()->params['img_url'], 'filepath' => $material->filepath, 'filename' => $material->filename); } $this->_user = $memberInfo; } else { Error::output(Error::ERR_NO_LOGIN); } } } return true; } else { return false; } }
// session = array echo '<table style="width:100%" >'; for ($aux = 0; $aux < count($_SESSION['produto']['editar'][$whatarray]); $aux++) { // percorre array de material if ($aux % 2 == 0) { //if else para tabela zebrada echo '<tr style="background-color:#ccc;">'; } else { echo '<tr style="background-color:#ddd;">'; } $id_qtd_tipo = explode(":", $_SESSION['produto']['editar'][$whatarray][$aux]); // separa os valores id e quantidade if ($id_qtd_tipo[2] == 'm') { // se for material $res = new Material(); $res = Material::get_material_id($id_qtd_tipo[0]); $uni = new Unidade_medida(); $uni = $uni->get_unidade_medida_by_id($res->id_unidade_medida); echo '<td ><span>' . $res->nome . ': </span></td><td><input id="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" onchange="increment(this.id)" style="width:70%; background-color: rgba(230,230,230,0.5)" type="number" value="' . $id_qtd_tipo[1] . '"> <span>' . $uni->sigla . '</span></td><td><a name="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" style="cursor:pointer" onclick="apagar(this.name,\'material\', \'editar\')"><img style="width:15px" src="../images/delete.png"></a></td>'; } else { if ($id_qtd_tipo[2] == 'p') { // se for produto $res = new Produto(); $res = $res->get_produto_id($id_qtd_tipo[0]); echo '<td ><span>' . $res->nome . ': </span></td><td><input id="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" onchange="increment(this.id)" style="width:70%; background-color: rgba(230,230,230,0.5)" type="number" value="' . $id_qtd_tipo[1] . '"></td><td><a name="' . $res->id . ':' . $id_qtd_tipo[1] . ':' . $id_qtd_tipo[2] . '" style="cursor:pointer" onclick="apagar(this.name,\'material\', \'editar\')"><img style="width:15px" src="../images/delete.png"></a></td>'; } } echo '</tr>'; } echo '</table>'; }
<div class="form-group label-floating"> <label for="from" class="control-label">From</label> <input type="text" class="form-control" id="from" name="from" required> <span class="help-block">Include starting from this date</span> </div> <div class="form-group label-floating"> <label for="to" class="control-label">Before</label> <input type="text" class="form-control" id="to" name="to" required> <span class="help-block">Include through this date</span> </div> <button type="submit" class="btn btn-raised btn-primary modal-submit pull-right">Download</button> <button type="button" class="btn btn-danger pull-right" data-dismiss="modal">Cancel</button> </fieldset> </form> </div> </div> </div> </div> </div> <?php Material::startBootstrap(); ?> </body> </html>
<?php include_once "../header.php"; include_once "../../model/class.materiais.php"; include_once "../../controller/class.materiais.php"; $material = new Material(); $acao = isset($_GET["acao"]) ? $_GET["acao"] : ""; $codigo = isset($_GET["id"]) ? $_GET["id"] : 0; if ($codigo > 0) { if (!$material->buscarPorCodigo($codigo)) { echo "<script>\n alert('Registro não encontrado!');\n window.location = 'listagem.php';\n </script>"; exit; } } if ($acao == "excluir" && $codigo > 0) { if ($material->excluir($codigo)) { echo "<script>window.location = 'listagem.php';</script>"; } else { echo "<script>\n alert('Erro ao excluir o cadastro. Verifique as dependências e tente novamente.');\n window.location = 'listagem.php';\n </script>"; } } if ($_POST) { if ($codigo == 0) { if ($material->incluir()) { echo "<script>window.location = 'listagem.php';</script>"; } else { echo "<script>alert('Erro ao incluir!')</script>"; } } else { if ($material->alterar($codigo)) { echo "<script>window.location = 'listagem.php';</script>";
function geMaterial() { $this->autoRender = false; $sql = "SELECT DISTINCT material FROM inventory;"; $datas = $this->Cabinet->query($sql); App::uses("Material", "Inventory.Model"); foreach ($datas as $data) { $material = new Material(); if (!empty($data['inventory']['material'])) { $m['Material']['name'] = $data['inventory']['material']; $m['Material']['code'] = $data['inventory']['material']; $m['Material']['material_group_id'] = 9; $material->save($m); } } }
<span class="glyphicon glyphicon-plus"></span> </button> </span> </div> </div> </div> <!--material--> <div class="form-group"> <label class="control-label col-sm-2">Material *</label> <div class="col-sm-10"> <div class="input-group"> <select name="idMaterial" class="form-control" tabindex="2" required> <option value="">Selecione uma opção...</option> <?php $materiais = Material::findAll(); ?> <?php foreach ($materiais as $material) { ?> <option value="<?php echo $material->getIdMaterial(); ?> "><?php echo $material->getNmMaterial(); ?> </option> <?php } ?> </select>
$toolbodystock->setToolBodyID($_GET['tid']); } $toolbodystock->createToolBodyStockList(); $sel = new selectlist('ToolBody_Stock_ID', $toolbodystock->getToolBodyStockList(), 'Select Tool Body', 'ToolBody_Stock_ID', 'tsid', '', ''); break; case 'holderstock': $holderstock = new Holderstock(); if (isset($_GET['hid'])) { $holderstock->setHolderID($_GET['hid']); } $holderstock->createHolderStockList(); $sel = new selectlist('Holder_Stock_ID', $holderstock->getHolderStockList(), 'Select Holder Stock', 'Holder_Stock_ID', 'tsid', '', ''); break; case 'minward': //material inward $mi = new Material(); if (isset($_GET['cid'])) { $mi->setCustID($_GET['cid']); } $mi->createMaterialInwardList(); $sel = new selectlist('Material_Inward_ID', $mi->getMaterialInwardList(), 'Select Challan', 'Material_Inward_ID', 'refer', '', ''); break; case 'pmlist': //part material inward list $mi = new PartMaterial(); if (isset($_GET['miid'])) { $mi->setInwardID($_GET['miid']); } $mi->createPartMaterialList(); $sel = new selectlist('MI_Drg_Qty_ID', $mi->getPartMaterialList(), 'Select Part', 'MI_Drg_Qty_ID', 'des', '', ''); break;
<div> <div> <h3 id="reasultsHeader">Αποτελέσματα Αναζήτησης</h3> </div> <hr class="style-seven"> <div> <div class="table-responsive"> <table id="results-grid" class="table "> <?php $material = new Material(); //$material = Material::get(); $records_per_page = 5; $newquery = $material->paging($_SESSION['last_query'], $records_per_page); $material->results_view($newquery, $_SESSION['last_terms']); $material->paginglink($_SESSION['last_query'], $_SESSION['last_terms'], $records_per_page); ?> </table> <?php if (!isset($_SESSION['username'])) { ?> <a href="?page=login_signup" id="confirmLoan-Button" type="button" class="btn btn-default">Επιβεβαίωση Δανεισμού <span class="glyphicon glyphicon-chevron-right"></span> </a>
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Material $value A Material object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Material $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getIdmaterial(); } // if key === null self::$instances[$key] = $obj; } }
$searchData = json_decode($request->getBody()); $cleanStr = preg_replace('/[ ]*,[ ]*/i', ',', $searchData->search); $materials = explode(",", $cleanStr); $materials = array_filter($materials); if (count($materials) > 20) { return $response->write('{"msg":"çok fazla malzeme bilgisi var"}'); } foreach ($materials as $material) { $oldMaterial = Material::where('name', $material)->get(); if (!$oldMaterial->isEmpty()) { $oldMaterial = $oldMaterial->first(); $oldMaterial->count += 1; $oldMaterial->last_update_date = date("YmdHi"); $oldMaterial->save(); } else { $newMaterial = new Material(); $newMaterial->name = $material; $newMaterial->create_date = date("YmdHi"); $newMaterial->last_update_date = date("YmdHi"); $newMaterial->save(); } } $sqlStr = "*" . implode("* *", $materials) . "*"; // giri *domates* *tavuk* *malzeme* şeklindedir // saklı yordam kullanılmıştır $foods = Food::hydrateRaw("CALL searchRecipe(?)", array($sqlStr)); return $response->write(json_encode($foods) . " "); })->setName('search_foods'); // sayfalı son yemekler $this->get('/all/{page:[0-9]+}', function ($request, $response, $args) { $food = Food::select('food_id', 'name', 'description')->where('deleted', 0)->take(6)->offset($args['page'] * 6)->orderBy('food_id', 'DESC')->get();