예제 #1
0
 public function bookjsonAction()
 {
     Zend_Loader::loadClass("Documents");
     $this->_helper->viewRenderer->setNoRender();
     $requestParams = $this->_request->getParams();
     $IDgazURI = false;
     $uri = false;
     if (isset($requestParams["IDgazURI"])) {
         $IDgazURI = $requestParams["IDgazURI"];
     }
     if (isset($requestParams["uri"])) {
         $uri = $requestParams["uri"];
     }
     $DocObj = new Documents();
     if ($uri != false) {
         Zend_Loader::loadClass("GazetteerRefs");
         $DocObj->getGapVisWithPlaceURI($uri);
     } else {
         $DocObj->getGapVisWithPlaceID($IDgazURI);
     }
     $data = $DocObj->documentData;
     unset($DocObj);
     $output = Zend_Json::encode($data);
     if (isset($requestParams["callback"])) {
         header('Content-Type: application/javascript; charset=utf8');
         $output = $requestParams["callback"] . "(" . $output . ");";
         echo $output;
     } else {
         header('Content-Type: application/json; charset=utf8');
         header("Access-Control-Allow-Origin: *");
         echo $output;
         //outputs JSON of a given book's word cloud
     }
 }
예제 #2
0
 public function __construct()
 {
     $groups = new Groups();
     $doc = new Documents();
     /**
      * Wenn gepostet wurde
      */
     if ($_POST) {
         // Gruppe wird erstellt
         if (isset($_POST["group_name"])) {
             $groups->saveGroup($this->saveInputs($_POST["group_name"]), $this->saveInputs($_POST["group_description"]), get_current_user_id());
         }
         // User wird hinzugefügt
         if (isset($_POST["userToAdd"])) {
             $groups->addUser($this->saveInputs($_POST["group_id"]), $this->saveInputs($_POST["userToAdd"]));
         }
         if (isset($_POST["userToDelete"])) {
             $groups->deleteUser($this->saveInputs($_POST["group_id"]), $this->saveInputs($_POST["userToDelete"]));
         }
     }
     // Bestimmte ID wird abgefragt
     if (isset($_GET["id"])) {
         $user = wp_get_current_user();
         $detailGroup = $groups->getGroupAndUsers($this->saveInputs($_GET["id"]));
         $detailGroup->userToAdd = array();
         if ($user->roles[0] == "dokuAdmin" || $user->roles[0] == "administrator") {
             $detailGroup->userToAdd = $groups->getUserNotInGroup($this->saveInputs($_GET["id"]));
         }
         $documentsInGroup = $doc->getDocumentsInGroup($this->saveInputs($_GET["id"]));
         echo $this->detailView($detailGroup, $documentsInGroup);
     } else {
         $arGroups = $groups->getAuthGroups();
         echo $this->groupView($arGroups);
     }
 }
예제 #3
0
 /**
  * @param $key
  * @param $value
  * @param $context \Workflow\VTEntity
  * @return array|void
  */
 public function doAction($configuration, $filepath, $filename, $context, $targetRecordIds = array())
 {
     $adb = \PearDatabase::getInstance();
     require_once 'modules/Documents/Documents.php';
     $focus = new \Documents();
     $focus->parentid = $context->getId();
     $docTitle = $configuration["title"];
     $docDescr = nl2br($configuration["description"]);
     $docTitle = \Workflow\VTTemplate::parse($docTitle, $context);
     $docDescr = \Workflow\VTTemplate::parse($docDescr, $context);
     $focus->column_fields['notes_title'] = $docTitle;
     $focus->column_fields['assigned_user_id'] = $context->get('assigned_user_id');
     $focus->column_fields['filename'] = $filename;
     $focus->column_fields['notecontent'] = $docDescr;
     $focus->column_fields['filetype'] = 'application/pdf';
     $focus->column_fields['filesize'] = filesize($filepath);
     $focus->column_fields['filelocationtype'] = 'I';
     $focus->column_fields['fileversion'] = '';
     $focus->column_fields['filestatus'] = 'on';
     $focus->column_fields['folderid'] = $configuration["folderid"];
     $focus->save('Documents');
     $upload_file_path = decideFilePath();
     $date_var = date("Y-m-d H:i:s");
     $next_id = $adb->getUniqueID("vtiger_crmentity");
     copy($filepath, $upload_file_path . $next_id . "_" . $filename);
     $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
     $params1 = array($next_id, $context->get('assigned_user_id'), $context->get('assigned_user_id'), "Documents Attachment", 'Documents Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
     $adb->pquery($sql1, $params1);
     $filetype = "application/octet-stream";
     $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
     $params2 = array($next_id, $filename, $docDescr, $filetype, $upload_file_path);
     $adb->pquery($sql2, $params2, true);
     $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
     $adb->pquery($sql3, array($focus->id, $next_id));
     if ($configuration["relation"] === "1") {
         foreach ($targetRecordIds as $id) {
             $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $id . ", notesid = " . $focus->id;
             $adb->query($sql);
         }
     } else {
         $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id;
         $adb->query($sql);
     }
     $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents");
     if ($configuration['workflowid'] !== "") {
         $objWorkflow = new \Workflow\Main($configuration['workflowid'], false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
 }
예제 #4
0
 protected function FindLocalPersonByDoc($seria, $number)
 {
     $c = new CDbCriteria();
     if (!(trim($seria) === "")) {
         $c->compare("Series", trim($seria));
     }
     if (!(trim($number) === "")) {
         $c->compare("Numbers", trim($number));
     }
     $models = Documents::model()->findAll($c);
     if (!is_array($models) && is_object($models)) {
         return $models->PersonID;
     }
     foreach ($models as $obj) {
         return $obj->PersonID;
         if ($obj->TypeID == 2) {
             return $obj->PersonID;
         }
         if ($obj->TypeID == 3) {
             return $obj->PersonID;
         }
         if ($obj->TypeID == 4) {
             return $obj->PersonID;
         }
     }
     return 0;
 }
예제 #5
0
function initialize_page()
{
    $post_action = "";
    if (isset($_POST['submit'])) {
        $post_action = $_POST['submit'];
    }
    if ($post_action == "Add Document" || $post_action == "Add and Return to List") {
        $name = $_POST['name'];
        $file_type = getFileExtension($_FILES['file']['name']);
        $filename = slug(getFileName($_FILES['file']['name']));
        $filename_string = $filename . "." . $file_type;
        // Check to make sure there isn't already a file with that name
        $possibledoc = Documents::FindByFilename($filename_string);
        if (is_object($possibledoc)) {
            setFlash("<h3>Failure: Document filename already exists!</h3>");
            redirect("admin/add_document");
        }
        $target_path = SERVER_DOCUMENTS_ROOT . $filename_string;
        if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
            $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type));
            $new_doc->save();
            if (!chmod($target_path, 0644)) {
                setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>");
            }
            setFlash("<h3>Document uploaded</h3>");
        } else {
            setFlash("<h3>Failure: Document could not be uploaded</h3>");
        }
        if ($post_action == "Add and Return to List") {
            redirect("admin/list_documents");
        }
    }
}
예제 #6
0
파일: Document.php 프로젝트: bersace/strass
 function direct($throw = true)
 {
     $slug = $this->getRequest()->getParam('document');
     $t = new Documents();
     try {
         $d = $t->findBySlug($slug);
     } catch (Strass_Db_Table_NotFound $e) {
         if ($throw) {
             throw new Strass_Controller_Action_Exception_NotFound("Document " . $slug . " inconnu.");
         } else {
             return null;
         }
     }
     $this->setBranche($d);
     return $d;
 }
 /**
  * Return all documents that belong to a category
  *
  * @param void
  * @return array
  */
 function getDocuments()
 {
     if ($this->documents === false) {
         $this->documents = Documents::findByCategory($this);
     }
     // if
     return $this->documents;
 }
