public function execute($action) { $forwards = $action->getForwards(); if (!isset($_SESSION['idProduction'])) { if ($_GET['idProduction'] == "new") { $production = new Production(); $production->setCreationDate(date('Y-m-d')); $production->setUpdateDate(date('Y-m-d')); $production->setRoomId($_GET["idRoom"]); $resultProduction = $this->dao->createProduction($production); if ($resultProduction) { $_SESSION['idProduction'] = $production->getProductionId(); } } else { $_SESSION['idProduction'] = $_GET['idProduction']; } $resultUpdateRoom = $this->dao->updateRoomState($_GET["idRoom"], true, $_SESSION['idProduction']); if ($resultUpdateRoom) { $_SESSION["idRoom"] = $_GET["idRoom"]; } $resultRoom = $this->dao->getRoom($_GET["idRoom"]); if ($resultRoom) { $_SESSION["currentRoomManager"] = $resultRoom->getUserId(); } $history = new History(); $history->setUserId($_SESSION["id"]); $history->setProductionId($_SESSION['idProduction']); $history->setDate(date('Y-m-d')); $resultHistory = $this->dao->saveHistory($history); } // Retrieving the users in the room $_REQUEST["users"] = $this->dao->getRoomUsers($_SESSION['idProduction']); // Showing the page $this->pageController->run($forwards['success']); }
function get_parts_group_by_prod_num($prod_num) { $prod = Production::find_by_num($prod_num); $results = array(); if ($prod) { $results = \Model\Part::build_parts_group($prod->parts); } return $results; }
public function showFav() { if (!empty($_SESSION['favorites'])) { $criteria_p = new CDbCriteria(); $product_array_session = implode(',', array_unique($_SESSION['favorites'])); $criteria_p->condition = '`t`.`id` IN (' . $product_array_session . ')'; $criteria_p->with = array('catalog'); $criteria_p->order = 'catid ASC'; $criteria_p->limit = 3; $product = Production::model()->findAll($criteria_p); $product_count = Production::model()->findAll(array('condition' => '`t`.`id` IN (' . $product_array_session . ')')); } else { $product = array(); $product_count = array(); } $this->renderPartial('fav_box', array('favorites' => $product, 'counter' => $product_count)); }
public function __construct($id_planeta) { $this->id = $id_planeta; $db = new Connect(); $sql = $db->query("SELECT edificios.fuente_base, edificios.planta_energia, edificios.reactor_fusion, \n edificios.mina_metal, edificios.mina_cristal, edificios.mina_tritio, \n edificios.almacen_metal, edificios.almacen_cristal, edificios.almacen_tritio, \n edificios.satelites, edificios.modulos, edificios.almacen_materia, edificios.distribuidor, edificios.nanobots,\n planetas.metal, planetas.cristal, planetas.tritio, \n planetas.ultima_act, planetas.temp_promd FROM edificios, planetas WHERE edificios.id_planeta='{$this->id}' \n AND planetas.id_planeta='{$this->id}' LIMIT 1;"); $dat = $db->recorrer($sql); $this->niveles = array('mina_metal' => $dat['mina_metal'], 'mina_cristal' => $dat['mina_cristal'], 'mina_tritio' => $dat['mina_tritio'], 'reactor_fusion' => $dat['reactor_fusion'], 'planta_energia' => $dat['planta_energia'], 'distribuidor' => $dat['distribuidor'], 'satelites' => $dat['satelites'], 'modulos' => $dat['modulos'], 'almacen_metal' => $dat['almacen_metal'], 'almacen_cristal' => $dat['almacen_cristal'], 'almacen_tritio' => $dat['almacen_tritio'], 'almacen_materia' => $dat['almacen_materia'], 'nanobots' => $dat['nanobots']); $this->metal = $dat['metal']; $this->cristal = $dat['cristal']; $this->tritio = $dat['tritio']; $tiempo = time(); $time = $tiempo - $dat['ultima_act']; parent::__construct($time, $this->niveles, $dat['fuente_base'], $dat['temp_promd'], $this->tritio); $prod_metal = $this->metal >= $this->getMetalCapacity() ? 0 : $this->getMetalProd(); $prod_cristal = $this->cristal >= $this->getCristalCapacity() ? 0 : $this->getCristalProd(); $prod_tritio = $this->tritio >= $this->getTritioCapacity() ? 0 : $this->getTritioProd(); $this->prod_resources = array('metal' => $prod_metal, 'cristal' => $prod_cristal, 'tritio' => $prod_tritio); //Actualizacion de recursos cada tano $update = $db->query("UPDATE planetas SET ultima_act='{$tiempo}', metal= metal + '{$prod_metal}', \n cristal= cristal + '{$prod_cristal}', tritio= tritio + '{$prod_tritio}' WHERE id_planeta='{$this->id}'"); $db->liberar($sql, $update); $db->close(); unset($prod_metal, $prod_cristal, $prod_tritio, $tiempo, $db); }
function stat_month_item_proc_2($sql, $project_src) { // get productions $results = array(); $prods = Production::find_by_sql($sql); // prod foreach ($prods as $prod) { $results[$prod->id] = array('num' => $prod->num, 'name' => $prod->name, 'project_src' => $prod->project_src, 'parts' => array()); // part foreach ($prod->parts as $part) { $results[$prod->id]['parts'][$part->id] = array('num' => $part->num, 'name' => $part->name, 'count' => $part->count, 'procs' => '', 'cur_proc' => '', 'cur_proc_production_date' => '', 'undo_work_hours' => get_total_undo_work_hours($part), 'is_done' => $part->is_done); // 初始化变量 $procs = array(); $cur_proc = array(); $cur_proc_production_date = ''; // proc if (count($part->processes)) { foreach ($part->processes as $proc) { $procs[] = array('id' => $proc->id, 'name' => get_proc_name($proc->name), 'priority' => $proc->priority, 'production_date' => $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : ''); // 查询当前正在执行的工序 // 查询条件: 投产日期非空 && 未完工 if (!empty($proc->production_date) && !$proc->is_done) { $cur_proc = array('id' => $proc->id, 'name' => get_proc_name($proc->name), 'priority' => $proc->priority, 'planned_completion_date' => $proc->planned_completion_date ? date('Y-m-d', strtotime($proc->planned_completion_date)) : date('Y-m-d', strtotime($proc->part->planned_completion_date)), 'production_date' => $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : '', 'staffs' => get_proc_all_staffs($proc), 'check_date' => get_proc_first_work_check_date($proc)); $cur_proc_production_date = $proc->production_date ? date('Y-m-d', strtotime($proc->production_date)) : ''; } } // end of proc // 如果没有找到当前执行的工序 // 默认为第一道工序 if (empty($cur_proc)) { $processes = $part->processes; $first_proc = $processes[0]; $last_proc = $processes[count($processes) - 1]; // 如果最后一道工序完工, 默认为最后一道工序 if ($last_proc->is_done) { $first_proc = $last_proc; } $cur_proc = array('id' => $first_proc->id, 'name' => get_proc_name($first_proc->name), 'priority' => $first_proc->priority, 'planned_completion_date' => $proc->planned_completion_date ? date('Y-m-d', strtotime($proc->planned_completion_date)) : date('Y-m-d', strtotime($proc->part->planned_completion_date)), 'production_date' => $first_proc->production_date ? date('Y-m-d', strtotime($first_proc->production_date)) : '', 'staffs' => get_proc_all_staffs($first_proc), 'check_date' => get_proc_first_work_check_date($first_proc)); $cur_proc_production_date = $first_proc->production_date ? date('Y-m-d', strtotime($first_proc->production_date)) : ''; } $results[$prod->id]['parts'][$part->id]['procs'] = $procs; $results[$prod->id]['parts'][$part->id]['cur_proc'] = $cur_proc; $results[$prod->id]['parts'][$part->id]['cur_proc_production_date'] = $cur_proc_production_date; } } } return $results; }
/** * Declares an association between this object and a Production object. * * @param Production $v * @return void * @throws PropelException */ public function setProduction($v) { if ($v === null) { $this->setProductionId(NULL); } else { $this->setProductionId($v->getProductionId()); } $this->aProduction = $v; }
/** * Save or update a production object * * @param Production $production : A production object */ public function createProduction($production) { try { return $production->save(); } catch (Exception $e) { echo $e; return null; } }
/** * Method called to associate a Production object to this object * through the Production foreign key attribute * * @param Production $l Production * @return void * @throws PropelException */ public function addProduction(Production $l) { $this->collProductions[] = $l; $l->setRoom($this); }
// return Carbon::create(2015-08-26 23:06:20)->endOfDay(); // return $prod->getCurrentProduction()->toArray(); return Auth::user()->role; if (Auth::attempt(array('password' => 'raymund123'))) { return 'true'; } else { return 'false'; } // return 10 + -10; // return Item::find(1)->cart; $temp = TempCart::all()->toArray(); $item = Item::where('barcode', '=', '900110023')->get()->toArray(); // return TempCart::all(); return json_encode(array_merge($temp, $item)); return DNS1D::getBarcodeHTML('123456789', "EAN13", 2, 60); $production = Production::find(2); return $production->items; }); Route::get('test/{trans_id}', ['uses' => 'SalesController@printInvoice']); Route::get('sample/{code}', ['uses' => 'SalesController@processOrder']); Route::get('/item/findbyname/{name}', ['uses' => 'ItemsController@findByName']); Route::group(array('before' => 'auth'), function () { Route::get('/', ['as' => 'home', 'uses' => 'BaseController@index']); // Route::get('/',function(){ // return View::make('index') // ->with('title',"Flibbys Point of Sale System"); // }); /* Inventory Routes */ Route::get('/inventory/', ['uses' => 'InventoryController@index']); Route::get('/inventory/stocks/{stockid}/edit', ['as' => 'stock.edit', 'uses' => 'IngredientsController@edit']); Route::put('/inventory/stocks/{stockid}/update', ['as' => 'stock.update', 'uses' => 'IngredientsController@update']);
/** * @test */ public function getWsHostShouldReturnTheConstantValue() { $env = new Production(); $this->assertEquals(Production::WS_HOST, $env->getWsHost()); }
public function execute($action) { $msgs = Localization::getInstance(); $forwards = $action->getForwards(); // Recebe os valores enviados $roomCourse = $_POST["group"]; $roomManager = $_POST['manager']; $userName = utf8_decode($_POST["name"]); $userEmail = $_POST["email"]; $userPasswordPlataform = "mude"; if (!empty($roomCourse) && !empty($roomManager) && !empty($userName) && !empty($userEmail)) { /** * Routine that checks which the browser used * If an error occurs during the login, the system should return to the previous page * If the browser used is Firefox, the system must go back two pages * If is Chrome should back 1 page * TODO Test with Internet Explorer */ $useragent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('|Firefox/([0-9\\.]+)|', $useragent, $matched)) { $browser_version = $matched[1]; $browser = 'Firefox'; $numReturnPages = 2; } else { $numReturnPages = 1; } /** * Via rest, it checks if this tool (in this case the Whiteboard) * have permission to use information from the Core */ $host = $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]; $pass = md5(date("d/m/Y") . $host); $server = "http://code.inf.poa.ifrs.edu.br/core/index.php/rest"; $action = str_replace("%40", "@", $userEmail); $rest = new RESTClient(); $rest->initialize(array('server' => $server, 'http_user' => $host, 'http_pass' => $pass)); $granted = $rest->get($action); if ($granted == 1) { // Caso o usuário esteja cadastrado na Plataform // CHECKING USER IN WHITEBOARD $user = $this->dao->login($userEmail, $userPasswordPlataform); if (count($user) <= 0) { // Not in database, create new user if (!empty($userEmail) && !empty($userName)) { // Instantiates a new user; $user = new User(); $user->setName($userName); $user->setEmail($userEmail); $user->setPassword($userPasswordPlataform); $user->setRoomcreator(0); $resultUser = $this->dao->saveNewUser($user); $user = $this->dao->login($userEmail, $userPasswordPlataform); } } if ($user->getName() != $userName) { // Upadate user; $resultUser = $this->dao->updateUserName($user->getUserId(), $userName); } // User contained in the database, loggin $_SESSION['id'] = $user->getUserId(); $_SESSION['name'] = $user->getName(); $_SESSION['roomCreator'] = $user->getRoomcreator(); $_SESSION['email'] = $user->getEmail(); $_SESSION['user'] = $user; // Verifies and creates, if necessary, the room of course $roomPlataform = $this->dao->getRoomByCourse($roomCourse); if (count($roomPlataform) <= 0) { $roomName = "Turma: " . $roomCourse; if ($user->getEmail() == $roomManager) { $managerId = $user->getUserId(); } else { $manager = $this->dao->login($roomManager, $userPasswordPlataform); if (count($manager) <= 0) { // Not in database, create new user coordinator $manager = new User(); $manager->setName("Professor " . $roomCourse); $manager->setEmail($roomManager); $manager->setPassword($userPasswordPlataform); $manager->setRoomcreator(1); $resultManager = $this->dao->saveNewUser($manager); $manager = $this->dao->login($manager->getEmail(), $userPasswordPlataform); } $managerId = $manager->getUserId(); } // Instantiates a new room; $roomPlataform = new Room(); $roomPlataform->setName($roomName); $roomPlataform->setUserId($managerId); $roomPlataform->setActive(0); $roomPlataform->setActiveProduction(0); $roomPlataform->setCourse($roomCourse); $resultRoom = $this->dao->saveNewRoom($roomPlataform); $roomPlataform = $this->dao->getRoomByCourse($roomCourse); // Set manager permission of room $permission = new Permission(); $permission->setUserId($managerId); $permission->setRoomId($roomPlataform->getRoomId()); $resultPermission = $this->dao->savePermission($permission); } // Checks permissions $permissions = $this->dao->listPermissions($roomPlataform->getRoomId()); $havePermission = false; foreach ($permissions as $permission) { if ($permission->getUserId() == $user->getUserId()) { $havePermission = true; } } if (!$havePermission) { $permission = new Permission(); $permission->setUserId($user->getUserId()); $permission->setRoomId($roomPlataform->getRoomId()); $resultPermission = $this->dao->savePermission($permission); } $roomPlataform = $this->dao->getRoomByCourse($roomCourse); $_SESSION['plataform'] = true; unset($_POST["group"]); unset($_POST['manager']); unset($_POST["name"]); unset($_POST["email"]); // If the room is active, will be given a join if ($roomPlataform->getActive() == 1) { $_SESSION["idRoom"] = $roomPlataform->getRoomId(); $room = $this->dao->getRoom($roomPlataform->getRoomId()); // put the production in the session $idProduction = $room->getActiveProduction(); $_SESSION['idProduction'] = $idProduction; $history = new History(); $history->setUserId($_SESSION["id"]); $history->setProductionId($idProduction); $history->setDate(date('Y-m-d')); $resultHistory = $this->dao->saveHistory($history); // Retrieving the users in the room $_REQUEST["users"] = $this->dao->getRoomUsers($_SESSION['idProduction']); // Showing the page $this->pageController->run($forwards['success']); } else { if ($user->getUserId() == $roomPlataform->getUserId()) { // If it is not active and the user is the owner of the room, will be given a start in the room $production = new Production(); $production->setCreationDate(date('Y-m-d')); $production->setUpdateDate(date('Y-m-d')); $production->setRoomId($roomPlataform->getRoomId()); $resultProduction = $this->dao->createProduction($production); if ($resultProduction) { $_SESSION['idProduction'] = $production->getProductionId(); } $resultUpdateRoom = $this->dao->updateRoomState($roomPlataform->getRoomId(), true, $_SESSION['idProduction']); if ($resultUpdateRoom) { $_SESSION["idRoom"] = $roomPlataform->getRoomId(); } $resultRoom = $this->dao->getRoom($roomPlataform->getRoomId()); if ($resultRoom) { $_SESSION["currentRoomManager"] = $resultRoom->getUserId(); } $history = new History(); $history->setUserId($_SESSION["id"]); $history->setProductionId($_SESSION['idProduction']); $history->setDate(date('Y-m-d')); $resultHistory = $this->dao->saveHistory($history); // Retrieving the users in the room $_REQUEST["users"] = $this->dao->getRoomUsers($_SESSION['idProduction']); $this->pageController->run($forwards['success']); } else { // Otherwise, the room is closed and the user must wait until she opens unset($_SESSION['id']); unset($_SESSION['name']); unset($_SESSION['roomCreator']); unset($_SESSION['email']); unset($_SESSION['user']); // Closed room echo "<script type='text/javascript'>"; echo "alert('" . $msgs->getText('error.plataform.closeRoom') . "');"; // Without permission echo "history.go(-{$numReturnPages});"; echo "</script>"; } } } else { // Without permission echo "<script type='text/javascript'>"; echo "alert('" . $msgs->getText('error.plataform.withoutPermission') . "');"; echo "history.go(-{$numReturnPages});"; echo "</script>"; } } else { // Insufficient data echo "<script type='text/javascript'>"; echo "alert('" . $msgs->getText('error.plataform.insufficientData') . "');"; echo "history.go(-{$numReturnPages});"; echo "</script>"; } }
/** * 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 = Production::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }