public function actionUpload() { if ($_GET['id']) { $id = intval($_GET['id']); } if ($_GET['unixtime']) { $unixtime = intval($_GET['unixtime']); } $folder = Yii::getPathOfAlias('webroot') . '/uploads/c' . Company::getId(); if ($id) { $folder .= '/' . $id . '/'; } else { $folder .= '/temp/' . $unixtime . '/'; } $result = Tools::uploadMaterials($folder); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); if ($id && $result['success'] && User::model()->isCustomer()) { EventHelper::materialsAdded($id); } }
public function actionUpload() { $this->_prepairJson(); $folder = $_SERVER['DOCUMENT_ROOT'] . $this->folder() . $_GET['id'] . '/'; $fileModel = new ZakazPartsFiles(); $fileModel->part_id = $_GET['id']; $fileModel->orig_name = $_GET['qqfile']; $this->result = Tools::uploadMaterials($folder, false); if ($this->result['success']) { $fileModel->file_name = $this->result['fileName']; $part = ZakazParts::model()->findByPk($_GET['id']); if (User::model()->isManager()) { $fileModel->approved = 1; } else { EventHelper::newFileInStage($_GET['proj_id'], $part->title); } $fileModel->save(); } //$this->result['html']='=)';//'<li>!!!<a href="' . $this->result['file_name'] . '" id="parts_file">' . $_GET['qqfile'] . '</a></li>'; //$this->result = array('error' => $this->result['error']); $this->_response->setData($this->result); $this->_response->send(); }