예제 #8
0
 public function loadDocumentsModel($id)
 {
     $model = Documents::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #9
0
function display_page_content()
{
    if (!requestIdParam()) {
        $documents = Documents::FindAll("DESC");
    } else {
        $documents = Documents::FindByFiletype(requestIdParam());
    }
    ?>
	
	<div id="edit-header" class="documentnav">
		<div class="nav-left column">
    		<h1>Choose a Document to Edit</h1>
		</div>
		<div class="nav-right column">
            <a href="<?php 
    echo get_link("admin/add_document");
    ?>
" class="hcd_button">Add a New Document</a>
		</div>
		<div class="clearleft"></div>
	</div>
	
	<p class="announce">Documents are defined as downloadable files or forms. PDFs, DOCs, and the like are acceptable. You may use this feature to make high resolution images downloadable as well. If the image is too large to upload, and you get an error, you may want to compress the image with StuffIt (.sit), WinZip (.zip), or ZipIt (.zip).</p>
	
<?php 
    if (count($documents) > 0) {
        ?>
			
	<div id="table-header" class="documents">
		<strong class="item-link">Document Name</strong>
		<span class="item-filename">Filename</span>
		<span class="item-viewlink">View file in new window</span>
	</div>
	
		<?php 
        //$filetypes = Documents::FindUniqueFiletypes();
        if (isset($filetypes) && count($filetypes) > 1) {
            echo "<ul class=\"menu tabs\">\n\t\t<li>Show Only: </li>\n";
            foreach ($filetypes as $type) {
                echo "\t\t<li><a href=\"" . get_link("admin/list_documents/" . $type->file_type) . "\">{$type->file_type}</a></li>\n";
            }
            echo "\t\t<li><a class=\"hcd_button\" href=\"" . get_link("admin/list_documents/") . "\">Show All</a></li>\n\t</ul>\n ";
        }
        ?>
	
	<ul id="listitems" class="managelist">
		<?php 
        foreach ($documents as $document) {
            echo "\t\t<li>\n\t\t\t<span class=\"item-link\"><a href=\"" . get_link("/admin/edit_document/{$document->id}") . "\">{$document->name} <small>EDIT</small></a></span>\n\t\t\t<span class=\"item-filename\">{$document->filename}</span>\n\t\t\t<span class=\"item-viewlink\"><a href=\"" . $document->getPublicUrl() . "\" target=\"_blank\">View file</a></span>\n\t\t</li>\n";
        }
        ?>
	
	</ul>
<?php 
    } else {
        echo "\t\t<h3 class=\"empty-list\">There are no documents to edit. <a class=\"short\" href=\"" . get_link("admin/add_document") . "\">Add one if you like</a>.</h3>";
    }
}
 public static function findFirstAsArray($id, $pullDocuments = false)
 {
     $p = parent::findFirst($id);
     $p = $p->toArray();
     if ($pullDocuments) {
         $p['documents'] = Documents::findByProjectId($id);
     }
     return $p;
 }
예제 #11
0
 /**
  * Erstellt die Sidebar mit Dokumenten, Gruppen usw.
  */
 public function __construct()
 {
     $docs = new Documents();
     $this->authDocs = $docs->getDocumentsCreatedByUser(get_current_user_id());
     $groups = new Groups();
     $this->authGroups = $groups->getAuthGroups();
     /**
      * SeitenUrl holen
      * @var array
      */
     $pagesFilter = array('post_type' => 'page', 'meta_key' => 'custom_element_grid_class_meta_box', 'meta_value' => 'Gruppen');
     $pages = get_posts($pagesFilter);
     $GroupLink = get_permalink($pages[0]->ID);
     $pagesFilter["meta_value"] = "Dokumente";
     $pages = get_posts($pagesFilter);
     $documentLink = get_permalink($pages[0]->ID);
     $pagesFilter["meta_value"] = "Startseite";
     $pages = get_posts($pagesFilter);
     $homeLink = get_permalink($pages[0]->ID);
     echo $this->view($GroupLink, $documentLink, $homeLink);
 }
 /**
  * Index page action
  * 
  * @param void
  * @return void
  */
 function index()
 {
     $page = (int) $this->request->get('page');
     if ($page < 1) {
         $page = 1;
     }
     // if
     $per_page = 10;
     list($documents, $pagination) = Documents::paginateDocuments($this->logged_user->getVisibility(), $page, $per_page);
     $this->smarty->assign(array('documents' => $documents, 'pagination' => $pagination));
     js_assign(array('pin_icon_url' => get_image_url('icons/pinned.16x16.gif'), 'unpin_icon_url' => get_image_url('icons/not-pinned.16x16.gif')));
 }
예제 #13
0
/**
 * Diese Funktions erstellt Rollen und DB-Tables bei der Aktivierung des Plugins im WP-Backend.
 */
function dokumummy_activated()
{
    /**
     * Rolen registrieren
     */
    new RoleSetup();
    /**
     * Seiten erstellen
     */
    new PageSetup();
    /**
     * Datenbanken für Gruppen erstellen
     */
    $groups = new Groups();
    $groups->initDatabase();
    /**
     * Datenbanken für Dokumente erstellen
     */
    $documents = new Documents();
    $documents->initDatabase();
}
 /**
  * Return parent object
  *
  * @param void
  * @return ApplicationObject
  */
 function &getParent()
 {
     if ($this->parent === false) {
         if (strtolower($this->getParentType()) == 'document') {
             $this->parent = $this->getParentId() ? Documents::findById($this->getParentId()) : null;
         } else {
             $this->parent = $this->getParentId() ? ProjectObjects::findById($this->getParentId()) : null;
         }
         // if
     }
     // if
     return $this->parent;
 }
예제 #15
0
 public function alljsonAction()
 {
     Zend_Loader::loadClass("Documents");
     $this->_helper->viewRenderer->setNoRender();
     $requestParams = $this->_request->getParams();
     $host = App_Config::getHost();
     $DocObj = new Documents();
     $DocObj->getAllComplete();
     $data = $DocObj->documentData;
     unset($DocObj);
     $output = Zend_Json::encode($data);
     if (isset($requestParams["callback"])) {
         header('Content-Type: application/javascript; charset=utf8');
         $output = $requestParams["callback"] . "(" . $output . ");";
         echo $output;
     } else {
         header('Content-Type: application/json; charset=utf8');
         header("Access-Control-Allow-Origin: *");
         echo $output;
         //outputs JSON of a given book's word cloud
     }
 }
예제 #16
0
 /**
 	 public function run()
 	 {
 		 // list of valid extensions, ex. array("jpeg", "xml", "bmp")
 		 $allowedExtensions = array("jpg");
 		 // max file size in bytes
 		 $sizeLimit = 1 * 1024 * 1024;
 	
 		 $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
 		 $result = $uploader->handleUpload('upload/');
 		 // to pass data through iframe you will need to encode all html tags
 		 $result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 		 echo $result;
 	 }
 	 **/
 public function run()
 {
     $folder = Documents::model()->getTempFolderPath();
     $allowedExtensions = array("jpg", "png");
     //array("jpg","jpeg","gif","exe","mov" and etc...
     $sizeLimit = 5 * 1024 * 1024;
     // maximum file size in bytes
     // perform upload
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload($folder);
     $return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     $fileSize = filesize($folder . $result['filename']);
     //GETTING FILE SIZE
     $fileName = $result['filename'];
     //GETTING FILE NAME
     echo $return;
     // it's array
 }
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * @param CAction $action the action to be executed.
  * @return boolean whether the action should be executed
  */
 public function beforeAction($action)
 {
     $response = false;
     if (Yii::app()->user->getState('project_selected') != null) {
         if (in_array($action->id, array('view', 'update', 'download'))) {
             $response = Documents::model()->countDocumentsByProject((int) $_GET['id'], Yii::app()->user->getState('project_selected')) > 0 ? true : false;
         } else {
             $response = true;
         }
     } else {
         $response = false;
     }
     if (!$response) {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     } else {
         return $response;
     }
 }
 /**
  * Creates a new model.
  */
 public function actionCreate()
 {
     // create Comments Object
     $model = new Comments();
     // if Comments form exist
     if (isset($_POST['Comments'])) {
         // set form elements to Comments model attributes
         $model->attributes = $_POST['Comments'];
         $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
         // set module_id finded to model
         $model->module_id = $module->module_id;
         $project = Yii::app()->user->getState('project_selected');
         $model->project_id = $project;
         // validate and save
         if ($model->save()) {
             // create an instance of file uploaded
             $image = CUploadedFile::getInstancesByName('Comment');
             // if file upload exist
             if (count($image > 0)) {
                 // for each file uploaded
                 for ($i = 0; $i < count($image); $i++) {
                     // create an Document object
                     $modeldocs = new Documents();
                     $modeldocs->image = $image[$i];
                     if (!$modeldocs->image->getError()) {
                         // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
                         $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
                         // set the extension file uploaded
                         $extension = $modeldocs->image->getExtensionName();
                         // if no error saving file
                         if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
                             $modeldocs->project_id = $project;
                             $modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30);
                             $modeldocs->document_description = $model->comment_text;
                             $modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
                             $modeldocs->document_revision = '1';
                             $modeldocs->document_uploadDate = date("Y-m-d");
                             $modeldocs->document_type = $modeldocs->image->getType();
                             $modeldocs->document_baseRevision = date('dmYHis');
                             $modeldocs->user_id = Yii::app()->user->id;
                             $modeldocs->comment_id = $model->primaryKey;
                             // save file uploaded as document
                             if ($modeldocs->save()) {
                                 Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk'));
                             } else {
                                 Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors());
                             }
                         } else {
                             Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError'));
                         }
                     } else {
                         Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors'));
                     }
                 }
             }
             // save log
             $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project);
             Logs::model()->saveLog($attributes);
             // find project managers to sent comment via mail
             $recipientsList = array();
             $ProjectManagers = Projects::model()->findManagersByProject($project);
             $managersArray = array();
             foreach ($ProjectManagers as $manager) {
                 $managersArray['email'] = $manager->user_email;
                 $managersArray['name'] = $manager->CompleteName;
                 array_push($recipientsList, $managersArray);
             }
             // find task owners to send comment via mail
             if ($module->module_name == 'tasks') {
                 $collaborators = Projects::model()->findAllUsersByProject($project);
                 $ColaboratorsArray = array();
                 foreach ($collaborators as $colaborator) {
                     $ColaboratorsArray['email'] = $colaborator->user_email;
                     $ColaboratorsArray['name'] = $colaborator->CompleteName;
                     // avoid to repeat email address
                     if (!in_array($ColaboratorsArray, $recipientsList)) {
                         array_push($recipientsList, $ColaboratorsArray);
                     }
                 }
             }
             // finding resource title
             switch ($module->module_name) {
                 case "budgets":
                     $resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title;
                     break;
                 case "invoices":
                     $resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number;
                     break;
                 case "expenses":
                     $resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name;
                     break;
                 case "documents":
                     $resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name;
                     break;
                 case "milestones":
                     $resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title;
                     break;
                 case "cases":
                     $resourceModelTitle = Cases::model()->findByPk($model->comment_resourceid)->case_name;
                     break;
                 case "tasks":
                     $resourceModelTitle = Tasks::model()->findByPk($model->comment_resourceid)->task_name;
                     break;
                 default:
                     $resourceModelTitle = "{empty}";
                     break;
             }
             // get project information
             $project = Projects::model()->findByPk($project);
             // prepare template to send via email
             $str = $this->renderPartial('//templates/comments/created', array('model' => $model, 'projectName' => $project->project_name, 'userposted' => Yii::app()->user->CompleteName, 'resourceTitle' => $resourceModelTitle, 'moduleName' => Yii::t('modules', $module->module_name), 'applicationName' => Yii::app()->name, 'applicationUrl' => Yii::app()->createAbsoluteUrl($module->module_name . '/view', array('id' => $model->comment_resourceid))), true);
             Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             $mailer = new yiiPhpMailer();
             $subject = Yii::t('email', 'CommentPosted') . " - " . $project->project_name . " - " . Yii::t('modules', $module->module_name);
             $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
         } else {
             Yii::app()->user->setFlash('CommentMessage', Yii::t('comments', 'RequiredComment'));
         }
     }
     $this->redirect(Yii::app()->createUrl($_GET['module'] . '/' . $_GET['action'], array('id' => $_GET['id'], '#' => 'comment-' . $model->primaryKey)));
 }
예제 #19
0
    /**
     * Get unassigned LB and GF documents
     * @param $clientID
     * @param $projectID
     * @param $userID
     * @param $year
     * @return CActiveRecord[]
     */
    public static function getUnassignedFromSession()
    {
        foreach ($_SESSION['unassigned_items'] as $key=>$value) {
            $ids_array[] = $key;
        }

        $condition = new CDbCriteria();
        $condition->join = "LEFT OUTER JOIN library_docs ON library_docs.Document_ID=t.Document_ID";
        $condition->condition = "library_docs.Document_ID IS NULL";
        $condition->addInCondition('t.Document_ID', $ids_array);

        $condition->order = "t.Created ASC";
        $documents = Documents::model()->with(array(
            'image'=>array(
                'select'=>'File_Name',
            ),
        ))->findAll($condition);

        return $documents;
    }
 public function postDocumentDescription()
 {
     $q = strtolower(Input::get('term'));
     if (!$q) {
         return;
     }
     $data['response'] = 'false';
     $query = Documents::where('documents_desc', 'LIKE', "%{$q}%")->select('documents_desc')->distinct()->get();
     if ($query) {
         $data['message'] = array();
         $data['response'] = 'true';
         foreach ($query as $row) {
             $data['message'][] = array('label' => $row->documents_desc, 'value' => $row->documents_desc);
         }
     }
     echo json_encode($data);
 }
예제 #21
0
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
//<<<<cutomview>>>>>>>
$oCustomView = new CustomView("Documents");
$viewid = $oCustomView->getViewId($currentModule);
$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
$viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
//<<<<<customview>>>>>
if (!isset($where)) {
    $where = "";
}
$url_string = '';
// assigning http url string
$focus = new Documents();
// Initialize sort by fields
$focus->initSortbyField('Documents');
// END
$smarty = new vtigerCRM_Smarty();
$other_text = array();
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to delete " . $errormsg . " " . $currentModule);
} else {
    $smarty->assign("ERROR", "");
}
//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
$sorder = $focus->getSortOrder();
$order_by = $focus->getOrderBy();
$_SESSION['NOTES_ORDER_BY'] = $order_by;
예제 #22
0
/**	function to add attachment for a ticket ie., the passed contents will be write in a file and the details will be stored in database
 *	@param array $input_array - array which contains the following values
 =>	int $id - customer ie., contact id
	int $sessionid - session id
	int $ticketid - ticket id
	string $filename - file name to be attached with the ticket
	string $filetype - file type
	int $filesize - file size
	string $filecontents - file contents as base64 encoded format
	*	return void
	*/
function add_ticket_attachment($input_array)
{
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    global $root_directory, $upload_badext;
    $log->debug("Entering customer portal function add_ticket_attachment");
    $adb->println("INPUT ARRAY for the function add_ticket_attachment");
    $adb->println($input_array);
    $id = $input_array['id'];
    $sessionid = $input_array['sessionid'];
    $ticketid = $input_array['ticketid'];
    $filename = $input_array['filename'];
    $filetype = $input_array['filetype'];
    $filesize = $input_array['filesize'];
    $filecontents = $input_array['filecontents'];
    if (!validateSession($id, $sessionid)) {
        return null;
    }
    //decide the file path where we should upload the file in the server
    $upload_filepath = decideFilePath();
    $attachmentid = $adb->getUniqueID("vtiger_crmentity");
    //fix for space in file name
    $filename = sanitizeUploadFileName($filename, $upload_badext);
    $new_filename = $attachmentid . '_' . $filename;
    $data = base64_decode($filecontents);
    $description = 'CustomerPortal Attachment';
    //write a file with the passed content
    $handle = @fopen($upload_filepath . $new_filename, 'w');
    fputs($handle, $data);
    fclose($handle);
    //Now store this file information in db and relate with the ticket
    $date_var = $adb->formatDate(date('Y-m-d H:i:s'), true);
    $crmquery = "insert into vtiger_crmentity (crmid,setype,description,createdtime) values(?,?,?,?)";
    $crmresult = $adb->pquery($crmquery, array($attachmentid, 'HelpDesk Attachment', $description, $date_var));
    $attachmentquery = "insert into vtiger_attachments(attachmentsid,name,description,type,path) values(?,?,?,?,?)";
    $attachmentreulst = $adb->pquery($attachmentquery, array($attachmentid, $filename, $description, $filetype, $upload_filepath));
    $relatedquery = "insert into vtiger_seattachmentsrel values(?,?)";
    $relatedresult = $adb->pquery($relatedquery, array($ticketid, $attachmentid));
    $user_id = getDefaultAssigneeId();
    require_once 'modules/Documents/Documents.php';
    $focus = new Documents();
    $focus->column_fields['notes_title'] = $filename;
    $focus->column_fields['filename'] = $filename;
    $focus->column_fields['filetype'] = $filetype;
    $focus->column_fields['filesize'] = $filesize;
    $focus->column_fields['filelocationtype'] = 'I';
    $focus->column_fields['filedownloadcount'] = 0;
    $focus->column_fields['filestatus'] = 1;
    $focus->column_fields['assigned_user_id'] = $user_id;
    $focus->column_fields['folderid'] = 1;
    $focus->parent_id = $ticketid;
    $focus->save('Documents');
    $related_doc = 'insert into vtiger_seattachmentsrel values (?,?)';
    $res = $adb->pquery($related_doc, array($focus->id, $attachmentid));
    $tic_doc = 'insert into vtiger_senotesrel values(?,?)';
    $res = $adb->pquery($tic_doc, array($ticketid, $focus->id));
    $log->debug("Exiting customer portal function add_ticket_attachment");
}
예제 #23
0
    $modObj->sorder = $sorder;
    $modObj->sortby = $order_by;
    $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
}
//<<<<cutomview>>>>>>>
$oCustomView = new CustomView("Documents");
$viewid = $oCustomView->getViewId($currentModule);
$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
$viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
//<<<<<customview>>>>>
if (!isset($where)) {
    $where = "";
}
$url_string = '';
// assigning http url string
$focus = new Documents();
// Initialize sort by fields
$focus->initSortbyField('Documents');
// END
$smarty = new vtigerCRM_Smarty();
$other_text = array();
if ($_REQUEST['errormsg'] != '') {
    $errormsg = vtlib_purify($_REQUEST['errormsg']);
    $smarty->assign("ERROR", "The User does not have permission to delete " . $errormsg . " " . $currentModule);
} else {
    $smarty->assign("ERROR", "");
}
//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
$sorder = $focus->getSortOrder();
$order_by = $focus->getOrderBy();
$_SESSION['NOTES_ORDER_BY'] = $order_by;
예제 #24
0
function create_note_from_webform($username, $sessionid, $subject, $desc)
{
    global $log;
    global $adb;
    global $current_user;
    if (!validateSession($username, $sessionid)) {
        return null;
    }
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($username);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, 'Users');
    $adb->println("Create New Document from Web Form - Starts");
    require_once "modules/Documents/Documents.php";
    $focus = new Documents();
    if (isPermitted("Documents", "EditView") == "yes") {
        $focus->column_fields['notes_title'] = $subject;
        $focus->column_fields['notecontent'] = $desc;
        $focus->save("Documents");
        $focus->retrieve_entity_info($focus->id, "Documents");
        $adb->println("Create New Document from Web Form - Ends");
        if ($focus->id != '') {
            return 'Document added successfully.';
        } else {
            return "Document creation failed. Try again";
        }
    } else {
        return $accessDenied;
    }
}
예제 #25
0
?>
    <?php 
//echo $form->error($model,'CourseID');
?>
                </div>
            </div>
        <hr>-->


    <div class="row-fluid">
        <div class="span5">
            <?php 
echo $form->labelEx($model, 'EntrantDocumentID');
?>
            <?php 
echo $form->dropDownList($model, 'EntrantDocumentID', Documents::PersonEntrantDocuments($personid, 1), array('empty' => '', 'class' => 'span12', 'disabled' => !$model->isNewRecord, 'onchange' => "PSN.onFacChange(this, '#" . CHtml::activeId($model, "SepcialityID") . "','" . CController::createUrl('personspeciality/speciality') . "');"));
?>
            <?php 
//echo $form->error($model,'CourseID');
?>
        </div>
        <div class="span5">
            <div class="row-fluid">
                <div class="span3">
                    <?php 
echo $form->labelEx($model, 'isCopyEntrantDoc');
?>
                    <div class="switch" data-on-label="Так" data-off-label="Ні">
                        <?php 
echo $form->checkBox($model, 'isCopyEntrantDoc');
?>
예제 #26
0
 /**
  * Gets the meta data.
  *
  * Returns an object full of business logic/database schema type definitions
  *
  * Returns stdClass
  *    phone_types
  *        {id}
  *            id
  *            name
  *            editable
  *    markets
  *        {id}
  *            id
  *            name
  *            active
  *            currency
  *    email_types
  *        {id}
  *            id
  *            name
  *    address_types
  *        {id}
  *            id
  *            name
  *    states
  *        {id}
  *            id
  *            name
  *            abbrev
  *            country_id
  *    countries
  *        {id}
  *            id
  *            name
  *            can_sell
  *            can_enroll
  *    presenter_status
  *        {id}
  *            id
  *            name
  *    product_credit_types
  *        {id}
  *            id
  *            name
  *            type
  *    product_credit_entry_types
  *        {id}
  *            id
  *            name
  *    product_credit_status_types
  *        {id}
  *            id
  *            name
  *    order_payment_processors
  *        {id}
  *            id
  *            name
  *    languages
  *        {id}
  *            id
  *            name
  *            localize_name
  *            locale
  *
  * @return \stdClass
  */
 private function _getMetaData()
 {
     $results = new stdClass();
     require_once APPLICATION_PATH . MODEL_DIR . '/Phone_type.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Market.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Address_type.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/State.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Country.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Email_type.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_status.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Product_credit_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Product_credit_entry_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Product_credit_status_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Order_payment_processors.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Secondary_order_status.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Royalty_status.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Language.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Documents.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_account_types.php';
     require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_us_tax_data.php';
     //phone types
     $phone_type = new Phone_type();
     $results->phone_types = $phone_type->getAllData();
     //presenter_us_tax_data
     $presenter_us_tax_data = new Presenter_us_tax_data();
     //$results->presenter_us_tax_data 		= $presenter_us_tax_data->getAllData();
     //markets
     $market = new Market();
     $results->markets = $market->getAllData();
     //email types
     $email_types = new Email_type();
     $results->email_types = $email_types->getAllData();
     //address types
     $address_types = new Address_type();
     $results->address_types = $address_types->getAllData();
     //states
     $states = new State();
     $results->states = $states->getAllData();
     //countries
     $countries = new Country();
     $results->countries = $countries->getAllData();
     //presenter status
     $presenter_status = new Presenter_status();
     $results->presenter_status = $presenter_status->getAllData();
     //order payment processor
     $order_payment_processor = new Order_payment_processor();
     $results->order_payment_processors = $order_payment_processor->getAllData();
     //product_credit_types
     $product_credit_types = new Product_credit_types();
     $results->product_credit_types = $product_credit_types->getAllData();
     //product_credit_entry_types
     $product_credit_entry_types = new Product_credit_entry_types();
     $results->product_credit_entry_types = $product_credit_entry_types->getAllData();
     //product_credit_status_types status
     $product_credit_status_types = new Product_credit_status_types();
     $results->product_credit_status_types = $product_credit_status_types->getAllData();
     //secondary_order_status
     $secondary_order_status = new Secondary_order_status();
     $results->secondary_order_status = $secondary_order_status->getAllData();
     //royalty_status
     $royalty_status = new Royalty_status();
     $results->royalty_status = $royalty_status->getAllData();
     //documents
     $documents = new Documents();
     $results->documents = $documents->getAllData();
     //presenter_account_types
     $presenter_account_types = new Presenter_account_types();
     $results->presenter_account_types = $presenter_account_types->getAllData();
     //language/locale
     $language = new Language();
     //var_export($this->Session->read()); exit;
     $results->language = $language->getAllData(1);
     //index meta data by column so it can be easily referenced in code
     $result = new stdClass();
     foreach ($results as $key => $value) {
         $result->{$key} = $this->_rekeyArray($value);
     }
     return $result;
 }
예제 #27
0
 /**
  * @param $context VTEntity
  */
 public function handleTask(&$context)
 {
     if (!getTabid('PDFMaker') || !vtlib_isModuleActive('PDFMaker')) {
         return 'yes';
     }
     global $adb, $current_user, $log, $root_directory;
     // PDFMaker greift auf Datenbank zurück. Daher zuerst speichern!
     $context->save();
     $userId = $context->get('assigned_user_id');
     if ($userId === null) {
         $userId = vtws_getWebserviceEntityId('Users', 1);
     }
     $moduleName = $context->getModuleName();
     $id = $context->getId();
     list($id2, $assigned_user_id) = explode("x", $userId);
     $parentid = $id;
     require_once 'modules/Documents/Documents.php';
     $focus = new \Documents();
     $focus->parentid = $parentid;
     $modFocus = $context->getInternalObject();
     $templateid = $this->template;
     $this->folder = 1;
     $foldername = $adb->getOne("SELECT foldername FROM vtiger_attachmentsfolder WHERE folderid='" . $this->folder . "'", 0, "foldername");
     $fieldname = $adb->getOne("SELECT fieldname FROM vtiger_field WHERE uitype=4 AND tabid=" . getTabId($moduleName), 0, "fieldname");
     /* new PDFMaker Routine */
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     if (isset($modFocus->column_fields[$fieldname]) && $modFocus->column_fields[$fieldname] != "") {
         $file_name = $PDFMaker->generate_cool_uri($modFocus->column_fields[$fieldname]) . ".pdf";
     } else {
         $file_name = generate_cool_uri($foldername . "_" . $templateid . $focus->parentid . date("ymdHi")) . ".pdf";
     }
     $this->addStat("Attach Document '" . $file_name . "'");
     $docTitle = $this->get("documenttitle", $context);
     $docDescr = $this->get("documentdescr", $context);
     $focus->column_fields['notes_title'] = $docTitle;
     $focus->column_fields['assigned_user_id'] = $assigned_user_id;
     $focus->column_fields['filename'] = $file_name;
     $focus->column_fields['notecontent'] = $docDescr;
     $focus->column_fields['filetype'] = 'application/pdf';
     $focus->column_fields['filesize'] = '';
     $focus->column_fields['filelocationtype'] = 'I';
     $focus->column_fields['fileversion'] = '';
     $focus->column_fields['filestatus'] = 'on';
     $focus->column_fields['folderid'] = $this->get("folderid");
     $focus->save('Documents');
     $language = $current_user->language;
     $request = $_REQUEST;
     $_REQUEST['search'] = true;
     $_REQUEST['submode'] = true;
     if ($current_user->is_admin != "on") {
         $useUser = Users::getActiveAdminUser();
     } else {
         $useUser = $current_user;
     }
     $oldCurrentUser = $current_user;
     $current_user = $useUser;
     $dummyRequest = new Vtiger_Request(array());
     $PDFMaker->createPDFAndSaveFile($dummyRequest, $this->get("template"), $focus, $modFocus, $file_name, $this->getModuleName(), $language);
     $current_user = $oldCurrentUser;
     $_REQUEST = $request;
     /* new PDFMaker Routine */
     $overwriteFilename = $this->get("filename", $context);
     if ($overwriteFilename != -1 && !empty($overwriteFilename)) {
         global $root_directory;
         $sql = "SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = " . $focus->id . " ORDER BY attachmentsid DESC LIMIT 1";
         $result = $adb->query($sql);
         if ($adb->num_rows($result) > 0) {
             $attachmentsid = $adb->query_result($result, 0, "attachmentsid");
             $attRst = $adb->query("SELECT * FROM vtiger_attachments WHERE attachmentsid = " . $attachmentsid);
             $attachment = $adb->fetchByAssoc($attRst);
             $oldFilename = $root_directory . "/" . $attachment["path"] . $attachmentsid . "_" . $attachment["name"];
             $newFilename = $root_directory . "/" . $attachment["path"] . $attachmentsid . "_" . $overwriteFilename;
             @rename($oldFilename, $newFilename);
             $adb->pquery("UPDATE vtiger_attachments SET name = ? WHERE attachmentsid = " . $attachmentsid, array($overwriteFilename));
             $adb->pquery("UPDATE vtiger_notes SET filename = ? WHERE notesid = " . $focus->id, array($overwriteFilename));
         }
         $file_name = $foldername . "_" . $overwriteFilename;
     }
     $_REQUEST = $request;
     if ($this->get("createrel") === "1") {
         $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $context->getId() . ", notesid = " . $focus->id;
         $adb->query($sql);
     } else {
         $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id;
         $adb->query($sql);
     }
     $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents");
     if ($this->get("workflow") !== "") {
         $objWorkflow = new \Workflow\Main($this->get("workflow"), false, $context->getUser());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
     $context->setEnvironment("new_record_id", $newContext->getWsId(), $this);
     return "yes";
 }
예제 #28
0
파일: Aps.php 프로젝트: ranvijayj/htmlasa
    /**
     * Approve AP
     * @param $docId
     * @param $userApprovalRange
     */
    public static function HardApApprove($docId, $userApprovalRange)
    {
        //check document
        $document = Documents::model()->with('client')->findByAttributes(array(
            'Client_ID' => Yii::app()->user->clientID,
            'Document_ID' => $docId,
        ));

        if ($document) {
            //get AP
            $ap = Aps::model()->with('ck_req_detail')->findByAttributes(array(
                'Document_ID' => $docId,
            ));

            if ($ap) {
                if ($ap->AP_Approval_Value < $userApprovalRange['user_appr_val']) {
                    // set AP_Approval_Value and save
                    $ap->Previous_AP_A_Val = $ap->AP_Approval_Value;
                    $ap->AP_Approval_Value = $userApprovalRange['user_appr_val'];

                    if ($userApprovalRange['user_appr_val'] == self::APPROVED) {
                        $ap->Approved = 1;
                        LibraryDocs::addDocumentToFolder($ap->Document_ID);
                    }

                    $ap->save();
                    Audits::LogAction($docId,Audits::ACTION_APPROVAL);

                    // regenerate pdf
                    if ($document->Origin == 'G') {
                        //Aps::generatePdfFpdf($ap->AP_ID, ($userApprovalRange['user_appr_val'] == Aps::APPROVED));
                        Documents::pdfGeneration($ap->Document_ID,'AP',($userApprovalRange['user_appr_val'] == Aps::APPROVED));
                        Audits::LogAction($ap->Document_ID,Audits::ACTION_REPDF);
                    }



                }

                // find and unset doc from session
                Helper::removeDocumentFromViewSession($docId, 'ap_to_review');
                Helper::removeDocumentFromViewSession($docId, 'ap_hard_approve');
            }
        }
    }
예제 #29
0
 function _SaveAttachements($attachments, $userid, $usetime, $relID = false)
 {
     $adb = PearDatabase::getInstance();
     $setype = "OSSMailView Attachment";
     $IDs = array();
     if ($attachments) {
         foreach ($attachments as $attachment) {
             $filename = $attachment['filename'];
             $filecontent = $attachment['attachment'];
             $attachid = $adb->getUniqueId('vtiger_crmentity');
             $description = $filename;
             $adb->pquery("INSERT INTO vtiger_crmentity(crmid, smcreatorid, smownerid, \n\t\t\t\t\tmodifiedby, setype, description, createdtime, modifiedtime, presence, deleted)\n\t\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($attachid, $userid, $userid, $userid, $setype, $description, $usetime, $usetime, 1, 0));
             $issaved = self::_SaveAttachmentFile($attachid, $filename, $filecontent);
             if ($issaved) {
                 require_once 'modules/Documents/Documents.php';
                 $document = new Documents();
                 $document->column_fields['notes_title'] = $filename;
                 $document->column_fields['filename'] = $filename;
                 $document->column_fields['filestatus'] = 1;
                 $document->column_fields['filelocationtype'] = 'I';
                 $document->column_fields['folderid'] = 1;
                 // Default Folder
                 $document->column_fields['assigned_user_id'] = $userid;
                 $document->save('Documents');
                 $IDs[] = $document->id;
                 $adb->pquery("INSERT INTO vtiger_seattachmentsrel(crmid, attachmentsid) VALUES(?,?)", array($document->id, $attachid));
                 $adb->pquery("UPDATE vtiger_crmentity SET createdtime = ?,smcreatorid = ?,modifiedby = ?  WHERE crmid = ? ", array($usetime, $userid, $userid, $document->id));
                 if ($relID && $relID != 0 && $relID != '') {
                     $dirname = Vtiger_Functions::initStorageFileDirectory('OSSMailView');
                     $url_to_image = $dirname . $attachid . '_' . $filename;
                     $adb->pquery("INSERT INTO vtiger_ossmailview_files(ossmailviewid, documentsid, attachmentsid) VALUES(?,?,?)", array($relID, $document->id, $attachid));
                     $db_content = $adb->pquery("SELECT content FROM vtiger_ossmailview where ossmailviewid = ?", array($relID), true);
                     $content = $adb->raw_query_result_rowdata($db_content, 0);
                     $content = $content['content'];
                     preg_match_all('/src="cid:(.*)"/Uims', $content, $matches);
                     if (count($matches)) {
                         $search = array();
                         $replace = array();
                         foreach ($matches[1] as $match) {
                             if (strpos($filename, $match) !== false || strpos($match, $filename) !== false) {
                                 $search[] = "src=\"cid:{$match}\"";
                                 $replace[] = "src=\"{$url_to_image}\"";
                             }
                         }
                         $content = str_replace($search, $replace, $content);
                     }
                     $adb->pquery("UPDATE vtiger_ossmailview SET content = ? WHERE ossmailviewid = ? ", array($content, $relID));
                 }
             }
         }
     }
     return $IDs;
 }
예제 #30
0
                     echo $cueAppr->DocType;
                 ?>
            </td>

            <td class="amount_cell width30"><?php echo CHtml::encode($cueAppr->Amount) ? Helper::cutText(15, 75, 10, number_format($cueAppr->Amount, 2, '.', ',')) : '<span class="not_set">Not set</span>'; ?></td>
            <td class="width90 control_name">
                <?php
                if($cueAppr->Approval_Value<1) {
                    echo "DEC";
                } else { echo $cueAppr->ApprName; }
                ?>
            </td>
            <td>
                <span class="cutted_cell">
                    <?php
                        $notes = Documents::getLastNoteById($cueAppr->DocID);
                        echo CHtml::encode($notes) ? Helper::cutText(11, 240, 29, $notes) : '<span class="not_set">No comments</span>';
                    ?>
                </span>
            </td>
        </tr>
    <?php
    }
} else {
    echo '<tr>
             <td>
                 Documents  not found.

             </td>
           </tr>';
}